Просмотр исходного кода

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

zx 2 лет назад
Родитель
Сommit
93876553d0

+ 2 - 0
src/main/java/com/steerinfo/DilApplicationMain.java

@@ -7,6 +7,7 @@ import org.springframework.boot.web.servlet.ServletComponentScan;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
 
 /**
  * @Author zhangnan
@@ -19,6 +20,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 @MapperScan({"com.steerinfo.dil.mapper"})
 @EnableDiscoveryClient
 @EnableFeignClients(basePackages="com.steerinfo.dil.feign")
+@EnableTransactionManagement
 public class DilApplicationMain {
     public static void main(String[] args) {
         SpringApplication.run(DilApplicationMain.class,args);

+ 9 - 13
src/main/java/com/steerinfo/dil/controller/TmstrainLoadingResultController.java

@@ -125,16 +125,12 @@ public class TmstrainLoadingResultController extends BaseRESTfulController {
             @ApiImplicitParam(name = "tmstrainLoadingResult", value = "修改车皮装车map", required = false, dataType = "TmstrainWagonLoadResult")
     })
     @PostMapping(value = "/upadteTmstrainLoadingResultByResultId")
-    public RESTfulResult upadteTmstrainLoadingResultByResultId(@RequestBody(required = false) Map<String,Object> map) throws Exception {
-        int i = tmstrainLoadingResultService.updateTmstrainLoadingResult(map);
-        if (i==-1){
-            return  failed("车皮号异常");
-        }else if(i==-2){
-            return  failed("主键异常");
-        }else if(i==-3){
-            return  failed("类型异常");
-        }else if(i==-4){
-            return  failed("采购订单号异常");
+    public RESTfulResult upadteTmstrainLoadingResultByResultId(@RequestBody(required = false) Map<String,Object> map) {
+        int i=-1;
+        try{
+            i = tmstrainLoadingResultService.updateTmstrainLoadingResult(map);
+        }catch (Exception e){
+            return  failed(e.getMessage());
         }
         return success(i);
     }
@@ -278,13 +274,13 @@ public class TmstrainLoadingResultController extends BaseRESTfulController {
 
     @ApiOperation(value = "国产矿物流新增装车")
     @PostMapping(value = "/addDomesticLoadResult")
-    public RESTfulResult addDomesticLoadResult(@RequestBody(required = false) List<Map<String, Object>> list) throws Exception {
-        return success(tmstrainLoadingResultService.addDomesticLoadResult(list));
+    public RESTfulResult addDomesticLoadResult(@RequestBody(required = false) Map<String, Object> mapValue) throws Exception {
+        return success(tmstrainLoadingResultService.addDomesticLoadResult(mapValue));
     }
 
     @ApiOperation(value = "国产矿物流补录装车信息")
     @PostMapping(value = "/updateDomesticLoadResult")
-    public RESTfulResult updateDomesticLoadResult(@RequestBody(required = false) Map<String, Object> map) {
+    public RESTfulResult updateDomesticLoadResult(@RequestBody(required = false) Map<String, Object> map) throws Exception {
         int i = tmstrainLoadingResultService.updateDomesticLoadResult(map);
         if(i==-1){
             return success("有委托发送失败,请联系技术人员");

+ 13 - 0
src/main/java/com/steerinfo/dil/model/TmstrainLoadingResult.java

@@ -177,6 +177,11 @@ public class TmstrainLoadingResult implements IBasePO<BigDecimal> {
     @ApiModelProperty(value = "车皮号列表")
     private List<String> wagonNoList;
 
+    @TableField(exist = false)
+    @ApiModelProperty(value = "用户id")
+    private String userId;
+
+
     private static final long serialVersionUID = 1L;
 
     @Override
@@ -449,4 +454,12 @@ public class TmstrainLoadingResult implements IBasePO<BigDecimal> {
     public void setWagonNoList(List<String> wagonNoList) {
         this.wagonNoList = wagonNoList;
     }
+
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
 }

+ 2 - 2
src/main/java/com/steerinfo/dil/service/ITmstrainLoadingResultService.java

@@ -51,10 +51,10 @@ public interface ITmstrainLoadingResultService{
     int addTrainLoadResultForConverted(Map<String, Object> map);
 
     //添加国产矿装车实绩
-    int addDomesticLoadResult(List<Map<String, Object>> list) throws Exception;
+    int addDomesticLoadResult(Map<String, Object> mapValue) throws Exception;
 
     //补录采购订单信息
-    int updateDomesticLoadResult(Map<String, Object> map);
+    int updateDomesticLoadResult(Map<String, Object> map) throws Exception;
 
     //内转物流通过id查询装车作业
     List<Map<String,Object>> selectLoadByResultId(BigDecimal resultId);

+ 57 - 31
src/main/java/com/steerinfo/dil/service/impl/TmstrainLoadingResultServiceImpl.java

@@ -112,6 +112,8 @@ public class TmstrainLoadingResultServiceImpl implements ITmstrainLoadingResultS
     @Transactional
     public int addTmstrainLoadingResult(TmstrainLoadingResult tmstrainLoadingResult) throws Exception{
         List<String> wagonNoList = tmstrainLoadingResult.getWagonNoList();
+        if(tmstrainLoadingResult.getUserId()==null)
+            throw new Exception("用户id为空,请先登录再操作!");
         if(wagonNoList.size()<=0){
             throw new Exception("车皮号异常");
         }
@@ -124,7 +126,7 @@ public class TmstrainLoadingResultServiceImpl implements ITmstrainLoadingResultS
         BigDecimal batchId = tmstrainLoadingResultMapper.getBatchIdByPurOrderId(purchaseOrderId);
         tmstrainLoadingResult.setBatchId(batchId);
         //添加常规字段
-        addRegularField(tmstrainLoadingResult);
+        addRegularField(tmstrainLoadingResult,tmstrainLoadingResult.getUserId());
         //准备插入
         int count = 0;
         List<Map<String,Object>> resultIdList=new ArrayList<>();
@@ -139,7 +141,6 @@ public class TmstrainLoadingResultServiceImpl implements ITmstrainLoadingResultS
             count += tmstrainLoadingResultMapper.insertSelective(tmstrainLoadingResult);
             //添加火运总实绩
             count += addTotalResult(maxId);
-
             //计量委托实绩list
             Map<String, Object> temp = new HashMap<>();
             temp.put("resultId",maxId);
@@ -160,17 +161,24 @@ public class TmstrainLoadingResultServiceImpl implements ITmstrainLoadingResultS
     }
 
     /**
-     * 添加国产矿装车实绩
-     * @param list
+     * 国产矿新增导入
+     * @param mapValue
      * @return
      */
-    public int addDomesticLoadResult(List<Map<String, Object>> list) throws Exception {
+    public int addDomesticLoadResult(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为空,请先登录再操作!");
         //装车临时list
         List<TmstrainLoadingTemp> loadingTemps=new ArrayList<>();
         //装车实绩list
         List<TmstrainLoadingResult> loadingResults=new ArrayList<>();
         int i = 0;
         for(Map<String,Object> map:list){
+            //车皮号、发站、到站、发货单位、物资是必要数据
             TmstrainLoadingTemp temp=new TmstrainLoadingTemp();
             TmstrainLoadingResult result=new TmstrainLoadingResult();
             //设置序列号主键
@@ -210,7 +218,7 @@ public class TmstrainLoadingResultServiceImpl implements ITmstrainLoadingResultS
                 result.setSendStationId(sendStationId);
             }
             //添加常规字段
-            addRegularField(result);
+            addRegularField(result,userId);
             //通过车皮号计算车皮标重
             result.setResultBillableTonnage(new BigDecimal(calculateWagonWeight(result.getResultWagonNo())));
             //通过到站ID匹配计量衡 如果是老区轨道衡或者是新区轨道衡 则匹配轨道衡
@@ -231,11 +239,11 @@ public class TmstrainLoadingResultServiceImpl implements ITmstrainLoadingResultS
     }
 
     /**
-     * 补录采购订单信息
+     * 国产矿新增配单补录
      * @param map
      * @return
      */
-    public int updateDomesticLoadResult(Map<String, Object> map){
+    public int updateDomesticLoadResult(Map<String, Object> map) throws Exception {
         //获取要补录的实绩ID 列表
         List<Integer> resultIdList = (List<Integer>) map.get("resultIdList");
         TmstrainLoadingResult tmstrainLoadingResult = new TmstrainLoadingResult();
@@ -252,15 +260,19 @@ public class TmstrainLoadingResultServiceImpl implements ITmstrainLoadingResultS
             tmstrainLoadingResult.setSendUnitId(supplierId);
         }
         tmstrainLoadingResult.setPurchaseOrderRailPlanId(purchaseOrderId); //采购订单Id
+        if(map.get("userId")!=null)
+            tmstrainLoadingResult.setUpdateUsername(map.get("userId").toString());
+        else
+            throw new Exception("用户id为空,请先登录!");
         int count = 0;
         //对每一个实绩id对应的记录修改字段
         for (Integer resultId : resultIdList) {
             tmstrainLoadingResult.setResultId(new BigDecimal(resultId)); //设置要补录的实绩主键
+            tmstrainLoadingResult.setUpdateTime(new Date());
             count += tmstrainLoadingResultMapper.updateByPrimaryKeySelective(tmstrainLoadingResult);
         }
-        //全部补录成功,发送计量委托
+        //配单成功,发送计量委托
         if(resultIdList.size()-count==0){
-//            System.out.println("发送计量委托");
             Map<String, Object> map1 = new HashMap<>();
             List<Map<String,Object>> resultIdList1=new ArrayList<>();
             for(Integer resultId:resultIdList){
@@ -326,9 +338,9 @@ public class TmstrainLoadingResultServiceImpl implements ITmstrainLoadingResultS
      * 添加常规字段
      * @param tmstrainLoadingResult
      */
-    public void addRegularField(TmstrainLoadingResult tmstrainLoadingResult){
+    public void addRegularField(TmstrainLoadingResult tmstrainLoadingResult,String userName){
         //常规字段插入
-        tmstrainLoadingResult.setInsertUsername("admin");
+        tmstrainLoadingResult.setInsertUsername(userName);
         tmstrainLoadingResult.setInsertTime(new Date());
         tmstrainLoadingResult.setInsertUpdateRemark("无");
         tmstrainLoadingResult.setDeleted(new BigDecimal(0));
@@ -345,10 +357,11 @@ public class TmstrainLoadingResultServiceImpl implements ITmstrainLoadingResultS
     }
 
     /**
-     * 修改火运装车实绩
+     * 修改进口矿国产矿火运装车实绩
      * @param map
      * @return
      */
+    @Transactional(rollbackFor = {Exception.class})
     @Override
     public int updateTmstrainLoadingResult(Map<String,Object> map) throws Exception{
         TmstrainLoadingResult tmstrainLoadingResult=new TmstrainLoadingResult();
@@ -356,15 +369,15 @@ public class TmstrainLoadingResultServiceImpl implements ITmstrainLoadingResultS
         BigDecimal resultId=DataChange.dataToBigDecimal(map.get("resultId"));
         Integer resultType=(Integer) map.get("resultType");
         if(wagonNo==null || wagonNo.length()!=7 || calculateWagonWeight(wagonNo)<=0){
-            return  -1;
+            throw new Exception("车皮号异常");
         }else if(resultId==null){
-            return  -2;
+            throw new Exception("主键为空");
         }else if(resultType==0){
-            return -3;
+            throw new Exception("类型异常");
         }
         //国产矿未配单仅支持修改部分字段,并且不重新发委托
         List<Map<String,Object>> results=tmstrainLoadingResultMapper.selectByResultId(resultId);
-        if(resultType==3 && results!=null && results.get(0)!=null && results.get(0).get("purchaseOrderRainPlanId")==null){
+        if(resultType==3 && results!=null && results.get(0)!=null && results.get(0).get("purchaseOrderNo")==null){
             tmstrainLoadingResult.setResultId(resultId);
             tmstrainLoadingResult.setResultWagonNo(wagonNo);
             tmstrainLoadingResult.setSendStationId(DataChange.dataToBigDecimal(map.get("sendStationId")));
@@ -373,7 +386,7 @@ public class TmstrainLoadingResultServiceImpl implements ITmstrainLoadingResultS
             if(map.get("resultRemarks")!=null)
                 tmstrainLoadingResult.setResultRemarks(map.get("resultRemarks").toString());
             tmstrainLoadingResultMapper.updateByPrimaryKeySelective(tmstrainLoadingResult);
-            return -5;
+            return 1;
         }
         //进口矿字段
         if(resultType!=3){
@@ -384,18 +397,23 @@ public class TmstrainLoadingResultServiceImpl implements ITmstrainLoadingResultS
             if(map.get("capacityId")!=null)
                 tmstrainLoadingResult.setCapacityId(DataChange.dataToBigDecimal(map.get("capacityId")));
             if(map.get("resultBillableTonnage")!=null)
-                tmstrainLoadingResult.setCapacityId(DataChange.dataToBigDecimal(map.get("resultBillableTonnage")));
+                tmstrainLoadingResult.setResultBillableTonnage(DataChange.dataToBigDecimal(map.get("resultBillableTonnage")));
         }
-        //通过采购订单号查询获得采购订单ID、批次ID
+        //通过采购订单号查询获得采购订单ID、批次ID、物资ID、发货单位ID
         if(map.get("purchaseOrderNo")!=null){
             String purchaseOrderNo = map.get("purchaseOrderNo").toString() ;
             BigDecimal purchaseOrderId = tmstrainLoadingResultMapper.getPurchaseOrderIdByPurOrderNo(purchaseOrderNo);
             BigDecimal batchId = tmstrainLoadingResultMapper.getBatchIdByPurOrderNo(purchaseOrderNo);
-            if(purchaseOrderId==null || batchId==null){
-                return  -4;
+            Map<String,Object> record=tmstrainLoadingResultMapper.getRecordByPurOrderId(purchaseOrderId);
+            BigDecimal materialId=DataChange.dataToBigDecimal(record.get("materialId"));
+            BigDecimal supplierId=DataChange.dataToBigDecimal(record.get("supplierId"));
+            if(purchaseOrderId==null || batchId==null ||materialId==null ||supplierId==null){
+                throw new Exception("采购订单号异常");
             }
             tmstrainLoadingResult.setBatchId(batchId);
             tmstrainLoadingResult.setPurchaseOrderRailPlanId(purchaseOrderId);
+            tmstrainLoadingResult.setMaterialId(materialId);
+            tmstrainLoadingResult.setSendUnitId(supplierId);
         }
         //设置其他字段
         tmstrainLoadingResult.setResultId(resultId);
@@ -406,18 +424,26 @@ public class TmstrainLoadingResultServiceImpl implements ITmstrainLoadingResultS
         if(map.get("resultRemarks")!=null)
             tmstrainLoadingResult.setResultRemarks(map.get("resultRemarks").toString());
         tmstrainLoadingResult.setUpdateTime(new Date());
+        if(map.get("userId")!=null){
+            tmstrainLoadingResult.setUpdateUsername(map.get("userId").toString());
+        }else{
+            throw new Exception("没有用户id,请登录再操作!");
+        }
         //更新
         int count=tmstrainLoadingResultMapper.updateByPrimaryKeySelective(tmstrainLoadingResult);
-        //更新完成,发送计量委托
-        if(count > 0){
-            List<Map<String, Object>> resultIdList = new ArrayList<>();
-            Map<String, Object> map1 = new HashMap<>();
-            Map<String, Object> map2 = new HashMap<>();
-            map1.put("resultId",resultId);
-            resultIdList.add(map1);
-            map2.put("resultIdList",resultIdList);
-            tmstrainMeasureCommissionService.batchSendMeasureCommission(map2);
+        if(count <= 0){
+            throw new Exception("修改失败");
         }
+        //修改成功,发送计量委托
+        List<Map<String, Object>> resultIdList = new ArrayList<>();
+        Map<String, Object> map1 = new HashMap<>();
+        Map<String, Object> map2 = new HashMap<>();
+        map1.put("resultId",resultId);
+        resultIdList.add(map1);
+        map2.put("resultIdList",resultIdList);
+        count = tmstrainMeasureCommissionService.batchSendMeasureCommission(map2);
+        if(count<=0)
+           throw new Exception("发送计量委托失败");
         return count;
     }
 

+ 3 - 24
src/main/java/com/steerinfo/dil/service/impl/TmstrainMeasureCommissionServiceImpl.java

@@ -76,12 +76,12 @@ public class TmstrainMeasureCommissionServiceImpl  implements ITmstrainMeasureCo
         measureCommission.put("isDel", false);
         measureCommission.put("isInsert", true);
         measureCommission.put("IsAssembly", false);
-        measureCommission.put("deliveryMethod", "磅重交货");
+        measureCommission.put("deliveryMethod", "磅重");
         measureCommission.put("packagesNum", 0);
         map.put("materialId", measureCommission.get("materialId"));
         map.put("resultTotalId", measureCommission.get("resultTotalId"));
         measureCommission.remove("resultTotalId");
-        //发送计量委托
+        //发送计量委托,成功返回1,失败返回0
         int i = sendMesToMeasure(measureCommission);
         if(i == 1){
             //添加计量委托实绩
@@ -97,29 +97,8 @@ public class TmstrainMeasureCommissionServiceImpl  implements ITmstrainMeasureCo
      * @return
      */
     public int updateTrainMeasureCommission(Map<String, Object> map){
-        //查询计量委托
-        Map<String, Object> measureCommission = getTrainMeasureCommission(map);
-        measureCommission.put("steelyardNum", "铁专线");
-        //车皮号
 
-//        measureCommission.put("isRelationEAS", true);
-//        measureCommission.put("flowTo", "进厂");
-//        measureCommission.put("isDel", false);
-//        measureCommission.put("isInsert", true);
-//        measureCommission.put("IsAssembly", false);
-//        measureCommission.put("deliveryMethod", "磅重交货");
-//        measureCommission.put("packagesNum", 0);
-//        map.put("materialId", measureCommission.get("materialId"));
-//        map.put("resultTotalId", measureCommission.get("resultTotalId"));
-//        measureCommission.remove("resultTotalId");
-        //发送计量委托
-        int i = sendMesToMeasure(measureCommission);
-        if(i == 1){
-            //添加计量委托实绩
-            addMeasureCommission(map);
-            updateTrainLoadResult(map);
-        }
-        return i;
+        return 0;
     }
 
     /**

+ 8 - 5
src/main/java/com/steerinfo/dil/service/impl/TmstrainWagonUnloadResultServiceImpl.java

@@ -46,6 +46,9 @@ public class TmstrainWagonUnloadResultServiceImpl implements ITmstrainWagonUnloa
 
     @Autowired
     private TmstrainTruckTotalResultMapper tmstrainTruckTotalResultMapper;
+
+    @Autowired
+    private TmstrainLoadingResultMapper tmstrainLoadingResultMapper;
     /**
      * 查看所有卸车实绩
      * 1采购进口矿(万州港-达州站/万州港-老区轨道衡) 2采购进口矿(海港-老区轨道衡) 3采购国产矿  4内转
@@ -110,7 +113,7 @@ public class TmstrainWagonUnloadResultServiceImpl implements ITmstrainWagonUnloa
      */
     public int addTmstrainWagonLoadResult(TmstrainWagonUnloadResult tmstrainWagonUnloadResult) throws Exception {
         //常规字段插入
-        tmstrainWagonUnloadResult.setInsertUsername("admin");
+        //tmstrainWagonUnloadResult.setInsertUsername("admin");
         tmstrainWagonUnloadResult.setInsertTime(new Date());
         tmstrainWagonUnloadResult.setDeleted(new BigDecimal(0));
         List<Map<String, Object>> wagonNoMapList = tmstrainWagonUnloadResult.getWagonNoList();
@@ -149,10 +152,10 @@ public class TmstrainWagonUnloadResultServiceImpl implements ITmstrainWagonUnloa
      */
     public int updateLoadingResult(Map<String, Object> map) throws Exception {
         //添加一条卸货实绩 修改装车状态为已卸车 2
-//        TmstrainLoadingResult tmstrainLoadingResult = new TmstrainLoadingResult();
-//        tmstrainLoadingResult.setResultId(DataChange.dataToBigDecimal(map.get("resultId")));
-        map.put("deleted",new BigDecimal(2));
-        return tmstrainLoadingResultService.updateTmstrainLoadingResult(map);
+        TmstrainLoadingResult tmstrainLoadingResult = new TmstrainLoadingResult();
+        tmstrainLoadingResult.setResultId(DataChange.dataToBigDecimal(map.get("resultId")));
+        tmstrainLoadingResult.setDeleted(new BigDecimal(2));
+        return tmstrainLoadingResultMapper.updateByPrimaryKeySelective(tmstrainLoadingResult);
     }
 
     /**

+ 4 - 1
src/main/resources/com/steerinfo/dil/mapper/TmstrainMeasureCommissionMapper.xml

@@ -375,7 +375,7 @@
     where TLR.RESULT_ID = #{resultId}
   </select>
 
-<!-- 查询计量 -->
+<!-- 查询计量 -->
   <select id="getLoadResultToSendMC" parameterType="map" resultType="java.util.Map">
     select
            *
@@ -412,12 +412,15 @@
         on RAS2.ARRIVAL_ID = TLR.ARRIVAL_STATION_ID
         left join TMSTRAIN_TOTAL_RESULT TTR
         on TTR.LOADING_ID = TLR.RESULT_ID
+        left join TMSTRAIN_WEIGHT_RESULT TWR
+        on TTR.TOTAL_RESULT_ID=TWR.RESULT_TOTAL_ID
         left join TMSTRAIN_WAGON_UNLOAD_RESULT TWUR
         on (TLR.PURCHASE_ORDER_RAIL_PLAN_ID=TWUR.PURCHASE_ORDER_RAIL_PLAN_ID and  TLR.RESULT_WAGON_NO=TWUR.RESULT_WAGON_NO)
            where TLR.DELETED = 0
              and TLR.RESULT_TYPE = #{resultType}
              and TLR.SEND_REQUEST = 2
              and APO.PURCHASE_ORDER_NO IS NOT NULL
+             and TWR.RESULT_POUND_NO IS NULL
              <if test="con!=null and con!=''.toString()">
              and (
                     APO.PURCHASE_ORDER_NO like concat('%',concat(#{con},'%'))