WmsInboundScanResultController.java 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. package com.steerinfo.dil.controller;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.TypeReference;
  4. import com.github.pagehelper.PageHelper;
  5. import com.steerinfo.dil.feign.ColumnDataFeign;
  6. import com.steerinfo.dil.mapper.WmspInboundResultMapper;
  7. import com.steerinfo.dil.model.*;
  8. import com.steerinfo.dil.service.impl.RmsMaterialServiceImpl;
  9. import com.steerinfo.dil.service.impl.RmsMaterialSteelServiceImpl;
  10. import com.steerinfo.dil.service.impl.WmsInboundResultServiceImpl;
  11. import com.steerinfo.dil.service.impl.WmsInboundScanResultServiceImpl;
  12. import com.steerinfo.dil.util.BaseRESTfulController;
  13. import com.steerinfo.dil.util.ColumnDataUtil;
  14. import com.steerinfo.dil.util.PageListAdd;
  15. import com.steerinfo.framework.controller.RESTfulResult;
  16. import io.swagger.annotations.ApiImplicitParam;
  17. import io.swagger.annotations.ApiImplicitParams;
  18. import io.swagger.annotations.ApiOperation;
  19. import org.apache.commons.collections.MapUtils;
  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.transaction.annotation.Transactional;
  22. import org.springframework.web.bind.annotation.PostMapping;
  23. import org.springframework.web.bind.annotation.RequestBody;
  24. import org.springframework.web.bind.annotation.RequestMapping;
  25. import org.springframework.web.bind.annotation.RestController;
  26. import springfox.documentation.spring.web.json.Json;
  27. import java.math.BigDecimal;
  28. import java.text.ParseException;
  29. import java.util.*;
  30. /**
  31. * @author luobang
  32. * @create 2021-09-07 15:15
  33. */
  34. @RestController
  35. @RequestMapping("${api.version}/inboundScanResult")
  36. public class WmsInboundScanResultController extends BaseRESTfulController {
  37. @Autowired
  38. WmsInboundResultServiceImpl wmsInboundResultService;
  39. @Autowired
  40. WmsInboundScanResultServiceImpl wmsInboundScanResultService;
  41. @Autowired
  42. RmsMaterialServiceImpl rmsMaterialService;
  43. @Autowired
  44. RmsMaterialSteelServiceImpl rmsMaterialSteelService;
  45. @Autowired
  46. WmspInboundResultMapper wmspInboundResultMapper;
  47. @Autowired
  48. ColumnDataUtil columnDataUtil;
  49. @Autowired
  50. ColumnDataFeign columnDataFeign;
  51. /**
  52. * 1.新增扫描吊牌实绩!!!此时入库实绩未生成
  53. * @param
  54. * @return
  55. */
  56. @ApiOperation(value = "新增扫描吊牌实绩")
  57. @PostMapping("/insertResult2")
  58. @Transactional
  59. public synchronized RESTfulResult insertScanResult(@RequestBody(required = false)Map<String,Object>map) throws ParseException {
  60. //这里需要的参数包括 扫码人账号 userId、二维码信息 resultMaterial
  61. //首先判断二维码是否已经被扫过了
  62. //判断条件是查询扫描实绩判断是否已经存在改唯一标识码并且扫码人是否是自己
  63. int isExist= wmsInboundScanResultService.isExist(map.get("userName").toString(),map.get("resultMaterial").toString().substring(0,map.get("resultMaterial").toString().length()-1));
  64. //通过用户ID查询、当前扫描没有下发的物质、最终展示的集合
  65. List<Map<String,Object>>mapList= wmsInboundScanResultService.noIssueScanResultList(map.get("userName").toString());
  66. if (isExist>0){
  67. //如果已经被少扫过了返回扫码实绩集合
  68. //返回结果显示
  69. return failed(mapList);
  70. }else {
  71. //如果没有被扫
  72. //创建一个扫码实绩
  73. Map<String, Object> wmspInboundScanResult =wmsInboundScanResultService.createInboundScanResultByResultMaterial(mapList.size(),map.get("userName").toString(),map.get("resultMaterial").toString());
  74. //判断是否创建成功、成功在添加
  75. if (wmspInboundScanResult!=null){
  76. mapList.add(wmspInboundScanResult);
  77. }
  78. }
  79. return success(mapList);
  80. }
  81. /**
  82. * 1.新增扫描吊牌实绩!!!此时入库实绩未生成
  83. * @param
  84. * @return
  85. */
  86. @ApiOperation(value = "新增扫描吊牌实绩")
  87. @PostMapping("/insertResult")
  88. @Transactional
  89. public synchronized RESTfulResult insertResult(@RequestBody(required = false)Map<String,Object>map) throws ParseException {
  90. int i=0;
  91. WmspInboundScanResult wmspInboundScanResult = new WmspInboundScanResult();
  92. //获取工号查找id
  93. BigDecimal loadId = wmsInboundScanResultService.getLoadId(map);
  94. map.put("loadId",loadId);
  95. BigDecimal inboundResultId = new BigDecimal((Integer)map.get("inboundId"));
  96. //判断是否重复扫码
  97. //调用判断是否重复扫码的方法
  98. if(inboundResultId.intValue() == -1){
  99. if(wmsInboundScanResultService.checkScanTag(map,loadId) == 0){
  100. List<Map<String,Object>>mapList =wmsInboundScanResultService.getScanResult(loadId);
  101. return failed(mapList);
  102. }
  103. }
  104. //设置入库物资件数,默认一件
  105. wmspInboundScanResult.setInboundMaterialNumber(new BigDecimal(1));
  106. //设置吊钢工已扫物资件数
  107. wmspInboundScanResult.setResultNumber(new BigDecimal(wmsInboundScanResultService.scanNumber(map)+1));
  108. map.put("resultNumber",wmspInboundScanResult.getResultNumber());
  109. //设置常规字段 插入人为吊钢工的名字
  110. wmspInboundScanResult.setInsertTime(new Date());
  111. //设置吊钢工扫描吊牌时间
  112. wmspInboundScanResult.setResultLoadTime(new Date());
  113. //设置状态为未下发
  114. wmspInboundScanResult.setResultStatus(new BigDecimal(0));
  115. //设置吊钢工Id
  116. wmspInboundScanResult.setLoadId(loadId);
  117. //设置扫描吊牌实绩
  118. String str = (String) map.get("resultMaterial");
  119. wmspInboundScanResult.setResultMaterial(str);
  120. //设置入库实绩ID
  121. if (inboundResultId.intValue() != -1){
  122. BigDecimal hh=wmspInboundScanResult.getInboundResultId() ;
  123. wmspInboundScanResult.setInboundResultId(inboundResultId);
  124. wmspInboundScanResult.setResultStatus(new BigDecimal(1));
  125. }
  126. //设置逻辑删除字段
  127. wmspInboundScanResult.setResultDeleted(new BigDecimal(1));
  128. //新增钢材物资ID
  129. Integer k = rmsMaterialSteelService.insertRmsMaterialSteel(str);
  130. wmspInboundScanResult.setMaterialId(new BigDecimal(k));
  131. //根据班次班组查找同一车间的另一位小伙伴
  132. //判断物资是否为线材
  133. BigDecimal count = wmsInboundScanResultService.selectMaterialTypeByMaterialId(new BigDecimal(k));
  134. wmspInboundScanResult.setInboundAbnormalis(new BigDecimal(0));
  135. if(count != null){
  136. BigDecimal otherLoadId = wmsInboundScanResultService.getOtherLoadId(map);
  137. map.put("otherLoadId",otherLoadId);
  138. //查找另一位兄弟的相同次数的扫描实绩里面的物资ID
  139. Integer otherMaterialId = wmsInboundScanResultService.getOtherMaterialSteelId(map);
  140. if (otherMaterialId==k) {
  141. wmspInboundScanResult.setInboundAbnormalis(new BigDecimal(1));
  142. }
  143. else{
  144. wmspInboundScanResult.setInboundAbnormalis(new BigDecimal(0));
  145. }
  146. }
  147. //插入扫描吊牌实绩
  148. Integer integer = wmsInboundScanResultService.insertWmsInboundScanResult(wmspInboundScanResult);
  149. System.out.println("-----------"+integer);
  150. if (integer!=1){
  151. return failed();
  152. }
  153. //判断物资是否为线材
  154. if(count != null){
  155. //如果不为线材
  156. //更新异常值
  157. wmsInboundScanResultService.updateInboundAbnormal(map);
  158. }
  159. List<Map<String,Object>>mapList =wmsInboundScanResultService.getScanResult(loadId);
  160. return success(mapList);
  161. }
  162. /**
  163. * 展示未下发扫描实绩
  164. * @return
  165. */
  166. @ApiOperation(value="展示未下发扫描实绩")
  167. @PostMapping("/getScanResult")
  168. public RESTfulResult getScanResult(@RequestBody(required = false) Map<String,Object>map){
  169. BigDecimal loadId = wmsInboundScanResultService.getLoadId(map);
  170. map.put("loadId",loadId);
  171. List<Map<String,Object>>mapList =wmsInboundScanResultService.getScanResult(loadId);
  172. return success(mapList);
  173. }
  174. /**
  175. *
  176. * @return
  177. */
  178. @ApiOperation(value="展示垛位")
  179. @PostMapping("/selectStackingInfoByWarehouseId")
  180. public RESTfulResult selectStackingInfoByWarehouseId(@RequestBody(required = false) Map<String,Object>map){
  181. List<Map<String,Object>>mapList =wmsInboundScanResultService.selectStacking(map);
  182. return success(mapList);
  183. }
  184. /**
  185. *
  186. * @return
  187. */
  188. @ApiOperation(value="更新状态")
  189. @PostMapping("/updateStatus")
  190. public RESTfulResult updateStatus(@RequestBody(required = false) Map<String,Object>map){
  191. Integer integer =wmsInboundScanResultService.updateStatus(map);
  192. return success(integer);
  193. }
  194. /**
  195. * 展示异常入库吊钢工扫描吊牌实绩
  196. * @return
  197. */
  198. @ApiOperation(value="展示异常入库吊钢工扫描吊牌实绩")
  199. @PostMapping("/getIssuedTagNoResult")
  200. public RESTfulResult getIssuedTagNoResult(){
  201. HashMap<String, Object> map = new HashMap<>();
  202. List<Map<String, Object>> scanIssuedTagResult = wmsInboundScanResultService.getIssuedScanTagNoResult(map);
  203. return success(scanIssuedTagResult);
  204. }
  205. //根据入库实绩id查找扫描实绩
  206. @PostMapping("/selectScanResultByIboundResultId")
  207. @ApiOperation(value = "根据入库实绩id获得扫描实绩数据")
  208. @ApiImplicitParams({
  209. @ApiImplicitParam(name = "apiId", value = "", required = false, dataType = "BigDecimal"),
  210. })
  211. public RESTfulResult selectScanResultByIboundResultId(@RequestBody(required = false) Map<String, Object> mapValue,
  212. Integer apiId,
  213. Integer pageNum,
  214. Integer pageSize,
  215. Integer inboundId) {
  216. if (inboundId!=null){
  217. mapValue.put("inboundId",inboundId);
  218. }
  219. List<Map<String, Object>> reboundResultTotal = wmsInboundResultService.selectScanResultByIboundResultId(mapValue);
  220. List<Map<String, Object>> columnDataList = columnDataFeign.getColumnData(apiId);
  221. /*分页*/
  222. PageHelper.startPage(pageNum, pageSize);
  223. /*返回中英文对照结果,计算表头*/
  224. List<Map<String, Object>> reboundResult = wmsInboundResultService.selectScanResultByIboundResultId(mapValue);
  225. for (Map<String, Object> columnData : columnDataList) {
  226. columnData.put("filters", setListMap(reboundResultTotal, columnData.get("prop").toString()));
  227. }
  228. PageListAdd pageList = new PageListAdd(reboundResult);
  229. pageList.setColumnData(columnDataList);
  230. return success(pageList);
  231. }
  232. Set<Map<String, Object>> setListMap(List<Map<String, Object>> list, String name) {
  233. Set<Map<String, Object>> setString = new HashSet<>();
  234. for (Map<String, Object> map : list) {
  235. Map<String, Object> map1 = new HashMap<>();
  236. map1.put("text", map.get(name));
  237. if (map.get(name) != null) {
  238. //判断是否是运力类型
  239. if ("capacity_type".equals(name)) {
  240. switch (map.get(name).toString().trim()) {
  241. case "自有电车":
  242. map1.put("value", 0);
  243. break;
  244. case "自有汽车":
  245. map1.put("value", 1);
  246. break;
  247. case "社会车辆":
  248. map1.put("value", 2);
  249. break;
  250. }
  251. } else {
  252. map1.put("value", map.get(name));
  253. }
  254. setString.add(map1);
  255. }
  256. }
  257. return setString;
  258. }
  259. }