This commit is contained in:
dxfeng 2022-12-09 17:05:01 +08:00
commit 6169b007ae
8 changed files with 538 additions and 11 deletions

View File

@ -0,0 +1,24 @@
package com.engine.organization.entity.version;
import lombok.Data;
import java.util.Date;
@Data
public class HrmDepartmentVersion {
int id;
int departmentId;
String departmentMark;
String departmentCode;
String departmentName;
int subCompanyId1;
int supDepId;
int bmfzr;
int showOrder;
int canceled;
String description;
String operator;
Double version;
Date operateTime;
}

View File

@ -0,0 +1,162 @@
package com.engine.organization.entity.version;
import lombok.Data;
import java.util.Date;
@Data
public class HrmResourceVersion {
private Integer id;
private Integer resourceid;
private Date companystartdate;
private Integer companyworkyear;
private Date workstartdate;
private Integer workyear;
private Integer usekind;
private Integer jobcall;
private String accumfundaccount;
private String birthplace;
private String folk;
private String residentphone;
private String residentpostcode;
private String extphone;
private String managerstr;
private Integer status;
private String fax;
private String islabouunion;
private Integer weight;
private String tempresidentnumber;
private Date probationenddate;
private Integer countryid;
private Date passwdchgdate;
private String lloginid;
private Integer dsporder;
private Integer passwordstate;
private Integer accounttype;
private Integer belongto;
private String messagerurl;
private String accountname;
private String loginid;
private String password;
private String lastname;
private String sex;
private String birthday;
private Integer nationality;
private String maritalstatus;
private String telephone;
private String mobile;
private String mobilecall;
private String email;
private Integer locationid;
private String workroom;
private String homeaddress;
private String resourcetype;
private Date startdate;
private Date enddate;
private Integer jobtitle;
private String jobactivitydesc;
private Integer joblevel;
private Integer seclevel;
private Integer departmentid;
private Integer subcompanyid1;
private Integer costcenterid;
private Integer managerid;
private Integer assistantid;
private Integer bankid1;
private String accountid1;
private Integer resourceimageid;
private String certificatenum;
private String nativeplace;
private Integer educationlevel;
private Date bememberdate;
private Date bepartydate;
private String workcode;
private String regresidentplace;
private String healthinfo;
private String residentplace;
private String policy;
private String degree;
private String height;
private String classification;
private String description;
private String operator;
private Double version;
private Date operateTime;
}

View File

@ -0,0 +1,22 @@
package com.engine.organization.entity.version;
import lombok.Data;
import java.util.Date;
@Data
public class HrmSubCompanyVersion {
Integer id;
Integer subComId;
String subCompanyDesc;
String subCompanyCode;
String subCompanyName;
Integer supsSubComId;
Integer showOrder;
Integer canceled;
String description;
String operator;
Double version;
Date operateTime;
}

View File

@ -1,5 +1,10 @@
package com.engine.organization.mapper.version;
import com.engine.organization.entity.version.HrmDepartmentVersion;
import com.engine.organization.entity.version.HrmResourceVersion;
import com.engine.organization.entity.version.HrmSubCompanyVersion;
import org.apache.ibatis.annotations.Param;
/**
* @Author weaver_cl
* @Description:
@ -7,4 +12,37 @@ package com.engine.organization.mapper.version;
* @Version V1.0
**/
public interface CompanyVersionMapper {
/**
* 取分部版本最大记录
*/
HrmSubCompanyVersion getMaxVersion(@Param("subComId") String subComId);
/**
* 新增分部版本
*/
int insertHrmSubComVersion(HrmSubCompanyVersion hrmSubCompanyVersion);
/**
* 取部门版本最大记录
*/
HrmDepartmentVersion getMaxDeptVersion(@Param("departmentid") String departmentid);
/**
* 新增部门版本
*/
int insertHrmDeptVersion(HrmDepartmentVersion hrmDepartmentVersion);
/**
* 人员版本最大记录
*/
HrmResourceVersion getMaxHrmVersion(@Param("getMaxHrmVersion") String getMaxHrmVersion);
/**
* 新增人员版本
*/
int insertHrmResourceVersion(HrmResourceVersion hrmResourceVersion);
}

View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.engine.organization.mapper.version.CompanyVersionMapper">
<resultMap id="BaseResultMap" type="com.engine.organization.entity.version.HrmSubCompanyVersion">
<result column="id" property="id"/>
<result column="subcomid" property="subComId"/>
<result column="subcompanydesc" property="subCompanyDesc"/>
<result column="subcompanycode" property="subCompanyCode"/>
<result column="subcompanyname" property="subCompanyName"/>
<result column="supssubcomid" property="supsSubComId"/>
<result column="showorder" property="showOrder"/>
<result column="canceled" property="canceled"/>
<result column="description" property="description"/>
<result column="operator" property="operator"/>
<result column="version" property="version"/>
<result column="operate_time" property="operateTime"/>
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
t.id ,t.subcomid ,t.subcompanydesc ,t.subcompanycode ,t.subcompanyname ,t.supsubcomid ,
t.showorder ,t.canceled ,t.description ,t.operator ,t.version ,t.operate_time
</sql>
<select id="getMaxVersion" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="baseColumns"/>
from hrmsubcompany_version t where t.subcomid=#{subComId} order by t.version desc limit 1
</select>
<insert id="insertHrmSubComVersion">
insert into hrmsubcompany_version
(subcomid ,subcompanydesc ,subcompanycode ,subcompanyname ,supsubcomid ,
showorder ,canceled ,description ,operator ,version ,operate_time)
values (#{subComId}, #{subCompanyDesc}, #{subCompanyCode}, #{subCompanyName}, #{supsSubComId},
#{showOrder}, #{canceled}, #{description}, #{operator}, #{version}, #{operateTime})
</insert>
<select id="getMaxDeptVersion" resultType="com.engine.organization.entity.version.HrmDepartmentVersion">
select * from hrmdepartment_version where departmentid=#{departmentid} order by version desc limit 1
</select>
<insert id="insertHrmDeptVersion">
insert into hrmdepartment_version
(departmentid, departmentmark, departmentcode, departmentname, subcompanyid1, supdepid,
bmfzr, showorder, canceled, description, operator, version, operate_time)
VALUES (#{departmentId}, #{departmentMark}, #{departmentCode}, #{departmentName}, #{subCompanyId1}, #{supDepId},
#{bmfzr}, #{showOrder}, #{canceled}, #{description}, #{operator}, #{version}, #{operateTime})
</insert>
<select id="getMaxHrmVersion" resultType="com.engine.organization.entity.version.HrmResourceVersion">
select * from hrmresource_version where resourceid=#{resourceid} order by versiiom desc limit 1
</select>
<insert id="insertHrmResourceVersion">
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>
</mapper>

View File

@ -1,6 +1,7 @@
package com.engine.organization.service;
import com.engine.organization.enums.ModuleTypeEnum;
import weaver.hrm.User;
import java.util.Map;
@ -17,5 +18,5 @@ public interface VersionManageService {
* @param moduleTypeEnum
* @param params
*/
void save(ModuleTypeEnum moduleTypeEnum, Map<String, Object> params);
void save(ModuleTypeEnum moduleTypeEnum, Map<String, Object> params, User user);
}

View File

@ -1,11 +1,26 @@
package com.engine.organization.service.impl;
import com.engine.core.impl.Service;
import com.engine.organization.entity.hrmresource.po.HrmResourcePO;
import com.engine.organization.entity.map.JclOrgMap;
import com.engine.organization.entity.version.HrmDepartmentVersion;
import com.engine.organization.entity.version.HrmResourceVersion;
import com.engine.organization.entity.version.HrmSubCompanyVersion;
import com.engine.organization.enums.ModuleTypeEnum;
import com.engine.organization.mapper.jclorgmap.JclOrgMapper;
import com.engine.organization.mapper.resource.ResourceMapper;
import com.engine.organization.mapper.trigger.CompTriggerMapper;
import com.engine.organization.mapper.version.CompanyVersionMapper;
import com.engine.organization.service.VersionManageService;
import com.engine.organization.util.OrganizationDateUtil;
import com.engine.organization.util.db.MapperProxyFactory;
import org.apache.commons.lang3.StringUtils;
import weaver.common.DateUtil;
import weaver.general.Util;
import weaver.hrm.User;
import java.sql.Date;
import java.util.Calendar;
import java.util.Map;
/**
@ -20,14 +35,200 @@ public class VersionManageServiceImpl extends Service implements VersionManageSe
return MapperProxyFactory.getProxy(CompanyVersionMapper.class);
}
@Override
public void save(ModuleTypeEnum moduleTypeEnum, Map<String, Object> params) {
//1.参数处理
//2.枚举处理不同mapper
//3.保存逻辑
//版本表 操作者,操作时间版本V1.0 + 0.1 (默认字段)
private JclOrgMapper getJclOrgMapMapper(){
return MapperProxyFactory.getProxy(JclOrgMapper.class);
}
@Override
public void save(ModuleTypeEnum moduleTypeEnum, Map<String, Object> params, User user) {
switch (moduleTypeEnum.getValue()){
case 1:
saveSubComToMap(params);
saveSubComToVersion(params,user);
break;
case 2:
saveComToVersion(params, user);
saveDeptToMap(params);
break;
case 4:
break;
default:
break;
}
}
/**
* 分部保存至map表
*/
void saveSubComToMap(Map<String, Object> params) {
String id = (String) params.get("id");
String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date());
JclOrgMap jclOrgMap = new JclOrgMap();
jclOrgMap.setId(Integer.parseInt((String) params.get("id")));
jclOrgMap.setFType(1);
jclOrgMap.setFObjId(Integer.parseInt((String) params.get("id")));
jclOrgMap.setFClass(0);
jclOrgMap.setFClassName("行政维度");
jclOrgMap.setFName((String) params.get("subCompanyName"));
jclOrgMap.setFParentId(Integer.parseInt((String) params.get("supSubComId")));
jclOrgMap.setFIsVitual(0);
jclOrgMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime()));
jclOrgMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2022-12-31").getTime()));
JclOrgMap jclOrgMapByFParentId = getJclOrgMapMapper().getSumPlanAndJobByFParentId(jclOrgMap.getFDateBegin(), String.valueOf(jclOrgMap.getId()));
if(jclOrgMapByFParentId !=null){
jclOrgMap.setFPlan(jclOrgMapByFParentId.getFPlan());
jclOrgMap.setFOnJob(jclOrgMapByFParentId.getFOnJob());
}else{
jclOrgMap.setFPlan(0);
jclOrgMap.setFOnJob(0);
}
Calendar cal = Calendar.getInstance();
cal.setTime(jclOrgMap.getFDateBegin());
Calendar calendar = DateUtil.addDay(cal, -1);
Date time = new Date(calendar.getTime().getTime());
getJclOrgMapMapper().deleteMap("1", id, jclOrgMap.getFDateBegin());
getJclOrgMapMapper().updateMap("1", id, jclOrgMap.getFDateBegin(), time);
getJclOrgMapMapper().insertMap(jclOrgMap);
}
/**
* 部门保存到map表
*/
void saveDeptToMap(Map<String, Object> params) {
String id = (String) params.get("id");
int st = 100000000;
int sj = 200000000;
int sk = 300000000;
String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date());
JclOrgMap jclOrgMap = new JclOrgMap();
jclOrgMap.setId(st + Integer.parseInt(id));
jclOrgMap.setFType(2);
jclOrgMap.setFObjId(Integer.parseInt(id));
jclOrgMap.setFClass(0);
jclOrgMap.setFClassName("行政维度");
String bmfzr = (String) params.get("bmfzr");
if (StringUtils.isNotBlank(bmfzr)) {
jclOrgMap.setFLeader(Integer.parseInt(bmfzr));
HrmResourcePO hrmResourcePO = MapperProxyFactory.getProxy(ResourceMapper.class).getResourceById(bmfzr);
jclOrgMap.setFLeaderImg(hrmResourcePO.getResourceImageId());
jclOrgMap.setFLeaderName(hrmResourcePO.getLastName());
jclOrgMap.setFLeaderJobId(Math.toIntExact(hrmResourcePO.getJobTitle()));
}
jclOrgMap.setFName((String) params.get("departmentName"));
jclOrgMap.setFParentId(Integer.parseInt((String) params.get("subCompanyId1")));
jclOrgMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime()));
jclOrgMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2022-12-31").getTime()));
jclOrgMap.setFIsVitual(0);
JclOrgMap jclOrgMapByFParentId = getJclOrgMapMapper().getSumPlanAndJobByFParentId(jclOrgMap.getFDateBegin(), String.valueOf(jclOrgMap.getId()));
if (null != jclOrgMapByFParentId) {
jclOrgMap.setFPlan(jclOrgMapByFParentId.getFPlan());
jclOrgMap.setFOnJob(jclOrgMapByFParentId.getFOnJob());
} else {
jclOrgMap.setFPlan(0);
jclOrgMap.setFOnJob(0);
}
Calendar cal = Calendar.getInstance();
cal.setTime(jclOrgMap.getFDateBegin());
Calendar calendar = DateUtil.addDay(cal, -1);
Date time = new Date(calendar.getTime().getTime());
getJclOrgMapMapper().deleteMap("2", id, jclOrgMap.getFDateBegin());
getJclOrgMapMapper().updateMap("2", id, jclOrgMap.getFDateBegin(), time);
getJclOrgMapMapper().insertMap(jclOrgMap);
}
/**
* 分部保存至版本表
*/
void saveSubComToVersion(Map<String, Object> params,User user) {
String id = (String) params.get("id");
String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date());
HrmSubCompanyVersion hrmSubCompanyVersion = new HrmSubCompanyVersion();
hrmSubCompanyVersion.setSubComId(Integer.parseInt(id));
hrmSubCompanyVersion.setSubCompanyDesc((String) params.get("subCompanyDesc"));
hrmSubCompanyVersion.setSubCompanyCode((String) params.get("subCompanyCode"));
hrmSubCompanyVersion.setSubCompanyName((String) params.get("subCompanyName"));
hrmSubCompanyVersion.setSupsSubComId(Integer.parseInt((String) params.get("supSubComId")));
String showOrder = (String) params.get("showOrder");
hrmSubCompanyVersion.setShowOrder(null==showOrder ? null : Integer.parseInt(showOrder));
hrmSubCompanyVersion.setCanceled(Integer.parseInt((String) params.get("canceled")));
hrmSubCompanyVersion.setDescription((String) params.get("description"));
hrmSubCompanyVersion.setOperator(user.getUsername());
hrmSubCompanyVersion.setVersion(genVersionId(1,id));
hrmSubCompanyVersion.setOperateTime(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime()));
getCompanyVersionMapper().insertHrmSubComVersion(hrmSubCompanyVersion);
}
/**
* 部门保存至版本
*/
void saveComToVersion(Map<String, Object> params,User user) {
String id = (String) params.get("id");
String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date());
HrmDepartmentVersion hrmDepartmentVersion = new HrmDepartmentVersion();
hrmDepartmentVersion.setDepartmentId(Integer.parseInt(id));
hrmDepartmentVersion.setDepartmentMark((String) params.get("departmentMark"));
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 bmfzr = (String) params.get("bmfzr");
if (!"".equals(bmfzr)){
hrmDepartmentVersion.setBmfzr(Integer.parseInt(bmfzr));
}
String showOrder = (String) params.get("showOrder");
hrmDepartmentVersion.setShowOrder(null==showOrder ? null : Integer.parseInt(showOrder));
hrmDepartmentVersion.setCanceled(Integer.parseInt((String) params.get("canceled")));
hrmDepartmentVersion.setDescription((String) params.get("description"));
hrmDepartmentVersion.setOperator(user.getLastname());
hrmDepartmentVersion.setVersion(genVersionId(2,id));
hrmDepartmentVersion.setOperateTime(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime()));
getCompanyVersionMapper().insertHrmDeptVersion(hrmDepartmentVersion);
}
/**
* 版本号生成
*/
private Double genVersionId(int fType,String sid) {
// 版本V1.0 + 0.1 (默认字段)
double id = 1.0;
switch (fType) {
case 1:
HrmSubCompanyVersion hrmSubCompanyVersion = getCompanyVersionMapper().getMaxVersion(sid);
if (null != hrmSubCompanyVersion) {
id = 0.1 + hrmSubCompanyVersion.getVersion();
}
break;
case 2:
HrmDepartmentVersion hrmDepartmentVersion = getCompanyVersionMapper().getMaxDeptVersion(sid);
if (null != hrmDepartmentVersion) {
id = 0.1 + hrmDepartmentVersion.getVersion();
}
break;
case 3:
HrmResourceVersion hrmResourceVersion = getCompanyVersionMapper().getMaxHrmVersion(sid);
if (null != hrmResourceVersion) {
id = 0.1 + hrmResourceVersion.getVersion();
}
break;
}
return id;
}
}

View File

@ -23,6 +23,6 @@ public class VersionManageWrapper extends OrganizationWrapper {
}
public void save(ModuleTypeEnum moduleTypeEnum, Map<String, Object> params) {
getVersionManageService(user).save(moduleTypeEnum,params);
getVersionManageService(user).save(moduleTypeEnum,params,user);
}
}