|
@@ -668,31 +668,57 @@ public class TmstrainLoadingResultServiceImpl implements ITmstrainLoadingResultS
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public int addWarehouseOutResult(Map<String, Object> map) {
|
|
|
- int i=0;
|
|
|
+ int resultId=0;
|
|
|
//根据车皮号计算标重
|
|
|
int wagonWeight=0;
|
|
|
+ BigDecimal batchId = null;
|
|
|
TmstrainLoadingTemp temp=new TmstrainLoadingTemp();
|
|
|
BigDecimal resultType =DataChange.dataToBigDecimal(map.get("resultType"));
|
|
|
List<Map<String,Object>> wagonList =(List<Map<String, Object>>) map.get("wagonList");
|
|
|
- for (Map<String,Object> wagon:wagonList){
|
|
|
- //根据车皮号计算车皮标重
|
|
|
- String wagonNo =(String) wagon.get("wagonNo");
|
|
|
- //根据采购订单号查找批次
|
|
|
- String purchaseNo =(String) map.get("purchaseNo");
|
|
|
- BigDecimal batchId=null;
|
|
|
- List<Map<String, Object>> batchInfocatoryByNo = tmstrainLoadingResultMapper.getBatchInfocatoryByNo(map);
|
|
|
- if (batchInfocatoryByNo.size() >= 1){
|
|
|
- Map<String, Object> map1 = batchInfocatoryByNo.get(0);
|
|
|
- batchId =DataChange.dataToBigDecimal(map1.get("batchId"));
|
|
|
- map.put("batchId",batchId);
|
|
|
- }else {
|
|
|
- return -2;
|
|
|
+ //增加是否拼装
|
|
|
+ Boolean isAssembly =(Boolean) map.get("isAssembly");
|
|
|
+ //不是拼装就计算车皮标重
|
|
|
+ if (!isAssembly) {
|
|
|
+ for (Map<String, Object> wagon : wagonList) {
|
|
|
+ //根据车皮号计算车皮标重
|
|
|
+ String wagonNo = (String) wagon.get("wagonNo");
|
|
|
+ List<Map<String, Object>> batchInfocatoryByNo = tmstrainLoadingResultMapper.getBatchInfocatoryByNo(map);
|
|
|
+ if (batchInfocatoryByNo.size() >= 1) {
|
|
|
+ Map<String, Object> map1 = batchInfocatoryByNo.get(0);
|
|
|
+ batchId = DataChange.dataToBigDecimal(map1.get("batchId"));
|
|
|
+ map.put("batchId", batchId);
|
|
|
+ } else {
|
|
|
+ return -2;
|
|
|
+ }
|
|
|
+ wagonWeight += calculateWagonWeight(wagonNo);
|
|
|
+ map.put("resultTonnage", wagonWeight);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ BigDecimal totalWeight=new BigDecimal(0);
|
|
|
+ //如果是拼装,获取车皮号标重
|
|
|
+ for (Map<String,Object> map2:wagonList) {
|
|
|
+ String wagonNo = (String) map2.get("wagonNo");
|
|
|
+ BigDecimal wagonTonnage = DataChange.dataToBigDecimal(map2.get("wagonWeight"));
|
|
|
+ //计算总吨位
|
|
|
+ if (wagonTonnage!=null) {
|
|
|
+ totalWeight = totalWeight.add(wagonTonnage);
|
|
|
+ map.put("resultTonnage", totalWeight);
|
|
|
+ }else {
|
|
|
+ wagonWeight += calculateWagonWeight(wagonNo);
|
|
|
+ map.put("resultTonnage", wagonWeight);
|
|
|
+ }
|
|
|
+ List<Map<String, Object>> batchInfocatoryByNo = tmstrainLoadingResultMapper.getBatchInfocatoryByNo(map);
|
|
|
+ if (batchInfocatoryByNo.size() >= 1) {
|
|
|
+ Map<String, Object> map1 = batchInfocatoryByNo.get(0);
|
|
|
+ batchId = DataChange.dataToBigDecimal(map1.get("batchId"));
|
|
|
+ map.put("batchId", batchId);
|
|
|
+ } else {
|
|
|
+ return -2;
|
|
|
+ }
|
|
|
}
|
|
|
- wagonWeight += calculateWagonWeight(wagonNo);
|
|
|
- map.put("resultTonnage",wagonWeight);
|
|
|
}
|
|
|
if(resultType.intValue() == 1){
|
|
|
- i = addOutWarehouse(map);
|
|
|
+ resultId = addOutWarehouse(map);
|
|
|
for (Map<String,Object> map1:wagonList) {
|
|
|
String wagonNo =(String) map1.get("wagonNo");
|
|
|
//根据采购订单号查找批次
|
|
@@ -700,11 +726,15 @@ public class TmstrainLoadingResultServiceImpl implements ITmstrainLoadingResultS
|
|
|
temp.setResultId(tmstrainLoadingTempMapper.selectMaxId());
|
|
|
temp.setResultWagonNo(wagonNo);
|
|
|
temp.setPurchaseOrderNo(purchaseNo);
|
|
|
- temp.setOutbountId(new BigDecimal(i));
|
|
|
- temp.setResultBillableTonnage(DataChange.dataToBigDecimal(calculateWagonWeight(wagonNo)));
|
|
|
+ temp.setOutbountId(new BigDecimal(resultId));
|
|
|
+ if (map1.get("wagonWeight")==null) {
|
|
|
+ temp.setResultBillableTonnage(DataChange.dataToBigDecimal(calculateWagonWeight(wagonNo)));
|
|
|
+ }else {
|
|
|
+ temp.setResultBillableTonnage(DataChange.dataToBigDecimal(map1.get("wagonWeight")));
|
|
|
+ }
|
|
|
tmstrainLoadingTempMapper.insertSelective(temp);
|
|
|
}
|
|
|
}
|
|
|
- return i;
|
|
|
+ return resultId;
|
|
|
}
|
|
|
}
|