WmsInboundResultServiceImpl.java 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. package com.steerinfo.dil.service.impl;
  2. import com.steerinfo.dil.mapper.WmspGridMaterialMapper;
  3. import com.steerinfo.dil.mapper.WmspInboundResultMapper;
  4. import com.steerinfo.dil.model.WmspGridMaterial;
  5. import com.steerinfo.dil.model.WmspInboundResult;
  6. import com.steerinfo.dil.service.IWmsInboundResultService;
  7. import com.steerinfo.dil.util.IDUtils;
  8. import com.steerinfo.dil.util.Liushuih;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.stereotype.Service;
  11. import java.math.BigDecimal;
  12. import java.util.Date;
  13. import java.util.List;
  14. import java.util.Map;
  15. /**
  16. * @author luobang
  17. * @create 2021-09-06 18:12
  18. */
  19. @Service
  20. public class WmsInboundResultServiceImpl implements IWmsInboundResultService {
  21. @Autowired
  22. WmspInboundResultMapper wmspInboundResultMapper;
  23. @Autowired
  24. WmspGridMaterialMapper wmspGridMaterialMapper;
  25. /**
  26. * 1.展示入库实绩所有信息
  27. * @param mapValue
  28. * @return
  29. */
  30. @Override
  31. public List<Map<String,Object>> getInboundResult(Map<String, Object> mapValue,Integer warehouseId){
  32. mapValue.put("warehouseId",warehouseId);
  33. List<Map<String, Object>> maps = wmspInboundResultMapper.selectWmsInboundResult(mapValue);
  34. return maps;
  35. }
  36. // 展示入库统计信息
  37. @Override
  38. public List<Map<String, Object>> getWmsInboundResultStatistics(Map<String, Object> mapValue, Integer warehouseId) {
  39. mapValue.put("warehouseId",warehouseId);
  40. if(mapValue.size()==2){
  41. mapValue.put("orderType","desc");
  42. mapValue.put("orderField","newtime");
  43. }
  44. List<Map<String, Object>> maps = wmspInboundResultMapper.getWmsInboundResultStatistics(mapValue);
  45. return maps;
  46. }
  47. @Override
  48. public List<Map<String,Object>> getInboundResults(Map<String, Object> mapValue,Integer warehouseId){
  49. mapValue.put("warehouseId",warehouseId);
  50. List<Map<String, Object>> maps = wmspInboundResultMapper.selectWmsInboundResults(mapValue);
  51. return maps;
  52. }
  53. /**
  54. * 1.展示入库实绩所有信息
  55. * @param mapValue
  56. * @return
  57. */
  58. @Override
  59. public List<Map<String,Object>> getWmsReservedResult(Map<String, Object> mapValue){
  60. List<Map<String, Object>> maps = wmspInboundResultMapper.selectWmsReservedResult(mapValue);
  61. return maps;
  62. }
  63. /**
  64. * 2.展示退库实绩所有信息
  65. * @param mapValue
  66. * @return
  67. */
  68. @Override
  69. public List<Map<String,Object>> getReboundResult(Map<String, Object> mapValue){
  70. List<Map<String, Object>> maps = wmspInboundResultMapper.selectWmsReboundResult(mapValue);
  71. return maps;
  72. }
  73. /**
  74. * 2.展示倒库主表实绩所有信息
  75. * @param mapValue
  76. * @return
  77. */
  78. @Override
  79. public List<Map<String,Object>> getIvboundResult(Map<String, Object> mapValue){
  80. List<Map<String, Object>> maps = wmspInboundResultMapper.selectWmsIvboundResult(mapValue);
  81. return maps;
  82. }
  83. @Override
  84. public List<Map<String,Object>> getIvboundMaterial(Map<String, Object> mapValue){
  85. List<Map<String, Object>> maps = wmspInboundResultMapper.selectWmsIvboundMaterialResult(mapValue);
  86. return maps;
  87. }
  88. @Override
  89. public List<Map<String, Object>> selectScanResultByIboundResultId(Map<String, Object> map) {
  90. return wmspInboundResultMapper.selectScanResultByIboundResultId(map);
  91. }
  92. /**
  93. * 2.获取最大ID数
  94. * @return
  95. */
  96. @Override
  97. public int count() {
  98. if (wmspInboundResultMapper.getCount()==null){
  99. return 0;
  100. }
  101. return wmspInboundResultMapper.getCount().intValue();
  102. }
  103. /**
  104. * 3.新增入库实绩
  105. * @param wmspInboundResult
  106. * @return
  107. */
  108. @Override
  109. public Integer insertWmsInboundResult(WmspInboundResult wmspInboundResult) {
  110. return wmspInboundResultMapper.insertSelective(wmspInboundResult);
  111. }
  112. /**
  113. * 更新退库实绩表
  114. * @param map9
  115. * @return
  116. */
  117. @Override
  118. public Integer updateReboundResult(Map<String, Object> map9) {
  119. return wmspInboundResultMapper.updateReboundResult(map9);
  120. }
  121. @Override
  122. public String selectWarehouseName(BigDecimal bigDecimal) {
  123. return wmspInboundResultMapper.selectWarehouseName(bigDecimal);
  124. }
  125. @Override
  126. public WmspInboundResult initAndWmspInboundResult(Integer complete, Integer resultNumber,BigDecimal personnelWorkshopid,BigDecimal inboundGroupId,String userName, BigDecimal distributeId, BigDecimal gridId, Map<String, Object> item) {
  127. WmspInboundResult wmspInboundResult=new WmspInboundResult();
  128. //1、给实绩属性赋值
  129. int orderNumber = count();
  130. // 主键ID
  131. wmspInboundResult.setInboundId(IDUtils.createIDYMD(String.valueOf(orderNumber)));
  132. //批次ID与批次绑定关系
  133. wmspInboundResult.setInboundDistributeId(distributeId);
  134. //分组
  135. wmspInboundResult.setInboundGroupId(inboundGroupId);
  136. //入库类型
  137. wmspInboundResult.setInboundType(new BigDecimal(0));
  138. //入库单/退库单/倒库单编号(WRKD-年月日-8位数的顺序号)
  139. String number= Liushuih.generateNextNumber("WRKD-", "yyyyMMdd-", 8, orderNumber);
  140. wmspInboundResult.setInboundNumber(number);
  141. //仓储网格
  142. wmspInboundResult.setGridId(gridId);
  143. //入库单是否下发:0:未下发;1:下发中; 2:已下发 3:已经接收
  144. wmspInboundResult.setResultStatus(new BigDecimal(1));
  145. //物资ID
  146. wmspInboundResult.setMaterialId(new BigDecimal(item.get("materialId").toString()));
  147. //仓库id
  148. wmspInboundResult.setPersonnelWorkshopid(personnelWorkshopid);
  149. //入库是否完成(0:未完成,1:已完成)
  150. wmspInboundResult.setInboundIscomplete(new BigDecimal(complete));
  151. //逻辑删除:1:删除;0:未删除
  152. wmspInboundResult.setResultDeleted(new BigDecimal(0));
  153. //入库日期
  154. wmspInboundResult.setInboundTime(new Date());
  155. //记录创建人
  156. wmspInboundResult.setInsertUsername(userName);
  157. //记录创建时间
  158. wmspInboundResult.setInsertTime(new Date());
  159. //创建序号
  160. wmspInboundResult.setResultNumber(new BigDecimal(resultNumber));
  161. //插入
  162. int status = wmspInboundResultMapper.insertSelective(wmspInboundResult);
  163. return status>0?wmspInboundResult:null;
  164. }
  165. @Override
  166. public Map<String,Object> selectInboundResultByGroupId(BigDecimal groupId) {
  167. return wmspInboundResultMapper.selectInboundResultByGroupId(groupId);
  168. }
  169. @Override
  170. public BigDecimal getGrid(String distributeId, int i) {
  171. return wmspInboundResultMapper.getGrid(distributeId,i);
  172. }
  173. @Override
  174. public int updateInboundStatus(BigDecimal distributeId) {
  175. return wmspInboundResultMapper.updateInboundStatus(distributeId);
  176. }
  177. // 根据出库的resultId修改入库实绩的逻辑删除状态和仓储网格的状态
  178. @Override
  179. public int updateInboundGridStatus(Integer resultId) {
  180. int i=0;
  181. // 根据出库的resultId获取当前的吊刚工扫描结果
  182. List<Map<String ,Object>> resultMaterial = wmspInboundResultMapper.getResultMaterialByResultId(resultId);
  183. for (Map<String, Object> map1: resultMaterial){
  184. String material = (String) map1.get("resultMaterial");
  185. // 根据扫描吊牌得到的物资唯一编码修改对应的入库实绩状态和仓储网格状态
  186. List<Map<String ,Object>> list =wmspInboundResultMapper.getInboundResult(material);
  187. for (Map<String, Object> map:list){
  188. BigDecimal inboundId = (BigDecimal) map.get("inboundId");
  189. BigDecimal grmId = (BigDecimal) map.get("gmId");
  190. // 创建入库实绩实体类
  191. WmspInboundResult wmspInboundResult = new WmspInboundResult();
  192. wmspInboundResult.setInboundId(inboundId);
  193. wmspInboundResult.setResultDeleted(new BigDecimal(1));
  194. i+= wmspInboundResultMapper.updateByPrimaryKeySelective(wmspInboundResult);
  195. // 创建仓储网格实体类
  196. WmspGridMaterial wmspGridMaterial = new WmspGridMaterial();
  197. wmspGridMaterial.setGmId(grmId);
  198. wmspGridMaterial.setDeleted(new BigDecimal(1));
  199. i+= wmspGridMaterialMapper.updateByPrimaryKeySelective(wmspGridMaterial);
  200. }
  201. }
  202. return i;
  203. }
  204. @Override
  205. public int getTypeMaterilaId(BigDecimal materialId) {
  206. return wmspInboundResultMapper.getTypeMaterilaId(materialId);
  207. }
  208. @Override
  209. public int updateStatusByMaterilaId(BigDecimal materialId) {
  210. return wmspInboundResultMapper.updateStatusByMaterilaId(materialId);
  211. }
  212. @Override
  213. public int updateStatusByMaterialId(BigDecimal materialId) {
  214. return wmspInboundResultMapper.updateStatusByMaterialId(materialId);
  215. }
  216. // 根据对应的入库实绩id修改入库状态为预留
  217. @Override
  218. public int changeReserved(List<Map<String, Object>> mapList) {
  219. int i=0;
  220. // 对mapList遍历,找到所有的入库id
  221. for (Map<String,Object> map:mapList){
  222. // 找到状态,判断其是属于入库转预留还是预留转入库,0表示入库转预留,1表示预留转入库
  223. Integer status= (Integer) map.get("status");
  224. Long inboundIds= (Long) map.get("inboundId");
  225. BigDecimal inboundId = new BigDecimal(inboundIds) ;
  226. // 创建入库实体类
  227. WmspInboundResult wmspInboundResult = new WmspInboundResult();
  228. wmspInboundResult.setInboundId(inboundId);
  229. wmspInboundResult.setInboundTime(new Date());
  230. wmspInboundResult.setInsertTime(new Date());
  231. if (status == 0){
  232. // 将入库状态改为预留状态
  233. wmspInboundResult.setInboundIscomplete(new BigDecimal(2));
  234. }else if (status == 1){
  235. // 将预留状态改为入库状态
  236. wmspInboundResult.setInboundIscomplete(new BigDecimal(1));
  237. }
  238. i+= wmspInboundResultMapper.updateByPrimaryKeySelective(wmspInboundResult);
  239. }
  240. return i;
  241. }
  242. }