From 43f00f7d9d19a0c2313f653a72cea9930a86bdbd Mon Sep 17 00:00:00 2001 From: Mlin Date: Wed, 14 Dec 2022 14:32:19 +0800 Subject: [PATCH] =?UTF-8?q?sqlserver=E5=AD=98=E5=85=A5=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E3=80=81=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 --- .../mapper/jclorgmap/JclOrgMapper.java | 3 + .../mapper/jclorgmap/JclOrgMapper.xml | 4 + .../mapper/version/CompanyVersionMapper.xml | 181 +++++++++++++++--- .../impl/VersionManageServiceImpl.java | 24 ++- .../organization/cronJob/JobAndPlanCron.java | 96 ++++++++++ 5 files changed, 279 insertions(+), 29 deletions(-) create mode 100644 src/weaver/interfaces/organization/cronJob/JobAndPlanCron.java diff --git a/src/com/engine/organization/mapper/jclorgmap/JclOrgMapper.java b/src/com/engine/organization/mapper/jclorgmap/JclOrgMapper.java index 8ed57b8e..12f95af8 100644 --- a/src/com/engine/organization/mapper/jclorgmap/JclOrgMapper.java +++ b/src/com/engine/organization/mapper/jclorgmap/JclOrgMapper.java @@ -4,6 +4,7 @@ import com.engine.organization.entity.map.JclOrgMap; import org.apache.ibatis.annotations.Param; import java.sql.Date; +import java.util.List; /** * @author:dxfeng @@ -26,4 +27,6 @@ public interface JclOrgMapper { JclOrgMap getSumPlanAndJobByFParentId(@Param("currentDate") Date currentDate, @Param("fparentid") String fparentid); int updateMapById(@Param("id") Integer id,@Param("fplan") Integer fplan,@Param("fonjob") Integer fonjob,@Param("currentDate") Date currentDate); + + List getJclOrgMapByType(@Param("fType") String fType, @Param("currentDate") Date currentDate); } diff --git a/src/com/engine/organization/mapper/jclorgmap/JclOrgMapper.xml b/src/com/engine/organization/mapper/jclorgmap/JclOrgMapper.xml index e72f55a3..3a9cd68e 100644 --- a/src/com/engine/organization/mapper/jclorgmap/JclOrgMapper.xml +++ b/src/com/engine/organization/mapper/jclorgmap/JclOrgMapper.xml @@ -66,4 +66,8 @@ AND FDATEBEGIN <= #{currentDate} AND FDATEEND >= #{currentDate} + + \ No newline at end of file diff --git a/src/com/engine/organization/mapper/version/CompanyVersionMapper.xml b/src/com/engine/organization/mapper/version/CompanyVersionMapper.xml index 2e39e4a8..c1e0e6e5 100644 --- a/src/com/engine/organization/mapper/version/CompanyVersionMapper.xml +++ b/src/com/engine/organization/mapper/version/CompanyVersionMapper.xml @@ -74,28 +74,163 @@ - - insert into hrmresource_version - (resourceid, companystartdate, companyworkyear, workstartdate, workyear, usekind, jobcall, - accumfundaccount, birthplace, folk, residentphone, residentpostcode, extphone, managerstr, - status, fax, islabouunion, weight, tempresidentnumber, probationenddate, countryid, passwdchgdate, - lloginid, dsporder, passwordstate, accounttype, belongto, messagerurl, accountname, - loginid, password, lastname, sex, birthday, nationality, maritalstatus, telephone, mobile, - mobilecall, email, locationid, workroom, homeaddress, resourcetype, startdate, enddate, jobtitle, - jobactivitydesc, joblevel, seclevel, departmentid, subcompanyid1, costcenterid, managerid, assistantid, - bankid1, accountid1, resourceimageid, certificatenum, nativeplace, educationlevel, bememberdate, - bepartydate, workcode, regresidentplace, healthinfo, residentplace, policy, degree, height, - classification, description, operator, version, operate_time) - values (#{resourceid}, #{companystartdate}, #{companyworkyear}, #{workstartdate}, #{workyear}, #{usekind}, #{jobcall}, - #{accumfundaccount}, #{birthplace}, #{folk}, #{residentphone}, #{residentpostcode}, #{extphone}, #{managerstr}, - #{status}, #{fax}, #{islabouunion}, #{weight}, #{tempresidentnumber}, #{probationenddate}, #{countryid}, #{passwdchgdate}, - #{lloginid}, #{dsporder}, #{passwordstate}, #{accounttype}, #{belongto}, #{messagerurl}, #{accountname}, - #{loginid}, #{password}, #{lastname}, #{sex}, #{birthday}, #{nationality}, #{maritalstatus}, #{telephone}, #{mobile}, - #{mobilecall}, #{email}, #{locationid}, #{workroom}, #{homeaddress}, #{resourcetype}, #{startdate}, #{enddate}, #{jobtitle}, - #{jobactivitydesc}, #{joblevel}, #{seclevel}, #{departmentid}, #{subcompanyid1}, #{costcenterid}, #{managerid}, #{assistantid}, - #{bankid1}, #{accountid1}, #{resourceimageid}, #{certificatenum}, #{nativeplace}, #{educationlevel}, #{bememberdate}, - #{bepartydate}, #{workcode}, #{regresidentplace}, #{healthinfo}, #{residentplace}, #{policy}, #{degree}, #{height}, - #{classification}, #{description}, #{operator}, #{version}, #{operateTime}) + + insert into hrmresource_version + + id, + resourceid, + companystartdate, + companyworkyear, + workstartdate, + workyear, + usekind, + jobcall, + accumfundaccount, + birthplace, + folk, + residentphone, + residentpostcode, + extphone, + managerstr, + status, + fax, + islabouunion, + weight, + tempresidentnumber, + probationenddate, + countryid, + passwdchgdate, + lloginid, + dsporder, + passwordstate, + accounttype, + belongto, + messagerurl, + accountname, + loginid, + password, + lastname, + sex, + birthday, + nationality, + maritalstatus, + telephone, + mobile, + mobilecall, + email, + locationid, + workroom, + homeaddress, + resourcetype, + startdate, + enddate, + jobtitle, + jobactivitydesc, + joblevel, + seclevel, + departmentid, + subcompanyid1, + costcenterid, + managerid, + assistantid, + bankid1, + accountid1, + resourceimageid, + certificatenum, + nativeplace, + educationlevel, + bememberdate, + bepartydate, + workcode, + regresidentplace, + healthinfo, + residentplace, + policy, + degree, + height, + classification, + description, + operator, + version, + operate_time, + + + #{id,jdbcType=INTEGER}, + #{resourceid,jdbcType=INTEGER}, + #{companystartdate,jdbcType=TIMESTAMP}, + #{companyworkyear,jdbcType=INTEGER}, + #{workstartdate,jdbcType=TIMESTAMP}, + #{workyear,jdbcType=INTEGER}, + #{usekind,jdbcType=INTEGER}, + #{jobcall,jdbcType=INTEGER}, + #{accumfundaccount,jdbcType=VARCHAR}, + #{birthplace,jdbcType=VARCHAR}, + #{folk,jdbcType=VARCHAR}, + #{residentphone,jdbcType=VARCHAR}, + #{residentpostcode,jdbcType=VARCHAR}, + #{extphone,jdbcType=VARCHAR}, + #{managerstr,jdbcType=VARCHAR}, + #{status,jdbcType=INTEGER}, + #{fax,jdbcType=VARCHAR}, + #{islabouunion,jdbcType=CHAR}, + #{weight,jdbcType=INTEGER}, + #{tempresidentnumber,jdbcType=VARCHAR}, + #{probationenddate,jdbcType=TIMESTAMP}, + #{countryid,jdbcType=INTEGER}, + #{passwdchgdate,jdbcType=TIMESTAMP}, + #{lloginid,jdbcType=VARCHAR}, + #{dsporder,jdbcType=INTEGER}, + #{passwordstate,jdbcType=INTEGER}, + #{accounttype,jdbcType=INTEGER}, + #{belongto,jdbcType=INTEGER}, + #{messagerurl,jdbcType=VARCHAR}, + #{accountname,jdbcType=VARCHAR}, + #{loginid,jdbcType=VARCHAR}, + #{password,jdbcType=VARCHAR}, + #{lastname,jdbcType=VARCHAR}, + #{sex,jdbcType=CHAR}, + #{birthday,jdbcType=CHAR}, + #{nationality,jdbcType=INTEGER}, + #{maritalstatus,jdbcType=CHAR}, + #{telephone,jdbcType=VARCHAR}, + #{mobile,jdbcType=VARCHAR}, + #{mobilecall,jdbcType=VARCHAR}, + #{email,jdbcType=VARCHAR}, + #{locationid,jdbcType=INTEGER}, + #{workroom,jdbcType=VARCHAR}, + #{homeaddress,jdbcType=VARCHAR}, + #{resourcetype,jdbcType=CHAR}, + #{startdate,jdbcType=TIMESTAMP}, + #{enddate,jdbcType=TIMESTAMP}, + #{jobtitle,jdbcType=INTEGER}, + #{jobactivitydesc,jdbcType=VARCHAR}, + #{joblevel,jdbcType=INTEGER}, + #{seclevel,jdbcType=INTEGER}, + #{departmentid,jdbcType=INTEGER}, + #{subcompanyid1,jdbcType=INTEGER}, + #{costcenterid,jdbcType=INTEGER}, + #{managerid,jdbcType=INTEGER}, + #{assistantid,jdbcType=INTEGER}, + #{bankid1,jdbcType=INTEGER}, + #{accountid1,jdbcType=VARCHAR}, + #{resourceimageid,jdbcType=INTEGER}, + #{certificatenum,jdbcType=VARCHAR}, + #{nativeplace,jdbcType=VARCHAR}, + #{educationlevel,jdbcType=INTEGER}, + #{bememberdate,jdbcType=TIMESTAMP}, + #{bepartydate,jdbcType=TIMESTAMP}, + #{workcode,jdbcType=VARCHAR}, + #{regresidentplace,jdbcType=VARCHAR}, + #{healthinfo,jdbcType=CHAR}, + #{residentplace,jdbcType=VARCHAR}, + #{policy,jdbcType=VARCHAR}, + #{degree,jdbcType=VARCHAR}, + #{height,jdbcType=VARCHAR}, + #{classification,jdbcType=CHAR}, + #{description,jdbcType=VARCHAR}, + #{operator,jdbcType=VARCHAR}, + #{version,jdbcType=FLOAT}, + #{operateTime,jdbcType=TIMESTAMP}, + - \ No newline at end of file diff --git a/src/com/engine/organization/service/impl/VersionManageServiceImpl.java b/src/com/engine/organization/service/impl/VersionManageServiceImpl.java index c87d1ac5..8db856f9 100644 --- a/src/com/engine/organization/service/impl/VersionManageServiceImpl.java +++ b/src/com/engine/organization/service/impl/VersionManageServiceImpl.java @@ -50,7 +50,7 @@ public class VersionManageServiceImpl extends Service implements VersionManageSe saveSubComToVersion(params,user); break; case 2: - saveComToVersion(params, user); + saveDeptToVersion(params, user); saveDeptToMap(params); break; case 4: @@ -82,6 +82,7 @@ public class VersionManageServiceImpl extends Service implements VersionManageSe jclOrgMap.setFClass(0); jclOrgMap.setFClassName("行政维度"); jclOrgMap.setFName((String) params.get("subCompanyName")); + String supSubComId = (String) params.get("supSubComId"); jclOrgMap.setFParentId(Integer.parseInt((String) params.get("supSubComId"))); jclOrgMap.setFIsVitual(0); jclOrgMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); @@ -131,7 +132,14 @@ public class VersionManageServiceImpl extends Service implements VersionManageSe jclOrgMap.setFLeaderJobId(Math.toIntExact(hrmResourcePO.getJobTitle())); } jclOrgMap.setFName((String) params.get("departmentName")); - jclOrgMap.setFParentId(st+Integer.parseInt((String) params.get("subCompanyId1"))); + String subCompanyId1 = (String) params.get("subCompanyId1"); + String supdepid = (String) params.get("supDepId"); + if (supdepid!=null){ + jclOrgMap.setFParentId(st + Integer.parseInt(supdepid)); + } + if ("0".equals(supdepid)){ + jclOrgMap.setFParentId(Integer.parseInt(subCompanyId1)); + } jclOrgMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); jclOrgMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2022-12-31").getTime())); jclOrgMap.setFIsVitual(0); @@ -235,7 +243,7 @@ public class VersionManageServiceImpl extends Service implements VersionManageSe /** * 部门保存至版本 */ - void saveComToVersion(Map params,User user) { + void saveDeptToVersion(Map params,User user) { String id = (String) params.get("id"); String currentDate = OrganizationDateUtil.getFormatLocalDateTime(new java.util.Date()); @@ -245,9 +253,12 @@ public class VersionManageServiceImpl extends Service implements VersionManageSe hrmDepartmentVersion.setDepartmentCode((String) params.get("departmentCode")); hrmDepartmentVersion.setDepartmentName((String) params.get("departmentName")); hrmDepartmentVersion.setSubCompanyId1(Integer.parseInt((String) params.get("subCompanyId1"))); - hrmDepartmentVersion.setSupDepId(Integer.parseInt((String) params.get("supDepId"))); + String supDepId = (String) params.get("supDepId"); + if (supDepId!=null){ + hrmDepartmentVersion.setSupDepId(Integer.parseInt(supDepId)); + } String bmfzr = (String) params.get("bmfzr"); - if (!"".equals(bmfzr)){ + if (!"".equals(bmfzr) && bmfzr!=null){ hrmDepartmentVersion.setBmfzr(Integer.parseInt(bmfzr)); } String showOrder = (String) params.get("showOrder"); @@ -280,7 +291,8 @@ public class VersionManageServiceImpl extends Service implements VersionManageSe hrmResourceVersion.setJobtitle(Integer.parseInt((String) params.get("jobtitle"))); hrmResourceVersion.setMobile((String) params.get("mobile")); hrmResourceVersion.setTelephone((String) params.get("telephone")); - hrmResourceVersion.setManagerid(Integer.parseInt((String) params.get("managerid"))); + String managerid = (String) params.get("managerid"); + hrmResourceVersion.setManagerid(StringUtils.isNotBlank(managerid) ? Integer.parseInt(managerid):null); hrmResourceVersion.setLastname((String) params.get("lastname")); hrmResourceVersion.setOperator(user.getLastname()); hrmResourceVersion.setVersion(genVersionId(4,id)); diff --git a/src/weaver/interfaces/organization/cronJob/JobAndPlanCron.java b/src/weaver/interfaces/organization/cronJob/JobAndPlanCron.java new file mode 100644 index 00000000..91a4fc2b --- /dev/null +++ b/src/weaver/interfaces/organization/cronJob/JobAndPlanCron.java @@ -0,0 +1,96 @@ +package weaver.interfaces.organization.cronJob; + +import com.engine.organization.entity.map.JclOrgMap; +import com.engine.organization.mapper.jclorgmap.JclOrgMapper; +import com.engine.organization.mapper.staff.StaffMapper; +import com.engine.organization.util.OrganizationDateUtil; +import com.engine.organization.util.db.MapperProxyFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.interfaces.schedule.BaseCronJob; + +import java.sql.Date; +import java.util.List; + +/** + * 定时任务刷新在岗数、编制数 + */ +public class JobAndPlanCron extends BaseCronJob { + + private static final Logger LOGGER = LoggerFactory.getLogger("chartDataLog"); + + char separator = Util.getSeparator(); + + private JclOrgMapper getJclOrgMapMapper(){ + return MapperProxyFactory.getProxy(JclOrgMapper.class); + } + + private StaffMapper getStaffMapper() { + return MapperProxyFactory.getProxy(StaffMapper.class); + } + @Override + public void execute() { + // 计划任务需要处理的逻辑 + RecordSet recordSet = new RecordSet(); + String fType = "3"; + String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date()); + List jclOrgMaps = getJclOrgMapMapper().getJclOrgMapByType(fType,new java.sql.Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); + + for (JclOrgMap jclOrgMap : jclOrgMaps){ + String id = String.valueOf(jclOrgMap.getId()); + + } + + } + + /** + * 刷新在岗数 + */ + void countJobs(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 = getJclOrgMapMapper().getSumPlanAndJobByFParentId(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime()), fparentid); + getJclOrgMapMapper().updateMapById(Integer.parseInt(fparentid), jclOrgMap.getFPlan(), jclOrgMap.getFOnJob(), new Date(OrganizationDateUtil.stringToDate(currentDate).getTime())); + + if (fparentid.equals("-1")) { + countJobs(ftype, Integer.parseInt(fparentid), 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 + + } + +}