Selaa lähdekoodia

修改船运结算

zx 2 vuotta sitten
vanhempi
commit
9daaf873a7

+ 6 - 3
src/main/java/com/steerinfo/dil/controller/BmsportHandlingFeeController.java

@@ -141,9 +141,12 @@ public class BmsportHandlingFeeController extends BaseRESTfulController {
     })
     @PostMapping("/addPortHandlingFeeSecond")
     public RESTfulResult addPortHandlingFeeSecond(@RequestBody Map<String,Object> map) throws Exception {
-        int code1 = bmsportHandlingFeeService.addPortHandlingFeeSecond(map);
-        if (code1==-2){
-            return failed("费用不一致,请仔细核对数据是否更改");
+        int code1=0;
+        try {
+             code1 = bmsportHandlingFeeService.addPortHandlingFeeSecond (map);
+        }
+        catch (Exception e){
+            return  failed(e.getMessage());
         }
         return success(code1);
     }

+ 1 - 1
src/main/java/com/steerinfo/dil/service/IBmsportHandlingFeeService.java

@@ -68,7 +68,7 @@ public interface IBmsportHandlingFeeService {
 
 
     //新增二程船装卸费
-    int addPortHandlingFeeSecond(Map<String, Object> map);
+    int addPortHandlingFeeSecond(Map<String, Object> map) throws Exception;
 
     //展示二程船装卸费用
     List<Map<String, Object>> selectPortFeeSecondList(Map<String, Object> map);

+ 10 - 3
src/main/java/com/steerinfo/dil/service/impl/BmsportHandlingFeeServiceImpl.java

@@ -8,6 +8,7 @@ import com.steerinfo.dil.service.IBmsportHandlingFeeService;
 import com.steerinfo.dil.util.DataChange;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.text.DecimalFormat;
@@ -141,15 +142,21 @@ public class BmsportHandlingFeeServiceImpl implements IBmsportHandlingFeeService
 
 
     @Override
-    public int addPortHandlingFeeSecond(Map<String, Object> map) {
+    @Transactional(rollbackFor = {Exception.class})
+    public int addPortHandlingFeeSecond(Map<String, Object> map) throws Exception {
         //获取运输单价
         BigDecimal Fee=null;
+        long makeTime = 0;
         BigDecimal unitPrice = DataChange.dataToBigDecimal(map.get("unitPrice"));
         //水运单总吨位
         BigDecimal tonnage =DataChange.dataToBigDecimal(map.get("realTonnage"));
         BigDecimal batchId =DataChange.dataToBigDecimal(map.get("batchId"));
         BigDecimal purchaseOrderId =DataChange.dataToBigDecimal(map.get("purchaseOrderId"));
-        long makeTime =(long) map.get("makeTime");
+        if(map.get("makeTime")!=null) {
+             makeTime = (long) map.get("makeTime");
+        }else {
+           throw new Exception("请填写制票日期");
+        }
         //获取userId
         String userId = (String) map.get("userId");
         //根据userId查找姓名
@@ -179,7 +186,7 @@ public class BmsportHandlingFeeServiceImpl implements IBmsportHandlingFeeService
             if (DataChange.dataToBigDecimal(map.get("fee")).compareTo(Fee) == 0) {
                 bmsshipFee.setFee(Fee);
             } else {
-                return -2;
+               throw new Exception("费用不一致");
             }
         }else {
             bmsshipFee.setFee(DataChange.dataToBigDecimal(map.get("fee")));