部门版本控制写入逻辑

pull/90/head^2
Mlin 3 years ago
parent 73dbaf75ac
commit 13ae136872

@ -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;
}

@ -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;
}

@ -17,6 +17,6 @@ public class HrmSubCompanyVersion {
Integer canceled;
String description;
String operator;
String version;
Double version;
Date operateTime;
}

@ -1,5 +1,7 @@
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;
@ -14,10 +16,33 @@ public interface CompanyVersionMapper {
/**
*
*/
HrmSubCompanyVersion getMaxVersion(@Param("sid") String sid);
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);
}

@ -22,10 +22,10 @@
t.showorder ,t.canceled ,t.description ,t.operator ,t.version ,t.operate_time
</sql>
<select id="getMaxVersion" resultMap="BaseResultMap">
<select id="getMaxVersion" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="baseColumns"/>
from hrmsubcompany_version t where t.sid=#{sid} order by t.version desc limit 1
from hrmsubcompany_version t where t.subcomid=#{subComId} order by t.version desc limit 1
</select>
<insert id="insertHrmSubComVersion">
@ -36,6 +36,44 @@
#{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>

@ -2,6 +2,8 @@ package com.engine.organization.service.impl;
import com.engine.core.impl.Service;
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;
@ -11,6 +13,7 @@ import com.engine.organization.service.VersionManageService;
import com.engine.organization.util.OrganizationDateUtil;
import com.engine.organization.util.db.MapperProxyFactory;
import weaver.common.DateUtil;
import weaver.general.Util;
import weaver.hrm.User;
import java.sql.Date;
@ -42,6 +45,7 @@ public class VersionManageServiceImpl extends Service implements VersionManageSe
saveSubComToVersion(params,user);
break;
case 2:
saveComToVersion(params, user);
break;
case 4:
break;
@ -64,23 +68,70 @@ public class VersionManageServiceImpl extends Service implements VersionManageSe
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("行政维度");
jclOrgMap.setFName((String) params.get("departmentName"));
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().getJclOrgMapByFParentId(jclOrgMap.getFDateBegin(), id);
jclOrgMap.setFPlan(jclOrgMapByFParentId.getFPlan());
jclOrgMap.setFOnJob(jclOrgMapByFParentId.getFOnJob());
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());
MapperProxyFactory.getProxy(CompTriggerMapper.class).deleteMap(jclOrgMap.getFType(), jclOrgMap.getFObjId(), jclOrgMap.getFDateBegin());
MapperProxyFactory.getProxy(CompTriggerMapper.class).updateMap(jclOrgMap.getFType(), jclOrgMap.getFObjId(), jclOrgMap.getFDateBegin(), time);
getJclOrgMapMapper().deleteMap("2", id, jclOrgMap.getFDateBegin());
getJclOrgMapMapper().updateMap("2", id, jclOrgMap.getFDateBegin(), time);
getJclOrgMapMapper().insertMap(jclOrgMap);
}
@ -98,28 +149,69 @@ public class VersionManageServiceImpl extends Service implements VersionManageSe
hrmSubCompanyVersion.setSubCompanyCode((String) params.get("subCompanyCode"));
hrmSubCompanyVersion.setSubCompanyName((String) params.get("subCompanyName"));
hrmSubCompanyVersion.setSupsSubComId(Integer.parseInt((String) params.get("supSubComId")));
hrmSubCompanyVersion.setShowOrder(Integer.parseInt((String) params.get("showOrder")));
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.setDescription((String) params.get("description"));
hrmSubCompanyVersion.setOperator(user.getUsername());
hrmSubCompanyVersion.setVersion(genVersionId(id));
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((int) params.get("supDepId"));
hrmDepartmentVersion.setBmfzr((int) params.get("bmfzr"));
String showOrder = (String) params.get("showOrder");
hrmDepartmentVersion.setShowOrder(null==showOrder ? null : Integer.parseInt(showOrder));
hrmDepartmentVersion.setCanceled((int)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()));
}
/**
*
*/
private String genVersionId(String sid) {
private Double genVersionId(int fType,String sid) {
// 版本V1.0 + 0.1 (默认字段)
double id = 1.0;
HrmSubCompanyVersion hrmSubCompanyVersion = getCompanyVersionMapper().getMaxVersion(sid);
if (null != hrmSubCompanyVersion) {
id = id + Double.parseDouble(hrmSubCompanyVersion.getVersion());
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 String.valueOf(id);
return id;
}
}

Loading…
Cancel
Save