|
@@ -1,14 +1,20 @@
|
|
|
package cn.ezhizao.framework.enbust;
|
|
|
|
|
|
|
|
|
-import cn.ezhizao.project.fegin.ExampleFeignClient;
|
|
|
+import cn.ezhizao.project.fegin.IFeignClient;
|
|
|
+import cn.ezhizao.project.tenant.domain.Tenant;
|
|
|
+import cn.ezhizao.project.tenant.service.ITenantService;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
-import org.springframework.cloud.client.loadbalancer.LoadBalanced;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.sql.Array;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
|
|
|
|
|
|
@Component("entrust")
|
|
@@ -16,81 +22,45 @@ public class EntrustTask {
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(EntrustTask.class);
|
|
|
@Resource
|
|
|
- @LoadBalanced
|
|
|
- private ExampleFeignClient feignClient;
|
|
|
+ private IFeignClient entrustFeignClient;
|
|
|
+ @Resource
|
|
|
+ private ITenantService tenantService;
|
|
|
|
|
|
public void next() {
|
|
|
{
|
|
|
try {
|
|
|
- feignClient.transNext();
|
|
|
- String test = feignClient.test();
|
|
|
- System.out.println("EntrustTask.next" + test);
|
|
|
+
|
|
|
+
|
|
|
+ //非工厂 -- 门店 !4
|
|
|
+ List<Tenant> storeList = tenantService.list(new LambdaQueryWrapper<Tenant>().in(Tenant::getVersionId, Arrays.asList(1, 2)));
|
|
|
+ if (storeList != null) {
|
|
|
+ for (Tenant tenant : storeList) {
|
|
|
+ entrustFeignClient.transNext(tenant.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.info("非工厂执行完毕"+ new Date());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //工厂 4
|
|
|
+ List<Tenant> factoryList = tenantService.list(new LambdaQueryWrapper<Tenant>().eq(Tenant::getVersionId, 4));
|
|
|
+ if (factoryList != null) {
|
|
|
+ for (Tenant tenant : factoryList) {
|
|
|
+ entrustFeignClient.transNextFactory(tenant.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ log.info("工厂执行完毕" + new Date());
|
|
|
+
|
|
|
+
|
|
|
+ log.info("定时任务成功");
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- log.info("定时任务出错");
|
|
|
+ log.info("定时任务出错"+e.getMessage());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- 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);
|
|
|
-// }
|
|
|
- }
|
|
|
+
|
|
|
}
|