提交 b87eaef2 authored 作者: 邓砥奕's avatar 邓砥奕

[自查模块]增加系统变量表存储系统的自查周期

上级 3ced4661
...@@ -23,6 +23,7 @@ import com.tykj.dev.misc.utils.StringSplitUtil; ...@@ -23,6 +23,7 @@ import com.tykj.dev.misc.utils.StringSplitUtil;
import com.tykj.dev.socket.MyWebSocket; import com.tykj.dev.socket.MyWebSocket;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
...@@ -42,6 +43,7 @@ import java.util.List; ...@@ -42,6 +43,7 @@ import java.util.List;
@RequestMapping(value = "/allot") @RequestMapping(value = "/allot")
@AutoDocument @AutoDocument
@Api(tags = "装备配发模块", description = "装备配发接口") @Api(tags = "装备配发模块", description = "装备配发接口")
@Slf4j
public class AllotBackBillController { public class AllotBackBillController {
@Autowired @Autowired
...@@ -129,6 +131,7 @@ public class AllotBackBillController { ...@@ -129,6 +131,7 @@ public class AllotBackBillController {
deviceLibraryService.update(deviceLibraryEntity); deviceLibraryService.update(deviceLibraryEntity);
} }
} }
log.info("[配发模块]:配发退回出库");
myWebSocket.sendMessage1(); myWebSocket.sendMessage1();
return ResponseEntity.ok(new ResultObj<>(taskBto1, signId.toString())); return ResponseEntity.ok(new ResultObj<>(taskBto1, signId.toString()));
} }
...@@ -179,6 +182,7 @@ public class AllotBackBillController { ...@@ -179,6 +182,7 @@ public class AllotBackBillController {
} }
} }
} }
log.info("[配发模块]:配发退回接收入库");
myWebSocket.sendMessage1(); myWebSocket.sendMessage1();
return ResponseEntity.ok("配发退回接收入库"); return ResponseEntity.ok("配发退回接收入库");
} }
...@@ -214,6 +218,7 @@ public class AllotBackBillController { ...@@ -214,6 +218,7 @@ public class AllotBackBillController {
deviceLibraryService.update(deviceLibraryEntity); deviceLibraryService.update(deviceLibraryEntity);
} }
} }
log.info("[配发模块]:配发退回审核成功并入库");
myWebSocket.sendMessage1(); myWebSocket.sendMessage1();
return ResponseEntity.ok(signId.toString()); return ResponseEntity.ok(signId.toString());
} }
...@@ -236,6 +241,7 @@ public class AllotBackBillController { ...@@ -236,6 +241,7 @@ public class AllotBackBillController {
deviceLibraryService.update(deviceLibraryEntity); deviceLibraryService.update(deviceLibraryEntity);
} }
} }
log.info("[配发模块]:配发退回入库审核失败");
myWebSocket.sendMessage1(); myWebSocket.sendMessage1();
return ResponseEntity.ok("配发退回接收入库审核失败"); return ResponseEntity.ok("配发退回接收入库审核失败");
} else { } else {
......
...@@ -25,6 +25,7 @@ import com.tykj.dev.misc.utils.TimestampUtil; ...@@ -25,6 +25,7 @@ import com.tykj.dev.misc.utils.TimestampUtil;
import com.tykj.dev.socket.MyWebSocket; import com.tykj.dev.socket.MyWebSocket;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
...@@ -44,6 +45,7 @@ import java.util.List; ...@@ -44,6 +45,7 @@ import java.util.List;
@RequestMapping(value = "/allot") @RequestMapping(value = "/allot")
@AutoDocument @AutoDocument
@Api(tags = "装备配发模块", description = "装备配发接口") @Api(tags = "装备配发模块", description = "装备配发接口")
@Slf4j
public class AllotBillController { public class AllotBillController {
@Autowired @Autowired
...@@ -106,6 +108,7 @@ public class AllotBillController { ...@@ -106,6 +108,7 @@ public class AllotBillController {
deviceLogService.addLog(deviceLogDto); deviceLogService.addLog(deviceLogDto);
} }
} }
log.info("[配发模块]:"+allotBillEntity.getSendUnit()+"对" + allotBillEntity.getReceiveUnit() + "发起配发");
myWebSocket.sendMessage1(); myWebSocket.sendMessage1();
return ResponseEntity.ok(new ResultObj(allotBillEntity, "发起成功")); return ResponseEntity.ok(new ResultObj(allotBillEntity, "发起成功"));
} }
...@@ -144,6 +147,7 @@ public class AllotBillController { ...@@ -144,6 +147,7 @@ public class AllotBillController {
deviceLibraryService.update(deviceLibraryEntity); deviceLibraryService.update(deviceLibraryEntity);
} }
} }
log.info("[配发模块]:配发审核成功并出库");
myWebSocket.sendMessage1(); myWebSocket.sendMessage1();
return ResponseEntity.ok(signId.toString()); return ResponseEntity.ok(signId.toString());
} }
...@@ -165,6 +169,7 @@ public class AllotBillController { ...@@ -165,6 +169,7 @@ public class AllotBillController {
deviceLogService.addLog(deviceLogDto); deviceLogService.addLog(deviceLogDto);
} }
} }
log.info("[配发模块]:配发出库审核失败");
myWebSocket.sendMessage1(); myWebSocket.sendMessage1();
return ResponseEntity.ok("配发审核失败"); return ResponseEntity.ok("配发审核失败");
} else { } else {
...@@ -218,6 +223,7 @@ public class AllotBillController { ...@@ -218,6 +223,7 @@ public class AllotBillController {
} }
} }
} }
log.info("[配发模块]:接收并发起入库");
myWebSocket.sendMessage1(); myWebSocket.sendMessage1();
return ResponseEntity.ok("配发接收入库"); return ResponseEntity.ok("配发接收入库");
} }
...@@ -253,6 +259,7 @@ public class AllotBillController { ...@@ -253,6 +259,7 @@ public class AllotBillController {
deviceLibraryService.update(deviceLibraryEntity); deviceLibraryService.update(deviceLibraryEntity);
} }
} }
log.info("[配发模块]:审核成功并入库");
myWebSocket.sendMessage1(); myWebSocket.sendMessage1();
return ResponseEntity.ok(signId.toString()); return ResponseEntity.ok(signId.toString());
} }
...@@ -275,12 +282,13 @@ public class AllotBillController { ...@@ -275,12 +282,13 @@ public class AllotBillController {
deviceLibraryService.update(deviceLibraryEntity); deviceLibraryService.update(deviceLibraryEntity);
} }
} }
myWebSocket.sendMessage1();
//生成配发退回子业务 //生成配发退回子业务
List<Integer> userIds = new ArrayList<>(); List<Integer> userIds = new ArrayList<>();
userIds.add(userUtils.getCurrentUserId()); userIds.add(userUtils.getCurrentUserId());
TaskBto taskBto1 = new TaskBto(StatusEnum.WAIT_BACK.id, "配发退回业务", taskBto.getId(), taskBto.getNodeIdDetail() + taskBto.getId() + ".", 0, BusinessEnum.ALLOT_BACK.id, userUtils.getCurrentUnitId(), 0, null, userIds); TaskBto taskBto1 = new TaskBto(StatusEnum.WAIT_BACK.id, "配发退回业务", taskBto.getId(), taskBto.getNodeIdDetail() + taskBto.getId() + ".", 0, BusinessEnum.ALLOT_BACK.id, userUtils.getCurrentUnitId(), 0, null, userIds);
TaskBto task = taskService.start(taskBto1); TaskBto task = taskService.start(taskBto1);
log.info("[配发模块]:配发入库审核失败");
myWebSocket.sendMessage1();
return ResponseEntity.ok(task); return ResponseEntity.ok(task);
} else { } else {
return ResponseEntity.ok("status只能为0或1"); return ResponseEntity.ok("status只能为0或1");
......
...@@ -33,6 +33,7 @@ import com.tykj.dev.misc.utils.StringSplitUtil; ...@@ -33,6 +33,7 @@ import com.tykj.dev.misc.utils.StringSplitUtil;
import com.tykj.dev.socket.MyWebSocket; import com.tykj.dev.socket.MyWebSocket;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
...@@ -48,6 +49,7 @@ import java.util.stream.Collectors; ...@@ -48,6 +49,7 @@ import java.util.stream.Collectors;
@Api(tags = "装备申请模块", description = "申请模块") @Api(tags = "装备申请模块", description = "申请模块")
@AutoDocument @AutoDocument
@RequestMapping("/apply") @RequestMapping("/apply")
@Slf4j
public class DeviceApplyController { public class DeviceApplyController {
@Autowired @Autowired
......
package com.tykj.dev.config.domin;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
/**
* 系统变量实体类
*/
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@ApiModel("系统变量表")
public class SystemVariable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty(name = "主键id")
private Integer id;
@ApiModelProperty(value = "变量名")
private String name;
@ApiModelProperty(value = "变量值")
private String vaule;
}
package com.tykj.dev.config.repository;
import com.tykj.dev.config.domin.SystemVariable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author dengdiyi
*/
public interface SystemVariableDao extends JpaRepository<SystemVariable,Integer>, JpaSpecificationExecutor<SystemVariable> {
SystemVariable findByName(String name);
}
package com.tykj.dev.config.service;
import com.tykj.dev.config.domin.SystemVariable;
/**
* @author dengdiyi
*/
public interface SystemVariableService {
SystemVariable add(SystemVariable systemVariable);
String getVaule(String name);
SystemVariable setVaule(String name,String vaule);
}
package com.tykj.dev.config.service.impl;
import com.tykj.dev.config.domin.SystemVariable;
import com.tykj.dev.config.repository.SystemVariableDao;
import com.tykj.dev.config.service.SystemVariableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author dengdiyi
*/
@Service
public class SystemVariableServiceImpl implements SystemVariableService {
@Autowired
private SystemVariableDao systemVariableDao;
@Override
public SystemVariable add(SystemVariable systemVariable) {
return systemVariableDao.save(systemVariable);
}
@Override
public String getVaule(String name) {
return systemVariableDao.findByName(name).getVaule();
}
@Override
public SystemVariable setVaule(String name,String vaule) {
SystemVariable systemVariable = systemVariableDao.findByName(name);
systemVariable.setVaule(vaule);
return systemVariableDao.save(systemVariable);
}
}
package com.tykj.dev.config.task;
import com.tykj.dev.config.domin.SystemVariable;
import com.tykj.dev.config.repository.SystemVariableDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import sun.tools.jar.CommandLine;
@Slf4j
@Component
public class SystemVariableRun implements CommandLineRunner {
@Autowired
private SystemVariableDao systemVariableDao;
@Override
public void run(String... args) throws Exception {
if (systemVariableDao.findAll().size()==0){
SystemVariable systemVariable = new SystemVariable();
systemVariable.setName("selfCheckCycle");
systemVariable.setVaule("quarter");
systemVariableDao.save(systemVariable);
log.info("系统变量新建成功");
}
else {
log.info("已有系统变量不新建");
}
}
}
...@@ -2,6 +2,7 @@ package com.tykj.dev.device.selfcheck.base; ...@@ -2,6 +2,7 @@ package com.tykj.dev.device.selfcheck.base;
import com.tykj.dev.config.GlobalMap; import com.tykj.dev.config.GlobalMap;
import com.tykj.dev.config.TaskBeanConfig; import com.tykj.dev.config.TaskBeanConfig;
import com.tykj.dev.config.service.SystemVariableService;
import com.tykj.dev.device.task.service.TaskService; import com.tykj.dev.device.task.service.TaskService;
import com.tykj.dev.device.task.subject.bto.TaskBto; import com.tykj.dev.device.task.subject.bto.TaskBto;
import com.tykj.dev.device.user.subject.dao.UnitsDao; import com.tykj.dev.device.user.subject.dao.UnitsDao;
...@@ -23,6 +24,7 @@ import java.lang.reflect.InvocationHandler; ...@@ -23,6 +24,7 @@ import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy; import java.lang.reflect.Proxy;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
/** /**
...@@ -36,13 +38,43 @@ public class SelfCheckSchedulerTask { ...@@ -36,13 +38,43 @@ public class SelfCheckSchedulerTask {
private String cron = "0 0 0 1 3,6,9,12 ? "; private String cron = "0 0 0 1 3,6,9,12 ? ";
/**
* 月度
*/
private String cron1 = "0 0 0 1 1/1 ? ";
/**
* 季度
*/
private String cron2 = "0 0 0 1 3,6,9,12 ? ";
/**
* 年度
*/
private String cron3 = "0 0 0 1 1 ? ";
private String cron4 = "0 0/1 * * * ? ";
private UnitsDao unitsDao = SpringUtils.getBean("unitsDao"); private UnitsDao unitsDao = SpringUtils.getBean("unitsDao");
private TaskService taskService = SpringUtils.getBean("taskServiceImpl"); private TaskService taskService = SpringUtils.getBean("taskServiceImpl");
private SystemVariableService systemVariableService = SpringUtils.getBean("systemVariableServiceImpl");
private ScheduledFuture scheduledFuture; private ScheduledFuture scheduledFuture;
public SelfCheckSchedulerTask() { public SelfCheckSchedulerTask() {
String vaule = Objects.requireNonNull(systemVariableService).getVaule("selfCheckCycle");
if ("month".equals(vaule)){
setCron(cron1);
}
if ("quarter".equals(vaule)){
setCron(cron2);
}
if ("year".equals(vaule)){
setCron(cron3);
}
if ("minute".equals(vaule)){
setCron(cron4);
}
scheduledFuture = TaskBeanConfig.getThreadPoolTaskScheduler().schedule(new SelfCheckTask(), triggerContext -> new CronTrigger(cron).nextExecutionTime(triggerContext)); scheduledFuture = TaskBeanConfig.getThreadPoolTaskScheduler().schedule(new SelfCheckTask(), triggerContext -> new CronTrigger(cron).nextExecutionTime(triggerContext));
} }
......
package com.tykj.dev.device.selfcheck.controller; package com.tykj.dev.device.selfcheck.controller;
import com.tykj.dev.config.service.SystemVariableService;
import com.tykj.dev.config.swagger.AutoDocument; import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.library.repository.DeviceLibraryDao; import com.tykj.dev.device.library.repository.DeviceLibraryDao;
import com.tykj.dev.device.library.service.DeviceLibraryService; import com.tykj.dev.device.library.service.DeviceLibraryService;
...@@ -90,6 +91,9 @@ public class SelfCheckController { ...@@ -90,6 +91,9 @@ public class SelfCheckController {
@Autowired @Autowired
private UnitsDao unitsDao; private UnitsDao unitsDao;
@Autowired
private SystemVariableService systemVariableService;
/** /**
* 月度 * 月度
*/ */
...@@ -101,16 +105,30 @@ public class SelfCheckController { ...@@ -101,16 +105,30 @@ public class SelfCheckController {
/** /**
* 年度 * 年度
*/ */
private String cron3 = "0 0 0 1 1 ? *"; private String cron3 = "0 0 0 1 1 ? ";
/**
* 定时任务cron修改触发器的标志,1:月度,2:季度,3:年度(默认季度)
*/
private int tag = 2;
private String cron4 = "0 0/1 * * * ? "; private String cron4 = "0 0/1 * * * ? ";
private final SelfCheckSchedulerTask selfCheckSchedulerTask = SpringUtils.getBean("selfCheckSchedulerTask"); private final SelfCheckSchedulerTask selfCheckSchedulerTask = SpringUtils.getBean("selfCheckSchedulerTask");
@ApiOperation(value = "查询自查周期", notes = "可以通过这个接口查询自查周期")
@GetMapping(value = "/select/cycle")
public ResponseEntity selectCycle(){
String vaule = systemVariableService.getVaule("selfCheckCycle");
if ("month".equals(vaule)){
return ResponseEntity.ok(1);
}
else if ("quarter".equals(vaule)){
return ResponseEntity.ok(2);
}
else if ("year".equals(vaule)){
return ResponseEntity.ok(3);
}
else {
return ResponseEntity.ok(0);
}
}
@ApiOperation(value = "设置自查周期", notes = "可以通过这个接口设置自查周期") @ApiOperation(value = "设置自查周期", notes = "可以通过这个接口设置自查周期")
@PostMapping(value = "/set/cycle/{type}") @PostMapping(value = "/set/cycle/{type}")
public ResponseEntity setCycle(@PathVariable("type") int type){ public ResponseEntity setCycle(@PathVariable("type") int type){
...@@ -121,24 +139,32 @@ public class SelfCheckController { ...@@ -121,24 +139,32 @@ public class SelfCheckController {
ScheduledFuture scheduledFuture = selfCheckSchedulerTask.getScheduledFuture(); ScheduledFuture scheduledFuture = selfCheckSchedulerTask.getScheduledFuture();
scheduledFuture.cancel(true); scheduledFuture.cancel(true);
selfCheckSchedulerTask.startTask(); selfCheckSchedulerTask.startTask();
systemVariableService.setVaule("selfCheckCycle","month");
log.info("[自查模块]:自查周期更改为月度");
return ResponseEntity.ok("自查周期更改为月度"); return ResponseEntity.ok("自查周期更改为月度");
case 2: case 2:
selfCheckSchedulerTask.setCron(cron2); selfCheckSchedulerTask.setCron(cron2);
ScheduledFuture scheduledFuture2 = selfCheckSchedulerTask.getScheduledFuture(); ScheduledFuture scheduledFuture2 = selfCheckSchedulerTask.getScheduledFuture();
scheduledFuture2.cancel(true); scheduledFuture2.cancel(true);
selfCheckSchedulerTask.startTask(); selfCheckSchedulerTask.startTask();
systemVariableService.setVaule("selfCheckCycle","quarter");
log.info("[自查模块]:自查周期更改为季度");
return ResponseEntity.ok("自查周期更改为季度"); return ResponseEntity.ok("自查周期更改为季度");
case 3: case 3:
selfCheckSchedulerTask.setCron(cron3); selfCheckSchedulerTask.setCron(cron3);
ScheduledFuture scheduledFuture3 = selfCheckSchedulerTask.getScheduledFuture(); ScheduledFuture scheduledFuture3 = selfCheckSchedulerTask.getScheduledFuture();
scheduledFuture3.cancel(true); scheduledFuture3.cancel(true);
selfCheckSchedulerTask.startTask(); selfCheckSchedulerTask.startTask();
systemVariableService.setVaule("selfCheckCycle","year");
log.info("[自查模块]:自查周期更改为年度");
return ResponseEntity.ok("自查周期更改为年度"); return ResponseEntity.ok("自查周期更改为年度");
case 4: case 4:
selfCheckSchedulerTask.setCron(cron4); selfCheckSchedulerTask.setCron(cron4);
ScheduledFuture scheduledFuture4 = selfCheckSchedulerTask.getScheduledFuture(); ScheduledFuture scheduledFuture4 = selfCheckSchedulerTask.getScheduledFuture();
scheduledFuture4.cancel(true); scheduledFuture4.cancel(true);
selfCheckSchedulerTask.startTask(); selfCheckSchedulerTask.startTask();
systemVariableService.setVaule("selfCheckCycle","minute");
log.info("[自查模块]:自查周期更改为每分钟");
return ResponseEntity.ok("自查周期更改为每分钟"); return ResponseEntity.ok("自查周期更改为每分钟");
default: default:
return ResponseEntity.ok(ResultUtil.failed("设置失败:type只能为1,2,3")); return ResponseEntity.ok(ResultUtil.failed("设置失败:type只能为1,2,3"));
...@@ -264,6 +290,7 @@ public class SelfCheckController { ...@@ -264,6 +290,7 @@ public class SelfCheckController {
deviceLogService.addLog(deviceLogDto); deviceLogService.addLog(deviceLogDto);
} }
} }
log.info("[自查模块]:发起自查");
myWebSocket.sendMessage1(); myWebSocket.sendMessage1();
return ResultUtil.success(selfExaminationBillEntity1); return ResultUtil.success(selfExaminationBillEntity1);
} }
...@@ -289,6 +316,7 @@ public class SelfCheckController { ...@@ -289,6 +316,7 @@ public class SelfCheckController {
deviceLogService.addLog(deviceLogDto); deviceLogService.addLog(deviceLogDto);
} }
} }
log.info("[自查模块]:审核通过自查完成");
myWebSocket.sendMessage1(); myWebSocket.sendMessage1();
return ResultUtil.success("审核通过自查完成"); return ResultUtil.success("审核通过自查完成");
} }
...@@ -306,6 +334,7 @@ public class SelfCheckController { ...@@ -306,6 +334,7 @@ public class SelfCheckController {
deviceLogService.addLog(deviceLogDto); deviceLogService.addLog(deviceLogDto);
} }
} }
log.info("[自查模块]:自查审核失败");
myWebSocket.sendMessage1(); myWebSocket.sendMessage1();
return ResultUtil.success("自查审核失败"); return ResultUtil.success("自查审核失败");
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论