|
@@ -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("车皮号异常");
|
|
|
- }
|
|
|
- //通过采购订单号获得批次ID
|
|
|
- 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
|
|
|
+ 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();
|
|
|
- //生成主键id
|
|
|
- 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.setResultIsclear(mapValue.get("resultIsclear").toString());
|
|
|
+// result.setResultClass(mapValue.get("resultClass").toString());
|
|
|
+ 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);
|
|
|
- //计量委托实绩list
|
|
|
- Map<String, Object> temp = new HashMap<>();
|
|
|
- temp.put("resultId",maxId);
|
|
|
- resultIdList.add(temp);
|
|
|
+ result.setResultBillableTonnage(new BigDecimal(calculateWagonWeight(result.getResultWagonNo())));
|
|
|
+ //通过到站ID匹配计量衡 如果是老区轨道衡或者是新区轨道衡 则匹配轨道衡
|
|
|
+ //如果到站ID是老区轨道衡
|
|
|
+ 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
|
|
|
- List<TmstrainLoadingTemp> loadingTemps=new ArrayList<>();
|
|
|
//装车实绩list
|
|
|
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.setSendDate((String)map.get("sendDate"));//发货日期
|
|
|
- temp.setResultWagonNo(map.get("wagonNo").toString());//车皮号
|
|
|
- //temp.setResultBillableTonnage(new BigDecimal((String)map.get("weight")));
|
|
|
+ //配单
|
|
|
+ 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()));//装车类型,国产矿应该为3
|
|
|
- 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;
|
|
|
}
|
|
|
|