|
@@ -2,23 +2,17 @@ package com.steerinfo.dil.service.impl;
|
|
|
|
|
|
import com.steerinfo.dil.feign.OmsFeign;
|
|
|
import com.steerinfo.dil.feign.QmsFeign;
|
|
|
-import com.steerinfo.dil.mapper.TmstruckEnfactoryResultMapper;
|
|
|
-import com.steerinfo.dil.mapper.TmstruckTotalResultMapper;
|
|
|
-import com.steerinfo.dil.mapper.TmstruckWeightResultMapper;
|
|
|
-import com.steerinfo.dil.model.TmstruckEnfactoryResult;
|
|
|
-import com.steerinfo.dil.model.TmstruckTotalResult;
|
|
|
-import com.steerinfo.dil.model.TmstruckWeightResult;
|
|
|
+import com.steerinfo.dil.mapper.*;
|
|
|
+import com.steerinfo.dil.model.*;
|
|
|
import com.steerinfo.dil.service.ITmstruckTotalResultService;
|
|
|
+import com.steerinfo.dil.util.DataChange;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @ author :TXF
|
|
@@ -40,6 +34,36 @@ public class TmstruckTotalResultServiceImpl implements ITmstruckTotalResultServi
|
|
|
@Autowired
|
|
|
TmstruckWeightResultMapper tmstruckWeightResultMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ TmstruckLoadResultMapper tmstruckLoadResultMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ TmstruckUnloadResultMapper tmstruckUnloadResultMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ TmstruckLeaveFactoryResultMapper tmstruckLeaveFactoryResultMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ TmstruckEnfactoryResultServiceImpl tmstruckEnfactoryResultService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ TmstruckLoadResultServiceImpl tmstruckLoadResultService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ TmstruckUnloadResultServiceImpl tmstruckUnloadResultService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ TmstruckWeightResultServiceImpl tmstruckWeightResultService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ TmstruckLeaveFactoryResultServiceImpl tmstruckLeaveFactoryResultService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ TmstruckReturnResultServiceImpl tmstruckReturnResultService;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 新增实绩总表
|
|
|
* 运输订单ID
|
|
@@ -159,4 +183,179 @@ public class TmstruckTotalResultServiceImpl implements ITmstruckTotalResultServi
|
|
|
addTotalResult(orderId);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public int changeOrderLine(Map<String, Object> mapValue) throws Exception {
|
|
|
+ //查询订单详情
|
|
|
+ Map<String,Object> mesMap=tmstruckTotalResultMapper.getLineId(mapValue);
|
|
|
+ if(mesMap==null){
|
|
|
+ throw new Exception("订单状态异常,无法变更!");
|
|
|
+ }
|
|
|
+ //更新线路Id
|
|
|
+ if(mapValue.get("lineId")==null){
|
|
|
+ throw new Exception("请选择线路!");
|
|
|
+ }else if(DataChange.dataToBigDecimal(mesMap.get("lineId")).compareTo(DataChange.dataToBigDecimal(mapValue.get("lineId")))==0){
|
|
|
+ throw new Exception("线路一致,无需更新!");
|
|
|
+ }else{
|
|
|
+ tmstruckTotalResultMapper.updateLineId(mapValue);
|
|
|
+ }
|
|
|
+ //校验订单,如果未接单就直接结束,已接单则继续修改实绩
|
|
|
+ if(DataChange.dataToBigDecimal(mesMap.get("orderStatus")).compareTo(new BigDecimal(4))==0){
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ //查询并记录有效实绩,进厂,计量,装货,卸货,出厂
|
|
|
+ mesMap.put("flag","1");//只查询有效实绩
|
|
|
+ List<TmstruckEnfactoryResult> enfactoryResults= tmstruckTotalResultMapper.selectAllEnfactory(mesMap);
|
|
|
+ List<TmstruckWeightResult> tmstruckWeightResults= tmstruckTotalResultMapper.selectAllWeight(mesMap);
|
|
|
+ List<TmstruckUnloadResult> unloadResults=tmstruckTotalResultMapper.selectAllUnload(mesMap);
|
|
|
+ List<TmstruckLeaveFactoryResult> leaveFactoryResults=tmstruckTotalResultMapper.selectAllLeavefactory(mesMap);
|
|
|
+ System.out.println(enfactoryResults);
|
|
|
+ System.out.println(tmstruckWeightResults);
|
|
|
+ System.out.println(unloadResults);
|
|
|
+ System.out.println(leaveFactoryResults);
|
|
|
+ //删除所有旧线路实绩
|
|
|
+ tmstruckTotalResultMapper.deleteEnByEnTotal(mesMap);
|
|
|
+ tmstruckTotalResultMapper.deleteWeightByEnTotal(mesMap);
|
|
|
+ tmstruckTotalResultMapper.deleteUnloadByEnTotal(mesMap);
|
|
|
+ tmstruckTotalResultMapper.deleteLeaveByEnTotal(mesMap);
|
|
|
+ //新增所有新线路实绩
|
|
|
+ mesMap.put("lineId",mapValue.get("lineId"));
|
|
|
+ addAllSonResult(mesMap);
|
|
|
+ //查询并记录所有新实绩
|
|
|
+ System.out.println("-------------------------------------");
|
|
|
+ mesMap.put("flag","0");//打开查询所有
|
|
|
+ List<TmstruckEnfactoryResult> enfactoryResultsNew= tmstruckTotalResultMapper.selectAllEnfactory(mesMap);
|
|
|
+ List<TmstruckWeightResult> tmstruckWeightResultsNew= tmstruckTotalResultMapper.selectAllWeight(mesMap);
|
|
|
+ //List<TmstruckUnloadResult> unloadResultsNew=tmstruckTotalResultMapper.selectAllUnload(mesMap);//卸货和出厂不处理
|
|
|
+ //List<TmstruckLeaveFactoryResult> leaveFactoryResultsNew=tmstruckTotalResultMapper.selectAllLeavefactory(mesMap);
|
|
|
+ System.out.println(enfactoryResultsNew);
|
|
|
+ System.out.println(tmstruckWeightResultsNew);
|
|
|
+ //System.out.println(unloadResultsNew);
|
|
|
+ //System.out.println(leaveFactoryResultsNew);
|
|
|
+ //更新订单信息,按顺序更新
|
|
|
+ for(int i=0;i<enfactoryResults.size();i++){
|
|
|
+ //进厂实绩
|
|
|
+ try{
|
|
|
+ TmstruckEnfactoryResult oldResult=enfactoryResults.get(i);
|
|
|
+ TmstruckEnfactoryResult newResult=enfactoryResultsNew.get(i);
|
|
|
+ if(oldResult!=null && newResult!=null){
|
|
|
+ newResult.setGatepostId(oldResult.getGatepostId());
|
|
|
+ newResult.setResultEntryMode(oldResult.getResultEntryMode());
|
|
|
+ newResult.setResultEntryGateTime(oldResult.getResultEntryGateTime());
|
|
|
+ }
|
|
|
+ tmstruckEnfactoryResultMapper.updateByPrimaryKeySelective(newResult);
|
|
|
+ }catch (Exception e){
|
|
|
+ //数组越界,不处理
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for(int i=0;i<tmstruckWeightResults.size();i++){
|
|
|
+ //计量实绩
|
|
|
+ try{
|
|
|
+ TmstruckWeightResult oldResult=tmstruckWeightResults.get(i);
|
|
|
+ TmstruckWeightResult newResult=tmstruckWeightResultsNew.get(i);
|
|
|
+ if(oldResult!=null && newResult!=null){
|
|
|
+ newResult.setResultGrossPlaceId(oldResult.getResultGrossPlaceId());
|
|
|
+ newResult.setResultGrossWeight(oldResult.getResultGrossWeight());
|
|
|
+ newResult.setResultGrossWeightTime(oldResult.getResultGrossWeightTime());
|
|
|
+ newResult.setMaterialId(oldResult.getMaterialId());
|
|
|
+ newResult.setResultPoundNo(oldResult.getResultPoundNo());
|
|
|
+// newResult.setResultTarePlaceId(oldResult.getResultTarePlaceId());
|
|
|
+// newResult.setResultTareWeight(oldResult.getResultTareWeight());
|
|
|
+// newResult.setResultTareWeightTime(oldResult.getResultTareWeightTime());
|
|
|
+ }
|
|
|
+ tmstruckWeightResultMapper.updateByPrimaryKeySelective(newResult);
|
|
|
+ }catch (Exception e){
|
|
|
+ //数组越界,不处理
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过线路子表路线图生成各实绩
|
|
|
+ * @param map
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public int addAllSonResult(Map<String, Object> map){
|
|
|
+ Integer resultTotalId = DataChange.dataToBigDecimal(map.get("resultTotalId")).intValue();
|
|
|
+ Integer lineId = DataChange.dataToBigDecimal(map.get("lineId")).intValue();
|
|
|
+ int result = 0;
|
|
|
+ //通过总实绩Id 查询关联的线路子表顺序
|
|
|
+ List<Map<String, Object>> segmentList = tmstruckTotalResultMapper.getLineMesByOrderId(map);
|
|
|
+ Map<String,Object> totalIdMap = new HashMap<>();
|
|
|
+ totalIdMap.put("resultTotalId",resultTotalId);
|
|
|
+ totalIdMap.put("lineId", lineId);
|
|
|
+ // 遍历路段顺序号子表
|
|
|
+ int count = 0;
|
|
|
+ BigDecimal lineType = (BigDecimal) segmentList.get(0).get("lineType");
|
|
|
+ if (lineType.intValue() == 4) {
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ //存放皮重路段顺序号和毛重路段顺序号map
|
|
|
+ Map<String, Object> tareAndGrossSegmentMap = new HashMap<>();
|
|
|
+ for (Map<String,Object> segmentMap : segmentList) {
|
|
|
+ BigDecimal segmentSqe = (BigDecimal) segmentMap.get("segmentSqe");
|
|
|
+ String linkName = (String) segmentMap.get("linkName");
|
|
|
+ totalIdMap.put("segmentSqe",segmentSqe);
|
|
|
+ // 判断是否是计毛
|
|
|
+ if (linkName.equals("计毛")) {
|
|
|
+ // 如果是计量则加一
|
|
|
+ count ++;
|
|
|
+ tareAndGrossSegmentMap.put("grossSegmentSqe", segmentSqe);
|
|
|
+ // 有两个计量的时候则新增实绩
|
|
|
+ if (count == 2) {
|
|
|
+ totalIdMap.putAll(tareAndGrossSegmentMap);//将皮重顺序号和毛重路段顺序号放进去
|
|
|
+ tmstruckWeightResultService.addWeightResult(totalIdMap);
|
|
|
+ // 新增一次则对计数器清零
|
|
|
+ count = 0;
|
|
|
+ tareAndGrossSegmentMap.clear(); // 清空毛重皮重 map
|
|
|
+ result++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 判断是否是计皮
|
|
|
+ if (linkName.equals("计皮")) {
|
|
|
+ // 如果是计皮则加一
|
|
|
+ count ++;
|
|
|
+ tareAndGrossSegmentMap.put("tareSegmentSqe", segmentSqe);
|
|
|
+ // 有两个计量的时候则新增实绩
|
|
|
+ if (count == 2) {
|
|
|
+ totalIdMap.putAll(tareAndGrossSegmentMap);
|
|
|
+ tmstruckWeightResultService.addWeightResult(totalIdMap);
|
|
|
+ // 新增一次则对计数器清零
|
|
|
+ count = 0;
|
|
|
+ tareAndGrossSegmentMap.clear(); // 清空毛重皮重 map
|
|
|
+ result++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 进厂
|
|
|
+ if (linkName.equals("进厂")) {
|
|
|
+ tmstruckEnfactoryResultService.addEnFactoryResult(totalIdMap);
|
|
|
+ result++;
|
|
|
+ }
|
|
|
+ // 出厂
|
|
|
+ if (linkName.equals("出厂")) {
|
|
|
+ tmstruckLeaveFactoryResultService.addLeaveFactory(totalIdMap);
|
|
|
+ result++;
|
|
|
+ }
|
|
|
+ // 装货
|
|
|
+ if (linkName.equals("装货")) {
|
|
|
+ tmstruckLoadResultService.addLoadResult(totalIdMap);
|
|
|
+ result++;
|
|
|
+ }
|
|
|
+ // 卸货
|
|
|
+ if (linkName.equals("卸货")) {
|
|
|
+ tmstruckUnloadResultService.addUnloadResult(totalIdMap);
|
|
|
+ result++;
|
|
|
+ }
|
|
|
+ // 退货
|
|
|
+// if (linkName.equals("退货")) {
|
|
|
+// totalIdMap.put("returnReason", map.get("returnReason")); //退货原因 仅退货有用
|
|
|
+// totalIdMap.put("orderId", map.get("orderId")); //添加新订单ID
|
|
|
+// tmstruckReturnResultService.addReturnGoodsResult(totalIdMap);
|
|
|
+// result++;
|
|
|
+// }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|