|
@@ -2,10 +2,9 @@ package com.steerinfo.dil.service.impl;
|
|
|
|
|
|
import com.steerinfo.dil.feign.OmsFeign;
|
|
|
import com.steerinfo.dil.feign.QmsFeign;
|
|
|
-import com.steerinfo.dil.mapper.RulesMapper;
|
|
|
-import com.steerinfo.dil.mapper.TmstruckReceiptResultMapper;
|
|
|
-import com.steerinfo.dil.mapper.TmstruckWeightResultMapper;
|
|
|
-import com.steerinfo.dil.mapper.UtilsMapper;
|
|
|
+import com.steerinfo.dil.mapper.*;
|
|
|
+import com.steerinfo.dil.model.TmstruckLeaveFactoryResult;
|
|
|
+import com.steerinfo.dil.model.TmstruckLoadResult;
|
|
|
import com.steerinfo.dil.model.TmstruckReceiptResult;
|
|
|
import com.steerinfo.dil.model.TmstruckWeightResult;
|
|
|
import com.steerinfo.dil.service.ITmstruckWeightResultService;
|
|
@@ -39,8 +38,6 @@ public class TmstruckWeightResultServiceImpl implements ITmstruckWeightResultSer
|
|
|
@Autowired
|
|
|
private TmstruckWeightResultMapper tmstruckWeightResultMapper;
|
|
|
|
|
|
- @Autowired
|
|
|
- private TmstruckReceiptResultMapper tmstruckReceiptResultMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private UtilsServiceImpl utilsService;
|
|
@@ -49,7 +46,7 @@ public class TmstruckWeightResultServiceImpl implements ITmstruckWeightResultSer
|
|
|
private UtilsMapper utilsMapper;
|
|
|
|
|
|
@Autowired
|
|
|
- private RulesServiceImpl rulesService;
|
|
|
+ private TmstruckLoadResultMapper tmstruckLoadResultMapper;
|
|
|
|
|
|
|
|
|
@Autowired
|
|
@@ -185,93 +182,248 @@ public class TmstruckWeightResultServiceImpl implements ITmstruckWeightResultSer
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 修改钢材计量实绩。
|
|
|
+ * @param map orderId, oldMaterialMapList, newMaterialMapList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public int updateSteelTruckWeightResult(Map<String, Object> map){
|
|
|
+ BigDecimal orderId = DataChange.dataToBigDecimal(map.get("orderId"));
|
|
|
+ List<Map<String, Object>> newMaterialMapList = (List<Map<String, Object>>) map.get("newMaterialMapList");
|
|
|
+ List<Map<String, Object>> oldMaterialMapList = (List<Map<String, Object>>) map.get("oldMaterialMapList");
|
|
|
+ int newSize = newMaterialMapList.size();
|
|
|
+ int oldSize = oldMaterialMapList.size();
|
|
|
+
|
|
|
+ if(newSize != oldSize){
|
|
|
+ Map<String, Object> mapOne = tmstruckWeightResultMapper.getOldWeightMes(orderId);
|
|
|
+ BigDecimal resultTotalId = DataChange.dataToBigDecimal(mapOne.get("resultTotalId"));
|
|
|
+ int maxGrossSqe = DataChange.dataToBigDecimal(mapOne.get("maxGrossSqe")).intValue();
|
|
|
+ int outFactorySqe = 0;
|
|
|
+ if(newSize > oldSize){
|
|
|
+
|
|
|
+ outFactorySqe = insertSomeResult(newSize, oldSize, maxGrossSqe, resultTotalId);
|
|
|
+ }else{
|
|
|
+ outFactorySqe = deleteSomeResult(newSize, oldSize, maxGrossSqe, resultTotalId);
|
|
|
+ }
|
|
|
+
|
|
|
+ TmstruckLeaveFactoryResult tmstruckLeaveFactoryResult = new TmstruckLeaveFactoryResult();
|
|
|
+ tmstruckLeaveFactoryResult.setResultTotalId(resultTotalId);
|
|
|
+ tmstruckLeaveFactoryResult.setSegmentSqe(new BigDecimal(outFactorySqe));
|
|
|
+ tmstruckWeightResultMapper.updateLeaveFactorySqe(tmstruckLeaveFactoryResult);
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal boundResultId = tmstruckWeightResultMapper.getOutBoundResult(orderId);
|
|
|
+ if(boundResultId != null){
|
|
|
+ Map<String, Object> changeMap = checkMaterial(oldMaterialMapList, newMaterialMapList);
|
|
|
+ if(changeMap.get("delete")!= null){
|
|
|
+
|
|
|
+ List<BigDecimal> delete = (List<BigDecimal>) changeMap.get("delete");
|
|
|
+ for (BigDecimal deleteMaterialId : delete) {
|
|
|
+ tmstruckWeightResultMapper.deleteOutBoundResult(boundResultId, deleteMaterialId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(changeMap.get("add")!= null){
|
|
|
+
|
|
|
+ List<Map<String, Object>> add = (List<Map<String, Object>>) changeMap.get("add");
|
|
|
+ for (Map<String, Object> addMap : add) {
|
|
|
+ addMap.put("boundResultId", boundResultId);
|
|
|
+ addMap.put("resultMaterialId",tmstruckWeightResultMapper.getOutBoundMaterialMaxId());
|
|
|
+ tmstruckWeightResultMapper.addOutBoundResult(addMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(changeMap.get("update") != null){
|
|
|
+
|
|
|
+ List<Map<String, Object>> update = (List<Map<String, Object>>) changeMap.get("update");
|
|
|
+ for (Map<String, Object> updateMap : update) {
|
|
|
+ updateMap.put("boundResultId", boundResultId);
|
|
|
+ tmstruckWeightResultMapper.updateOutBoundResult(updateMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public int insertSomeResult(int newSize, int oldSize, int maxGrossSqe, BigDecimal resultTotalId){
|
|
|
+
|
|
|
+ for (int i = 0; i < newSize - oldSize; i++) {
|
|
|
+ TmstruckWeightResult tmstruckWeightResult = new TmstruckWeightResult();
|
|
|
+ tmstruckWeightResult.setId(tmstruckWeightResultMapper.selectMaxId());
|
|
|
+ tmstruckWeightResult.setResultTotalId(resultTotalId);
|
|
|
+ tmstruckWeightResult.setTareSegmentSqe(new BigDecimal(++ maxGrossSqe));
|
|
|
+ tmstruckWeightResult.setInsertTime(new Date());
|
|
|
+
|
|
|
+ TmstruckLoadResult tmstruckLoadResult = new TmstruckLoadResult();
|
|
|
+ tmstruckLoadResult.setResultId(tmstruckLoadResultMapper.selectMaxId());
|
|
|
+ tmstruckLoadResult.setResultTotalId(resultTotalId);
|
|
|
+ tmstruckLoadResult.setSegmentSqe(new BigDecimal(++ maxGrossSqe));
|
|
|
+ tmstruckLoadResult.setInsertTime(new Date());
|
|
|
+ tmstruckLoadResultMapper.insertSelective(tmstruckLoadResult);
|
|
|
+
|
|
|
+ tmstruckWeightResult.setGrossSegmentSqe(new BigDecimal(++ maxGrossSqe));
|
|
|
+ tmstruckWeightResultMapper.insertSelective(tmstruckWeightResult);
|
|
|
+ }
|
|
|
+ return ++ maxGrossSqe;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- * 更新计量实绩 计皮点 计毛点 皮重
|
|
|
- * @param map
|
|
|
+ * 删除计量实绩及装车实绩
|
|
|
+ * @param newSize
|
|
|
+ * @param oldSize
|
|
|
+ * @param maxGrossSqe
|
|
|
+ * @param resultTotalId
|
|
|
+ * @return
|
|
|
*/
|
|
|
- public int updateWeightResult(Map<String, Object> map){
|
|
|
- TmstruckWeightResult tmstruckWeightResult = new TmstruckWeightResult();
|
|
|
-
|
|
|
- BigDecimal id = tmstruckWeightResultMapper.getWeightIdBySQEAndOrderId(map);
|
|
|
- tmstruckWeightResult.setId(id);
|
|
|
- if(map.get("tarePlaceId") != null){
|
|
|
- tmstruckWeightResult.setResultTarePlaceId(DataChange.dataToBigDecimal(map.get("tarePlaceId")));
|
|
|
+ public int deleteSomeResult(int newSize, int oldSize, int maxGrossSqe, BigDecimal resultTotalId ){
|
|
|
+ for (int i = 0; i < oldSize - newSize; i++) {
|
|
|
+ tmstruckWeightResultMapper.deleteWeightResult(resultTotalId, maxGrossSqe--);
|
|
|
+
|
|
|
+ tmstruckWeightResultMapper.deleteLoadResult(resultTotalId, maxGrossSqe--);
|
|
|
+
|
|
|
+ maxGrossSqe --;
|
|
|
}
|
|
|
- if(map.get("grossPlaceId") != null){
|
|
|
- tmstruckWeightResult.setResultGrossPlaceId(DataChange.dataToBigDecimal(map.get("grossPlaceId")));
|
|
|
+
|
|
|
+ return maxGrossSqe + 1;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 遍历两次物资集合,找出哪些修改哪些新增哪些删除的物资
|
|
|
+ * @param newMaterialMapList
|
|
|
+ * @param oldMaterialMapList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, Object> checkMaterial(List<Map<String, Object>> oldMaterialMapList, List<Map<String, Object>> newMaterialMapList){
|
|
|
+ Map<String, Object> returnMap = new HashMap<>();
|
|
|
+ List<BigDecimal> delete = new ArrayList<>();
|
|
|
+ List<Map<String, Object>> add = new ArrayList<>();
|
|
|
+ List<Map<String, Object>> update = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Map<String, Object> map : oldMaterialMapList) {
|
|
|
+ String materialId = String.valueOf(map.get("materialId"));
|
|
|
+
|
|
|
+ Map<String, Object> newMap = getNewMap(materialId, newMaterialMapList);
|
|
|
+ if(newMap == null){
|
|
|
+
|
|
|
+ delete.add(DataChange.dataToBigDecimal(map.get("materialId")));
|
|
|
+ }else{
|
|
|
+ BigDecimal newNumber = DataChange.dataToBigDecimal(newMap.get("materialNumber"));
|
|
|
+ BigDecimal oldNumber = DataChange.dataToBigDecimal(map.get("materialNumber"));
|
|
|
+ int i = newNumber.compareTo(oldNumber);
|
|
|
+ if(i != 0){
|
|
|
+ Map<String, Object> updateMap = new HashMap<>();
|
|
|
+ updateMap.put("materialId", materialId);
|
|
|
+ updateMap.put("materialNumber", newNumber);
|
|
|
+ update.add(updateMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- if(map.get("resultTareWeight")!= null){
|
|
|
- tmstruckWeightResult.setResultTareWeight(DataChange.dataToBigDecimal(map.get("resultTareWeight")));
|
|
|
+
|
|
|
+ for (Map<String, Object> map : newMaterialMapList) {
|
|
|
+ String materialId = String.valueOf(map.get("materialId"));
|
|
|
+ Map<String, Object> oldMaps = getNewMap(materialId, oldMaterialMapList);
|
|
|
+ if(oldMaps == null){
|
|
|
+
|
|
|
+ add.add(map);
|
|
|
+ }
|
|
|
}
|
|
|
- return tmstruckWeightResultMapper.updateByPrimaryKeySelective(tmstruckWeightResult);
|
|
|
+ if(add.size() != 0) returnMap.put("add", add);
|
|
|
+ if(delete.size() != 0) returnMap.put("delete", delete);
|
|
|
+ if(update.size() != 0) returnMap.put("update", update);
|
|
|
+ return returnMap;
|
|
|
}
|
|
|
|
|
|
|
|
|
- * 自动签收
|
|
|
+ * 遍历list查看里面的map是否包含这个值
|
|
|
+ * @param key
|
|
|
+ * @param mapList
|
|
|
* @return
|
|
|
*/
|
|
|
- public int autoReceipt(BigDecimal resultTotalId){
|
|
|
- TmstruckReceiptResult tmstruckReceiptResult = new TmstruckReceiptResult();
|
|
|
- tmstruckReceiptResult.setResultTotalId(resultTotalId);
|
|
|
- tmstruckReceiptResult.setStatus(new BigDecimal(1));
|
|
|
- tmstruckReceiptResult.setInsertUsername("admin");
|
|
|
- tmstruckReceiptResult.setInsertTime(new Date());
|
|
|
- return tmstruckReceiptResultMapper.updateByTotalResultId(tmstruckReceiptResult);
|
|
|
+ public Map<String, Object> getNewMap(String key, List<Map<String, Object>> mapList){
|
|
|
+ for (Map<String, Object> map : mapList) {
|
|
|
+ if(map.containsValue(key)){
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 更新计量实绩 计皮点 计毛点 皮重
|
|
|
+ * @param map
|
|
|
+ */
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
* 多拼计算计毛汽车衡
|
|
|
* @param map
|
|
|
*/
|
|
|
- public int calculateTruckCalculate(Map<String, Object> map, Integer resultTotalId){
|
|
|
-
|
|
|
- Integer orderId = utilsService.getOrderIdByTotalId(resultTotalId);
|
|
|
-
|
|
|
- List<Map<String, Object>> list = rulesService.judgeLastMaterial(new BigDecimal(orderId));
|
|
|
- Map<String, Object> mesMap = new HashMap<>();
|
|
|
- mesMap.put("orderId", orderId);
|
|
|
- int i = 0;
|
|
|
- if(list.size() == 0){
|
|
|
-
|
|
|
- mesMap.put("materialId", map.get("materialId"));
|
|
|
- mesMap.put("nature", 1);
|
|
|
- Integer calculate = rulesService.calculateWeighbridge(mesMap);
|
|
|
-
|
|
|
- mesMap.put("grossPlaceId", calculate);
|
|
|
- i += updateWeightResult(mesMap);
|
|
|
- }else {
|
|
|
-
|
|
|
- mesMap.put("materialId", map.get("materialId"));
|
|
|
- mesMap.put("grossPlaceId", 10);
|
|
|
- i += updateWeightResult(mesMap);
|
|
|
- }
|
|
|
- return i;
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
* 单拼销售计算汽车衡
|
|
|
* @return
|
|
|
*/
|
|
|
- public int calculateTruckCalculateByOne(Map<String, Object> map, Integer type){
|
|
|
- String orderNumber = (String) map.get("orderNumber");
|
|
|
-
|
|
|
- Map<String, Object> oIdAndMidMap = tmstruckWeightResultMapper.getOrderIdAndMaterialIdByOrderNum(orderNumber);
|
|
|
-
|
|
|
- if(type == 1){
|
|
|
-
|
|
|
- oIdAndMidMap.put("nature", type);
|
|
|
- int calculateId = rulesService.calculateWeighbridge(oIdAndMidMap);
|
|
|
- oIdAndMidMap.put("tarePlaceId", calculateId);
|
|
|
-
|
|
|
- }else if(type == 2){
|
|
|
-
|
|
|
- oIdAndMidMap.put("nature", type);
|
|
|
- int calculateId = rulesService.calculateWeighbridge(oIdAndMidMap);
|
|
|
- oIdAndMidMap.put("grossPlaceId", calculateId);
|
|
|
- }
|
|
|
- return updateWeightResult(oIdAndMidMap);
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|