Redeem 1 年之前
父節點
當前提交
4c6b920bc5

+ 3 - 0
src/main/java/com/steerinfo/dil/mapper/BmstruckDetailsOrderMapper.java

@@ -241,4 +241,7 @@ public interface BmstruckDetailsOrderMapper extends IBaseMapper<BmstruckDetailsO
     List<BigDecimal> getOrderIds(BigDecimal orderId);
 
     BigDecimal getWeightBatchNetWeight(BigDecimal weightBatchId);
+
+    BigDecimal getDetailsIdByBatchId(BigDecimal weightBatchId);
+
 }

+ 28 - 21
src/main/java/com/steerinfo/dil/service/impl/BmstruckDetailsOrderServiceImpl.java

@@ -1359,7 +1359,7 @@ public class BmstruckDetailsOrderServiceImpl implements IBmstruckDetailsOrderSer
     }
 
     @Override
-    public int updateDetailsDirect(Map<String, Object> mapValue) throws Exception {
+    public synchronized int updateDetailsDirect(Map<String, Object> mapValue) throws Exception {
         List<BigDecimal> orderIds = (List<BigDecimal>) mapValue.get("orderList");
         BigDecimal priceValue = DataChange.dataToBigDecimal(mapValue.get("detailAmount"));//以java变量名为准,这里是所填写的单价值
         if(priceValue.intValue() < 0){
@@ -1388,32 +1388,39 @@ public class BmstruckDetailsOrderServiceImpl implements IBmstruckDetailsOrderSer
             bmstruckDetailsOrderMapper.updateAsomPriceIdByOrderId(orderId,priceId);
             saleLogUtil.logOrder(orderId,"直接修改单价",userName,SaleLogUtil.UPDATE);
             //查询订单计量详情
-            List<Map<String,Object>> weightTaskResultIdList = bmstruckDetailsOrderMapper.getSteelWeightTaskResultId(orderId);
-            for (Map<String, Object> map : weightTaskResultIdList) {
-                BigDecimal weightTaskResultId = DataChange.dataToBigDecimal(map.get("weightTaskResultId"));
-                BigDecimal netWeightIsNull = bmstruckDetailsOrderMapper.getNetWeight(weightTaskResultId);
-                if (netWeightIsNull == null) {
+            List<Map<String,Object>> batchIdList = bmstruckDetailsOrderMapper.getWeightBatchIds(orderId);
+            for (Map<String, Object> map : batchIdList) {
+                BigDecimal weightBatchId = DataChange.dataToBigDecimal(map.get("weightBatchId"));
+                //根据计量实绩查找批次ID
+                BigDecimal netWeight = DataChange.dataToBigDecimal(map.get("netWeight"));
+                if (netWeight == null) {
                     System.out.println("没有计量实绩,不生成结算数据:" + orderId);
                     continue;
                 }
-                //计算总费用
-                BigDecimal  detailsAmountOld = generateTruckFeesForDirect(priceValue, weightTaskResultId);
+                // 得到计费公式
+                String formula_string = null;
+                if (orderType.intValue() >= 1 && orderType.intValue() <= 3) {
+                    // 得到销售10km差距内的汽运计费公式
+                    formula_string = bmstruckFormulaService.getTruckFormula(new BigDecimal(10));
+                    // 替换采购汽运运计算公式
+                    formula_string = formula_string.replace("运输单价",priceValue.toString())
+                            .replace("物资净重",netWeight.toString());
+                }
+                String s = toSufExpr(formula_string);
+                BigDecimal  detailsAmountOld = calSufExpr(s);
                 Double amount = detailsAmountOld.doubleValue();
                 BigDecimal detailsAmount = new BigDecimal(amount).setScale(2,RoundingMode.HALF_UP);
-                //判断该计量实绩有没有结算数据
-                if(bmstruckDetailsOrderMapper.getIsHaveDetailsOrder(weightTaskResultId) > 0 ){
-                    //如果有,更新
-                    Map<String,Object> temp =new HashMap<>();
-                    temp.put("orderId",orderId);
-                    temp.put("weightTaskResultId",weightTaskResultId);
-                    temp.put("priceValue",priceValue);
-                    temp.put("detailAmount",detailsAmount);
-                    temp.put("detailRemark",detailRemark);
-                    temp.put("url",url);
-                    temp.put("userId",userId);
-                    result +=bmstruckDetailsOrderMapper.updateTruckDetails(temp);
+                if(bmstruckDetailsOrderMapper.getIsHaveDetailsOrderByBatch(weightBatchId) > 0 ){
+                    //获取详单ID
+                    BigDecimal detailsId = bmstruckDetailsOrderMapper.getDetailsIdByBatchId(weightBatchId);
+                    BmstruckDetailsOrder bmstruckDetailsOrder = bmstruckDetailsOrderMapper.selectByPrimaryKey(detailsId);
+                    bmstruckDetailsOrder.setDetailsId(detailsId);
+                    bmstruckDetailsOrder.setDetailsAmount(detailsAmount);
+                   result += bmstruckDetailsOrderMapper.updateByPrimaryKeySelective(bmstruckDetailsOrder);
                     continue;
                 }
+                //计算总费用
+                //判断该计量实绩有没有结算数据
                 //否则,新增详单
                 try {
                     BmstruckDetailsOrder bmstruckDetailsOrder = new BmstruckDetailsOrder();
@@ -1422,7 +1429,7 @@ public class BmstruckDetailsOrderServiceImpl implements IBmstruckDetailsOrderSer
                     BigDecimal detailsId = selectMaxId();
                     String detailsNo = noUtil.setResultNo("QYXD", detailsId);
                     bmstruckDetailsOrder.setDetailsId(detailsId);
-                    bmstruckDetailsOrder.setWeightTaskResultId(weightTaskResultId);
+                    bmstruckDetailsOrder.setWeightBatchId(weightBatchId);
                     bmstruckDetailsOrder.setOrderId(orderId);
                     bmstruckDetailsOrder.setDetailsNo(detailsNo);
                     bmstruckDetailsOrder.setDetailsAmount(detailsAmount);

+ 4 - 0
src/main/resources/com/steerinfo/dil/mapper/BmstruckDetailsOrderMapper.xml

@@ -2679,4 +2679,8 @@
         SELECT SUM(BATCH_NET_WEIGHT) FROM TMSTRUCK_WEIGHT_BATCH
         WHERE WEIGHT_BATCH_ID = #{weightBatchId}
     </select>
+    <select id="getDetailsIdByBatchId" resultType="java.math.BigDecimal">
+        SELECT BDO.DETAILS_ID  FROM BMSTRUCK_DETAILS_ORDER BDO
+        WHERE BDO.WEIGHT_BATCH_ID = #{weightBatchId}
+    </select>
 </mapper>