编程语言
首页 > 编程语言> > S-HRPER06 入职当天离职或录用分配当天离职导入功能之导入模板实现源码

S-HRPER06 入职当天离职或录用分配当天离职导入功能之导入模板实现源码

作者:互联网

https://www.cnblogs.com/luojiabao/p/11088698.html阅读,含导入上传数据的思路;

关注submitData即可;

package com.kingdee.shr.batchAffair.io.impl;

import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.bos.db.TempTablePool;
import com.kingdee.bos.metadata.entity.DataType;
import com.kingdee.bos.sql.ParserException;
import com.kingdee.bos.util.BOSUuid;
import com.kingdee.eas.base.message.util.StringUtil;
import com.kingdee.eas.base.permission.UserInfo;
import com.kingdee.eas.base.ssc.UserFactory;
import com.kingdee.eas.basedata.person.PersonCollection;
import com.kingdee.eas.basedata.person.PersonFactory;
import com.kingdee.eas.basedata.person.PersonHisFactory;
import com.kingdee.eas.basedata.person.PersonHisInfo;
import com.kingdee.eas.basedata.person.PersonInfo;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.framework.CoreBaseCollection;
import com.kingdee.eas.framework.CoreBaseInfo;
import com.kingdee.eas.framework.ICoreBase;
import com.kingdee.eas.hr.base.AffairActionReasonFactory;
import com.kingdee.eas.hr.base.AffairActionReasonInfo;
import com.kingdee.eas.hr.base.DimissionReasonFactory;
import com.kingdee.eas.hr.base.DimissionReasonInfo;
import com.kingdee.eas.hr.base.EmpLaborRelationFactory;
import com.kingdee.eas.hr.base.EmpLaborRelationHisFactory;
import com.kingdee.eas.hr.base.EmpLaborRelationHisInfo;
import com.kingdee.eas.hr.base.EmpLaborRelationInfo;
import com.kingdee.eas.hr.base.EmpPosOrgRelationCollection;
import com.kingdee.eas.hr.base.EmpPosOrgRelationFactory;
import com.kingdee.eas.hr.base.EmpPosOrgRelationInfo;
import com.kingdee.eas.hr.base.EmployeeTypeFactory;
import com.kingdee.eas.hr.base.EmployeeTypeInfo;
import com.kingdee.eas.hr.base.HRBizDefChangeReasonCollection;
import com.kingdee.eas.hr.base.HRBizDefVariationReasonCollection;
import com.kingdee.eas.hr.base.HRBizDefineCollection;
import com.kingdee.eas.hr.base.HRBizDefineFactory;
import com.kingdee.eas.hr.base.VariationReasonFactory;
import com.kingdee.eas.hr.emp.PersonPositionFactory;
import com.kingdee.eas.hr.emp.PersonPositionHisFactory;
import com.kingdee.eas.hr.emp.PersonPositionHisInfo;
import com.kingdee.eas.hr.emp.PersonPositionInfo;
import com.kingdee.eas.util.app.ContextUtil;
import com.kingdee.eas.util.app.DbUtil;
import com.kingdee.jdbc.rowset.IRowSet;
import com.kingdee.shr.base.syssetting.SHRFileTemplateFieldsCollection;
import com.kingdee.shr.base.syssetting.SHRFileTemplateFieldsInfo;
import com.kingdee.shr.base.syssetting.app.io.BaseColumnInfo;
import com.kingdee.shr.base.syssetting.app.io.ExcelUtil;
import com.kingdee.shr.base.syssetting.app.io.impl.ResignBizBillHrManFileService;
import com.kingdee.shr.base.syssetting.app.io.impl.person.PersonChangeImportUtil;
import com.kingdee.shr.base.syssetting.app.io.impl.util.BizBillBaseImportCheck;
import com.kingdee.shr.base.syssetting.app.io.impl.util.ResignImportCheck;
import com.kingdee.shr.base.syssetting.context.SHRContext;
import com.kingdee.shr.base.syssetting.exception.ShrWebBizException;
import com.kingdee.util.DateTimeUtils;
import com.kingdee.util.NumericExceptionSubItem;
import com.kingdee.util.StringUtils;
import com.kingdee.util.UuidException;

public class PersonResignOSDChangeFileService extends ResignBizBillHrManFileService {
private List<Map<String,Object>> dataMaps=new ArrayList();
private Map<String, Object> dataMap = new HashMap();
private static boolean ISRUNNING = false;

public static void main(String[] args) {
// com.kingdee.shr.base.syssetting.web.handler.ImportInfoHandler
// com.kingdee.shr.batchAffair.io.impl.PersonResignChangeFileService
// com.kingdee.shr.base.syssetting.web.handler.ImportInfoHandler

//当天录用分配导入 com.kingdee.shr.base.syssetting.app.io.impl.AllotByTodayFileService
}

/**
* 增加定义的员工编码/员工名字 属性
*/
protected void addSelfDefineColumnInfo(SHRFileTemplateFieldsCollection fields) {
SHRFileTemplateFieldsInfo personNumber = new SHRFileTemplateFieldsInfo();
personNumber.setName("员工编码");
personNumber.setIsNeed(false);
personNumber.setPropName("empNumber");
personNumber.setIsPrimayField(true);
fields.addObject(0, personNumber);
SHRFileTemplateFieldsInfo personName = new SHRFileTemplateFieldsInfo();
personName.setName("员工名字");
personName.setIsNeed(true);
personName.setPropName("empName");
personName.setIsPrimayField(false);
fields.addObject(1, personName);
}


/**
* 自定义的员工编码/员工名字属性赋值
*/

@Override
public Map<String, BaseColumnInfo> getColumnInfo() {
Map columnInfos = super.getColumnInfo();
columnInfos.put("员工编码", new BaseColumnInfo("empNumber",
BaseColumnInfo.SimpleType, DataType.STRING, null, false));
columnInfos.put("员工名字", new BaseColumnInfo("empName",
BaseColumnInfo.SimpleType, DataType.STRING, null, true));
return columnInfos;
}

/**
* 增加示例数据
*/

protected void addExampleFieldValue(SHRFileTemplateFieldsCollection fields,XSSFWorkbook wb, Row row) {
Map columnInfoMap = getColumnInfo();
CellStyle blue = wb.createCellStyle();
Font font = wb.createFont();
font.setColor(IndexedColors.ROYAL_BLUE.getIndex());
font.setItalic(true);
blue.setFont(font);
CellStyle other = wb.createCellStyle();
Font font2 = wb.createFont();
font2.setItalic(true);
other.setFont(font2);
other.setAlignment((short) 1);
other.setDataFormat(wb.createDataFormat().getFormat("@"));
for (int i = 0; i < fields.size(); ++i) {
SHRFileTemplateFieldsInfo field = fields.get(i);
String name = field.getName();
BaseColumnInfo clumnInfo = (BaseColumnInfo) columnInfoMap.get(name);
Cell cell = row.createCell(i);
if ("empName".equals(clumnInfo.getPropName())){ //员工姓名
cell.setCellValue("张三");
cell.setCellStyle(other);
} else if ("empNumber".equals(clumnInfo.getPropName())) {//员工编号
cell.setCellValue("Y03235");
cell.setCellStyle(other);
} else if ("hrBizDefine".equals(clumnInfo.getPropName())) {//变动操作-离职操作
cell.setCellValue("辞退");
cell.setCellStyle(other);
} else if ("affairActionReason".equals(clumnInfo.getPropName())) {//变动类型-离职类型
cell.setCellValue("辞退");
cell.setCellStyle(other);
} else if ("variationReason".equals(clumnInfo.getPropName())) {//变动原因-离职原因
cell.setCellValue("个人发展");
cell.setCellStyle(other);
} else if ("empType".equals(clumnInfo.getPropName())) {//目标用工状态
cell.setCellValue("离职");
cell.setCellStyle(other);
} else if ("bizDate".equals(clumnInfo.getPropName())) {//离职日期
cell.setCellValue("2014-07-14");
cell.setCellStyle(other);
}
}
}

//添加模板说明
@Override
protected void addTemplateReadMe(XSSFWorkbook wb) {
StringBuffer sb = new StringBuffer("模板说明:");
sb.append("\r\n").append("1、红色字体为必录项;").append("\r\n").append(
"2、员工姓名存在重名时,请填写员工编码以唯一确定要变动的员工;").append("\r\n").append(
"3、变动操作必须是在入职单据上配置的事务类型;").append("\r\n").append(
"4、变动操作对应多个变动类型和变动原因时,请指定;").append("\r\n").append(
"5、离职生效日期对应系统的生效日期,若要反写离职日期,需要在员工变动操作中进行配置;").append("\r\n")
.append("6、单据状态选择提交工作流,则导入成功后自动进入工作流审批;若选择直接生效则导入后单据直接提交生效;")
.append("\r\n");

XSSFSheet sheetDec = wb.createSheet("模板说明");

sheetDec.addMergedRegion(new CellRangeAddress(0, 4, 0, 4));
sheetDec.setAutobreaks(true);

CellStyle autoChange = wb.createCellStyle();
autoChange.setWrapText(true);
Font font = wb.createFont();
font.setFontHeightInPoints((short) 12);
autoChange.setFont(font);
for (int i = 0; i < 5; ++i) {
Row rowDec = sheetDec.createRow(i);
rowDec.setHeight((short) 800);
Cell cellDec = rowDec.createCell(i);
sheetDec.setColumnWidth(i, 6000);
if (i == 0) {
cellDec.setCellValue(sb.toString());
}
cellDec.setCellStyle(autoChange);
}
}


//导入的实体名称
@Override
protected String getImportEntityName() {
// TODO Auto-generated method stub
return "com.kingdee.eas.hr.affair.app.ResignBizBillEntry";
}


/***********************
| 数据导入校验操作 |
======================*/
/**
* 创建导入数据临时表

public String getTempTable(Context ctx){
String tempTable="ttOSD";
String createSql="create table "
+tempTable
+"(" +
"empNumber varchar(255)," +
"empName varchar(255)," +
"hrBizDefine varchar(255)," +
"affairActionReason varchar(255)," +
"variationReason varchar(255)," +
"empType varchar(255)," +
"bizDate varchar(255)" +
")";
TempTablePool tp=TempTablePool.getInstance(ctx);
try {
tempTable=tp.createTempTable(createSql);
} catch (Exception e) {
e.printStackTrace();
}
return tempTable;
}
*/

@Override
protected boolean validData(boolean valid, int i,
Map<Integer, String> error_report) throws BOSException {

boolean otherValid = true;
Map columnInfoMap = getColumnInfo();
this.row = this.sheet.getRow(i);
Context ctx = SHRContext.getInstance().getContext();

Map validMap = new HashMap();
//{...}线程执行该顺序,有多少条数据,就更新即可;
for (int j = 0; j < this.colNum; ++j) {
String field = (String) this.fieldMap.get(Integer.valueOf(j));
BaseColumnInfo columnInfo = (BaseColumnInfo) columnInfoMap.get(field);
if (columnInfo == null){
continue;
}
this.cell = this.row.getCell((short) j);
Object value = ExcelUtil.getCellValue(this.cell);
validMap.put(columnInfo.getPropName(), value.toString());

}

String errorMsg = "";
//新的校验类
PersonResignOSDChangeFileService.BizBillBaseImportCheckEx ric
= new PersonResignOSDChangeFileService.BizBillBaseImportCheckEx();

//校验员工
if (StringUtils.isEmpty(errorMsg)) {
errorMsg = ric.checkPerson(ctx, validMap);
}

//校验变动原因,变动操作,变动类型
if(StringUtil.isEmpty(validMap.get("empType").toString())){
errorMsg="目标用工状态不应为空。";
}

/**
* 离职操作:辞退
* 离职类型:辞退 劝退
* 离职原因:个人发展,培训不合格,体检不合格,实操期间自动放弃,辞退,培训期间自动放弃,劝退
* 目标用工状态:离职员工
*/
if (StringUtils.isEmpty(errorMsg)) {
errorMsg = ric.checkActionReasonAndVariation(ctx, validMap);
}

/**
* com.kingdee.eas.hr.base.web.CheckEmployeeTypeOperatorService
* com.kingdee.eas.hr.affair.app.HRAffairBillBizBean._check(Context, IObjectPK, IObjectValue)==》
CheckEmployeeTypeOperatorUtil.checkPersonAfterDateModify(ctx, personID, effdt, actionId, targetEmpTypeId, targetPositionId, targetOrgAdminId);

*com.kingdee.eas.hr.base.web.CheckEmployeeTypeOperatorService.checkForMainAction()
*/

//将检验数据的结果最终放置到这个error_report中;
if (!(StringUtils.isEmpty(errorMsg))) {
error_report.put(Integer.valueOf(i), errorMsg);
otherValid = false;
}else{

//添加员工数据进来
dataMaps.add(validMap);
//System.out.println("excel表中的员工是:"+dataMaps);
}
return otherValid;
}

/**
* 内置类 起新的校验功能
*/
static class BizBillBaseImportCheckEx extends BizBillBaseImportCheck{
String errorMsg;
/**
* 校验员工
*/
@Override
public String checkPerson(Context ctx, Map<String, String> validMap)
throws BOSException {
this.errorMsg = "";
//员工编码
String empNumber = (String) validMap.get("empNumber");
//员工姓名
String empName = (String) validMap.get("empName");
int size = 0;
if (StringUtils.isEmpty(empName)) {
this.errorMsg = "人员姓名不能为空!";
return this.errorMsg;
}
//员工列表
PersonCollection pCol = getPersonInfoSize(ctx, empName, empNumber,null, null);
if (pCol != null) {
size = pCol.size();
}
if (StringUtils.isEmpty(empNumber)) {
if (size == 0) {
this.errorMsg = "此在职人员不存在!";
return this.errorMsg;
}
if (size > 1) {
this.errorMsg = "系统存在重名人员,请输入对应人员编码!";
return this.errorMsg;
}
} else if (size == 0) {
this.errorMsg = "人员姓名和编码不匹配,请检查!";
return this.errorMsg;
}

/**
* 员工当前最新的主要任职的企业任职经历的变动操作必须是“入职”或者“录用分配”,
若不是,则不允许导入,错误报告提示:“该员工非入职或分配当日离职,请由系统标准的离职功能进行操作。”
*/
StringBuffer sql1=new StringBuffer();
sql1.append("select fid from t_bd_person where fnumber='")
.append(empNumber)
.append("' and fname_l2='")
.append(empName).append("'");
IRowSet rs1=DbUtil.executeQuery(ctx, sql1.toString());
IObjectPK personPK=null;
try {
if(rs1.next()){
personPK=new ObjectUuidPK(BOSUuid.read(rs1.getString("fid")));
}
} catch (SQLException e) {
e.printStackTrace();
this.errorMsg="查询编号是"+empNumber+"的员工数据时发生错误!";
return this.errorMsg;
}

StringBuffer sql2=new StringBuffer();
sql2.append(" SELECT top 1 eor.fpersonid,eor.FEFFDT bizDate,eor.flastUpdateTime lastupdatetime,action.FNAME_L2 action,empType.FNAME_l2 empType, ")
.append(" case empType.FUSERSTATE when 1 then '启用' when 2 then '禁用' else '其他'end as forbidden ")
.append(" FROM t_hr_emporgrelation eor ")
.append(" left join T_BD_PERSON person on person.FID =eor.fpersonid ")
.append(" left join T_HR_HRBizDefine action on eor.FACTIONID=action.fid ")
.append(" left join T_HR_EmpLaborRelation elr on elr.FID =eor.FLABORRELATIONID ")
.append(" left join T_HR_BDEmployeeType empType on empType.FID=elr.FLABORRELATIONSTATEID ")
.append(" where eor.FPERSONID ='").append(personPK).append("'")
.append(" order by lastupdatetime desc ");
IRowSet rs2=DbUtil.executeQuery(ctx,sql2.toString());
String action="";
Date bizDate=null;
String forbidden="";
try {
if(rs2.next()){
//开始时间
bizDate=rs2.getDate("bizDate");
//变动操作
action=rs2.getString("action");
//用户状态
forbidden=rs2.getString("forbidden");
}
} catch (SQLException e) {
e.printStackTrace();
this.errorMsg="查询员工最新企业任职经历变动操作时发生错误";
return this.errorMsg;
}

/**
* 填写的员工当前的用工关系状态对应的用户状态不能是“禁用”状态,若是,则不允许导入,
错误报告提示:“该员工当前状态不能进行离职操作。
*/
if(forbidden.equals("禁用")){
this.errorMsg="编号为:"+empNumber+"的员工当前状态不能进行离职操作。";
return this.errorMsg;
}

if(!action.equals("入职")&&!action.equals("录用分配")){
this.errorMsg="编号为:"+empNumber+"的员工非入职或分配当日离职,请由系统标准的离职功能进行操作。";
return this.errorMsg;
}

/**
* 填写的离职日期必须与员工当前最新的主要任职的企业任职经历的开始日期是同一天,若不是,则不允许导入,
错误报告提示:“该员工非入职或分配当日离职,请由系统标准的离职功能进行操作。”
*/
if(StringUtil.isEmpty(validMap.get("bizDate").toString())){
this.errorMsg="离职时间不应为空。";
return this.errorMsg;
}else{
if(!sameDay(validMap.get("bizDate").toString(),bizDate)){
this.errorMsg="编号为:"+empNumber+"的员工非入职或分配当日离职,请由系统标准的离职功能进行操作。";
return this.errorMsg;
}
}

return this.errorMsg;
}

}//校验内部类结束

protected static boolean sameDay(String d1,Date d2){
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
try {
return DateTimeUtils.dayEquals(sdf.parse(d1),d2);
} catch (ParseException e) {
e.printStackTrace();
}
return false;
}

protected static Timestamp effect(String d){
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Timestamp ts = null;
try {
ts = new Timestamp(sdf.parse(d+" 00:00:00").getTime());
} catch (ParseException e) {
e.printStackTrace();
}
return ts;
}

/***********************
| 数据导入操作 |
======================*/

//com.kingdee.shr.batchAffair.io.impl.PersonResignChangeFileService
//HRAffairBizBillControllerBean

/**
* 更新操作;
*/
@Override
protected void submitData(ICoreBase corebase, CoreBaseInfo baseInfo)throws ParserException, EASBizException, BOSException {
Context ctx = SHRContext.getInstance().getContext();

// UserInfo currentUserInfo = ContextUtil.getCurrentUserInfo(ctx);
UserInfo uInfo = (UserInfo) ctx.get("UserInfo");
PersonInfo pInfo = uInfo.getPerson();

List<PersonInfo> persons=new ArrayList<PersonInfo>();

Iterator iter=dataMaps.iterator();
while (iter.hasNext()) {
Map<String,Object> dataMap=(Map<String, Object>) iter.next();

String sql="select fid from t_bd_person where fnumber='"+dataMap.get("empNumber")+"' and fname_l2='"+dataMap.get("empName")+"'";
IRowSet rs=DbUtil.executeQuery(ctx,sql);
IObjectPK pid=null;
try {
if(rs.next()){
pid=new ObjectUuidPK(BOSUuid.read(String.valueOf(rs.getString(1))));
}
} catch (UuidException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
/**
* 更新个人信息
*
* 个人信息 用工关系状态 T_BD_Person.FEmployeeTypeID EXCEL中填写的目标用工状态
备注 T_BD_Person.FDescription_L2 EXCEL中填写的备注内容
最新修改人 T_BD_Person.Flastupdateuserid 当前操作用户ID
最新修改时间 T_BD_Person.FLastupdatetime EXCEL导入生效的时间
*
*/
PersonInfo person=PersonFactory.getLocalInstance(ctx).getPersonInfo(pid);
person.setEmployeeType(EmployeeTypeFactory.getLocalInstance(ctx).getEmployeeTypeInfo("where name='"+dataMap.get("empType")+"'"));
person.setDescription(StringUtil.isEmpty((String) dataMap.get("description"))==true?"":dataMap.get("description").toString());
person.setLastUpdateTime(effect(dataMap.get("bizDate").toString()));
person.setLastUpdateUser(uInfo);
PersonFactory.getLocalInstance(ctx).save(person);
/**
* 个人信息历史(针对当前最新记录) 用工关系状态 T_BD_Personhis.FEmployeeTypeID EXCEL中填写的目标用工状态
备注 T_BD_Personhis.FDescription_L2 EXCEL中填写的备注内容
最新修改人 T_BD_Personhis.Flastupdateuserid 当前操作用户ID
最新修改时间 T_BD_Personhis.FLastupdatetime EXCEL导入生效的时间
*/
String sql2="select fid from t_bd_personhis where fnumber='"+dataMap.get("empNumber")+"'";
IRowSet rs2=DbUtil.executeQuery(ctx,sql2);
IObjectPK phisId=null;
try {
if(rs2.next()){
phisId=new ObjectUuidPK(BOSUuid.read(rs2.getString(1)));
}
} catch (UuidException e1) {
e1.printStackTrace();
} catch (SQLException e1) {
e1.printStackTrace();
}
PersonHisInfo personHis=PersonHisFactory.getLocalInstance(ctx).getPersonHisInfo(phisId);
personHis.setEmployeeType(EmployeeTypeFactory.getLocalInstance(ctx).getEmployeeTypeInfo("where name='"+dataMap.get("empType")+"'"));
personHis.setDescription(StringUtil.isEmpty((String) dataMap.get("description"))==true?"":dataMap.get("description").toString());
personHis.setLastUpdateTime(effect(dataMap.get("bizDate").toString()));
personHis.setLastUpdateUser(uInfo);
PersonHisFactory.getLocalInstance(ctx).save(personHis);
/**
* 职业信息
*
* 离职日期 T_HR_PersonPosition.FLeftDate
T_HR_PersonPositionhis.FLeftDate EXCEL中填写的离职日期
离职原因 T_HR_PersonPosition.FDimissionReasonid
T_HR_PersonPositionhis. FDimissionReasonid EXCEL中填写的离职原因
最新修改人 T_HR_PersonPosition.Flastupdateuserid
T_HR_PersonPositionhis. Flastupdateuserid 导入的操作用户ID
最新修改时间 T_HR_PersonPosition. FLastupdatetime
T_HR_PersonPositionhis. FLastupdatetime EXCEL导入生效的时间
*/
String sql3="select top 1 fid from t_hr_personposition where fpersonid='"+pid.toString()+"' order by flastupdatetime desc ";
IRowSet rs3=DbUtil.executeQuery(ctx,sql3.toString());
IObjectPK ppid=null;
try {
if(rs3.next()){
ppid=new ObjectUuidPK(BOSUuid.read(rs3.getString(1)));
}
} catch (UuidException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
PersonPositionInfo personpositionInfo=PersonPositionFactory.getLocalInstance(ctx).getPersonPositionInfo(ppid);
personpositionInfo.setLeftDate(new Date(effect(dataMap.get("bizDate").toString()).getTime()));
personpositionInfo.setDimissionReason(DimissionReasonFactory.getLocalInstance(ctx).getDimissionReasonInfo("where name='"+dataMap.get("variationReason").toString()+"'"));
personpositionInfo.setLastUpdateUser(uInfo);
personpositionInfo.setLastUpdateTime(effect(dataMap.get("bizDate").toString()));
PersonPositionFactory.getLocalInstance(ctx).save(personpositionInfo);
/**
* 职业信息历史(针对当前最新记录)
*/
String sql4="select top 1 fid from t_hr_personpositionhis where fpersonid='"+pid.toString()+"' order by flastupdatetime desc ";
IRowSet rs4=DbUtil.executeQuery(ctx,sql4.toString());
IObjectPK pphisid=null;
try {
if(rs4.next()){
pphisid=new ObjectUuidPK(BOSUuid.read(rs4.getString(1)));
}
} catch (UuidException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
PersonPositionHisInfo personPositionHisInfo=PersonPositionHisFactory.getLocalInstance(ctx).getPersonPositionHisInfo(pphisid);
personPositionHisInfo.setLeftDate(new Date(effect(dataMap.get("bizDate").toString()).getTime()));
personPositionHisInfo.setDimissionReason(DimissionReasonFactory.getLocalInstance(ctx).getDimissionReasonInfo("where name='"+dataMap.get("variationReason").toString()+"'"));
personPositionHisInfo.setLastUpdateUser(uInfo);
personPositionHisInfo.setLastUpdateTime(effect(dataMap.get("bizDate").toString()));
PersonPositionHisFactory.getLocalInstance(ctx).save(personPositionHisInfo);
/**
* 用工关系
*
* 用工关系状态 T_HR_EmpLaborRelation.FLaborRelationStateID EXCEL中填写的目标用工状态
用工关系类型 T_HR_EmpLaborRelation.FEmployeeModleID EXCEL中填写的目标用工状态对应的用工关系类型
最新修改人 T_HR_EmpLaborRelation.Flastupdateuserid 导入的操作用户ID
最新修改时间 T_HR_EmpLaborRelation.FLastupdatetime EXCEL导入生效的时间
*/
String sql5="select top 1 fid from T_HR_EmpLaborRelation where fpersonid='"+pid.toString()+"' order by flastupdatetime desc ";
IRowSet rs5=DbUtil.executeQuery(ctx,sql5.toString());
IObjectPK elrId=null;
try {
if(rs5.next()){
elrId=new ObjectUuidPK(BOSUuid.read(rs5.getString(1)));
}
} catch (UuidException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
EmpLaborRelationInfo empLaborRelationInfo=EmpLaborRelationFactory.getLocalInstance(ctx).getEmpLaborRelationInfo(elrId);
empLaborRelationInfo.setLaborRelationState(EmployeeTypeFactory.getLocalInstance(ctx).getEmployeeTypeInfo("where name='"+dataMap.get("empType").toString()+"'"));
empLaborRelationInfo.setEmployeeModle(EmployeeTypeFactory.getLocalInstance(ctx).getEmployeeTypeInfo("where name='"+dataMap.get("empType").toString()+"'").getEmployeeModle());
empLaborRelationInfo.setLastUpdateTime(effect(dataMap.get("bizDate").toString()));
empLaborRelationInfo.setLastUpdateUser(uInfo);
EmpLaborRelationFactory.getLocalInstance(ctx).save(empLaborRelationInfo);
/**
* 用工关系历史(针对当前最新记录)
*
* 用工关系状态 T_HR_EmpLaborRelationhis.FLaborRelationStateID EXCEL中填写的目标用工状态
用工关系类型 T_HR_EmpLaborRelationhis.FEmployeeModleID EXCEL中填写的目标用工状态对应的用工关系类型
最新修改人 T_HR_EmpLaborRelationhis.Flastupdateuserid 导入操作的用户ID
最新修改时间 T_HR_EmpLaborRelationhis.FLastupdatetime EXCEL导入生效的时间
*/
String sql6="select top 1 fid from T_HR_EmpLaborRelationhis where fpersonid='"+pid.toString()+"' order by flastupdatetime desc ";
IRowSet rs6=DbUtil.executeQuery(ctx,sql6.toString());
IObjectPK elrHisId=null;
try {
if(rs6.next()){
elrHisId=new ObjectUuidPK(BOSUuid.read(rs6.getString(1)));
}
} catch (UuidException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
EmpLaborRelationHisInfo empLaborRelationHisInfo=EmpLaborRelationHisFactory.getLocalInstance(ctx).getEmpLaborRelationHisInfo(elrHisId);
empLaborRelationHisInfo.setLaborRelationState(EmployeeTypeFactory.getLocalInstance(ctx).getEmployeeTypeInfo("where name='"+dataMap.get("empType").toString()+"'"));
empLaborRelationHisInfo.setEmployeeModle(EmployeeTypeFactory.getLocalInstance(ctx).getEmployeeTypeInfo("where name='"+dataMap.get("empType").toString()+"'").getEmployeeModle());
empLaborRelationHisInfo.setLastUpdateTime(effect(dataMap.get("bizDate").toString()));
empLaborRelationHisInfo.setLastUpdateUser(uInfo);
EmpLaborRelationHisFactory.getLocalInstance(ctx).save(empLaborRelationHisInfo);
/**
* 企业任职经历(针对当前最新的主要任职的记录)
*
* 变动操作 T_HR_EmpOrgRelation. FActionID EXCEL中填写的离职操作
变动类型 T_HR_EmpOrgRelation. FActionTypeID EXCEL中填写的离职类型
变动原因 T_HR_EmpOrgRelation. FActionReasonID EXCEL中填写的离职原因对应的变动原因
备注 T_HR_EmpOrgRelation.FRemark EXCEL中填写的备注内容
最新修改人 T_HR_EmpOrgRelation.Flastupdateuserid 导入操作的用户ID
最新修改时间 T_HR_EmpOrgRelation.FLastupdatetime EXCEL导入生效的时间
*/
String sql7="select top 1 fid from T_HR_EmpOrgRelation where fpersonid='"+pid.toString()+"' order by flastupdatetime desc ";
IRowSet rs7=DbUtil.executeQuery(ctx,sql7.toString());
IObjectPK eorId=null;
try {
if(rs7.next()){
eorId=new ObjectUuidPK(BOSUuid.read(rs7.getString(1)));
}
} catch (UuidException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
EmpPosOrgRelationInfo empPosOrgRelationInfo=EmpPosOrgRelationFactory.getLocalInstance(ctx).getEmpPosOrgRelationInfo(eorId);
empPosOrgRelationInfo.setAction(HRBizDefineFactory.getLocalInstance(ctx).getHRBizDefineInfo("where name='"+dataMap.get("hrBizDefine").toString()+"'"));
empPosOrgRelationInfo.setActionType(AffairActionReasonFactory.getLocalInstance(ctx).getAffairActionReasonInfo("where name='"+dataMap.get("affairActionReason").toString()+"'"));
empPosOrgRelationInfo.setActionReason(VariationReasonFactory.getLocalInstance(ctx).getVariationReasonInfo("where name='"+dataMap.get("variationReason").toString()+"'"));
empPosOrgRelationInfo.setDescription(StringUtil.isEmpty((String) dataMap.get("description"))==true?"":dataMap.get("description").toString());
empPosOrgRelationInfo.setLastUpdateUser(uInfo);
empPosOrgRelationInfo.setLastUpdateTime(effect(dataMap.get("bizDate").toString()));
EmpPosOrgRelationFactory.getLocalInstance(ctx).save(empPosOrgRelationInfo);
}
}

/**
* 导入
*/
@Override
public String importData() throws Exception {
// TODO Auto-generated method stub
//return super.importData();
String importData = null;

if (ISRUNNING) {
throw new ShrWebBizException("导入操作未执行完毕,请稍等!");
}

ISRUNNING = true;
try {
importData = super.importData();
} finally {
ISRUNNING = false;
}

return importData;
}
}

标签:get,ctx,kingdee,当天,导入,import,eas,com,离职
来源: https://www.cnblogs.com/luojiabao/p/11102153.html