Kaynağa Gözat

Merge branch 'master' of https://git.steerinfo.com/DAL-DAZHOU1/DAL-DAZHOU-BMSTRUCK-API

liyg 2 yıl önce
ebeveyn
işleme
e01de40174

+ 7 - 0
src/main/java/com/steerinfo/dil/service/IBmstruckDetailsOrderService.java

@@ -27,6 +27,13 @@ public interface IBmstruckDetailsOrderService {
      */
     int insertSelective(BigDecimal orderId) throws Exception;
 
+    /**
+     * 新增汽运详单(专为计费详单服务)
+     * @param orderId
+     * @return
+     */
+    int insertSelectiveNew(BigDecimal orderId) throws Exception;
+
     /**
      * 查询最大id
      * @return

+ 118 - 6
src/main/java/com/steerinfo/dil/service/impl/BmstruckDetailsOrderServiceImpl.java

@@ -95,6 +95,69 @@ public class BmstruckDetailsOrderServiceImpl implements IBmstruckDetailsOrderSer
             return 0;
         }
         BigDecimal priceId = (BigDecimal) priceMap.get("priceId");
+        if (priceId.intValue() == 0) {
+            return 0;
+        }
+        int result = 0;
+        for (Map<String, Object> map : weightTaskResultIdList) {
+            BigDecimal weightTaskResultId = DataChange.dataToBigDecimal(map.get("weightTaskResultId"));
+            //判断该计量实绩有没有结算数据
+            if(bmstruckDetailsOrderMapper.getIsHaveDetailsOrder(weightTaskResultId) > 0 ){
+                continue;
+            }
+            //BigDecimal detailsAmountOld=new BigDecimal(0);
+            try {
+                BigDecimal  detailsAmountOld = generateTruckFees(orderId, weightTaskResultId);
+                Double amount = detailsAmountOld.doubleValue();
+                BigDecimal detailsAmount = new BigDecimal(amount).setScale(2,RoundingMode.HALF_UP);
+                BigDecimal orderType = bmstruckDetailsOrderMapper.getOrderType(orderId);
+                BmstruckDetailsOrder bmstruckDetailsOrder = new BmstruckDetailsOrder();
+                if (orderType.intValue() == 3) {
+                    BigDecimal purchaseOrderId = getFormulaMembers(orderId);
+                    bmstruckDetailsOrder.setPurchaseOrderId(purchaseOrderId);
+                }
+                if (orderType.intValue() == 2 || orderType.intValue() == 1) {
+                    bmstruckDetailsOrder.setWetherToStatement(new BigDecimal(0));
+                }
+                // 得到最大id
+                BigDecimal detailsId = selectMaxId();
+                String detailsNo = noUtil.setResultNo("QYXD", detailsId);
+                bmstruckDetailsOrder.setDetailsId(detailsId);
+                bmstruckDetailsOrder.setWeightTaskResultId(weightTaskResultId);
+                bmstruckDetailsOrder.setOrderId(orderId);
+                bmstruckDetailsOrder.setDetailsNo(detailsNo);
+                bmstruckDetailsOrder.setPriceId(priceId);
+                bmstruckDetailsOrder.setDetailsAmount(detailsAmount);
+                bmstruckDetailsOrder.setDetailsTime(new Date());
+                // 设置常规字段
+                bmstruckDetailsOrder.setInsertTime(new Date());
+                bmstruckDetailsOrder.setUpdateTime(new Date());
+                bmstruckDetailsOrder.setInsertUsername("admin");
+                bmstruckDetailsOrder.setUpdateUsername("admin");
+                bmstruckDetailsOrder.setInsertUpdateRemark("无");
+                result += bmstruckDetailsOrderMapper.insertSelective(bmstruckDetailsOrder);
+            }catch (Exception e){
+                //不打印给控制台(有可能是正常情况)
+                e.printStackTrace();
+            }
+        }
+        return result;
+    }
+
+
+    /**
+     * 新增详单(只为计费详单修改数据时才使用)
+     * @param orderId
+     * @return
+     */
+    @Override
+    public int insertSelectiveNew(BigDecimal orderId) throws Exception {
+        List<Map<String,Object>> weightTaskResultIdList = bmstruckDetailsOrderMapper.getSteelWeightTaskResultId(orderId);
+        Map<String,Object> priceMap = getPriceId(orderId);
+        if (priceMap == null || priceMap.size() == 0) {
+            return 0;
+        }
+        BigDecimal priceId = (BigDecimal) priceMap.get("priceId");
 //        if (priceId.intValue() == 0) {
 //            return 0;
 //        }
@@ -107,7 +170,7 @@ public class BmstruckDetailsOrderServiceImpl implements IBmstruckDetailsOrderSer
             }
             //BigDecimal detailsAmountOld=new BigDecimal(0);
             try {
-                BigDecimal  detailsAmountOld = generateTruckFees(orderId, weightTaskResultId);
+                BigDecimal  detailsAmountOld = generateTruckFeesNew(orderId, weightTaskResultId);
                 Double amount = detailsAmountOld.doubleValue();
                 BigDecimal detailsAmount = new BigDecimal(amount).setScale(2,RoundingMode.HALF_UP);
                 BigDecimal orderType = bmstruckDetailsOrderMapper.getOrderType(orderId);
@@ -259,10 +322,10 @@ public class BmstruckDetailsOrderServiceImpl implements IBmstruckDetailsOrderSer
         BigDecimal priceValue = getPriceValue(priceId);
         BigDecimal netWeight = getNetWeight(weightTaskResultId);
         //用于给单价id为2400的生成详单
-        if (priceValue==null||priceValue.compareTo(BigDecimal.ZERO)==0){
-            //该值为任意给的值
-            priceValue=BigDecimal.TEN;
-        }
+//        if (priceValue==null||priceValue.compareTo(BigDecimal.ZERO)==0){
+//            //该值为任意给的值
+//            priceValue=BigDecimal.TEN;
+//        }
         // 得到计费公式
         String formula_string = null;
         if (orderType.intValue() == 3) {
@@ -295,6 +358,55 @@ public class BmstruckDetailsOrderServiceImpl implements IBmstruckDetailsOrderSer
         return calSufExpr(s);
     }
 
+    /**
+     * 替换汽运费公式并进行计算(专为计费详单服务)
+     * @param orderId
+     * @return
+     * @throws Exception
+     */
+    public BigDecimal generateTruckFeesNew (BigDecimal orderId,BigDecimal weightTaskResultId) throws Exception {
+        BigDecimal orderType = bmstruckDetailsOrderMapper.getOrderType(orderId);
+        Map<String, Object> priceMap = getPriceId(orderId);
+        BigDecimal priceId = (BigDecimal) priceMap.get("priceId");
+        BigDecimal priceValue = getPriceValue(priceId);
+        BigDecimal netWeight = getNetWeight(weightTaskResultId);
+        //用于给单价id为2400的生成详单
+        if (priceValue==null||priceValue.compareTo(BigDecimal.ZERO)==0){
+            //该值为任意给的值
+            priceValue=BigDecimal.TEN;
+        }
+        // 得到计费公式
+        String formula_string = null;
+        if (orderType.intValue() == 3) {
+            // 得到采购汽运计费公式
+            formula_string = bmstruckFormulaService.getTruckFormula(new BigDecimal(8));
+            // 替换采购汽运运计算公式
+            formula_string = formula_string.replace("到厂计量湿吨",netWeight.toString())
+                    .replace("单价",priceValue.toString());
+        }
+        if (orderType.intValue() >= 1 && orderType.intValue() <= 3) {
+//            BigDecimal distance = new BigDecimal(101);
+            // 得到销售汽运计费公式
+//            if (distance.intValue() >= 91 || distance.intValue() <= 109) {
+            // 得到销售10km差距内的汽运计费公式
+            formula_string = bmstruckFormulaService.getTruckFormula(new BigDecimal(10));
+            // 替换采购汽运运计算公式
+            formula_string = formula_string.replace("运输单价",priceValue.toString())
+                    .replace("物资净重",netWeight.toString());
+//            }
+//            else {
+//                // 得到销售10km差距外的汽运计费公式
+//                formula_string = bmstruckFormulaService.getTruckFormula(new BigDecimal(11));
+//                // 替换采购汽运运计算公式
+//                formula_string = formula_string.replace("运输单价",priceValue.toString())
+//                        .replace("运输距离",distance.toString())
+//                        .replace("物资净重",netWeight.toString());
+//            }
+        }
+        String s = toSufExpr(formula_string);
+        return calSufExpr(s);
+    }
+
     public BigDecimal updateSteelAmounts(Map<String,Object> map) throws Exception {
         BigDecimal orderId = DataChange.dataToBigDecimal(map.get("orderId"));
         BigDecimal weightTaskResultId = DataChange.dataToBigDecimal(map.get("weightTaskResultId"));
@@ -544,7 +656,7 @@ public class BmstruckDetailsOrderServiceImpl implements IBmstruckDetailsOrderSer
         BigDecimal orderId = DataChange.dataToBigDecimal(mapValue.get("orderId"));
         BigDecimal priceId = DataChange.dataToBigDecimal(mapValue.get("priceId"));
         try {
-            int i = insertSelective(orderId);
+            int i = insertSelectiveNew(orderId);
         } catch (Exception e) {
             //不打印给控制台(可能是正常情况)
         }