Sfoglia il codice sorgente

修改批量方法

yousongbo 3 settimane fa
parent
commit
5b6dd7a7c5

+ 16 - 1
suishenbang-order/src/main/java/com/dgtly/order/controller/CustomersStartController.java

@@ -3,6 +3,7 @@ package com.dgtly.order.controller;
 import java.util.List;
 
 import com.dgtly.sync.service.HanaOrderComponent;
+import com.dgtly.system.service.ISysUserOrderAuthorService;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -99,13 +100,27 @@ public class CustomersStartController extends BaseController
      * 经销商解冻查询接口
      */
     @PostMapping("/addFreeCustomer")
-    @ResponseBody
     public String addFreeCustomer(String customer) {
         try {
             hanaOrderComponent.hanaFreezeCustomer(customer);
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
+        return "执行成功";
+    }
+    @Autowired
+    private ISysUserOrderAuthorService sysUserOrderAuthorService;
+
+    /**
+     * 经销商解冻查询接口
+     */
+    @PostMapping("/customersStarts")
+    public String addFreeCustomer() {
+        try {
+            sysUserOrderAuthorService.customersStart();
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
         return "";
     }
 

File diff suppressed because it is too large
+ 9 - 5
suishenbang-sync/suishenbang-sync-common/src/main/java/com/dgtly/sync/service/HanaOrderComponent.java


+ 3 - 0
suishenbang-system/src/main/java/com/dgtly/system/mapper/CustomerMapper.java

@@ -82,4 +82,7 @@ public interface CustomerMapper
      * @return 结果
      */
     public int insertCustomersStart(CustomersVo customersVo);
+
+    //批量新增经销商启用
+    int insertCustomersStartBatch(List<CustomersVo> list);
 }

+ 8 - 1
suishenbang-system/src/main/java/com/dgtly/system/service/impl/SysUserOrderAuthorServiceImpl.java

@@ -5,6 +5,7 @@ import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import com.alibaba.fastjson.JSON;
 import com.dgtly.common.core.domain.Ztree;
 import com.dgtly.common.utils.DateUtils;
 import com.dgtly.common.utils.StringUtils;
@@ -13,6 +14,7 @@ import com.dgtly.system.domain.*;
 import com.dgtly.system.mapper.*;
 import com.dgtly.system.service.ISysDictDataService;
 import com.dgtly.system.util.MailUtils;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
@@ -33,6 +35,7 @@ import javax.mail.internet.MimeMessage;
  * @author dgtly
  * @date 2022-03-22
  */
+@Slf4j
 @Service
 @Component
 public class SysUserOrderAuthorServiceImpl implements ISysUserOrderAuthorService
@@ -872,6 +875,9 @@ public class SysUserOrderAuthorServiceImpl implements ISysUserOrderAuthorService
     public void customersStart() {
         List<DataMasterCustomerVO> customerVOS = customersMapper.selectCustomerCodeByNotStart();
         if(customerVOS !=null && customerVOS.size()>0){
+            log.info("开始执行经销商自动上线");
+            log.info("待上线经销商:{}", JSON.toJSON(customerVOS));
+            List<CustomersVo> customers = new ArrayList<>();
             customerVOS.forEach(customer->{
                 Calendar calendar = Calendar.getInstance();
                 //昨日
@@ -882,8 +888,9 @@ public class SysUserOrderAuthorServiceImpl implements ISysUserOrderAuthorService
                 customersStart.setOnlineTime(calendar.getTime());
                 //all
                 customersStart.setCustomerType(3);
-                customersMapper.insertCustomersStart(customersStart);
+                customers.add(customersStart);
             });
+            customersMapper.insertCustomersStartBatch(customers);
         }
     }
 

+ 6 - 0
suishenbang-system/src/main/resources/mapper/system/CustomerMapper.xml

@@ -172,5 +172,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="customerType !=null and customerType != '' ">#{customerType},</if>
         </trim>
     </insert>
+    <insert id="insertCustomersStartBatch" parameterType="java.util.List">
+             insert into  customers_start (customers_code,customers_name,online_time,customer_type) values
+             <foreach item="item" index="index" collection="list" separator=",">
+                 (#{item.customersCode},#{item.customersName},#{item.onlineTime},#{item.customerType})
+             </foreach>
+    </insert>
     
 </mapper>