WmspGridMaterialServiceImpl.java 13 KB

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