diff --git a/WEB-INF/prop/jcsecond.properties b/WEB-INF/prop/jcsecond.properties new file mode 100644 index 0000000..2249176 --- /dev/null +++ b/WEB-INF/prop/jcsecond.properties @@ -0,0 +1,14 @@ + +#\u4E1C\u65B9\u9A8F\u9A70\u82B1\u540D\u518C\u5FEB\u7167\u81EA\u5B9A\u4E49\u5B57\u6BB5 + +#\u94F6\u884C\u5361\u53F7 +account=field3 +#\u94F6\u884C\u540D\u79F0 +bankField=field26 +#\u6237\u7C4D\u5730\u5740 +regresidentplace=field6 +#\u9996\u6B21\u53C2\u4FDD\u65E5\u671F +femdate=field27 + +#\u5EFA\u6A21\u5FEB\u7167\u6570\u636E\u6A21\u5757id +modeId=77 \ No newline at end of file diff --git a/src/com/engine/kqsolution/entity/HistoryResourcePO.java b/src/com/engine/kqsolution/entity/HistoryResourcePO.java new file mode 100644 index 0000000..abfa8b4 --- /dev/null +++ b/src/com/engine/kqsolution/entity/HistoryResourcePO.java @@ -0,0 +1,68 @@ +package com.engine.kqsolution.entity; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author liang.cheng + * @Date 2024/8/28 10:05 AM + * @Description: 花名册快照 + * @Version 1.0 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class HistoryResourcePO { + + private Integer resourceId; + + private String workcode; + + private String lastName; + + private String birthday; + + private String sex; + + private String subCompany; + + private String department; + + private String managerId; + + private String companyStartDate; + + private String createDate; + + private String accumfundAccount; + + private String accountId; + + private String bankName; + + private String firstEnrollmentDate; + + private String startdate; + + private String endDate; + + private String jobTitle; + + private String status; + + private String educationlevel; + + private String mobile; + + private String certificatenum; + + private String nativeplace; + + private String regresidentplace; + + + +} diff --git a/src/com/engine/kqsolution/util/ResourceSnipUtils.java b/src/com/engine/kqsolution/util/ResourceSnipUtils.java new file mode 100644 index 0000000..ea22057 --- /dev/null +++ b/src/com/engine/kqsolution/util/ResourceSnipUtils.java @@ -0,0 +1,122 @@ +package com.engine.kqsolution.util; + +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.job.EducationLevelComInfo; +import weaver.hrm.job.JobTitlesComInfo; +import weaver.hrm.resource.ResourceComInfo; + +/** + * @Author liang.cheng + * @Date 2024/8/28 2:35 PM + * @Description: 人员数据类型转换工具 + * @Version 1.0 + */ +public class ResourceSnipUtils { + + + /** + * 分部 + * @param subcompanyid + * @return + */ + public static String selectSubCompanyName(String subcompanyid) { + SubCompanyComInfo sub = new SubCompanyComInfo(); + return sub.getSubCompanyname(subcompanyid); + } + + /** + * 部门 + * @param departmentId + * @return + */ + public static String selectDeptName(String departmentId) { + DepartmentComInfo dept = new DepartmentComInfo(); + try { + return dept.getDepartmentName(departmentId); + } catch (Exception e) { + return ""; + } + } + + /** + * 岗位 + * @param jobId + * @return + */ + public static String selectJobName(String jobId) { + JobTitlesComInfo jc = new JobTitlesComInfo(); + return jc.getJobTitlesname(jobId); + } + + /** + * 人员 + * @param resourceId + * @return + */ + public static String selectResourceName(String resourceId) { + try { + ResourceComInfo rc = new ResourceComInfo(); + return rc.getLastname(resourceId); + } catch (Exception e) { + return ""; + } + } + + + /** + * 工资银行 + * @param fieldId + * @param value + * @return + */ + public static String selectBankName(String fieldId,Integer value){ + RecordSet rs = new RecordSet(); + String id = fieldId.substring(Math.min(5, fieldId.length())); + rs.executeQuery("select selectname from cus_selectitem where fieldid = ? and selectvalue = ?",id,value); + rs.next(); + return Util.null2String(rs.getString("selectname")); + } + + + /** + * 状态 + * @param status + * @return + */ + public static String selectStatusName(Integer status) { + switch (status) { + case 0: + return "试用"; + case 1: + return "正式"; + case 2: + return "临时"; + case 3: + return "试用延期"; + case 4: + return "解聘"; + case 5: + return "离职"; + case 6: + return "退休"; + case 7: + return "无效"; + default : + return ""; + } + } + + /** + * 学历 + * @param educLevel + * @return + */ + public static String selectEducName(String educLevel){ + EducationLevelComInfo educ = new EducationLevelComInfo(); + return educ.getEducationLevelname(educLevel); + } + +} diff --git a/src/weaver/interfaces/kqsolution/crob/ResourceSnipCrob.java b/src/weaver/interfaces/kqsolution/crob/ResourceSnipCrob.java new file mode 100644 index 0000000..9331013 --- /dev/null +++ b/src/weaver/interfaces/kqsolution/crob/ResourceSnipCrob.java @@ -0,0 +1,116 @@ +package weaver.interfaces.kqsolution.crob; + +import com.engine.kqsolution.entity.HistoryResourcePO; +import com.engine.kqsolution.util.ResourceSnipUtils; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.interfaces.schedule.BaseCronJob; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Author liang.cheng + * @Date 2024/8/28 9:12 AM + * @Description: 花名册快照定时任务 + * @Version 1.0 + */ +public class ResourceSnipCrob extends BaseCronJob { + + + @Override + public void execute() { + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + String account = bb.getPropValue("jcsecond", "account"); + String bankField = bb.getPropValue("jcsecond", "bankField"); + String regresidentplace = bb.getPropValue("jcsecond", "regresidentplace"); + String femdate = bb.getPropValue("jcsecond", "femdate"); + + //1.获取数据 + List snipList = new ArrayList<>(); + rs.executeQuery("select a.id,a.workcode,a.lastname,a.birthday,a.sex,a.subcompanyid1,a.departmentid,a.managerid,a.companystartdate,\n" + + "a.createdate,a.accumfundaccount,b.field3 as account,b.field26 as bankname,c.field27 as femdate,\n" + + "a.startdate,a.enddate,a.jobtitle,a.status,a.educationlevel,a.mobile,a.certificatenum,\n" + + "a.nativeplace,b.field6 as regresidentplace from hrmresource a\n" + + "left join cus_fielddata b on a.id = b.id and b.scopeid = 1\n" + + "left join cus_fielddata c on a.id = c.id and c.scopeid = -1"); + + while (rs.next()) { + HistoryResourcePO build = HistoryResourcePO.builder() + .resourceId(Util.getIntValue(rs.getString("id"))) + .workcode(Util.null2String(rs.getString("workcode"))) + .lastName(Util.null2String(rs.getString("lastname"))) + .birthday(Util.null2String(rs.getString("birthday"))) + .sex("0".equals(Util.null2String(rs.getString("sex"))) ? "男" : "女") + .subCompany(ResourceSnipUtils.selectSubCompanyName(Util.null2String(rs.getString("subcompanyid1")))) + .department(ResourceSnipUtils.selectDeptName(Util.null2String(rs.getString("departmentid")))) + .managerId(ResourceSnipUtils.selectResourceName(Util.null2String(rs.getString("managerid")))) + .companyStartDate(Util.null2String(rs.getString("companystartdate"))) + .createDate(Util.null2String(rs.getString("createdate"))) + .accumfundAccount(Util.null2String(rs.getString("accumfundaccount"))) + .accountId(Util.null2String(rs.getString("account"))) + .bankName(ResourceSnipUtils.selectBankName(bankField,Util.getIntValue(rs.getString("bankname")))) + .firstEnrollmentDate(Util.null2String(rs.getString("femdate"))) + .startdate(Util.null2String(rs.getString("startdate"))) + .endDate(Util.null2String(rs.getString("enddate"))) + .jobTitle(ResourceSnipUtils.selectJobName(Util.null2String(rs.getString("jobtitle")))) + .status(ResourceSnipUtils.selectStatusName(Util.getIntValue(rs.getString("status")))) + .educationlevel(ResourceSnipUtils.selectEducName(Util.null2String(rs.getString("educationlevel")))) + .mobile(Util.null2String(rs.getString("mobile"))) + .certificatenum(Util.null2String(rs.getString("certificatenum"))) + .nativeplace(Util.null2String(rs.getString("nativeplace"))) + .regresidentplace(Util.null2String(rs.getString("regresidentplace"))) + .build(); + snipList.add(build); + } + + //获取当前月格式2024-08 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM"); + String currentMonth = LocalDate.now().format(formatter); + String modeId = bb.getPropValue("jcsecond", "modeId"); + String currentDate = TimeUtil.getCurrentDateString(); + String onlyCurrentTime = TimeUtil.getOnlyCurrentTimeString(); + + //2.存储快照 + //区分是否数据存在,List存在部分更新,未存在数据新增 + List hList = new ArrayList<>(); + rs.executeQuery("select ryid from uf_hmckz where cdrq = ?",currentMonth); + while (rs.next()) { + hList.add(Util.getIntValue(rs.getString("ryid"))); + } + + //已存在数据 + List uList = snipList.stream() + .filter(item -> hList.contains(item.getResourceId())) + .collect(Collectors.toList()); + //未存在数据 + List iList = snipList.stream() + .filter(item -> !hList.contains(item.getResourceId())) + .collect(Collectors.toList()); + + for (HistoryResourcePO i : uList) { + rs.executeUpdate("update uf_hmckz set gh = ?,xm = ?,csrq = ?,xb = ?,fb = ?,bm = ?,zjsj = ?,rzrq = ?,cjrq = ?,gjjzh = ?," + + " gzzh = ?,gzyx = ?, sccbsj = ?,htksrq = ?,htjsrq = ?,gw = ?,zt = ?,xl = ?,dh = ?,sfzh = ?,jg = ?," + + " hkszd = ? where id = ? and cdrq = ?",i.getWorkcode(),i.getLastName(),i.getBirthday(), + i.getSex(),i.getSubCompany(),i.getDepartment(), i.getManagerId(),i.getCompanyStartDate(),i.getCreateDate(),i.getAccumfundAccount(), + i.getAccountId(),i.getBankName(),i.getFirstEnrollmentDate(),i.getStartdate(),i.getEndDate(),i.getJobTitle(),i.getStatus(),i.getEducationlevel(), + i.getMobile(),i.getCertificatenum(),i.getNativeplace(),i.getRegresidentplace(),i.getResourceId(),currentMonth); + } + + for (HistoryResourcePO i : iList) { + rs.executeUpdate("insert into uf_hmckz(ryid,gh,xm,csrq,xb,fb,bm,zjsj,rzrq,cjrq,gjjzh,gzzh,gzyx,sccbsj,htksrq,htjsrq,gw,zt,xl,dh,sfzh,jg,hkszd,cdrq,formmodeid,modedatacreatedate,modedatacreatetime) " + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",i.getResourceId(),i.getWorkcode(),i.getLastName(),i.getBirthday(), + i.getSex(),i.getSubCompany(),i.getDepartment(), i.getManagerId(),i.getCompanyStartDate(),i.getCreateDate(),i.getAccumfundAccount(), + i.getAccountId(),i.getBankName(),i.getFirstEnrollmentDate(),i.getStartdate(),i.getEndDate(),i.getJobTitle(),i.getStatus(),i.getEducationlevel(), + i.getMobile(),i.getCertificatenum(),i.getNativeplace(),i.getRegresidentplace(),currentMonth,modeId,currentDate,onlyCurrentTime); + } + + } +} diff --git a/src/weaver/interfaces/kqsolution/crob/SignDataSummaryCrob.java b/src/weaver/interfaces/kqsolution/crob/SignDataSummaryCrob.java index aa8bebb..d72da9b 100644 --- a/src/weaver/interfaces/kqsolution/crob/SignDataSummaryCrob.java +++ b/src/weaver/interfaces/kqsolution/crob/SignDataSummaryCrob.java @@ -49,6 +49,8 @@ public class SignDataSummaryCrob extends BaseCronJob { SignDataSummaryServiceImpl summaryService = new SignDataSummaryServiceImpl(); BaseBean bb = new BaseBean(); + bb.writeLog("同步考勤数据原始参数:"+attendanceDate); + if (Objects.isNull(attendanceDate)) { attendanceDate = DateUtil.getYesterday();