|
@@ -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);
|
|
|
+// }
|
|
|
+ }
|
|
|
+}
|