weaver-hrm-organization/src/com/engine/organization/service/impl/VersionManageServiceImpl.java

454 lines
22 KiB
Java
Raw Normal View History

2022-12-08 09:56:25 +08:00
package com.engine.organization.service.impl;
2022-12-15 09:59:57 +08:00
import com.alibaba.fastjson.JSONObject;
2022-12-08 09:56:25 +08:00
import com.engine.core.impl.Service;
import com.engine.organization.entity.hrmresource.po.HrmResourcePO;
2022-12-09 08:50:23 +08:00
import com.engine.organization.entity.map.JclOrgMap;
2022-12-16 18:31:50 +08:00
import com.engine.organization.entity.version.*;
2022-12-08 09:56:25 +08:00
import com.engine.organization.enums.ModuleTypeEnum;
2022-12-09 08:50:23 +08:00
import com.engine.organization.mapper.jclorgmap.JclOrgMapper;
import com.engine.organization.mapper.resource.ResourceMapper;
2022-12-08 09:56:25 +08:00
import com.engine.organization.mapper.version.CompanyVersionMapper;
import com.engine.organization.service.VersionManageService;
2022-12-09 08:50:23 +08:00
import com.engine.organization.util.OrganizationDateUtil;
2022-12-08 09:56:25 +08:00
import com.engine.organization.util.db.MapperProxyFactory;
import org.apache.commons.lang3.StringUtils;
2022-12-16 18:31:50 +08:00
import org.docx4j.wml.U;
2022-12-09 08:50:23 +08:00
import weaver.common.DateUtil;
2022-12-12 17:55:50 +08:00
import weaver.conn.RecordSet;
2022-12-09 16:04:35 +08:00
import weaver.general.Util;
2022-12-09 08:50:23 +08:00
import weaver.hrm.User;
2022-12-08 09:56:25 +08:00
2022-12-09 08:50:23 +08:00
import java.sql.Date;
2022-12-12 17:55:50 +08:00
import java.sql.Timestamp;
2022-12-15 19:51:04 +08:00
import java.text.SimpleDateFormat;
2022-12-15 14:38:48 +08:00
import java.util.*;
2022-12-08 09:56:25 +08:00
/**
* @Author weaver_cl
* @Description:
* @Date 2022/12/8
* @Version V1.0
**/
public class VersionManageServiceImpl extends Service implements VersionManageService {
2022-12-20 15:36:39 +08:00
2022-12-15 20:29:58 +08:00
private CompanyVersionMapper getCompanyVersionMapper() {
2022-12-08 09:56:25 +08:00
return MapperProxyFactory.getProxy(CompanyVersionMapper.class);
}
2022-12-15 20:29:58 +08:00
private JclOrgMapper getJclOrgMapMapper() {
2022-12-09 08:50:23 +08:00
return MapperProxyFactory.getProxy(JclOrgMapper.class);
}
2022-12-08 09:56:25 +08:00
@Override
2022-12-09 08:50:23 +08:00
public void save(ModuleTypeEnum moduleTypeEnum, Map<String, Object> params, User user) {
2022-12-15 09:59:57 +08:00
String id = (String) params.get("id");
JSONObject paramMap = null;
2022-12-15 14:38:48 +08:00
2022-12-15 20:29:58 +08:00
switch (moduleTypeEnum.getValue()) {
2022-12-09 08:50:23 +08:00
case 1:
2022-12-16 18:31:50 +08:00
HrmSubCompanyDto hrmSubComp = getCompanyVersionMapper().getHrmSubComp(id);
saveSubComToVersion(hrmSubComp, user);
// saveSubComToMap(paramMap);
2022-12-09 08:50:23 +08:00
break;
case 2:
2022-12-16 18:31:50 +08:00
HrmDepartmentDto hrmDepartmentDto = getCompanyVersionMapper().getHrmDepartment(id);
saveDeptToVersion(hrmDepartmentDto, user);
// saveDeptToMap(paramMap);
2022-12-09 08:50:23 +08:00
break;
case 4:
2022-12-16 18:31:50 +08:00
HrmResourceDto hrmResourceDto = getCompanyVersionMapper().getHrmResource(id);
saveHrmToVersion(hrmResourceDto, user);
// saveHrmToMap(paramMap);
2022-12-09 08:50:23 +08:00
break;
}
}
2022-12-13 14:58:22 +08:00
@Override
2022-12-15 14:38:48 +08:00
public Map<String, Object> getVersion(ModuleTypeEnum moduleTypeEnum, Map<String, Object> params, User user) {
2022-12-16 16:39:09 +08:00
String operateName = "";
2022-12-15 14:38:48 +08:00
String id = (String) params.get("id");
2022-12-15 18:57:32 +08:00
String version = (String) params.get("version");
2022-12-15 19:51:04 +08:00
String operateTime = "";
Map<String, Object> resultMap = new HashMap<>();
2022-12-15 18:57:32 +08:00
List versions = new ArrayList<>();
List<VersionData> datas = new ArrayList<>();
2022-12-15 19:51:04 +08:00
switch (moduleTypeEnum.getValue()) {
2022-12-15 09:59:57 +08:00
case 1:
2022-12-15 19:51:04 +08:00
List<HrmSubCompanyVersion> list = getCompanyVersionMapper().getSubComVersionList(id, null);
2022-12-15 18:57:32 +08:00
int size = list.size();
2022-12-15 19:51:04 +08:00
if (size < 1) {
break;
}
for (HrmSubCompanyVersion hrmSubCompanyVersion : list) {
Map<String, String> map = new HashMap<>();
map.put("value", String.format("%.1f", hrmSubCompanyVersion.getVersion()));
2022-12-15 18:57:32 +08:00
versions.add(map);
}
2022-12-15 20:29:58 +08:00
if (version.equals("1.0")) {
version = "1";
2022-12-15 18:57:32 +08:00
}
2022-12-15 19:51:04 +08:00
list = getCompanyVersionMapper().getSubComVersionList(id, version);
for (HrmSubCompanyVersion hrmSubCompanyVersion : list) {
2022-12-15 18:57:32 +08:00
datas.add(VersionData.builder().fieldId("分部简称").fieldValue(Util.null2String(hrmSubCompanyVersion.getSubCompanyName())).build());
2022-12-20 10:57:46 +08:00
datas.add(VersionData.builder().fieldId("分部全称").fieldValue(Util.null2String(hrmSubCompanyVersion.getSubCompanyDesc())).build());
datas.add(VersionData.builder().fieldId("上级分部").fieldValue(Util.null2String(hrmSubCompanyVersion.getSupSubComName())).build());
2022-12-15 19:51:04 +08:00
datas.add(VersionData.builder().fieldId("版本号").fieldValue(Util.null2String(String.format("%.1f", hrmSubCompanyVersion.getVersion()))).build());
2022-12-20 10:57:46 +08:00
datas.add(VersionData.builder().fieldId("分部编号").fieldValue(Util.null2String(hrmSubCompanyVersion.getSubCompanyCode())).build());
2022-12-15 18:57:32 +08:00
datas.add(VersionData.builder().fieldId("排序").fieldValue(Util.null2String(hrmSubCompanyVersion.getShowOrder())).build());
operateName = hrmSubCompanyVersion.getOperator();
2022-12-15 19:51:04 +08:00
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
operateTime = sdf.format(hrmSubCompanyVersion.getOperateTime());
2022-12-15 14:38:48 +08:00
}
2022-12-15 09:59:57 +08:00
break;
case 2:
2022-12-15 19:51:04 +08:00
List<HrmDepartmentVersion> deptVersionList = getCompanyVersionMapper().getDeptVersionList(id, null);
2022-12-15 18:57:32 +08:00
int deptSize = deptVersionList.size();
2022-12-15 19:51:04 +08:00
if (deptSize < 1) {
break;
}
for (HrmDepartmentVersion hrmDepartmentVersion : deptVersionList) {
Map<String, String> map = new HashMap<>();
map.put("value", String.format("%.1f", hrmDepartmentVersion.getVersion()));
2022-12-15 18:57:32 +08:00
versions.add(map);
}
2022-12-15 20:29:58 +08:00
if (version.equals("1.0")) {
version = "1";
2022-12-15 18:57:32 +08:00
}
2022-12-15 19:51:04 +08:00
deptVersionList = getCompanyVersionMapper().getDeptVersionList(id, version);
for (HrmDepartmentVersion hrmDepartmentVersion : deptVersionList) {
2022-12-15 18:57:32 +08:00
datas.add(VersionData.builder().fieldId("部门编号").fieldValue(Util.null2String(hrmDepartmentVersion.getDepartmentCode())).build());
datas.add(VersionData.builder().fieldId("部门简称").fieldValue(Util.null2String(hrmDepartmentVersion.getDepartmentName())).build());
2022-12-20 10:57:46 +08:00
datas.add(VersionData.builder().fieldId("部门全称").fieldValue(Util.null2String(hrmDepartmentVersion.getDepartmentMark())).build());
datas.add(VersionData.builder().fieldId("所属分部").fieldValue(Util.null2String(hrmDepartmentVersion.getSubcompanyname())).build());
datas.add(VersionData.builder().fieldId("上级部门").fieldValue(Util.null2String(hrmDepartmentVersion.getSupDepName())).build());
datas.add(VersionData.builder().fieldId("部门负责人").fieldValue(Util.null2String(hrmDepartmentVersion.getBmfzrName())).build());
2022-12-15 19:51:04 +08:00
datas.add(VersionData.builder().fieldId("版本号").fieldValue(Util.null2String(String.format("%.1f", hrmDepartmentVersion.getVersion()))).build());
2022-12-15 18:57:32 +08:00
datas.add(VersionData.builder().fieldId("排序").fieldValue(Util.null2String(hrmDepartmentVersion.getShowOrder())).build());
2022-12-15 19:51:04 +08:00
operateName = hrmDepartmentVersion.getOperator();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
operateTime = sdf.format(hrmDepartmentVersion.getOperateTime());
2022-12-15 18:57:32 +08:00
}
2022-12-15 09:59:57 +08:00
break;
case 4:
2022-12-15 19:51:04 +08:00
List<HrmResourceVersion> resVersionList = getCompanyVersionMapper().getResourceVersionList(id, null);
2022-12-15 18:57:32 +08:00
int resSize = resVersionList.size();
2022-12-15 19:51:04 +08:00
if (resSize < 1) {
break;
}
for (HrmResourceVersion hrmResourceVersion : resVersionList) {
Map<String, String> map = new HashMap<>();
map.put("value", String.format("%.1f", hrmResourceVersion.getVersion()));
2022-12-15 18:57:32 +08:00
versions.add(map);
}
2022-12-15 20:29:58 +08:00
if (version.equals("1.0")) {
version = "1";
2022-12-15 18:57:32 +08:00
}
2022-12-15 19:51:04 +08:00
resVersionList = getCompanyVersionMapper().getResourceVersionList(id, version);
for (HrmResourceVersion hrmResourceVersion : resVersionList) {
2022-12-15 18:57:32 +08:00
datas.add(VersionData.builder().fieldId("姓名").fieldValue(Util.null2String(hrmResourceVersion.getLastname())).build());
datas.add(VersionData.builder().fieldId("部门").fieldValue(Util.null2String(hrmResourceVersion.getDepartmentname())).build());
datas.add(VersionData.builder().fieldId("岗位").fieldValue(Util.null2String(hrmResourceVersion.getJobtitlename())).build());
datas.add(VersionData.builder().fieldId("分部").fieldValue(Util.null2String(hrmResourceVersion.getSubcompanyname())).build());
2022-12-15 19:51:04 +08:00
datas.add(VersionData.builder().fieldId("版本号").fieldValue(Util.null2String(String.format("%.1f", hrmResourceVersion.getVersion()))).build());
operateName = hrmResourceVersion.getOperator();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
operateTime = sdf.format(hrmResourceVersion.getOperateTime());
2022-12-15 18:57:32 +08:00
}
2022-12-15 09:59:57 +08:00
break;
default:
break;
}
2022-12-16 16:39:09 +08:00
2022-12-15 19:51:04 +08:00
resultMap.put("operateName", operateName);
resultMap.put("operateTime", operateTime);
resultMap.put("versions", versions);
resultMap.put("datas", datas);
2022-12-16 16:39:09 +08:00
if (versions.size() < 1) {
return null;
}
2022-12-15 14:38:48 +08:00
return resultMap;
2022-12-13 14:58:22 +08:00
}
2022-12-09 08:50:23 +08:00
/**
* 分部保存至map表
*/
2022-12-15 09:59:57 +08:00
void saveSubComToMap(JSONObject params) {
2022-12-09 08:50:23 +08:00
String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date());
2022-12-15 09:59:57 +08:00
String id = params.getString("id");
2022-12-09 08:50:23 +08:00
JclOrgMap jclOrgMap = new JclOrgMap();
2022-12-15 09:59:57 +08:00
jclOrgMap.setId(Integer.parseInt(id));
2022-12-09 08:50:23 +08:00
jclOrgMap.setFType(1);
2022-12-15 09:59:57 +08:00
jclOrgMap.setFObjId(Integer.parseInt(id));
2022-12-09 08:50:23 +08:00
jclOrgMap.setFClass(0);
jclOrgMap.setFClassName("行政维度");
2022-12-15 09:59:57 +08:00
jclOrgMap.setFName(params.getString("subcompanyname"));
String supSubComId = params.getString("supsubcomid");
2022-12-15 20:29:58 +08:00
jclOrgMap.setFParentId(StringUtils.isNotBlank(supSubComId) ? Integer.parseInt(supSubComId) : null);
2022-12-09 16:04:35 +08:00
jclOrgMap.setFIsVitual(0);
jclOrgMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime()));
jclOrgMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2022-12-31").getTime()));
2022-12-15 20:29:58 +08:00
JclOrgMap jclOrgMapByFParentId = getJclOrgMapMapper().getSumPlanAndJobByFParentId(jclOrgMap.getFDateBegin(), Util.null2String(jclOrgMap.getId()));
if (jclOrgMapByFParentId != null) {
2022-12-09 16:04:35 +08:00
jclOrgMap.setFPlan(jclOrgMapByFParentId.getFPlan());
jclOrgMap.setFOnJob(jclOrgMapByFParentId.getFOnJob());
2022-12-15 20:29:58 +08:00
} else {
2022-12-09 16:04:35 +08:00
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);
2022-12-15 20:29:58 +08:00
if (!params.getString("canceled").equals("1")) {
getJclOrgMapMapper().insertMap(jclOrgMap);
}
2022-12-09 16:04:35 +08:00
}
/**
* 部门保存到map表
*/
2022-12-15 09:59:57 +08:00
void saveDeptToMap(JSONObject params) {
String id = params.getString("id");
2022-12-09 16:04:35 +08:00
int st = 100000000;
2022-12-12 17:55:50 +08:00
2022-12-09 16:04:35 +08:00
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("行政维度");
2022-12-15 09:59:57 +08:00
String bmfzr = params.getString("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()));
}
2022-12-15 09:59:57 +08:00
jclOrgMap.setFName(params.getString("departmentname"));
String subCompanyId1 = params.getString("subcompanyid1");
String supdepid = params.getString("supdepid");
2022-12-15 20:29:58 +08:00
if (supdepid != null) {
jclOrgMap.setFParentId(st + Integer.parseInt(supdepid));
}
2022-12-15 20:29:58 +08:00
if ("0".equals(supdepid)) {
jclOrgMap.setFParentId(Integer.parseInt(subCompanyId1));
}
2022-12-09 08:50:23 +08:00
jclOrgMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime()));
jclOrgMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2022-12-31").getTime()));
jclOrgMap.setFIsVitual(0);
2022-12-09 08:50:23 +08:00
2022-12-09 16:04:35 +08:00
JclOrgMap jclOrgMapByFParentId = getJclOrgMapMapper().getSumPlanAndJobByFParentId(jclOrgMap.getFDateBegin(), String.valueOf(jclOrgMap.getId()));
if (null != jclOrgMapByFParentId) {
2022-12-09 16:04:35 +08:00
jclOrgMap.setFPlan(jclOrgMapByFParentId.getFPlan());
jclOrgMap.setFOnJob(jclOrgMapByFParentId.getFOnJob());
} else {
2022-12-09 16:04:35 +08:00
jclOrgMap.setFPlan(0);
jclOrgMap.setFOnJob(0);
}
2022-12-09 08:50:23 +08:00
Calendar cal = Calendar.getInstance();
cal.setTime(jclOrgMap.getFDateBegin());
Calendar calendar = DateUtil.addDay(cal, -1);
Date time = new Date(calendar.getTime().getTime());
2022-12-08 09:56:25 +08:00
2022-12-09 16:04:35 +08:00
getJclOrgMapMapper().deleteMap("2", id, jclOrgMap.getFDateBegin());
getJclOrgMapMapper().updateMap("2", id, jclOrgMap.getFDateBegin(), time);
2022-12-15 20:29:58 +08:00
if (!params.getString("canceled").equals("1")) {
getJclOrgMapMapper().insertMap(jclOrgMap);
}
2022-12-08 09:56:25 +08:00
}
2022-12-09 08:50:23 +08:00
2022-12-12 17:55:50 +08:00
/**
* 人员保存至map
*/
2022-12-15 20:29:58 +08:00
void saveHrmToMap(JSONObject params) {
2022-12-15 09:59:57 +08:00
String id = params.getString("id");
2022-12-12 17:55:50 +08:00
String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date());
int sk = 300000000;
RecordSet rs = new RecordSet();
JclOrgMap jclOrgMap = new JclOrgMap();
jclOrgMap.setId(sk + Integer.parseInt(id));
jclOrgMap.setFType(4);
jclOrgMap.setFObjId(Integer.parseInt(id));
jclOrgMap.setFClass(0);
jclOrgMap.setFClassName("行政维度");
2022-12-15 09:59:57 +08:00
jclOrgMap.setFName(params.getString("lastname"));
2022-12-12 17:55:50 +08:00
if (StringUtils.isNotBlank(id)) {
2022-12-15 20:29:58 +08:00
rs.executeQuery("select messagerurl, lastname, jobtitle from hrmresource where id=" + id + ";");
if (rs.next()) {
2022-12-12 17:55:50 +08:00
jclOrgMap.setFLeaderImg(Util.null2String(rs.getString("messagerurl")));
jclOrgMap.setFLeaderName(Util.null2String(rs.getString("lastname")));
jclOrgMap.setFLeaderJobId(Integer.valueOf(rs.getString("jobtitle")));
}
}
2022-12-15 09:59:57 +08:00
String jobtitle = params.getString("jobtitle");
2022-12-15 20:29:58 +08:00
jclOrgMap.setFParentId(StringUtils.isNotBlank(jobtitle) ? sk + Integer.parseInt(jobtitle) : null);
2022-12-15 09:59:57 +08:00
jclOrgMap.setFPlan(0);
jclOrgMap.setFOnJob(0);
2022-12-12 17:55:50 +08:00
jclOrgMap.setFIsVitual(0);
jclOrgMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime()));
jclOrgMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2022-12-31").getTime()));
Calendar cal = Calendar.getInstance();
cal.setTime(jclOrgMap.getFDateBegin());
Calendar calendar = DateUtil.addDay(cal, -1);
Date time = new Date(calendar.getTime().getTime());
getJclOrgMapMapper().deleteMap("4", id, jclOrgMap.getFDateBegin());
getJclOrgMapMapper().updateMap("4", id, jclOrgMap.getFDateBegin(), time);
2022-12-15 20:29:58 +08:00
if (!params.getString("canceled").equals("1")) {
getJclOrgMapMapper().insertMap(jclOrgMap);
}
2022-12-12 17:55:50 +08:00
}
2022-12-09 08:50:23 +08:00
/**
* 分部保存至版本表
*/
2022-12-16 18:31:50 +08:00
void saveSubComToVersion(HrmSubCompanyDto hrmSubComp, User user) {
2022-12-12 17:55:50 +08:00
String currentDate = OrganizationDateUtil.getFormatLocalDateTime(new java.util.Date());
2022-12-16 18:31:50 +08:00
int id = hrmSubComp.getId();
2022-12-09 08:50:23 +08:00
HrmSubCompanyVersion hrmSubCompanyVersion = new HrmSubCompanyVersion();
2022-12-16 18:31:50 +08:00
hrmSubCompanyVersion.setSubComId(id);
hrmSubCompanyVersion.setSubCompanyDesc(hrmSubComp.getSubcompanydesc());
hrmSubCompanyVersion.setSubCompanyCode(hrmSubComp.getSubcompanycode());
hrmSubCompanyVersion.setSubCompanyName(hrmSubComp.getSubcompanyname());
String supSubComId = hrmSubComp.getSupsubcomid();
2022-12-15 14:38:48 +08:00
hrmSubCompanyVersion.setSupSubComId(StringUtils.isNotBlank(supSubComId) ? Integer.parseInt(supSubComId) : null);
2022-12-16 18:31:50 +08:00
String showOrder = hrmSubComp.getShoworder();
if (showOrder != null && !showOrder.equals("0")) {
int length = showOrder.indexOf(".");
if (length>0){
showOrder = showOrder.substring(0, length);
}
2022-12-15 14:38:48 +08:00
}
2022-12-15 09:59:57 +08:00
hrmSubCompanyVersion.setShowOrder(null == showOrder ? null : Integer.parseInt(showOrder));
2022-12-16 18:31:50 +08:00
String canceled = hrmSubComp.getCanceled();
2022-12-15 14:38:48 +08:00
;
2022-12-15 09:59:57 +08:00
hrmSubCompanyVersion.setCanceled(StringUtils.isNotBlank(canceled) ? Integer.parseInt(canceled) : null);
hrmSubCompanyVersion.setDescription(null);
2022-12-09 08:50:23 +08:00
hrmSubCompanyVersion.setOperator(user.getUsername());
2022-12-16 18:31:50 +08:00
hrmSubCompanyVersion.setVersion(genVersionId(1, Util.null2String(id)));
2022-12-12 17:55:50 +08:00
hrmSubCompanyVersion.setOperateTime(new Timestamp(OrganizationDateUtil.stringToDateTime(currentDate).getTime()));
2022-12-09 08:50:23 +08:00
getCompanyVersionMapper().insertHrmSubComVersion(hrmSubCompanyVersion);
}
2022-12-09 16:04:35 +08:00
/**
* 部门保存至版本
*/
2022-12-16 18:31:50 +08:00
void saveDeptToVersion(HrmDepartmentDto hrmDepartmentDto, User user) {
int id = hrmDepartmentDto.getId();
2022-12-12 17:55:50 +08:00
String currentDate = OrganizationDateUtil.getFormatLocalDateTime(new java.util.Date());
2022-12-09 16:04:35 +08:00
HrmDepartmentVersion hrmDepartmentVersion = new HrmDepartmentVersion();
2022-12-16 18:31:50 +08:00
hrmDepartmentVersion.setDepartmentId(id);
hrmDepartmentVersion.setDepartmentMark(hrmDepartmentDto.getDepartmentmark());
hrmDepartmentVersion.setDepartmentCode(hrmDepartmentDto.getDepartmentcode());
hrmDepartmentVersion.setDepartmentName(hrmDepartmentDto.getDepartmentname());
String subCompanyId1 = hrmDepartmentDto.getSubcompanyid1();
2022-12-15 09:59:57 +08:00
hrmDepartmentVersion.setSubCompanyId1(StringUtils.isNotBlank(subCompanyId1) ? Integer.parseInt(subCompanyId1) : null);
2022-12-16 18:31:50 +08:00
String supDepId = hrmDepartmentDto.getSupdepid();
2022-12-15 09:59:57 +08:00
if (supDepId != null) {
hrmDepartmentVersion.setSupDepId(Integer.parseInt(supDepId));
}
2022-12-16 18:31:50 +08:00
String bmfzr = hrmDepartmentDto.getBmfzr();
2022-12-15 09:59:57 +08:00
if (!"".equals(bmfzr) && bmfzr != null) {
hrmDepartmentVersion.setBmfzr(bmfzr);
}
2022-12-16 18:31:50 +08:00
String showOrder = hrmDepartmentDto.getShoworder();
if (showOrder != null && !showOrder.equals("0")) {
int length = showOrder.indexOf(".");
if (length>0){
showOrder = showOrder.substring(0, length);
}
2022-12-15 14:38:48 +08:00
}
2022-12-15 09:59:57 +08:00
hrmDepartmentVersion.setShowOrder(null == showOrder ? null : Integer.parseInt(showOrder));
2022-12-16 18:31:50 +08:00
String canceled = hrmDepartmentDto.getCanceled();
2022-12-15 09:59:57 +08:00
hrmDepartmentVersion.setCanceled(StringUtils.isNotBlank(canceled) ? Integer.parseInt(canceled) : null);
hrmDepartmentVersion.setDescription(null);
2022-12-09 16:04:35 +08:00
hrmDepartmentVersion.setOperator(user.getLastname());
2022-12-16 18:31:50 +08:00
hrmDepartmentVersion.setVersion(genVersionId(2, Util.null2String(id)));
hrmDepartmentVersion.setOperateTime(new Timestamp(OrganizationDateUtil.stringToDateTime(currentDate).getTime()));
getCompanyVersionMapper().insertHrmDeptVersion(hrmDepartmentVersion);
2022-12-09 16:04:35 +08:00
}
2022-12-12 17:55:50 +08:00
/**
* 人员保存至版本
*/
2022-12-16 18:31:50 +08:00
void saveHrmToVersion(HrmResourceDto hrmResourceDto, User user) {
Integer id = hrmResourceDto.getId();
2022-12-12 17:55:50 +08:00
String currentDate = OrganizationDateUtil.getFormatLocalDateTime(new java.util.Date());
HrmResourceVersion hrmResourceVersion = new HrmResourceVersion();
2022-12-16 18:31:50 +08:00
hrmResourceVersion.setResourceid(id);
2022-12-12 17:55:50 +08:00
/* hrmResourceVersion.setCompanystartdate(new Date(OrganizationDateUtil.stringToDate((String) params.get("companystartdate")).getTime()));
hrmResourceVersion.setCompanyworkyear(Integer.parseInt((String) params.get("companyworkyear")));
hrmResourceVersion.setWorkstartdate(new Date(OrganizationDateUtil.stringToDate((String) params.get("workstartdate")).getTime()));*/
2022-12-16 18:31:50 +08:00
hrmResourceVersion.setDepartmentid(hrmResourceDto.getDepartmentid());
hrmResourceVersion.setDsporder(Double.valueOf(hrmResourceDto.getDsporder()).intValue());
hrmResourceVersion.setSubcompanyid1(hrmResourceDto.getSubcompanyid1());
hrmResourceVersion.setJobtitle(hrmResourceDto.getJobtitle());
hrmResourceVersion.setMobile(hrmResourceDto.getMobile());
hrmResourceVersion.setTelephone(hrmResourceDto.getTelephone());
String managerid = hrmResourceDto.getManagerid();
2022-12-15 20:29:58 +08:00
hrmResourceVersion.setManagerid(StringUtils.isNotBlank(managerid) ? Integer.parseInt(managerid) : null);
2022-12-16 18:31:50 +08:00
hrmResourceVersion.setLastname(hrmResourceDto.getLastname());
2022-12-12 17:55:50 +08:00
hrmResourceVersion.setOperator(user.getLastname());
hrmResourceVersion.setVersion(genVersionId(4, String.valueOf(id)));
2022-12-12 17:55:50 +08:00
hrmResourceVersion.setOperateTime(new Timestamp(OrganizationDateUtil.stringToDateTime(currentDate).getTime()));
getCompanyVersionMapper().insertHrmResourceVersion(hrmResourceVersion);
}
2022-12-09 08:50:23 +08:00
/**
* 版本号生成
*/
2022-12-15 20:29:58 +08:00
private Double genVersionId(int fType, String sid) {
2022-12-09 08:50:23 +08:00
// 版本V1.0 + 0.1 (默认字段)
double id = 1.0;
2022-12-09 16:04:35 +08:00
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;
2022-12-16 18:31:50 +08:00
case 4:
2022-12-09 16:04:35 +08:00
HrmResourceVersion hrmResourceVersion = getCompanyVersionMapper().getMaxHrmVersion(sid);
if (null != hrmResourceVersion) {
id = 0.1 + hrmResourceVersion.getVersion();
}
break;
2022-12-09 08:50:23 +08:00
}
2022-12-09 16:04:35 +08:00
return id;
2022-12-09 08:50:23 +08:00
}
2022-12-20 15:36:39 +08:00
2022-12-08 09:56:25 +08:00
}