Ver Fonte

无车优化,自有车接口返回

Administrator há 2 anos atrás
pai
commit
9a79941437

+ 5 - 0
src/main/java/com/jkcredit/invoice/mapper/customer/CustomerOperMapper.java

@@ -30,4 +30,9 @@ public interface CustomerOperMapper extends BaseMapper<CustomerOper> {
      */
     @Override
     int insert(CustomerOper record);
+
+
+    int updateStatus(@Param("batchStatus") Integer batchStatus,@Param("batchNumber") String batchNumber);
+
+    int countHasNotFinish(String customerName);
 }

+ 14 - 0
src/main/java/com/jkcredit/invoice/model/entity/customer/CustomerOper.java

@@ -21,6 +21,11 @@ public class CustomerOper {
      */
     private int operType;
 
+    /**
+     * 操作状态
+     */
+    private int batchStatus;
+
     public Long getId() {
         return id;
     }
@@ -77,6 +82,14 @@ public class CustomerOper {
         this.operType = operType;
     }
 
+    public int getBatchStatus() {
+        return batchStatus;
+    }
+
+    public void setBatchStatus(int batchStatus) {
+        this.batchStatus = batchStatus;
+    }
+
     @Override
     public String toString() {
         return "CustomerOper{" +
@@ -87,6 +100,7 @@ public class CustomerOper {
                 ", createTime='" + createTime + '\'' +
                 ", batchNumber='" + batchNumber + '\'' +
                 ", operType=" + operType +
+                ", batchStatus=" + batchStatus +
                 '}';
     }
 }

+ 4 - 0
src/main/java/com/jkcredit/invoice/service/customer/CustomerOperService.java

@@ -28,4 +28,8 @@ public interface CustomerOperService {
      * @return
      */
     String saveCustomerOper(String customerName, int operType);
+
+    int updateStatus(int batchStatus,String batchNumber);
+
+    int countHasNotFinish(String customerName);
 }

+ 11 - 0
src/main/java/com/jkcredit/invoice/service/customer/impl/CustomerOperServiceImpl.java

@@ -59,7 +59,18 @@ public class CustomerOperServiceImpl extends ServiceImpl<CustomerOperMapper, Cus
         customerOper.setBatchNumber(batchNumber);
         customerOper.setCustomerPhone(user.getPhone());
         customerOper.setCustomerName(customerName);
+        customerOper.setBatchStatus(1);
         customerOperMapper.insert(customerOper);
         return batchNumber;
     }
+
+    @Override
+    public int updateStatus(int batchStatus,String batchNumber) {
+        return customerOperMapper.updateStatus(batchStatus,batchNumber);
+    }
+
+    @Override
+    public int countHasNotFinish(String customerName) {
+        return customerOperMapper.countHasNotFinish(customerName);
+    }
 }

+ 8 - 6
src/main/java/com/jkcredit/invoice/service/lowerservice/impl/NoCarServiceImpl.java

@@ -744,17 +744,11 @@ public class NoCarServiceImpl implements NoCarService {
                         noCarWayBill.setInterType(4);
                     }
                 }
-                noCarWayBill.setPlateNum(responseRespR.getData().getPlateNum());
-                noCarWayBill.setStartTime(DateUtil.tTimeToDate(responseRespR.getData().getWaybillStartTime()));
-                noCarWayBill.setPredictEndTime(DateUtil.tTimeToDate(responseRespR.getData().getWaybillEndTime()));
                 //更改票状态
                 noCarWayBill.setBillwayStatus(tempStatus);
                 insertOrUpdateBill(noCarWayBill);
             } else {
                 //更改票状态
-                noCarWayBill.setPlateNum(responseRespR.getData().getPlateNum());
-                noCarWayBill.setStartTime(DateUtil.tTimeToDate(responseRespR.getData().getWaybillStartTime()));
-                noCarWayBill.setPredictEndTime(DateUtil.tTimeToDate(responseRespR.getData().getWaybillEndTime()));
                 noCarWayBill.setBillwayStatus(tempStatus);
                 noCarWayBill.setUpdateTime(DateUtil.getCurrentDateStr());
                 noCarWaybillMapper.updateByBillNum(noCarWayBill);
@@ -790,6 +784,13 @@ public class NoCarServiceImpl implements NoCarService {
     private boolean countCalculateInfo(NoCarWayBill noCarWayBill, byte isKf, RespR<WaybillNumFindInvoiceResponse> responseRespR) {
         //删除已有发票
         billInvoiceMapper.deleteByBillNum(noCarWayBill.getBillNum());
+        /*if(noCarWayBill.getSplitFlag() == NoCarWayBill.SPLIT_FALG_TRUE) {
+            int size = DateUtil.getSplitTimeOver96(noCarWayBill.getStartTime(), noCarWayBill.getPredictEndTime()).size();
+            for (int i = 0; i < size; i++) {
+                String newBillNum = noCarWayBill.getBillNum() + "-jk0" + i;
+                billInvoiceMapper.deleteByBillNum(newBillNum);
+            }
+        }*/
         //发票入库
         List<InvoiceProcessingListModel> invoiceProcessingListModels = responseRespR.getData().getResult();
         //用set来去重计费信息
@@ -800,6 +801,7 @@ public class NoCarServiceImpl implements NoCarService {
             billInvoice.setCompanyName(noCarWayBill.getCompanyName());
             billInvoice.setCompanyNum(noCarWayBill.getCompanyNum());
             billInvoice.setCustomerName(noCarWayBill.getCustomerName());
+            billInvoice.setWaybillNum(noCarWayBill.getBillNum());
             //扣费明细入账
             NoCarCalculateInfor calculateInfor = new NoCarCalculateInfor();
             if (noCarWayBill.getInterType() != FOR_NUM && noCarWayBill.getInterType() != THREE_NUM) {

+ 8 - 35
src/main/java/com/jkcredit/invoice/service/nocar/impl/NoCarBillWayServiceImpl.java

@@ -172,8 +172,11 @@ public class NoCarBillWayServiceImpl extends ServiceImpl<NoCarWaybillMapper, NoC
                 }
 
             });
+
             log.error("开始平台指令上传失败NoCarBillWayServiceImpl.batchBillWayStart:{}", stringBuffer.toString());
+            customerOperService.updateStatus(0,batchNumber);
         });
+
         return new RespR("批次号:" + batchNumber);
     }
 
@@ -244,6 +247,7 @@ public class NoCarBillWayServiceImpl extends ServiceImpl<NoCarWaybillMapper, NoC
                     e.printStackTrace();
                 }
             });
+            customerOperService.updateStatus(0,batchNumber);
             if (!StringUtils.isEmpty(stringBuffer.toString())) {
                 log.error(stringBuffer.toString());
             }
@@ -314,42 +318,11 @@ public class NoCarBillWayServiceImpl extends ServiceImpl<NoCarWaybillMapper, NoC
         if (!customerService.checkMoneyEnough(customerName)) {
             return new RespR(false, "余额不足");
         }
+        if(customerOperService.countHasNotFinish(customerName)>0){
+            return new RespR(false, "您账号下还有批量开始运单未执行完成,请等待执行完成再上传结束运单");
+        }
         StringBuffer stringBuffer = new StringBuffer();
-        for(NoCarWayBill noCarWayBill : noCarWayBills){
-
-            log.info("运单结束开始:NoCarServiceImpl.noCarWaybillEnd{}", noCarWayBill);
-            NoCarWayBill noCarWayBillDb = null;
-            try {
-                noCarWayBillDb = noCarWaybillMapper.selectByBillNum(noCarWayBill.getBillNum());
-            } catch (Exception e) {
-                noCarWaybillMapper.deleteNotRightWayBill(noCarWayBill.getBillNum());
-                try {
-                    noCarWayBillDb = noCarWaybillMapper.selectByBillNum(noCarWayBill.getBillNum());
-                } catch (Exception e1) {
-                    return new RespR(false, "运单异常,请联系管理员处理");
-                }
-            }
-            if (noCarWayBillDb == null) {
-                try {
-                    noCarWayBillDb = noCarWayBill.clone();
-                } catch (Exception e) {
-                    e.printStackTrace();
-                    return new RespR(false, "系统异常,请重试");
-                }
-
-            }
 
-
-            if (null != noCarWayBillDb && noCarWayBillDb.getBillwayStatus() > 1) {
-                log.error("运单结束开始-运单已经结束或者是历史已结束运单,请联系管理员确认:NoCarServiceImpl.noCarWaybillEnd{}", noCarWayBillDb);
-                return new RespR(false, "运单已经结束或者是历史已结束运单,请联系管理员确认");
-            }
-            if (null != noCarWayBillDb &&  1 != noCarWayBillDb.getBillwayStatus() ) {
-                log.error("运单结束开始-开始运单未传或者还未处理完成,请确认并5分钟后重试:NoCarServiceImpl.noCarWaybillEnd{}", noCarWayBillDb);
-                return new RespR(false, "开始运单未传或者还未处理完成,请确认并5分钟后重试");
-            }
-
-        }
         //保存批次号信息
         String batchNumber = customerOperService.saveCustomerOper(customerName, 2);
         executorService.execute(() -> {
@@ -374,7 +347,7 @@ public class NoCarBillWayServiceImpl extends ServiceImpl<NoCarWaybillMapper, NoC
                 }
 
             });
-
+            customerOperService.updateStatus(0,batchNumber);
             if (!StringUtils.isEmpty(stringBuffer.toString())) {
                 log.error("开始平台指令上传失败NoCarBillWayServiceImpl.batchBillWayEnd:{}", stringBuffer.toString());
             }

+ 15 - 3
src/main/resources/mapper/customer/CustomerOperMapper.xml

@@ -10,6 +10,7 @@
         <result column="createTime" property="createTime"/>
         <result column="batchNumber" property="batchNumber"/>
         <result column="operType" property="operType"/>
+        <result column="batchStatus" property="batchStatus"/>
     </resultMap>
 
     <sql id="baseSql">
@@ -19,7 +20,8 @@
         company,
         createTime,
         batchNumber,
-        operType
+        operType,
+        batchStatus
     </sql>
     <select id="selectAllByPage" resultMap="BaseResultMap">
         select
@@ -48,11 +50,21 @@
             company,
             createTime,
             batchNumber,
-            operType
+            operType,
+            batchStatus
         )
         values ( #{customerName,jdbcType=VARCHAR}, #{customerPhone,jdbcType=VARCHAR},
             #{company,jdbcType=VARCHAR},#{createTime,jdbcType=VARCHAR}, #{batchNumber,jdbcType=INTEGER},
-            #{operType,jdbcType=INTEGER}
+            #{operType,jdbcType=INTEGER},#{batchStatus,jdbcType=INTEGER}
         )
     </insert>
+    <resultMap id="notfinishCont" type="java.lang.Integer">
+        <result column="notfinishCont" property="notfinishCont"/>
+    </resultMap>
+    <select id="countHasNotFinish" parameterType="java.lang.String" resultMap="notfinishCont">
+        select count(1) notfinishCont from t_cusomerOper where customerName = #{customerName,jdbcType=VARCHAR} and batchStatus=1 and operType=1
+    </select>
+    <update id="updateStatus" parameterType="java.util.Map">
+        UPDATE t_cusomerOper SET batchStatus = #{batchStatus,jdbcType=INTEGER} where batchNumber =  #{batchNumber,jdbcType=VARCHAR}
+    </update>
 </mapper>