Browse Source

no message

ly 1 year ago
parent
commit
626be9c5e8

+ 24 - 2
pom.xml

@@ -50,12 +50,22 @@
             <artifactId>spring-cloud-starter-openfeign</artifactId>
             <version>3.1.3</version>
         </dependency>
-
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-loadbalancer</artifactId>
+            <version>3.1.3</version>
+        </dependency>
         <!-- Spring-Cloud-Nacos -->
         <dependency>
             <groupId>com.alibaba.cloud</groupId>
             <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
             <version>${spring-cloud-nacos.version}</version>
+<!--            <exclusions>-->
+<!--                <exclusion>-->
+<!--                    <groupId>org.springframework.cloud</groupId>-->
+<!--                    <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>-->
+<!--                </exclusion>-->
+<!--            </exclusions>-->
         </dependency>
         <dependency>
             <groupId>com.alibaba.cloud</groupId>
@@ -322,8 +332,20 @@
             <artifactId>dynamic-datasource-spring-boot-starter</artifactId>
             <version>3.5.2</version>
         </dependency>
+        <dependency>
+            <groupId>org.redisson</groupId>
+            <artifactId>redisson</artifactId>
+            <version>3.24.3</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.redisson</groupId>
+            <artifactId>redisson</artifactId>
+            <version>3.24.3</version>
+            <scope>compile</scope>
+        </dependency>
 
-<!--        <dependency>-->
+        <!--        <dependency>-->
 <!--            <groupId>com.ezhizao</groupId>-->
 <!--            <artifactId>snms-spring-boot-starter</artifactId>-->
 <!--            <version>0.0.2</version>-->

+ 96 - 0
src/main/java/cn/ezhizao/framework/enbust/EntrustTask.java

@@ -0,0 +1,96 @@
+package cn.ezhizao.framework.enbust;
+
+
+import cn.ezhizao.project.fegin.ExampleFeignClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.springframework.cloud.client.loadbalancer.LoadBalanced;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+
+@Component("entrust")
+public class EntrustTask {
+
+    private static final Logger log = LoggerFactory.getLogger(EntrustTask.class);
+    @Resource
+    @LoadBalanced
+    private ExampleFeignClient feignClient;
+
+    public void next() {
+        {
+            try {
+               feignClient.transNext();
+                String test = feignClient.test();
+                System.out.println("EntrustTask.next" + test);
+            } catch (Exception e) {
+                e.printStackTrace();
+                log.info("定时任务出错");
+            }
+
+        }
+    }
+
+    private void nextEntrust() {
+//        // 将本月改为上一月,将下月改成本月,添加新月
+//        List<SysCurrentMonth> months = sysCurrentMonthService.query().eq("tenant_id", getTenantId()).ge("type", 0).list();
+//        SysCurrentMonth currentMonth = months.stream().filter(v -> v.getType().equals(0)).findFirst().orElse(new SysCurrentMonth());
+//        if (currentMonth.getId() == null) {
+//            throw new ServiceException("未设定本月");
+//        }
+//        SysCurrentMonth nextMonth = months.stream().filter(v -> v.getType().equals(1)).findFirst().orElse(new SysCurrentMonth());
+//        SysCurrentMonth newNextMonth = new SysCurrentMonth();
+//        currentMonth.setType(-1);
+//        nextMonth.setType(0);
+//        DateTime nextMonthDate = DateTime.of(nextMonth.getYear() + nextMonth.getMonth() + "01", "yyyyMMdd");
+//        newNextMonth.setMonth(nextMonthDate.offsetNew(DateField.MONTH, 1).toString("MM"));
+//        newNextMonth.setYear(nextMonthDate.offsetNew(DateField.MONTH, 1).toString("yyyy"));
+//        newNextMonth.setTenantId(getTenantId());
+//        newNextMonth.setType(1);
+//
+//        // 获取上月的委托
+//        List<BizEntrust> entrusts = bizEntrustService.query().eq("tenant_id", getTenantId()).eq("work_month", nextMonthDate.toSqlDate()).list();
+//        List<BizEntrust> entr = new ArrayList<>(entrusts);
+//        //将到截至月的委托去掉
+//        for (BizEntrust b : entr) {
+//            List<BizWorkOrder> workOrder = bizWorkOrderService.query().eq("id", b.getWorkOrderId()).list();
+//
+//            Calendar calendar = Calendar.getInstance();
+//            // 设置年份
+//            calendar.set(Calendar.YEAR, Integer.parseInt(months.get(0).getYear()));
+//            // 设置月份为(注意:月份是从0开始的,所以要减1)
+//            calendar.set(Calendar.MONTH, Integer.parseInt(months.get(0).getMonth()) - 1);
+//            // 设置日期
+//            calendar.set(Calendar.DAY_OF_MONTH, 1);
+//            Date currentMonthDate = new Date(calendar.getTime().getTime());
+//            if (!workOrder.isEmpty()) {
+//                if (workOrder.get(0).getIsStop() == 1 || (currentMonthDate == workOrder.get(0).getEndMonth())) {
+//                    entrusts.removeIf(s -> s.getWorkOrderId().equals(b.getWorkOrderId()));
+//                }
+//            }
+//        }
+//        entrusts.forEach(l -> {
+//            DateTime currentWorkMonth = DateTime.of(l.getWorkMonth());
+//            DateTime currentMonthDate = DateTime.of(l.getCurrentMonth());
+//            l.setWorkMonth(currentWorkMonth.offsetNew(DateField.MONTH, 1).toSqlDate());
+//            l.setCurrentMonth(currentMonthDate.offsetNew(DateField.MONTH, 1).toSqlDate());
+//            l.setId(null);
+//        });
+//        if (currentMonth != null) {
+//            sysCurrentMonthService.updateById(currentMonth);
+//        }
+//
+//        if (nextMonth != null) {
+//            sysCurrentMonthService.updateById(nextMonth);
+//        }
+//
+//        if (newNextMonth != null) {
+//            sysCurrentMonthService.save(newNextMonth);
+//        }
+//        if (CollectionUtils.isNotEmpty(entrusts)) {
+//            bizEntrustService.saveBatch(entrusts);
+//        }
+    }
+}

+ 16 - 0
src/main/java/cn/ezhizao/project/fegin/ExampleFeignClient.java

@@ -0,0 +1,16 @@
+package cn.ezhizao.project.fegin;
+
+import cn.ezhizao.framework.web.domain.AjaxResult;
+import org.springframework.cloud.client.loadbalancer.LoadBalanced;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+
+@FeignClient(name = "ezhizao-yzbh-entrust")
+public interface ExampleFeignClient {
+
+    @GetMapping("/business/workOrderCurrent/transNext")
+    AjaxResult transNext();
+
+    @GetMapping("/business/workOrderCurrent/test")
+    String test();
+}