|
@@ -105,57 +105,96 @@ public class TmstrainLoadingResultServiceImpl implements ITmstrainLoadingResultS
|
|
|
|
|
|
|
|
|
* 进口矿新增装车实绩
|
|
|
- * @param tmstrainLoadingResult
|
|
|
+ * @param mapValue
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public int addTmstrainLoadingResult(TmstrainLoadingResult tmstrainLoadingResult) throws Exception{
|
|
|
- List<String> wagonNoList = tmstrainLoadingResult.getWagonNoList();
|
|
|
- if(tmstrainLoadingResult.getUserId()==null)
|
|
|
+ public int addTmstrainLoadingResult(Map<String,Object> mapValue) throws Exception{
|
|
|
+ List<Map<String, Object>> list= (List<Map<String, Object>>) mapValue.get("list");
|
|
|
+ String userId=null;
|
|
|
+ if(mapValue.get("userId")!=null)
|
|
|
+ userId=mapValue.get("userId").toString();
|
|
|
+ else
|
|
|
throw new Exception("用户id为空,请先登录再操作!");
|
|
|
- if(wagonNoList.size()<=0){
|
|
|
- throw new Exception("车皮号异常");
|
|
|
- }
|
|
|
-
|
|
|
- BigDecimal purchaseOrderId = tmstrainLoadingResult.getPurchaseOrderRailPlanId();
|
|
|
- BigDecimal arrivalStationId = tmstrainLoadingResult.getArrivalStationId();
|
|
|
- if(arrivalStationId.intValue() == 1){
|
|
|
- tmstrainLoadingResult.setSendRequest(new BigDecimal(1));
|
|
|
- }
|
|
|
- BigDecimal batchId = tmstrainLoadingResultMapper.getBatchIdByPurOrderId(purchaseOrderId);
|
|
|
- tmstrainLoadingResult.setBatchId(batchId);
|
|
|
-
|
|
|
- addRegularField(tmstrainLoadingResult,tmstrainLoadingResult.getUserId());
|
|
|
-
|
|
|
- int count = 0;
|
|
|
- List<Map<String,Object>> resultIdList=new ArrayList<>();
|
|
|
- for (String wagonNo : wagonNoList) {
|
|
|
- tmstrainLoadingResult.setResultWagonNo(wagonNo);
|
|
|
+
|
|
|
+ List<TmstrainLoadingResult> loadingResults=new ArrayList<>();
|
|
|
+
|
|
|
+ List<String> splits=tmstrainLoadingResultMapper.findSplitsForImported();
|
|
|
+ int i = 0;
|
|
|
+ for(Map<String,Object> map:list){
|
|
|
+ TmstrainLoadingResult result=new TmstrainLoadingResult();
|
|
|
+
|
|
|
BigDecimal maxId = tmstrainLoadingResultMapper.selectMaxId();
|
|
|
-
|
|
|
- tmstrainLoadingResult.setResultId(maxId);
|
|
|
+ result.setResultId(maxId);
|
|
|
+
|
|
|
+ List<Map<String,Object>> orderList= tmstrainLoadingResultMapper.getPurchaseOrderListForImported(map);
|
|
|
+ if(orderList.size() > 1){
|
|
|
+
|
|
|
+ map.put("materialName",map.get("mineral"));
|
|
|
+ String productName=map.get("productName").toString();
|
|
|
+ for(String split:splits){
|
|
|
+ String arr[]=productName.split(split);
|
|
|
+ if(arr.length>1){
|
|
|
+
|
|
|
+ map.put("resultForeignShipName",arr[1]);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ orderList= tmstrainLoadingResultMapper.getPurchaseOrderListForImported(map);
|
|
|
+ }
|
|
|
+ if(orderList.size() > 0){
|
|
|
+ Map<String,Object> details=orderList.get(0);
|
|
|
+ BigDecimal purchaseOrderId=DataChange.dataToBigDecimal(details.get("purchaseOrderId"));
|
|
|
+ BigDecimal materialId=DataChange.dataToBigDecimal(details.get("materialId"));
|
|
|
+ BigDecimal supplierId=DataChange.dataToBigDecimal(details.get("supplierId"));
|
|
|
+ BigDecimal batchId=DataChange.dataToBigDecimal(details.get("batchId"));
|
|
|
+ result.setPurchaseOrderRailPlanId(purchaseOrderId);
|
|
|
+ result.setMaterialId(materialId);
|
|
|
+ result.setSendUnitId(supplierId);
|
|
|
+ result.setBatchId(batchId);
|
|
|
+ }else{
|
|
|
+ throw new Exception("没有对应的进口矿采购订单号:"+map.get("productName").toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ result.setSendStationId(DataChange.dataToBigDecimal(mapValue.get("sendStationId")));
|
|
|
+ result.setArrivalStationId(DataChange.dataToBigDecimal(mapValue.get("arrivalStationId")));
|
|
|
+ result.setResultLoadingDate(new Date((Long)mapValue.get("resultLoadingDate")));
|
|
|
+ result.setResultType(DataChange.dataToBigDecimal(mapValue.get("resultType")));
|
|
|
+
|
|
|
+
|
|
|
+ result.setResultRemarks((String) mapValue.get("resultRemarks"));
|
|
|
+ result.setResultWagonNo(map.get("wagonNo").toString());
|
|
|
+
|
|
|
+ addRegularField(result,userId);
|
|
|
|
|
|
- int wagonWeight = calculateWagonWeight(tmstrainLoadingResult.getResultWagonNo());
|
|
|
- tmstrainLoadingResult.setResultBillableTonnage(new BigDecimal(wagonWeight));
|
|
|
- count += tmstrainLoadingResultMapper.insertSelective(tmstrainLoadingResult);
|
|
|
-
|
|
|
- count += addTotalResult(maxId);
|
|
|
-
|
|
|
- Map<String, Object> temp = new HashMap<>();
|
|
|
- temp.put("resultId",maxId);
|
|
|
- resultIdList.add(temp);
|
|
|
+ result.setResultBillableTonnage(new BigDecimal(calculateWagonWeight(result.getResultWagonNo())));
|
|
|
+
|
|
|
+
|
|
|
+ BigDecimal arrivalStationId = result.getArrivalStationId();
|
|
|
+ if(arrivalStationId!=null && arrivalStationId.intValue() == 1){
|
|
|
+ result.setTrainCalculateId(new BigDecimal(13));
|
|
|
+ result.setSendRequest(new BigDecimal(1));
|
|
|
+ }
|
|
|
+ loadingResults.add(result);
|
|
|
+ i += addTotalResult(maxId);
|
|
|
}
|
|
|
-
|
|
|
- if(resultIdList.size()==wagonNoList.size()){
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("resultIdList",resultIdList);
|
|
|
- int i = tmstrainMeasureCommissionService.batchSendMeasureCommission(map);
|
|
|
+
|
|
|
+ int count = tmstrainLoadingResultMapper.batchInsert(loadingResults);
|
|
|
+
|
|
|
+ if(count==loadingResults.size()){
|
|
|
+ ArrayList<Map<String,Object>> resultIdList=new ArrayList<>();
|
|
|
+ Map<String, Object> map1 = new HashMap<>();
|
|
|
+ for(TmstrainLoadingResult tmstrainLoadingResult:loadingResults){
|
|
|
+ Map<String, Object> temp = new HashMap<>();
|
|
|
+ temp.put("resultId",tmstrainLoadingResult.getResultId());
|
|
|
+ resultIdList.add(temp);
|
|
|
+ }
|
|
|
+ map1.put("resultIdList",resultIdList);
|
|
|
+ i = tmstrainMeasureCommissionService.batchSendMeasureCommission(map1);
|
|
|
if(i==-1){
|
|
|
- return i;
|
|
|
+ throw new Exception("计量委托发送失败!");
|
|
|
}
|
|
|
- }else{
|
|
|
- return -1;
|
|
|
}
|
|
|
return count;
|
|
|
}
|
|
@@ -172,32 +211,49 @@ public class TmstrainLoadingResultServiceImpl implements ITmstrainLoadingResultS
|
|
|
userId=mapValue.get("userId").toString();
|
|
|
else
|
|
|
throw new Exception("用户id为空,请先登录再操作!");
|
|
|
-
|
|
|
- List<TmstrainLoadingTemp> loadingTemps=new ArrayList<>();
|
|
|
|
|
|
List<TmstrainLoadingResult> loadingResults=new ArrayList<>();
|
|
|
+
|
|
|
+ List<String> splits=tmstrainLoadingResultMapper.findSplitsForDomestic();
|
|
|
int i = 0;
|
|
|
for(Map<String,Object> map:list){
|
|
|
-
|
|
|
- TmstrainLoadingTemp temp=new TmstrainLoadingTemp();
|
|
|
TmstrainLoadingResult result=new TmstrainLoadingResult();
|
|
|
|
|
|
BigDecimal maxId = tmstrainLoadingResultMapper.selectMaxId();
|
|
|
- temp.setResultId(maxId);
|
|
|
result.setResultId(maxId);
|
|
|
-
|
|
|
- temp.setSendStation((String)map.get("sendStation"));
|
|
|
- temp.setArrivalStation((String)map.get("arrivalStation"));
|
|
|
- temp.setMaterialName((String)map.get("materialName"));
|
|
|
- temp.setSupplierName((String)map.get("supplierName"));
|
|
|
-
|
|
|
- temp.setResultWagonNo(map.get("wagonNo").toString());
|
|
|
-
|
|
|
+
|
|
|
+ List<Map<String,Object>> orderList= tmstrainLoadingResultMapper.getPurchaseOrderList(map);
|
|
|
+ if(orderList.size() <= 0){
|
|
|
+
|
|
|
+ String productName=map.get("productName").toString();
|
|
|
+ for(String split:splits){
|
|
|
+ String []arr=productName.split(split);
|
|
|
+ if(arr.length>1){
|
|
|
+ String supplierName=arr[0];
|
|
|
+ map.put("supplierName",supplierName);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ orderList=tmstrainLoadingResultMapper.getPurchaseOrderList(map);
|
|
|
+ }
|
|
|
+ if(orderList.size() > 0){
|
|
|
+ Map<String,Object> details=orderList.get(0);
|
|
|
+ BigDecimal purchaseOrderId=DataChange.dataToBigDecimal(details.get("purchaseOrderId"));
|
|
|
+ BigDecimal materialId=DataChange.dataToBigDecimal(details.get("materialId"));
|
|
|
+ BigDecimal supplierId=DataChange.dataToBigDecimal(details.get("supplierId"));
|
|
|
+ BigDecimal batchId=DataChange.dataToBigDecimal(details.get("batchId"));
|
|
|
+ result.setPurchaseOrderRailPlanId(purchaseOrderId);
|
|
|
+ result.setMaterialId(materialId);
|
|
|
+ result.setSendUnitId(supplierId);
|
|
|
+ result.setBatchId(batchId);
|
|
|
+ }else{
|
|
|
+ throw new Exception("没有对应的国产矿采购订单号:"+map.get("productName"));
|
|
|
+ }
|
|
|
|
|
|
- result.setArrivalStationId(new BigDecimal(map.get("arrivalStationId").toString()));
|
|
|
+ result.setArrivalStationId(new BigDecimal(map.get("arrivalStationId").toString()));
|
|
|
result.setResultLoadingDate(new Date((Long)map.get("resultLoadingDate")));
|
|
|
result.setResultType(new BigDecimal(map.get("resultType").toString()));
|
|
|
- result.setResultRemarks((String) map.get("resultRemarks"));
|
|
|
+ result.setResultRemarks((String) map.get("resultRemarks"));
|
|
|
result.setResultWagonNo(map.get("wagonNo").toString());
|
|
|
|
|
|
String sendStationName=(String) map.get("sendStation");
|
|
@@ -228,13 +284,26 @@ public class TmstrainLoadingResultServiceImpl implements ITmstrainLoadingResultS
|
|
|
result.setTrainCalculateId(new BigDecimal(13));
|
|
|
result.setSendRequest(new BigDecimal(1));
|
|
|
}
|
|
|
- loadingTemps.add(temp);
|
|
|
loadingResults.add(result);
|
|
|
i += addTotalResult(maxId);
|
|
|
}
|
|
|
|
|
|
- tmstrainLoadingTempMapper.batchInsert(loadingTemps);
|
|
|
int count = tmstrainLoadingResultMapper.batchInsert(loadingResults);
|
|
|
+
|
|
|
+ if(count==loadingResults.size()){
|
|
|
+ ArrayList<Map<String,Object>> resultIdList=new ArrayList<>();
|
|
|
+ Map<String, Object> map1 = new HashMap<>();
|
|
|
+ for(TmstrainLoadingResult tmstrainLoadingResult:loadingResults){
|
|
|
+ Map<String, Object> temp = new HashMap<>();
|
|
|
+ temp.put("resultId",tmstrainLoadingResult.getResultId());
|
|
|
+ resultIdList.add(temp);
|
|
|
+ }
|
|
|
+ map1.put("resultIdList",resultIdList);
|
|
|
+ i = tmstrainMeasureCommissionService.batchSendMeasureCommission(map1);
|
|
|
+ if(i==-1){
|
|
|
+ throw new Exception("计量委托发送失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
return count;
|
|
|
}
|
|
|
|