You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
weaver-hrm-organization/src/com/engine/organization/service/impl/VersionManageServiceImpl.java

126 lines
5.0 KiB
Java

3 years ago
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.HrmSubCompanyVersion;
3 years ago
import com.engine.organization.enums.ModuleTypeEnum;
import com.engine.organization.mapper.jclorgmap.JclOrgMapper;
import com.engine.organization.mapper.trigger.CompTriggerMapper;
3 years ago
import com.engine.organization.mapper.version.CompanyVersionMapper;
import com.engine.organization.service.VersionManageService;
import com.engine.organization.util.OrganizationDateUtil;
3 years ago
import com.engine.organization.util.db.MapperProxyFactory;
import weaver.common.DateUtil;
import weaver.hrm.User;
3 years ago
import java.sql.Date;
import java.util.Calendar;
3 years ago
import java.util.Map;
/**
* @Author weaver_cl
* @Description:
* @Date 2022/12/8
* @Version V1.0
**/
public class VersionManageServiceImpl extends Service implements VersionManageService {
private CompanyVersionMapper getCompanyVersionMapper(){
return MapperProxyFactory.getProxy(CompanyVersionMapper.class);
}
private JclOrgMapper getJclOrgMapMapper(){
return MapperProxyFactory.getProxy(JclOrgMapper.class);
}
3 years ago
@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:
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("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());
3 years ago
Calendar cal = Calendar.getInstance();
cal.setTime(jclOrgMap.getFDateBegin());
Calendar calendar = DateUtil.addDay(cal, -1);
Date time = new Date(calendar.getTime().getTime());
3 years ago
MapperProxyFactory.getProxy(CompTriggerMapper.class).deleteMap(jclOrgMap.getFType(), jclOrgMap.getFObjId(), jclOrgMap.getFDateBegin());
MapperProxyFactory.getProxy(CompTriggerMapper.class).updateMap(jclOrgMap.getFType(), jclOrgMap.getFObjId(), jclOrgMap.getFDateBegin(), time);
3 years ago
getJclOrgMapMapper().insertMap(jclOrgMap);
3 years ago
}
/**
*
*/
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")));
hrmSubCompanyVersion.setShowOrder(Integer.parseInt((String) params.get("showOrder")));
hrmSubCompanyVersion.setCanceled(Integer.parseInt((String) params.get("canceled")));
hrmSubCompanyVersion.setDescription((String) params.get("description"));
hrmSubCompanyVersion.setOperator(user.getUsername());
hrmSubCompanyVersion.setVersion(genVersionId(id));
hrmSubCompanyVersion.setOperateTime(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime()));
getCompanyVersionMapper().insertHrmSubComVersion(hrmSubCompanyVersion);
}
/**
*
*/
private String genVersionId(String sid) {
// 版本V1.0 + 0.1 (默认字段)
double id = 1.0;
HrmSubCompanyVersion hrmSubCompanyVersion = getCompanyVersionMapper().getMaxVersion(sid);
if (null != hrmSubCompanyVersion) {
id = id + Double.parseDouble(hrmSubCompanyVersion.getVersion());
}
return String.valueOf(id);
}
3 years ago
}