WmspGridMaterialServiceImpl.java 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. package com.steerinfo.dil.service.impl;
  2. import com.steerinfo.dil.mapper.*;
  3. import com.steerinfo.dil.model.WmspCheckWarehouse;
  4. import com.steerinfo.dil.model.WmspGridMaterial;
  5. import com.steerinfo.dil.model.WmspRestackMakeResult;
  6. import com.steerinfo.dil.model.WmspRestackScanResult;
  7. import com.steerinfo.dil.service.IWmspGridMaterialService;
  8. import com.steerinfo.dil.util.DataChange;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.stereotype.Service;
  11. import java.math.BigDecimal;
  12. import java.util.*;
  13. /**
  14. * WmspGridMaterial服务实现:
  15. * @author generator
  16. * @version 1.0-SNAPSHORT 2021-09-08 06:02
  17. * 类描述
  18. * 修订历史:
  19. * 日期:2021-09-08
  20. * 作者:generator
  21. * 参考:
  22. * 描述:WmspGridMaterial服务实现
  23. * @see null
  24. * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
  25. */
  26. @Service
  27. public class WmspGridMaterialServiceImpl implements IWmspGridMaterialService {
  28. @Autowired
  29. private WmspGridMaterialMapper wmspGridMaterialMapper;
  30. @Autowired
  31. private RmsStackingMapper rmsStackingMapper;
  32. @Autowired
  33. private RmsPwarehouseGridMapper rmsPwarehouseGridMapper;
  34. @Autowired
  35. private WmspRestackScanResultMapper wmspRestackScanResultMapper;
  36. @Autowired
  37. private WmspRestackMakeResultMapper wmspRestackMakeResultMapper;
  38. @Autowired
  39. private WmspCheckWarehouseMapper wmspCheckWarehouseMapper;
  40. //新增
  41. @Override
  42. public int insertSelective(WmspGridMaterial wmspGridMaterial) {
  43. // long id;
  44. // BigDecimal MAXid=wmspGridMaterial.getGmId();
  45. // if (MAXid==null){
  46. // id=1;
  47. // }else {
  48. // id=MAXid.longValue()+1;
  49. // }
  50. // wmspGridMaterial.setGmId(new BigDecimal(id));
  51. return wmspGridMaterialMapper.insertSelective(wmspGridMaterial);
  52. }
  53. //更新
  54. @Override
  55. public int updateByPrimaryKeySelective(WmspGridMaterial wmspGridMaterial) {
  56. return wmspGridMaterialMapper.updateByPrimaryKeySelective(wmspGridMaterial);
  57. }
  58. //查询实时库存数据
  59. @Override
  60. public List<Map<String, Object>> selectGridMaterial(Map<String, Object> mapval) {
  61. return wmspGridMaterialMapper.selectGridMaterial(mapval);
  62. }
  63. //根据仓储网格统计数据
  64. @Override
  65. public Long countByGmId() {
  66. return wmspGridMaterialMapper.countByGmId();
  67. }
  68. @Override
  69. public List<Map<String, Object>> selectInboundTimeAndThreshold(BigDecimal gridId) {
  70. return wmspGridMaterialMapper.selectInboundTimeAndThreshold(gridId);
  71. }
  72. @Override
  73. public Integer insertWmspGridMaterial(WmspGridMaterial wmspGridMaterial) {
  74. return wmspGridMaterialMapper.insertSelective(wmspGridMaterial);
  75. }
  76. @Override
  77. public List<Map<String, Object>> selectGridMaterialListByGridId(Map<String, Object> mapval) {
  78. return wmspGridMaterialMapper.selectGridMaterialListByGridId(mapval);
  79. }
  80. @Override
  81. public int updateRmsMaterialSteelDemotion(Map<String, Object> map) {
  82. String gridId = map.get("gridId").toString();
  83. BigDecimal materialSteelId = wmspGridMaterialMapper.selectMaterialSteelIdByGridId(new BigDecimal(gridId));
  84. map.put("materialSteelId",materialSteelId);
  85. //逻辑删除物资钢材表的这个钢材数据并修改其质量是否合格状态
  86. wmspGridMaterialMapper.updateRmsMaterialSteelDemotion(map);
  87. //逻辑删除物资为当前钢材的钢材仓库网格物资存放关系表数据(用对象)
  88. WmspGridMaterial wmspGridMaterial = new WmspGridMaterial();
  89. wmspGridMaterial.setGridId(new BigDecimal(gridId));
  90. wmspGridMaterial.setDeleted(new BigDecimal(0));
  91. wmspGridMaterialMapper.updateByPrimaryKeySelective(wmspGridMaterial);
  92. //逻辑删除入库作业实绩以及相关联的所有表数据
  93. //通过钢材Id获取入库作业实绩Id
  94. BigDecimal inboundId = wmspGridMaterialMapper.selectInboundIdByMaterialSteelId(materialSteelId);
  95. //通过入库实绩ID逻辑删除库管员纠正吊牌实绩数据
  96. wmspGridMaterialMapper.updateInboundCorrectByInboundId(inboundId);
  97. //通过入库实绩ID逻辑删除行车工吊装入库实绩数据
  98. wmspGridMaterialMapper.updateInboundDrivingByInboundId(inboundId);
  99. //通过入库实绩ID逻辑删除吊钢工扫描吊牌实绩数据
  100. wmspGridMaterialMapper.updateInboundScanByInboundId(inboundId);
  101. //通过入库实绩ID逻辑删除系统/库管员选择垛位实绩数据
  102. return wmspGridMaterialMapper.updateInboundStackByInboundId(inboundId);
  103. }
  104. /**
  105. * 创建实时库存
  106. * @param item
  107. * @param houseGrid
  108. */
  109. @Override
  110. public void initInsertWmspGridMaterial(Map<String, Object> item, BigDecimal houseGrid) {
  111. /*
  112. 插入一条网格物资中间表
  113. */
  114. WmspGridMaterial wmspGridMaterial = new WmspGridMaterial();
  115. //设置主键ID
  116. wmspGridMaterial.setGmId(wmspGridMaterialMapper.getCount());
  117. wmspGridMaterial.setGridId(houseGrid);
  118. wmspGridMaterial.setGmNumber(new BigDecimal(1));
  119. wmspGridMaterial.setStandardDataId(new BigDecimal(1));
  120. //设置网格物资表里面的物资ID
  121. BigDecimal materialId= DataChange.dataToBigDecimal(item.get("materialId"));
  122. wmspGridMaterial.setMaterialId(materialId);
  123. //设置逻辑删除字段
  124. wmspGridMaterial.setDeleted(new BigDecimal(0));
  125. //设置常规字段
  126. wmspGridMaterial.setInsertUsername("admin");
  127. wmspGridMaterial.setInsertTime(new Date());
  128. wmspGridMaterial.setUpdateUsername("admin");
  129. wmspGridMaterial.setInsertUpdateRemark("无");
  130. wmspGridMaterial.setStatus(new BigDecimal(2));
  131. insertWmspGridMaterial(wmspGridMaterial);
  132. }
  133. @Override
  134. public Map<String, Object> getReboundScanResultByResultMaterial(String material,String materialOnlyCode) {
  135. return wmspGridMaterialMapper.getReboundScanResultByResultMaterial(material,materialOnlyCode);
  136. }
  137. //修改实时库存(倒垛)
  138. /**
  139. * 所需要参数:原来的仓储网格id,修改后的垛位
  140. * @param map
  141. * @return
  142. */
  143. @Override
  144. public int updateWmspGridMaterial(List<Map<String, Object>> map,String restackMake) {
  145. int CC=0;
  146. int MN=0;
  147. int CX=0;
  148. int i =0;
  149. //获取物资唯一编码
  150. // List<Map<String,Object>> contents=(List<Map<String, Object>>) map.get("contents");
  151. for (Map<String,Object> map1:map) {
  152. String content =(String) map1.get("contents");
  153. //截取
  154. String[] split = content.split("-");
  155. String materialOnlyCode = split[7];
  156. //获取原来的垛位,修改垛位剩余物资数量
  157. //根据物资唯一编码查找原来垛位的仓储网格id
  158. BigDecimal GirdId = wmspGridMaterialMapper.slelectGridIdByMaterialOnlyCode(materialOnlyCode);
  159. //根据物资唯一编码和物资编码去查找物资现存仓存网格
  160. Map<String,Object> stringObjectMap = wmspGridMaterialMapper.selectGmIdByMaterialOnlyCode(GirdId);
  161. BigDecimal gmId = DataChange.dataToBigDecimal(stringObjectMap.get("gmId"));
  162. WmspGridMaterial wmspGridMaterial=new WmspGridMaterial();
  163. wmspGridMaterial.setGmId(gmId);
  164. //设置为删除且锁定的状态
  165. wmspGridMaterial.setDeleted(new BigDecimal(1));
  166. wmspGridMaterial.setStatus(new BigDecimal(1));
  167. wmspGridMaterialMapper.updateByPrimaryKeySelective(wmspGridMaterial);
  168. //获取垛位id
  169. BigDecimal stackingId = DataChange.dataToBigDecimal(map1.get("stackingId"));
  170. //根据最新的垛位
  171. //计算仓储网格id
  172. //获取物资数
  173. MN=rmsStackingMapper.selectMaterialNumber(map1);
  174. //计算层次号
  175. CC=(MN)/24+1;
  176. //计算层序号
  177. CX=(MN)%24+1;
  178. //根据原来的仓储网格id查询仓库id
  179. BigDecimal warehouseId = DataChange.dataToBigDecimal(stringObjectMap.get("warehouseId"));
  180. Map<String,Object> map2=new HashMap<>();
  181. map2.put("gradationNumber",CC);
  182. map2.put("sequenceNumber",CX);
  183. map2.put("stackingID",stackingId);
  184. map2.put("warehouseId",warehouseId);
  185. BigDecimal GridId = rmsPwarehouseGridMapper.selectGridId(map2);
  186. BigDecimal gmNumber =(BigDecimal) stringObjectMap.get("gmNumber");
  187. BigDecimal weight = (BigDecimal) stringObjectMap.get("weight");
  188. BigDecimal materialId =(BigDecimal) stringObjectMap.get("materialId");
  189. //新增实时库存
  190. wmspGridMaterial.setGmId(wmspGridMaterialMapper.getCount());
  191. wmspGridMaterial.setGridId(GridId);
  192. wmspGridMaterial.setMaterialId(materialId);
  193. wmspGridMaterial.setGmNumber(gmNumber);
  194. wmspGridMaterial.setGmWeight(weight);
  195. wmspGridMaterial.setInsertTime(new Date());
  196. wmspGridMaterial.setInsertUsername("admin");
  197. wmspGridMaterial.setDeleted(new BigDecimal(0));
  198. wmspGridMaterial.setStatus(new BigDecimal(2));
  199. wmspGridMaterial.setStandardDataId(new BigDecimal(1));
  200. wmspGridMaterialMapper.insertSelective(wmspGridMaterial);
  201. // 4、改变当前订单中已经稽核的吊牌的状态,改为已倒垛
  202. // 根据吊牌扫描结果查找对应的吊牌扫描实绩Id
  203. BigDecimal resultId=wmspRestackScanResultMapper.getResultId(content);
  204. WmspRestackScanResult wmspRestackScanResult = new WmspRestackScanResult();
  205. wmspRestackScanResult.setResultId(resultId);
  206. wmspRestackScanResult.setStatus(new BigDecimal(1));
  207. i += wmspRestackScanResultMapper.updateByPrimaryKeySelective(wmspRestackScanResult);
  208. // 3、将当前订单的总数量减去上面当前订单中已经稽核的吊牌
  209. WmspRestackMakeResult wmspRestackMakeResult = new WmspRestackMakeResult();
  210. wmspRestackMakeResult.setResultId(new BigDecimal(restackMake));
  211. BigDecimal quantity=wmspRestackMakeResultMapper.getQuantity(restackMake);
  212. // 判断当前订单的总数量是否小于或等于0
  213. if (quantity.compareTo(new BigDecimal(1))==-1){
  214. // 当存在时直接结束当前循环
  215. break;
  216. }
  217. // 将当前订单的总数量减一
  218. wmspRestackMakeResult.setQuantity(quantity.subtract(new BigDecimal(1)));
  219. i += wmspRestackMakeResultMapper.updateByPrimaryKeySelective(wmspRestackMakeResult);
  220. }
  221. return i;
  222. }
  223. public List<Map<String, Object>> getMaterialTypeList(String warehouseid, BigDecimal stackingId, BigDecimal gradtionNumber) {
  224. return wmspGridMaterialMapper.getMaterialTypeList(warehouseid,stackingId,gradtionNumber);
  225. }
  226. // 新增库存盘点实绩
  227. @Override
  228. public int insertStockTaking(String warehouseId, String materialCode, Integer quantity) {
  229. // 根据仓库id和物资类型编码,查询当前的今日库存以及今天入库和出库数量
  230. int count = wmspGridMaterialMapper.getStockTakingList(warehouseId,materialCode);
  231. // 调用插入库存盘点实绩接口
  232. // 创建库存盘点实绩类
  233. WmspCheckWarehouse wmspCheckWarehouse = new WmspCheckWarehouse();
  234. // 添加仓库id
  235. wmspCheckWarehouse.setWarehouseId(new BigDecimal(warehouseId));
  236. // 添加物资ID
  237. BigDecimal materialId = wmspGridMaterialMapper.getMaterialIds(materialCode);
  238. wmspCheckWarehouse.setMaterialId(materialId);
  239. // 添加实际数量
  240. wmspCheckWarehouse.setElectronicsMaterialAmount(new BigDecimal(count));
  241. // 添加盘点数量
  242. wmspCheckWarehouse.setRealMaterialAmount(new BigDecimal(quantity));
  243. // 添加盈亏数
  244. Integer checkProfitloss = count - quantity;
  245. wmspCheckWarehouse.setCheckProfitloss(new BigDecimal(checkProfitloss));
  246. wmspCheckWarehouse.setInsertTime(new Date());
  247. wmspCheckWarehouse.setInsertUsername("admin");
  248. // 查找当前盘点库存实绩表的最大Id
  249. BigDecimal checkId = wmspCheckWarehouseMapper.getMaxId();
  250. wmspCheckWarehouse.setCheckId(checkId);
  251. int result = wmspCheckWarehouseMapper.insertSelective(wmspCheckWarehouse);
  252. return result;
  253. }
  254. @Override
  255. public List<Map<String, Object>> getStockTakingList() {
  256. return wmspCheckWarehouseMapper.getStockTakingList();
  257. }
  258. @Override
  259. public List<Map<String, Object>> getSteelMaterialList() {
  260. return wmspCheckWarehouseMapper.getSteelMaterialList();
  261. }
  262. }