OyeWarehouseController.java 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. package com.steerinfo.dil.controller;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.steerinfo.dil.mapper.AmsSaleMaterialMapper;
  4. import com.steerinfo.dil.mapper.RmsReceivePlaceMapper;
  5. import com.steerinfo.dil.model.RmsReceivePlace;
  6. import com.steerinfo.dil.service.impl.OyeWarehouseServiceImpl;
  7. import com.steerinfo.dil.util.BaseRESTfulController;
  8. import com.steerinfo.dil.util.ColumnDataUtil;
  9. import com.steerinfo.dil.util.DataChange;
  10. import com.steerinfo.dil.util.PageListAdd;
  11. import com.steerinfo.framework.controller.RESTfulResult;
  12. import com.steerinfo.framework.service.pagehelper.PageHelper;
  13. import io.swagger.annotations.ApiModelProperty;
  14. import io.swagger.annotations.ApiOperation;
  15. import org.springframework.transaction.annotation.Transactional;
  16. import org.springframework.web.bind.annotation.PostMapping;
  17. import org.springframework.web.bind.annotation.RequestBody;
  18. import org.springframework.web.bind.annotation.RequestMapping;
  19. import org.springframework.web.bind.annotation.RestController;
  20. import javax.annotation.Resource;
  21. import java.math.BigDecimal;
  22. import java.text.SimpleDateFormat;
  23. import java.util.Date;
  24. import java.util.HashMap;
  25. import java.util.List;
  26. import java.util.Map;
  27. @RestController
  28. @RequestMapping("/${api.version}/OyeWarehouse")
  29. public class OyeWarehouseController extends BaseRESTfulController {
  30. private final SimpleDateFormat sdfDateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  31. @Resource
  32. RmsReceivePlaceMapper rmsReceivePlaceMapper;
  33. @Resource
  34. ColumnDataUtil columnDataUtil;
  35. @Resource
  36. OyeWarehouseServiceImpl oyeWarehouseService;
  37. @Resource
  38. AmsSaleMaterialMapper amsSaleMaterialMapper;
  39. @ApiOperation("新增欧冶具体库房")
  40. @PostMapping("/insertOyeWarehouse")
  41. public RESTfulResult insertOyeWarehouse(@RequestBody Map<String,Object> map) {
  42. RmsReceivePlace rmsReceivePlace = new RmsReceivePlace();
  43. rmsReceivePlace.setPlaceId(rmsReceivePlaceMapper.selectMaxId());
  44. rmsReceivePlace.setAddressId(new BigDecimal(3));
  45. rmsReceivePlace.setAddressDeliveryAddress(map.get("warehouseName").toString());
  46. rmsReceivePlace.setInsertUpdateRemark(map.get("carrierName").toString());
  47. rmsReceivePlaceMapper.insertSelective(rmsReceivePlace);
  48. return success("新增成功");
  49. }
  50. @ApiOperation("新增欧冶具体库房")
  51. @PostMapping("/insertOyeWarehouseSide")
  52. public RESTfulResult insertOyeWarehouseSide(@RequestBody Map<String,Object> map) {
  53. RmsReceivePlace rmsReceivePlace = new RmsReceivePlace();
  54. rmsReceivePlace.setPlaceId(rmsReceivePlaceMapper.selectMaxId());
  55. rmsReceivePlace.setAddressId(new BigDecimal(5));
  56. rmsReceivePlace.setAddressDeliveryAddress(map.get("warehouseName").toString());
  57. rmsReceivePlace.setInsertUpdateRemark(map.get("carrierName").toString());
  58. rmsReceivePlaceMapper.insertSelective(rmsReceivePlace);
  59. rmsReceivePlaceMapper.insertWarehouse(map);
  60. return success("新增成功");
  61. }
  62. @ApiOperation("查询欧冶库具体库房信息")
  63. @PostMapping("getOyeWarehouse")
  64. public RESTfulResult getOyeWarehouse(@RequestBody(required = false) Map<String,Object> mapValue,
  65. Integer pageNum,
  66. Integer pageSize,
  67. Integer apiId) {
  68. PageHelper.startPage(pageNum,pageSize);
  69. //分页数据
  70. List<Map<String, Object>> mapList = rmsReceivePlaceMapper.getOyeWarehouse(mapValue);
  71. PageListAdd pageList = columnDataUtil.tableColumnData(apiId, null,mapList);
  72. return success(pageList);
  73. }
  74. @ApiOperation("查询欧冶库具体库房信息")
  75. @PostMapping("getOyeWarehouseSide")
  76. public RESTfulResult getOyeWarehouseSide(@RequestBody(required = false) Map<String,Object> mapValue,
  77. Integer pageNum,
  78. Integer pageSize,
  79. Integer apiId) {
  80. PageHelper.startPage(pageNum,pageSize);
  81. //分页数据
  82. List<Map<String, Object>> mapList = rmsReceivePlaceMapper.getOyeWarehouseSide(mapValue);
  83. PageListAdd pageList = columnDataUtil.tableColumnData(apiId, null,mapList);
  84. return success(pageList);
  85. }
  86. @ApiModelProperty(value = "新增欧冶转运计划")
  87. @PostMapping("/addTransPlan")
  88. public RESTfulResult addTransPlan(@RequestBody Map<String,Object> mapValue){
  89. JSONObject jsonObject = new JSONObject(mapValue);
  90. System.out.println(new Date() + "=======================");
  91. System.out.println(jsonObject);
  92. System.out.println(new Date() + "=======================");
  93. try {
  94. // 成功
  95. int result = oyeWarehouseService.addTransPlan(mapValue);
  96. return success(result);
  97. } catch (Exception e) {
  98. // 失败
  99. return failed(e.getMessage());
  100. }
  101. }
  102. @ApiOperation("批量新增欧冶转运计划")
  103. @PostMapping("addTransPlanList")
  104. @Transactional(rollbackFor = Exception.class)
  105. public RESTfulResult addTransPlanList(@RequestBody List<Map<String,Object>> mapList) throws Exception {
  106. int count = 0;
  107. String saleOrderNo = null;
  108. System.out.println("------新增欧冶转运计划Excel导入-----" + new Date());
  109. try {
  110. Map<String, Object> logMap = new HashMap<>();
  111. logMap.put("mapList",mapList);
  112. JSONObject jsonObject = new JSONObject(logMap);
  113. System.out.println(jsonObject);
  114. }catch (Exception e){
  115. e.printStackTrace();
  116. }
  117. System.out.println("------销售订单批量导入Excel导入-----" + new Date());
  118. try {
  119. for (Map<String,Object> map:mapList
  120. ) {
  121. saleOrderNo = map.get("saleOrderNo").toString();
  122. count++;
  123. oyeWarehouseService.addTransPlan(map);
  124. //根据销售订单ID再去查询汇总一遍
  125. }
  126. } catch (Exception e) {
  127. System.out.println(e);
  128. throw new Exception("销售订单编号为:" + saleOrderNo + e.getMessage());
  129. }
  130. return success(count);
  131. }
  132. @ApiOperation("查询转运计划")
  133. @PostMapping("/getTransPlan")
  134. public RESTfulResult getTransPlan(@RequestBody(required=false) Map<String,Object> mapValue,
  135. Integer apiId,
  136. Integer pageNum,
  137. Integer pageSize,
  138. String startTime,
  139. String endTime){
  140. DataChange.queryDataByDateTime(startTime, endTime, mapValue, sdfDateTime);//根据时间段查询数据
  141. if (mapValue.containsKey("saler")) {
  142. String saler = mapValue.get("saler").toString();
  143. List<String> saleAreaRemark = amsSaleMaterialMapper.getSaleAreaRemark(saler);
  144. if(saleAreaRemark.size() > 0) {
  145. mapValue.put("saleAreaRemark",saleAreaRemark);
  146. }
  147. mapValue.put("salers",saler);
  148. }
  149. PageHelper.startPage(pageNum,pageSize);
  150. List<Map<String, Object>> mapList = oyeWarehouseService.getTransPlan(mapValue);
  151. PageListAdd pageList = columnDataUtil.tableColumnData(apiId, null,mapList);
  152. return success(pageList);
  153. }
  154. @ApiOperation("审核转运计划")
  155. @PostMapping("approveTransPlan")
  156. public RESTfulResult approveTransPlan(@RequestBody Map<String,Object> map) {
  157. try {
  158. String s = oyeWarehouseService.approveTransPlan(map);
  159. return success(s);
  160. } catch (Exception e) {
  161. e.printStackTrace();
  162. return failed(e.getMessage());
  163. }
  164. }
  165. }