Administrator 4 månader sedan
förälder
incheckning
d8bca45d7f

+ 26 - 5
src/main/java/com/jkcredit/invoice/controller/interserver/NoCarServiceController.java

@@ -8,6 +8,7 @@ import com.jkcredit.invoice.model.entity.customer.CustomerCarRec;
 import com.jkcredit.invoice.model.entity.customer.CustomerRec;
 import com.jkcredit.invoice.model.entity.user.User;
 import com.jkcredit.invoice.model.entity.waybill.NoCarWayBill;
+import com.jkcredit.invoice.model.vo.MigrateVo;
 import com.jkcredit.invoice.service.lowerservice.CheckHasAuthRole;
 import com.jkcredit.invoice.service.lowerservice.NoCarService;
 import com.jkcredit.invoice.service.lowerservice.vo.HcInvoiceQueryVo;
@@ -15,6 +16,7 @@ import com.jkcredit.invoice.service.lowerservice.vo.MonthAccountQueryVo;
 import com.jkcredit.invoice.util.RespR;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -104,14 +106,19 @@ public class NoCarServiceController {
     @ApiOperation(value = "月账单交易查询更新", notes = "月账单交易查询更新")
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
     public RespR monthAccQueryUpdate(@RequestBody MonthAccountQueryVo monthAccountQueryVo) {
+        if(StringUtils.isEmpty(monthAccountQueryVo.getCompanyName())){
+            List<CustomerRec> companys = customerRecMapper.selectAllNoCarComapany();
+            mounthAccMapper.deleteAll();
+            for (int i = 0; i < companys.size(); i++) {
+                monthAccountQueryVo.setCompanyName(companys.get(i).getCompanyName());
+                noCarService.monthAccQueryUpdate(monthAccountQueryVo);
 
-        List<CustomerRec> companys = customerRecMapper.selectAllNoCarComapany();
-        mounthAccMapper.deleteAll();
-        for (int i = 0; i < companys.size(); i++) {
-            monthAccountQueryVo.setCompanyName(companys.get(i).getCompanyName());
+            }
+        }else{
+            mounthAccMapper.deleteByCompanyName(monthAccountQueryVo.getCompanyName());
             noCarService.monthAccQueryUpdate(monthAccountQueryVo);
-
         }
+
         return new RespR(true);
     }
 
@@ -156,4 +163,18 @@ public class NoCarServiceController {
         checkHasAuthRole.checkCustomerRole(user, customerCarRec.getCustomerName());
         return noCarService.customerCarRecQuery(customerCarRec);
     }
+
+    /**
+     * @param
+     * @return
+     */
+    @PostMapping("/migrateData")
+    @ApiOperation(value = "", notes = "按时间迁移数据(月)")
+    @LoginRequired
+    public RespR migrateData(@RequestBody MigrateVo migrateVo, User user) {
+        if(!(StringUtils.isEmpty(migrateVo.getStartMounth())|| StringUtils.isEmpty(migrateVo.getEndmounth())))
+        noCarService.migrateData(migrateVo);
+        return  new RespR(true);
+    }
+
 }

+ 1 - 1
src/main/java/com/jkcredit/invoice/credit/SimpleCoreFilter.java

@@ -231,7 +231,7 @@ public class SimpleCoreFilter implements Filter {
             "/noCarService/customerCarRec",
             "/noCarService/customeRecUpperQuery",
             "/noCarService/customerCarRecQuery",
-
+            "/noCarService/migrateData",
 
             "/selfCarService/getTradeList",
             "/selfCarService/applInvoice",

+ 1 - 0
src/main/java/com/jkcredit/invoice/mapper/binvoce/BillInvoiceMapper.java

@@ -52,6 +52,7 @@ public interface BillInvoiceMapper extends BaseMapper<BillInvoice> {
     @Override
     int insert(BillInvoice record);
 
+    int insertHis(BillInvoice record);
     /**
      * 更新发票
      *

+ 1 - 1
src/main/java/com/jkcredit/invoice/mapper/calculateinfor/MounthAccMapper.java

@@ -24,7 +24,7 @@ public interface MounthAccMapper {
      * @return
      */
     int deleteAll();
-
+    int deleteByCompanyName(String companyName);
     /**
      * 查询月账单列表
      * @return

+ 10 - 1
src/main/java/com/jkcredit/invoice/mapper/waybill/NoCarWaybillMapper.java

@@ -47,6 +47,8 @@ public interface NoCarWaybillMapper extends BaseMapper<NoCarWayBill> {
     @Override
     int insert(NoCarWayBill record);
 
+    int insertHis(NoCarWayBill record);
+
     /**
      * 更新运单信息
      * @param record
@@ -101,7 +103,7 @@ public interface NoCarWaybillMapper extends BaseMapper<NoCarWayBill> {
      * @param wayBillNum
      */
     void deleteNotRightWayBill(String wayBillNum);
-
+    void deleteWayBill(String wayBillNum);
     /**
      * 根据运单号查询运单列表
      * @param noCarWayBill
@@ -122,4 +124,11 @@ public interface NoCarWaybillMapper extends BaseMapper<NoCarWayBill> {
      * @return
      */
     List<NoCarWayBill> getNoCarNoVoiceQuery(String customerName);
+
+    /**
+     * 查询一千条运单数据
+     * @param noCarWayBill
+     * @return
+     */
+    List<NoCarWayBill> selectMigrateDatas(@Param("noCarWayBill") NoCarWayBill noCarWayBill);
 }

+ 18 - 0
src/main/java/com/jkcredit/invoice/model/vo/MigrateVo.java

@@ -0,0 +1,18 @@
+package com.jkcredit.invoice.model.vo;
+
+import lombok.Data;
+
+/**
+ * 数据迁移参数
+ */
+@Data
+public class MigrateVo {
+    /**
+     * 开始月份
+     */
+    private String startMounth;
+    /**
+     * 结束月份
+     */
+    private String endmounth;
+}

+ 2 - 1
src/main/java/com/jkcredit/invoice/service/lowerservice/NoCarService.java

@@ -2,6 +2,7 @@ package com.jkcredit.invoice.service.lowerservice;
 
 import com.jkcredit.invoice.model.entity.customer.CustomerCarRec;
 import com.jkcredit.invoice.model.entity.waybill.NoCarWayBill;
+import com.jkcredit.invoice.model.vo.MigrateVo;
 import com.jkcredit.invoice.service.lowerservice.vo.HcInvoiceQueryVo;
 import com.jkcredit.invoice.service.lowerservice.vo.MonthAccountQueryVo;
 import com.jkcredit.invoice.util.RespR;
@@ -131,5 +132,5 @@ public interface NoCarService {
      * @param noCarWayBill 运单
      */
     void updateByBillNumEnd(NoCarWayBill noCarWayBill);
-
+    RespR migrateData(MigrateVo migrateVo);
 }

+ 29 - 1
src/main/java/com/jkcredit/invoice/service/lowerservice/impl/NoCarServiceImpl.java

@@ -44,12 +44,15 @@ import com.jkcredit.invoice.model.entity.invoice.HcInvoice;
 import com.jkcredit.invoice.model.entity.manager.Param;
 import com.jkcredit.invoice.model.entity.waybill.NoCarWayBill;
 import com.jkcredit.invoice.model.entity.waybill.NoCarWayBillFileInfo;
+import com.jkcredit.invoice.model.vo.MigrateVo;
 import com.jkcredit.invoice.service.lowerservice.NoCarService;
 import com.jkcredit.invoice.service.lowerservice.vo.HcInvoiceQueryVo;
 import com.jkcredit.invoice.service.lowerservice.vo.MonthAccountQueryVo;
 import com.jkcredit.invoice.service.manager.ParamService;
 import com.jkcredit.invoice.service.nocar.HcInvoiceService;
+import com.jkcredit.invoice.service.nocar.NoCarBillWayService;
 import com.jkcredit.invoice.service.nocar.NoCarRecService;
+import com.jkcredit.invoice.service.nocar.WayBillFileService;
 import com.jkcredit.invoice.service.upservice.NoCarInterface;
 import com.jkcredit.invoice.util.DateUtil;
 import com.jkcredit.invoice.util.MathUtil;
@@ -125,7 +128,6 @@ public class NoCarServiceImpl implements NoCarService {
     HcInvoiceMapper hcInvoiceMapper;
     @Autowired
     MounthAccMapper mounthAccMapper;
-
     @Override
     public RespR customerCarRec(List<CustomerCarRec> customerCarRecs) {
         log.info("车辆备案开始NoCarServiceImpl.customerCarRec{}", customerCarRecs);
@@ -1295,6 +1297,32 @@ public class NoCarServiceImpl implements NoCarService {
         log.info("99999999{}", noCarWayBill.getBillNum());
         return new RespR("success");
     }
+    @Autowired
+    WayBillFileService wayBillFileService;
+    @Override
+    public RespR migrateData(MigrateVo migrateVo) {
+        //按时间每次查询一千条数据 2024-03
+        String startTime = migrateVo.getStartMounth()+"-01 00:00:00";
+        String endTime = migrateVo.getEndmounth()+"-01 00:00:00";
+        NoCarWayBill noCarWayBill = new NoCarWayBill();
+        noCarWayBill.setStartBegin(startTime);
+        noCarWayBill.setStartEnd(endTime);
+         int i  = 0;
+        while(i>-1){
+            List<NoCarWayBill> noCarWayBills = noCarWaybillMapper.selectMigrateDatas(noCarWayBill);
+            if(noCarWayBills.size() == 0){
+                i=-2;
+            }
+            i++;
+            noCarWayBills.forEach(noCarWayBill1 -> {
+                wayBillFileService.migrateData1(noCarWayBill1);
+            });
+            log.info("第{}次删除时间{},{}",i,startTime,endTime);
+        }
+
+        //对这一千条数据进行先入运单表,再入发票表,再删除运单和发票
+        return new RespR("success");
+    }
 
     @Override
     public void updateByBillNumEnd(NoCarWayBill noCarWayBill) {

+ 2 - 1
src/main/java/com/jkcredit/invoice/service/nocar/WayBillFileService.java

@@ -2,6 +2,7 @@ package com.jkcredit.invoice.service.nocar;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.jkcredit.invoice.model.entity.waybill.NoCarWayBill;
 import com.jkcredit.invoice.model.entity.waybill.NoCarWayBillFileInfo;
 import org.apache.ibatis.annotations.Param;
 
@@ -15,5 +16,5 @@ public interface WayBillFileService {
     NoCarWayBillFileInfo selectFileInfo(String batchNum,String wayBillNum);
 
     NoCarWayBillFileInfo selectFileInfoNoFile(String batchNum,String wayBillNum);
-
+    void migrateData1(NoCarWayBill noCarWayBill);
 }

+ 22 - 2
src/main/java/com/jkcredit/invoice/service/nocar/impl/WayBillFileServiceImpl.java

@@ -2,15 +2,23 @@ package com.jkcredit.invoice.service.nocar.impl;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jkcredit.invoice.mapper.binvoce.BillInvoiceMapper;
+import com.jkcredit.invoice.mapper.waybill.NoCarWaybillMapper;
 import com.jkcredit.invoice.mapper.waybill.WayBillFileMapper;
+import com.jkcredit.invoice.model.entity.invoice.BillInvoice;
+import com.jkcredit.invoice.model.entity.waybill.NoCarWayBill;
 import com.jkcredit.invoice.model.entity.waybill.NoCarWayBillFileInfo;
 import com.jkcredit.invoice.service.nocar.WayBillFileService;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 @Service
+@Slf4j
 public class WayBillFileServiceImpl extends ServiceImpl<WayBillFileMapper, NoCarWayBillFileInfo> implements WayBillFileService {
     @Autowired
     WayBillFileMapper wayBillFileMapper;
@@ -39,6 +47,18 @@ public class WayBillFileServiceImpl extends ServiceImpl<WayBillFileMapper, NoCar
         }
         return wayBillFileMapper.selectFileInfoNoFile(batchNum,wayBillNum);
     }
-
-
+    @Autowired
+    NoCarWaybillMapper noCarWaybillMapper;
+    @Autowired
+    BillInvoiceMapper billInvoiceMapper;
+    @Override
+    @Transactional(isolation = Isolation.READ_COMMITTED,rollbackFor=Exception.class)
+    public void migrateData1(NoCarWayBill noCarWayBill) {
+        log.info("开始迁移数据{}",noCarWayBill.getBillNum());
+        noCarWaybillMapper.insertHis(noCarWayBill);
+        noCarWaybillMapper.deleteWayBill(noCarWayBill.getBillNum());
+        List<BillInvoice> billInvoices = billInvoiceMapper.selectByBillNum(noCarWayBill.getBillNum());
+        billInvoices.forEach(billInvoice -> {billInvoiceMapper.insert(billInvoice);});
+        billInvoiceMapper.deleteByBillNum(noCarWayBill.getBillNum());
+    }
 }

+ 3 - 0
src/main/resources/mapper/calculateinfor/MounthAccMapper.xml

@@ -54,4 +54,7 @@
     <delete id="deleteAll">
         delete from t_mouth_cal where 1=1
     </delete>
+    <delete id="deleteByCompanyName">
+        delete from t_mouth_cal where companyName = #{companyName,jdbcType=VARCHAR}
+    </delete>
 </mapper>

+ 49 - 0
src/main/resources/mapper/invoice/BillInvoiceMapper.xml

@@ -272,6 +272,55 @@
                 ,#{waybillNumAct,jdbcType=VARCHAR}
         )
     </insert>
+    <insert id="insertHis" parameterType="com.jkcredit.invoice.model.entity.invoice.BillInvoice" >
+        insert into t_billInvoice_his_one (
+        companyNum,
+        customerName,
+        companyName,
+        waybillNum,
+        invoiceNum,
+        invoiceCode,
+        invoiceMakeTime,
+        invoiceUrl,
+        invoiceHtmlUrl,
+        enStation,
+        exStation,
+        exTime,
+        fee,
+        totalTaxAmount,
+        plateNum,
+        vehicleType,
+        sellerName,
+        sellerTaxpayerCode,
+        waybillStatus,
+        waybillStartTime,
+        waybillEndTime,
+        totalAmount,
+        taxRate,
+        invoiceType,
+        amount,
+        transactionId,
+        tradeMatchTime,
+        buyerName,
+        buyerTaxpayerCode,calculateTime,
+        invoiceStatus,
+        msg,
+        waybillNumAct
+        )
+        values ( #{companyNum,jdbcType=VARCHAR},#{customerName,jdbcType=VARCHAR},#{companyName,jdbcType=VARCHAR},#{waybillNum,jdbcType=VARCHAR}, #{invoiceNum,jdbcType=VARCHAR},
+        #{invoiceCode,jdbcType=VARCHAR}, #{invoiceMakeTime,jdbcType=VARCHAR}, #{invoiceUrl,jdbcType=VARCHAR},
+        #{invoiceHtmlUrl,jdbcType=VARCHAR}, #{enStation,jdbcType=VARCHAR}, #{exStation,jdbcType=VARCHAR},
+        #{exTime,jdbcType=VARCHAR}, #{fee,jdbcType=INTEGER}, #{totalTaxAmount,jdbcType=INTEGER},
+        #{plateNum,jdbcType=VARCHAR},#{vehicleType,jdbcType=VARCHAR},#{sellerName,jdbcType=VARCHAR},
+        #{sellerTaxpayerCode,jdbcType=VARCHAR},#{waybillStatus,jdbcType=INTEGER}, #{waybillStartTime,jdbcType=VARCHAR}, #{waybillEndTime,jdbcType=VARCHAR}
+        , #{totalAmount,jdbcType=INTEGER}, #{taxRate,jdbcType=DOUBLE},#{invoiceType,jdbcType=VARCHAR},#{amount,jdbcType=INTEGER},
+        #{transactionId,jdbcType=VARCHAR},#{tradeMatchTime,jdbcType=VARCHAR},#{buyerName,jdbcType=VARCHAR},#{buyerTaxpayerCode,jdbcType=VARCHAR}
+        ,#{calculateTime,jdbcType=VARCHAR}
+        ,#{invoiceStatus,jdbcType=INTEGER}
+        ,#{msg,jdbcType=VARCHAR}
+        ,#{waybillNumAct,jdbcType=VARCHAR}
+        )
+    </insert>
     <update id="updateByPrimaryKey" parameterType="com.jkcredit.invoice.model.entity.invoice.BillInvoice" >
         update t_billInvoice
         set

+ 49 - 0
src/main/resources/mapper/waybill/NoCarWaybillMapper.xml

@@ -98,6 +98,18 @@
             </if>
         </where>
     </select>
+    <select id="selectMigrateDatas" resultMap="BaseResultMap">
+        select
+        <include refid="baseSql" />
+        from t_waybill_no
+        <where>
+            1 = 1
+            <if test="noCarWayBill.startBegin != null and noCarWayBill.startBegin != ''">
+                and intfaceStartTime BETWEEN #{noCarWayBill.startBegin} and #{noCarWayBill.startEnd}
+            </if>
+        </where>
+        limit 1000
+    </select>
     <select id="selectAllByPageHis" resultMap="BaseResultMap">
         select
         <include refid="baseSql" />
@@ -207,6 +219,39 @@
         ,#{batchNumEnd,jdbcType=VARCHAR},#{failReason,jdbcType=VARCHAR},#{interType,jdbcType=INTEGER},#{splitFlag,jdbcType=INTEGER}
         )
     </insert>
+    <insert id="insertHis" parameterType="com.jkcredit.invoice.model.entity.waybill.NoCarWayBill" >
+        insert into t_waybill_no_his_one (
+        customerName,
+        companyName,
+        billNum,
+        plateNum,
+        plateColor,
+        startTime,
+        sourceAddr,
+        destAddr,
+        predictEndTime,
+        fee,
+        titleType,
+        taxplayerCode,
+        intfaceStartTime,
+        interfaceEndTime,
+        billwayStatus,
+        hisFlag,
+        companyAdress,
+        companyBank,
+        companyBankAcc,
+        companyTel,companyNum,updateTime,batchNumber,batchNumEnd,failReason,interType,splitFlag
+        )
+        values ( #{customerName,jdbcType=VARCHAR}, #{companyName,jdbcType=VARCHAR},
+        #{billNum,jdbcType=VARCHAR}, #{plateNum,jdbcType=VARCHAR}, #{plateColor,jdbcType=VARCHAR},
+        #{startTime,jdbcType=VARCHAR}, #{sourceAddr,jdbcType=VARCHAR}, #{destAddr,jdbcType=VARCHAR},
+        #{predictEndTime,jdbcType=VARCHAR}, #{fee,jdbcType=INTEGER}, #{titleType,jdbcType=INTEGER},
+        #{taxplayerCode,jdbcType=VARCHAR},#{intfaceStartTime,jdbcType=VARCHAR},#{interfaceEndTime,jdbcType=VARCHAR},
+        #{billwayStatus,jdbcType=INTEGER},#{hisFlag,jdbcType=INTEGER}, #{companyAdress,jdbcType=VARCHAR}, #{companyBank,jdbcType=VARCHAR}
+        , #{companyBankAcc,jdbcType=VARCHAR}, #{companyTel,jdbcType=VARCHAR},#{companyNum,jdbcType=VARCHAR},#{updateTime,jdbcType=VARCHAR},#{batchNum,jdbcType=VARCHAR}
+        ,#{batchNumEnd,jdbcType=VARCHAR},#{failReason,jdbcType=VARCHAR},#{interType,jdbcType=INTEGER},#{splitFlag,jdbcType=INTEGER}
+        )
+    </insert>
     <update id="updateByPrimaryKey" parameterType="com.jkcredit.invoice.model.entity.waybill.NoCarWayBill" >
         update t_waybill_no
         set customerName = #{customerName,jdbcType=VARCHAR},
@@ -348,4 +393,8 @@
         delete from t_waybill_no
         where  billNum = BINARY #{billNum,jdbcType=VARCHAR} and billwayStatus &lt; 1
    </delete>
+    <delete id="deleteWayBill" parameterType="java.lang.String">
+        delete from t_waybill_no
+        where  billNum = BINARY #{billNum,jdbcType=VARCHAR}
+    </delete>
 </mapper>