Explorar o código

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

zx %!s(int64=2) %!d(string=hai) anos
pai
achega
a2dbd0748b

+ 10 - 0
src/main/java/com/steerinfo/dil/controller/TmstruckLoadResultController.java

@@ -392,4 +392,14 @@ public class TmstruckLoadResultController extends BaseRESTfulController {
         PageListAdd pageList = columnDataUtil.tableColumnData(apiId, LoadingResult,loadResult);
         return success(pageList);
     }
+
+    @ApiOperation(value = "新增装货")
+    @PostMapping("/addLoad")
+    public RESTfulResult addLoad(@RequestBody(required=false) Map<String, Object> map){
+        int i = tmstruckLoadResultService.addLoad1(map);
+        if(i == 1) {
+            return success("装货成功");
+        }
+        return failed("装货失败");
+    }
 }

+ 6 - 0
src/main/java/com/steerinfo/dil/mapper/TmstruckWeightResultMapper.java

@@ -114,4 +114,10 @@ public interface TmstruckWeightResultMapper extends IBaseMapper<TmstruckWeightRe
     BigDecimal getOutBoundMaterialMaxId();
 
     int updateOutBoundResult(Map<String, Object> updateMap);
+
+    //查询出路段顺序号
+    BigDecimal queryRoadId(BigDecimal orderId);
+
+    //更新路段顺序号
+    void updateToRoadId(BigDecimal orderlinesequence,BigDecimal orderId);
 }

+ 3 - 0
src/main/java/com/steerinfo/dil/service/ITmstruckLoadResultService.java

@@ -87,4 +87,7 @@ public interface ITmstruckLoadResultService{
    //查询采购内转装车实绩
     List<Map<String, Object>> getCgNzLoadingResult(Map<String, Object> mapval);
 
+    //插入装货
+    int addLoad1(Map<String,Object> map);
+
 }

+ 68 - 0
src/main/java/com/steerinfo/dil/service/impl/TmstruckLoadResultServiceImpl.java

@@ -7,6 +7,7 @@ import com.steerinfo.dil.mapper.*;
 import com.steerinfo.dil.model.TmstruckEnfactoryResult;
 import com.steerinfo.dil.model.TmstruckLeaveFactoryResult;
 import com.steerinfo.dil.model.TmstruckLoadResult;
+import com.steerinfo.dil.model.TmstruckWeightResult;
 import com.steerinfo.dil.service.ITmstruckLoadResultService;
 import com.steerinfo.dil.util.DataChange;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -14,6 +15,8 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 /**
@@ -46,6 +49,8 @@ public class TmstruckLoadResultServiceImpl implements ITmstruckLoadResultService
 
     @Autowired
     private UtilsServiceImpl utilsService;
+    @Autowired
+    private  TmstruckWeightResultMapper tmstruckWeightResultMapper;
 
     @Autowired
     private TmstruckLeaveFactoryResultMapper tmstruckLeaveFactoryResultMapper;
@@ -70,6 +75,7 @@ public class TmstruckLoadResultServiceImpl implements ITmstruckLoadResultService
     @Autowired
     private TmstruckUnloadResultMapper tmstruckUnloadResultMapper;
 
+
     /**
      * 生成销售装车实绩(虚拟装车实绩)
      * @param map
@@ -698,4 +704,66 @@ public class TmstruckLoadResultServiceImpl implements ITmstruckLoadResultService
     public List<Map<String, Object>> getCgNzLoadingResult(Map<String, Object> mapval) {
         return tmstruckLoadResultMapper.getCgNzLoadingResult(mapval);
     }
+
+    /**
+     * @author:zyf
+     * @version:1.0
+     * @Date:
+     * @Description:新增装货表
+    */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int addLoad1(Map<String, Object> map) {
+        //获取装货表主键ID
+        BigDecimal ResultId = tmstruckLoadResultMapper.selectMaxId();
+        TmstruckLoadResult tmstruckLoadResult = new TmstruckLoadResult();
+        //总实绩ID 开始时间 结束时间 装车时长 物资Id 装卸工ID 装货点Id 备注
+        //主键ID
+        tmstruckLoadResult.setResultId(ResultId);
+        //装卸工ID
+        tmstruckLoadResult.setLoaderId(DataChange.dataToBigDecimal(map.get("loadId")));
+        //装货开始时间
+        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String loadStartTime =(String) map.get("loadStartTime");
+        try {
+            Date loadStartTime1 = sdf2.parse(loadStartTime);
+            tmstruckLoadResult.setResultLoadStartTime(loadStartTime1);
+            //结束时间
+            Date loadEndTime = new Date();
+            tmstruckLoadResult.setResultLoadEndTime(loadEndTime);
+            //装货时长
+            long duration = (loadEndTime.getTime() - loadStartTime1.getTime()) / 60000;
+            tmstruckLoadResult.setResultLoadDuration(new BigDecimal(duration));
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        //总实绩ID
+        tmstruckLoadResult.setResultTotalId(DataChange.dataToBigDecimal(map.get("resultid")));
+        //物资ID
+        tmstruckLoadResult.setMaterialId(BigDecimal.valueOf((int)map.get("materialId")));
+        //装货点ID
+        tmstruckLoadResult.setLoadingId(BigDecimal.valueOf((int)map.get("warehouseId")));
+        //理重
+        BigDecimal lz= (BigDecimal.valueOf((Double) map.get("calculateTW")));
+        tmstruckLoadResult.setResultMeasuredTonnage(lz);
+        int i=tmstruckLoadResultMapper.insertSelective(tmstruckLoadResult);
+        TmstruckWeightResult tmstruckWeightResult=new TmstruckWeightResult();
+        tmstruckWeightResult.setWeightTaskResultId(tmstruckWeightResultMapper.selectMaxId());
+        tmstruckWeightResult.setResultTotalId(DataChange.dataToBigDecimal(map.get("resultid")));
+        tmstruckWeightResult.setResultNetWeight(lz);
+        tmstruckWeightResultMapper.insertSelective(tmstruckWeightResult);
+        //给运输订单的路段序列号加一
+        //1.先查询出来
+        BigDecimal orderId=BigDecimal.valueOf((int)map.get("orderId"));
+        BigDecimal orderlinesequence=tmstruckWeightResultMapper.queryRoadId(orderId);
+        if (orderlinesequence==null){
+            orderlinesequence=BigDecimal.ZERO;
+        }
+        //2.加一在赋值进去
+        tmstruckWeightResultMapper.updateToRoadId(orderlinesequence.add(BigDecimal.valueOf(1)),orderId);
+        if (i==1){
+            return i;
+        }
+        return 0;
+    }
 }

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

@@ -153,7 +153,7 @@ public class TmstruckUnloadResultServiceImpl implements ITmstruckUnloadResultSer
 
         int orderType = DataChange.dataToBigDecimal(mesMap.get("orderType")).intValue();
         //判断是不是内转
-        if(orderType == 11 || orderType == 15 || orderType == 16){
+        if(orderType == 11 || orderType == 15 || orderType == 16 || orderType == 25){
             //如果是内转新增卸货实绩
             Integer sqe = utilsMapper.getLineSequenceByOrderNumber((String) map.get("orderNumber"));
             sqe = sqe == null ? 1 : sqe +1;
@@ -165,7 +165,7 @@ public class TmstruckUnloadResultServiceImpl implements ITmstruckUnloadResultSer
             //更新路段顺序号
             //内转只要是卸货都直接关闭订单 事务跨服务更改同表同一行数据 不能调用 会锁行
             //如果没有净重更新路段顺序号需要继续回皮 有就结束订单
-            if(netWeight == 0){
+            if(netWeight == 0 && orderType != 25){
                 mesMap.put("orderLineSequence",sqe);
                 utilsService.updateOrderLineSqeByOrderNumber(mesMap);
             }else {
@@ -177,7 +177,7 @@ public class TmstruckUnloadResultServiceImpl implements ITmstruckUnloadResultSer
             BigDecimal orderId = DataChange.dataToBigDecimal(mesMap.get("orderId"));
             Map<String,Object>  remarkMap=tmstruckTimeTaskResultMapper.selectInwardDueTimeByOrderId(orderId);
             String remark =(String) remarkMap.get("remark");
-            if (remark.contains("计时")){
+            if (remark.contains("计时") && orderType != 25){
                  map.put("inwardTypes",3);
                  tmstruckTimeTaskResultService.addTimeTaskResult(map);
             }

+ 6 - 6
src/main/resources/com/steerinfo/dil/mapper/StatisticalReportMapper.xml

@@ -1770,11 +1770,11 @@
                 AND OO.OPTIONER_CODE=#{orgCode}
             </if>
             <if test="oneDate != null">
-                and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt; =  TWR.RESULT_TARE_WEIGHT_TIME
+                and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt; = greatest(TWR.RESULT_TARE_WEIGHT_TIME,TWR.RESULT_GROSS_WEIGHT_TIME)
             </if>
             <if test="startDate != null">
-                and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt; =   TWR.RESULT_TARE_WEIGHT_TIME
-                and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= TWR.RESULT_TARE_WEIGHT_TIME
+                and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt; =  greatest(TWR.RESULT_TARE_WEIGHT_TIME,TWR.RESULT_GROSS_WEIGHT_TIME)
+                and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >= greatest(TWR.RESULT_TARE_WEIGHT_TIME,TWR.RESULT_GROSS_WEIGHT_TIME)
             </if>
             <if test="index!=null">
                 and ((instr(RC.CAPACITY_NUMBER, #{index}) > 0) or (instr(RW1.WAREHOUSE_NAME, #{index}) > 0)
@@ -1859,11 +1859,11 @@
             or  (instr( RC.CARRIER_NAME , #{index}) > 0)  or     (instr(RL.LINE_NAME , #{index}) > 0))
         </if>
         <if test="oneDate != null">
-            and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt; = TWR.RESULT_TARE_WEIGHT_TIME
+            and to_date(#{oneDate}, 'yyyy-mm-dd hh24:mi:ss') &lt; = GREATEST(TWR.RESULT_GROSS_WEIGHT_TIME,TWR.RESULT_TARE_WEIGHT_TIME)
         </if>
         <if test="startDate != null">
-            and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;=  TWR.RESULT_TARE_WEIGHT_TIME
-            and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >=  TWR.RESULT_TARE_WEIGHT_TIME
+            and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;=  GREATEST(TWR.RESULT_GROSS_WEIGHT_TIME,TWR.RESULT_TARE_WEIGHT_TIME)
+            and to_date(#{endDate}, 'yyyy-mm-dd hh24:mi:ss') >=  GREATEST(TWR.RESULT_GROSS_WEIGHT_TIME,TWR.RESULT_TARE_WEIGHT_TIME)
         </if>
         )
     </select>

+ 12 - 0
src/main/resources/com/steerinfo/dil/mapper/TmstruckWeightResultMapper.xml

@@ -2843,4 +2843,16 @@
         set MATERIAL_NUMBER = #{materialNumber}
         where OUTBOUND_RESULT_ID = #{boundResultId} and MATERIAL_ID = #{materialId}
     </update>
+
+    <select id="queryRoadId" resultType="java.math.BigDecimal">
+        select oo.ORDER_LINE_SEQUENCE
+        from OMSTRUCK_ORDER oo
+        where oo.ORDER_ID=#{orderId}
+    </select>
+
+    <update id="updateToRoadId">
+        update OMSTRUCK_ORDER oo
+        set oo.ORDER_LINE_SEQUENCE=#{orderlinesequence}
+        where oo.ORDER_ID=#{orderId}
+    </update>
 </mapper>