组织架构图增加定时任务存储和删除功能
parent
58b57c81b7
commit
64ab363237
@ -0,0 +1,70 @@
|
|||||||
|
package weaver.interfaces.organization.cronjob;
|
||||||
|
|
||||||
|
import com.engine.organization.service.impl.ChartServiceImpl;
|
||||||
|
import com.engine.organization.util.OrganizationAssert;
|
||||||
|
import com.engine.organization.util.OrganizationDateUtil;
|
||||||
|
import weaver.conn.RecordSet;
|
||||||
|
import weaver.general.Util;
|
||||||
|
import weaver.interfaces.schedule.BaseCronJob;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author liang.cheng
|
||||||
|
* @Date 2024/8/1 3:12 PM
|
||||||
|
* @Description: 组织架构版本定时删除
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
public class OrgVersionDeleteCron extends BaseCronJob {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
|
||||||
|
RecordSet rs = new RecordSet();
|
||||||
|
|
||||||
|
List<Integer> idList = new ArrayList<>();
|
||||||
|
String createTime = "";
|
||||||
|
rs.executeQuery("select id,createtime from jcl_org_chartversion order by createtime asc");
|
||||||
|
if (rs.next()){
|
||||||
|
idList.add(Util.getIntValue(rs.getString("id")));
|
||||||
|
createTime = Util.null2String(rs.getString("createtime"));
|
||||||
|
}
|
||||||
|
|
||||||
|
OrganizationAssert.notEmpty(idList,"未查询到组织架构图历史版本");
|
||||||
|
|
||||||
|
//1.type=1 删除最早版本记录日期
|
||||||
|
//2.type=2 删除最早版本日期--往后一个月的数据
|
||||||
|
if("2".equals(type)){
|
||||||
|
String lastMonthDate = OrganizationDateUtil.getLastMonthDate(createTime);
|
||||||
|
rs.executeQuery("select id from jcl_org_chartversion where createtime >= ? and createtime <= ?",createTime,lastMonthDate);
|
||||||
|
while (rs.next()) {
|
||||||
|
idList.add(Util.getIntValue(rs.getString("id")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//3.type=3 删除最早版本日期--往后一年的数据
|
||||||
|
if("3".equals(type)){
|
||||||
|
String lastYearDate = OrganizationDateUtil.getLastYearDate(createTime);
|
||||||
|
rs.executeQuery("select id from jcl_org_chartversion where createtime >= ? and createtime <= ?",createTime,lastYearDate);
|
||||||
|
while (rs.next()) {
|
||||||
|
idList.add(Util.getIntValue(rs.getString("id")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//删除数据
|
||||||
|
ChartServiceImpl chartService = new ChartServiceImpl();
|
||||||
|
idList.forEach(chartService::versionDelete);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package weaver.interfaces.organization.cronjob;
|
||||||
|
|
||||||
|
import com.engine.organization.service.impl.ChartServiceImpl;
|
||||||
|
import com.engine.organization.util.OrganizationDateUtil;
|
||||||
|
import weaver.hrm.User;
|
||||||
|
import weaver.interfaces.schedule.BaseCronJob;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author liang.cheng
|
||||||
|
* @Date 2024/8/2 9:39 AM
|
||||||
|
* @Description: 组织架构图定时版本保存
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
public class OrgVersionRecordCron extends BaseCronJob {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
|
||||||
|
ChartServiceImpl chartService = new ChartServiceImpl();
|
||||||
|
User user = new User();
|
||||||
|
user.setUid(1);
|
||||||
|
|
||||||
|
// 获取当前日期
|
||||||
|
LocalDate today = LocalDate.now();
|
||||||
|
String example = OrganizationDateUtil.dateExample(today);
|
||||||
|
String description = "版本自动记录"+example;
|
||||||
|
|
||||||
|
Map<String, Object> params = new HashMap<String, Object>(){
|
||||||
|
{
|
||||||
|
put("description",description);
|
||||||
|
}};
|
||||||
|
|
||||||
|
chartService.versionRecord(params,user);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue