提交 a65f5ced authored 作者: Matrix's avatar Matrix

[核查模块] 核查周期保存

上级 515efe4d
......@@ -22,7 +22,7 @@ public enum CheckType {
*/
MANUAL_CHECK(2, "手动核查");
private Integer id;
private String name;
private final Integer id;
private final String name;
}
package com.tykj.dev.device.confirmcheck.common;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* TaskPeriod.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2020/10/26 at 4:47 下午
*/
@Getter
@AllArgsConstructor
public enum TaskPeriod {
/**
* 月度
*/
monthly("0 0 0 1 * ? *"),
/**
* 季度
*/
quarterly("0 0 0 1 3/3 ? *"),
/**
* 年度
*/
yearly("0 0 0 1 3/3 ? *");
private final String cron;
}
package com.tykj.dev.device.confirmcheck.common;
import javax.persistence.AttributeConverter;
import java.util.stream.Stream;
/**
* TaskPeriodConvert.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2020/10/26 at 4:54 下午
*/
public class TaskPeriodConvert implements AttributeConverter<TaskPeriod, String> {
/**
* Converts the value stored in the entity attribute into the
* data representation to be stored in the database.
*
* @param attribute the entity attribute value to be converted
* @return the converted data to be stored in the database
* column
*/
@Override
public String convertToDatabaseColumn(TaskPeriod attribute) {
if (attribute == null) {
return null;
}
return attribute.getCron();
}
/**
* Converts the data stored in the database column into the
* value to be stored in the entity attribute.
* Note that it is the responsibility of the converter writer to
* specify the correct <code>dbData</code> type for the corresponding
* column for use by the JDBC driver: i.e., persistence providers are
* not expected to do such type conversion.
*
* @param dbData the data from the database column to be
* converted
* @return the converted value to be stored in the entity
* attribute
*/
@Override
public TaskPeriod convertToEntityAttribute(String dbData) {
if (dbData == null) {
return null;
}
return Stream.of(TaskPeriod.values())
.filter(t -> t.getCron().equals(dbData))
.findFirst()
.orElseThrow(IllegalArgumentException::new);
}
}
package com.tykj.dev.device.confirmcheck.entity.domain;
import com.tykj.dev.device.confirmcheck.common.TaskPeriod;
import com.tykj.dev.misc.base.BaseEntityNoDelete;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import javax.persistence.Entity;
import java.time.LocalDateTime;
/**
* DeviceCheckPeriod.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2020/10/26 at 5:03 下午
*/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity
public class DeviceCheckPeriod extends BaseEntityNoDelete {
private TaskPeriod cronExpression;
}
package com.tykj.dev.device.confirmcheck.repository;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckDetail;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckPeriod;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* DeviceCheckPeriodDao.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2020/10/26 at 5:10 下午
*/
public interface DeviceCheckPeriodDao extends JpaRepository<DeviceCheckPeriod, Integer>, JpaSpecificationExecutor<DeviceCheckPeriod> {
/**
* @return 最新的一条周期数据
*/
DeviceCheckPeriod findTopByOrderByIdDesc();
}
......@@ -9,5 +9,5 @@ import org.springframework.data.jpa.repository.JpaRepository;
* @author Matrix <xhyrzldf@gmail.com>
* @since 2020/8/16 at 5:26 下午
*/
public interface DeviceCheckStatRepo extends JpaRepository<DeviceCheckStat, Integer> {
public interface DeviceCheckStatDao extends JpaRepository<DeviceCheckStat, Integer> {
}
package com.tykj.dev.device.confirmcheck.service;
import com.tykj.dev.device.confirmcheck.common.TaskPeriod;
import com.tykj.dev.device.confirmcheck.entity.domain.DeviceCheckPeriod;
import com.tykj.dev.device.confirmcheck.entity.vo.CheckStatTableVo;
import org.springframework.data.domain.Page;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
/**
* CheckStatService.
*
......@@ -15,9 +21,52 @@ public interface ConfirmCheckService {
* 根据关键字查询报告列表
*
* @param keyword 要查询的字
* @param page 页码
* @param size 每页数据量
* @param page 页码
* @param size 每页数据量
* @return {@link CheckStatTableVo} 's List
*/
Page<CheckStatTableVo> findAllStatTable(String keyword, int page, int size);
/**
* 开启自动核查
* @return 自动核查所开启的统计以及详情的账单id和任务id集合
*/
Map<String, List<Integer>> autoCheck();
/**
* 更新自动核查的任务周期
*
* @param taskPeriod 要更新成为的周期
* @return 周期表的最新id
*/
Integer updateTaskPeriod(TaskPeriod taskPeriod);
/**
* 获得当前自动核查的任务周期
*
* @return 当前的 {@link TaskPeriod}
*/
DeviceCheckPeriod getCurrentTaskPeriod();
/**
* 获得下一次计划任务的执行时间
* @return 下次计划任务的执行时间
*/
LocalDate getNextTaskDate();
/**
* 开启自动核查计划任务
*
* @return 任务是否开启成功
*/
boolean startAutoCheckCron();
/**
* 关闭自动核查计划任务
*
* @return 任务是否关闭成功
*/
boolean stopAutoCheckCron();
}
package com.tykj.dev.misc.base;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import java.time.LocalDateTime;
/**
* BaseEntityNoDelete.
*
* @author Matrix <xhyrzldf@gmail.com>
* @since 2020/10/26 at 5:05 下午
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public class BaseEntityNoDelete {
/**
* 主键id
*/
@Id
@GeneratedValue
private Integer id;
/**
* 创建用户id
*/
@CreatedBy
private Integer createUserId;
/**
* 更新用户id
*/
@LastModifiedBy
private Integer updateUserId;
/**
* 创建时间
*/
@CreatedDate
private LocalDateTime createTime;
/**
* 更新时间
*/
@LastModifiedDate
private LocalDateTime updateTime;
}
......@@ -10,7 +10,7 @@ import com.tykj.dev.device.allot.subject.domin.AllotBill;
import com.tykj.dev.device.apply.service.DeviceApplyBillService;
import com.tykj.dev.device.confirmcheck.repository.DeviceCheckBillDao;
import com.tykj.dev.device.confirmcheck.repository.DeviceCheckDetailDao;
import com.tykj.dev.device.confirmcheck.repository.DeviceCheckStatRepo;
import com.tykj.dev.device.confirmcheck.repository.DeviceCheckStatDao;
import com.tykj.dev.device.destroy.entity.domain.DeviceDestroyBill;
import com.tykj.dev.device.destroy.service.DeviceDestroyBillService;
import com.tykj.dev.device.library.subject.vo.FileVo;
......@@ -328,9 +328,9 @@ public class LogAspect {
}
break;
case 7:
DeviceCheckStatRepo deviceCheckStatRepo = SpringUtils.getBean("deviceCheckStatRepo");
if (deviceCheckStatRepo != null) {
getFieldsParam(deviceCheckStatRepo.getOne(outPutTask.getBillId()));
DeviceCheckStatDao deviceCheckStatDao = SpringUtils.getBean("deviceCheckStatRepo");
if (deviceCheckStatDao != null) {
getFieldsParam(deviceCheckStatDao.getOne(outPutTask.getBillId()));
}
break;
case 8:
......
......@@ -10,7 +10,7 @@ import com.tykj.dev.device.confirmcheck.entity.vo.CheckDetailVo;
import com.tykj.dev.device.confirmcheck.entity.vo.CheckStatVo;
import com.tykj.dev.device.confirmcheck.entity.vo.DevLibVo;
import com.tykj.dev.device.confirmcheck.repository.DeviceCheckDetailDao;
import com.tykj.dev.device.confirmcheck.repository.DeviceCheckStatRepo;
import com.tykj.dev.device.confirmcheck.repository.DeviceCheckStatDao;
import com.tykj.dev.device.confirmcheck.utils.ObjTransUtil;
import com.tykj.dev.device.library.repository.DeviceLibraryDao;
import com.tykj.dev.device.task.repository.TaskDao;
......@@ -64,7 +64,7 @@ class DeviceCheckControllerTest extends BaseTest {
@Autowired
private DeviceCheckDetailDao detailRepo;
@Autowired
private DeviceCheckStatRepo statRepo;
private DeviceCheckStatDao statRepo;
@Autowired
private DeviceLibraryDao deviceRepo;
@Autowired
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论