From 94690cbd862a67cae8a068a9034f73b703d491ef Mon Sep 17 00:00:00 2001 From: Mlin Date: Wed, 14 Dec 2022 17:42:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{cronJob => cronjob}/JobAndPlanCron.java | 68 ++++++++++--------- 1 file changed, 36 insertions(+), 32 deletions(-) rename src/weaver/interfaces/organization/{cronJob => cronjob}/JobAndPlanCron.java (56%) diff --git a/src/weaver/interfaces/organization/cronJob/JobAndPlanCron.java b/src/weaver/interfaces/organization/cronjob/JobAndPlanCron.java similarity index 56% rename from src/weaver/interfaces/organization/cronJob/JobAndPlanCron.java rename to src/weaver/interfaces/organization/cronjob/JobAndPlanCron.java index 91a4fc2b..1dcc33e0 100644 --- a/src/weaver/interfaces/organization/cronJob/JobAndPlanCron.java +++ b/src/weaver/interfaces/organization/cronjob/JobAndPlanCron.java @@ -1,6 +1,7 @@ -package weaver.interfaces.organization.cronJob; +package weaver.interfaces.organization.cronjob; import com.engine.organization.entity.map.JclOrgMap; +import com.engine.organization.entity.staff.po.StaffPO; import com.engine.organization.mapper.jclorgmap.JclOrgMapper; import com.engine.organization.mapper.staff.StaffMapper; import com.engine.organization.util.OrganizationDateUtil; @@ -12,7 +13,9 @@ import weaver.general.Util; import weaver.interfaces.schedule.BaseCronJob; import java.sql.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * 定时任务刷新在岗数、编制数 @@ -39,21 +42,43 @@ public class JobAndPlanCron extends BaseCronJob { List jclOrgMaps = getJclOrgMapMapper().getJclOrgMapByType(fType,new java.sql.Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); for (JclOrgMap jclOrgMap : jclOrgMaps){ - String id = String.valueOf(jclOrgMap.getId()); - + int id = jclOrgMap.getId(); + countJobAndPlans(fType,id,currentDate); } - } /** - * 刷新在岗数 + * 刷新在岗、编制数 */ - void countJobs(String type,int id,String currentDate) { - //找上级 + void countJobAndPlans(String type,int id,String currentDate) { + Date date = new Date(OrganizationDateUtil.stringToDate(currentDate).getTime()); RecordSet rs = new RecordSet(); + StaffPO staffPO = null; + switch (type) { + case "1": + staffPO = getStaffMapper().getStaffsByParamId(Integer.parseInt(type), String.valueOf(id), null, null); + break; + case "2": + staffPO = getStaffMapper().getStaffsByParamId(Integer.parseInt(type), null, String.valueOf(id), null); + break; + case "3": + staffPO = getStaffMapper().getStaffsByParamId(Integer.parseInt(type), null, null, String.valueOf(id)); + rs.executeQuery("select count(1) as fonjob from jcl_org_map ftype=? and id=? and fdateend>?"); + if (rs.next()) { + getJclOrgMapMapper().updateMapById(id, null, Integer.valueOf(rs.getString("fonjob")), date); + } + break; + default: + break; + } + if (staffPO != null) { + // 处理自身 + getJclOrgMapMapper().updateMapById(id, staffPO.getStaffNum(), null, date); + } + //处理上级 String sql = "select fparentid from jcl_org_map where ftype=? and id=? and fdateend>?"; String typeSql = "select ftype from jcl_org_map where id=? and fdateend>?"; - rs.executeQuery(sql, type, currentDate); + rs.executeQuery(sql, type, id, currentDate); String fparentid = null; String ftype = null; if (rs.next()) { @@ -63,34 +88,13 @@ public class JobAndPlanCron extends BaseCronJob { ftype = rs.getString("ftype"); } } - JclOrgMap jclOrgMap = getJclOrgMapMapper().getSumPlanAndJobByFParentId(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime()), fparentid); - getJclOrgMapMapper().updateMapById(Integer.parseInt(fparentid), jclOrgMap.getFPlan(), jclOrgMap.getFOnJob(), new Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); + JclOrgMap jclOrgMap = getJclOrgMapMapper().getSumPlanAndJobByFParentId(date, fparentid); + getJclOrgMapMapper().updateMapById(Integer.parseInt(fparentid), jclOrgMap.getFPlan(), null, date); if (fparentid.equals("-1")) { - countJobs(ftype, Integer.parseInt(fparentid), currentDate); + countJobAndPlans(ftype, Integer.parseInt(fparentid), String.valueOf(currentDate)); } - } - /** - * 刷新编制数 - */ - void countPlans(String type,int id,String currentDate) { - //找上级 - RecordSet rs = new RecordSet(); - String sql = "select fparentid from jcl_org_map where ftype=? and id=? and fdateend>?"; - String typeSql = "select ftype from jcl_org_map where id=? and fdateend>?"; - rs.executeQuery(sql, type, currentDate); - String fparentid = null; - String ftype = null; - if (rs.next()) { - fparentid = rs.getString("fparentid"); - rs.executeQuery(typeSql, fparentid, currentDate); - if (rs.next()) { - ftype = rs.getString("ftype"); - } - } -// JclOrgMap jclOrgMap - } }