196 lines
7.5 KiB
Java
196 lines
7.5 KiB
Java
package weaver.interfaces.hzzx.action;
|
|
|
|
import com.engine.hzzx.conn.DataUtil;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import weaver.conn.RecordSet;
|
|
import weaver.hrm.resource.ResourceComInfo;
|
|
import weaver.interfaces.workflow.action.Action;
|
|
import weaver.soa.workflow.request.*;
|
|
|
|
import java.util.*;
|
|
|
|
/**
|
|
* @author:dxfeng
|
|
* @createTime: 2025/02/28
|
|
* @version: 1.0
|
|
*/
|
|
public class TrainingEffectManageAction implements Action {
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
@Override
|
|
public String execute(RequestInfo requestInfo) {
|
|
try {
|
|
int creatorId = requestInfo.getRequestManager().getCreater();
|
|
MainTableInfo mainTableInfo = requestInfo.getMainTableInfo();
|
|
Property[] properties = mainTableInfo.getProperty();
|
|
Map<String, String> mainDataMap = new HashMap<>();
|
|
for (Property property : properties) {
|
|
mainDataMap.put(property.getName(), property.getValue());
|
|
}
|
|
|
|
List<Map<String, String>> detailDataList = new ArrayList<>();
|
|
DetailTableInfo detailTableInfo = requestInfo.getDetailTableInfo();
|
|
DetailTable detailTable = detailTableInfo.getDetailTable(0);
|
|
Row[] rows = detailTable.getRow();
|
|
for (Row row : rows) {
|
|
Map<String, String> detailDataMap = new HashMap<>();
|
|
Cell[] cells = row.getCell();
|
|
for (Cell cell : cells) {
|
|
detailDataMap.put(cell.getName(), cell.getValue());
|
|
}
|
|
detailDataList.add(detailDataMap);
|
|
}
|
|
|
|
|
|
// 培训名称
|
|
String pxmc = mainDataMap.get("pxmc");
|
|
// 培训效果评估方式
|
|
String pxxgpgfs = mainDataMap.get("pxxgpgfs");
|
|
// 培训已完成组织
|
|
String pxywczz = mainDataMap.get("pxywczz");
|
|
// 培训符合归档要求
|
|
String pxfhgdyq = mainDataMap.get("pxfhgdyq");
|
|
|
|
/*查询培训基本信息*/
|
|
Map<String, String> trainInfoMap = new HashMap<>();
|
|
rs.executeQuery("select * from uf_pxsssq where id = ? ", pxmc);
|
|
if (rs.next()) {
|
|
trainInfoMap.put("pxmc", rs.getString("pxmc"));
|
|
trainInfoMap.put("pxzt", rs.getString("pxzt"));
|
|
trainInfoMap.put("pxsj", rs.getString("pxsj"));
|
|
trainInfoMap.put("jssjyc", rs.getString("jssjyc"));
|
|
trainInfoMap.put("pxdd", rs.getString("pxdd"));
|
|
trainInfoMap.put("szbm", rs.getString("szbm"));
|
|
trainInfoMap.put("pxdx", rs.getString("pxdx"));
|
|
trainInfoMap.put("pxrs", rs.getString("pxrs"));
|
|
trainInfoMap.put("xs", rs.getString("xs"));
|
|
trainInfoMap.put("jf", rs.getString("jf"));
|
|
}
|
|
|
|
Map<String, String> trainEmployeesMap = new HashMap<>();
|
|
trainEmployeesMap.put("pxmc", pxmc);
|
|
trainEmployeesMap.put("pxqssj", trainInfoMap.get("pxsj"));
|
|
trainEmployeesMap.put("pxjssj", trainInfoMap.get("jssjyc"));
|
|
trainEmployeesMap.put("pxzt", trainInfoMap.get("pxzt"));
|
|
trainEmployeesMap.put("pxxs", trainInfoMap.get("xs"));
|
|
trainEmployeesMap.put("pxjf", trainInfoMap.get("jf"));
|
|
trainEmployeesMap.put("pxzzdw", mainDataMap.get("szbm"));
|
|
// TODO 待确定
|
|
trainEmployeesMap.put("pxxs_", null);
|
|
|
|
// 写入员工培训信息
|
|
insertTrainEmployees(String.valueOf(creatorId), pxmc, pxxgpgfs, new HashMap<>(trainEmployeesMap));
|
|
|
|
Map<String, String> trainerMap = new HashMap<>();
|
|
trainerMap.put("pxmc", pxmc);
|
|
trainerMap.put("pxqssj", trainInfoMap.get("pxsj"));
|
|
trainerMap.put("pxjssj", trainInfoMap.get("jssjyc"));
|
|
trainerMap.put("pxzt", trainInfoMap.get("pxzt"));
|
|
trainerMap.put("pxzzdw", mainDataMap.get("szbm"));
|
|
|
|
if (!"0".equals(pxywczz)) {
|
|
return SUCCESS;
|
|
}
|
|
|
|
|
|
// 写入培训授课信息
|
|
for (Map<String, String> detailData : detailDataList) {
|
|
String pxsnb = detailData.get("pxsnb");
|
|
if (StringUtils.isNotBlank(pxsnb)) {
|
|
insertTrainer(pxsnb, String.valueOf(creatorId), pxmc, new HashMap<>(trainerMap));
|
|
}
|
|
}
|
|
|
|
return SUCCESS;
|
|
} catch (Exception e) {
|
|
rs.writeLog(e);
|
|
requestInfo.getRequestManager().setMessagecontent(e.getMessage());
|
|
return FAILURE_AND_CONTINUE;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 根据培训名称、查询培训签到表的数据,如果满足任一条件,员工培训记录写入员工档案
|
|
*
|
|
* @param creatorId
|
|
* @param pxmc
|
|
* @param pxxgpgfs
|
|
* @param trainEmployeesMap
|
|
*/
|
|
private void insertTrainEmployees(String creatorId, String pxmc, String pxxgpgfs, Map<String, String> trainEmployeesMap) throws Exception {
|
|
String sql = "select xm from uf_grqdtz where pxmc = ? ";
|
|
// 培训效果评估方式 == 培训效果评估表
|
|
if ("0".equals(pxxgpgfs)) {
|
|
sql += " and pxxgpgbsftj = 0 ";
|
|
} else {
|
|
sql += " and (pxxgpgbsftj = 0 or kssftg = 0 or khsftg = 0)";
|
|
}
|
|
rs.executeQuery(sql, pxmc);
|
|
List<String> list = new ArrayList<>();
|
|
while (rs.next()) {
|
|
list.add(rs.getString("xm"));
|
|
}
|
|
|
|
ResourceComInfo resourceComInfo = new ResourceComInfo();
|
|
String insertTableName = "uf_pxxx";
|
|
|
|
int formModeId = DataUtil.getModeIdByTableName(insertTableName);
|
|
trainEmployeesMap.put("formmodeid", String.valueOf(formModeId));
|
|
DataUtil.buildModeInsertFields(trainEmployeesMap, creatorId);
|
|
|
|
// 遍历人员,插入培训信息表
|
|
for (String userId : list) {
|
|
String workCode = resourceComInfo.getWorkcode(userId);
|
|
trainEmployeesMap.put("gh", workCode);
|
|
trainEmployeesMap.put("xm", userId);
|
|
// 插入数据
|
|
String uuid = UUID.randomUUID().toString();
|
|
trainEmployeesMap.put("modeuuid", uuid);
|
|
DataUtil.insertData(trainEmployeesMap, insertTableName);
|
|
DataUtil.refreshRight(uuid, insertTableName, formModeId, creatorId);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* 插入培训授课信息
|
|
*
|
|
* @param trainer
|
|
* @param creatorId
|
|
* @param pxmc
|
|
* @param trainerMap
|
|
* @throws Exception
|
|
*/
|
|
private void insertTrainer(String trainer, String creatorId, String pxmc, Map<String, String> trainerMap) throws Exception {
|
|
ResourceComInfo resourceComInfo = new ResourceComInfo();
|
|
String workCode = resourceComInfo.getWorkcode(trainer);
|
|
trainerMap.put("gh", workCode);
|
|
trainerMap.put("xm", trainer);
|
|
// 查询导师数据
|
|
rs.executeQuery("select * from uf_pxsssq_dt1 where sklsnb = ? and mainid = ?", trainer, pxmc);
|
|
if (rs.next()) {
|
|
String jf = rs.getString("jf");
|
|
String xs = rs.getString("xs");
|
|
trainerMap.put("pxskxs", xs);
|
|
trainerMap.put("pxskjf", jf);
|
|
}
|
|
|
|
String insertTableName = "uf_pxskxx";
|
|
int formModeId = DataUtil.getModeIdByTableName(insertTableName);
|
|
trainerMap.put("formmodeid", String.valueOf(formModeId));
|
|
DataUtil.buildModeInsertFields(trainerMap, creatorId);
|
|
|
|
// 插入数据
|
|
String uuid = UUID.randomUUID().toString();
|
|
trainerMap.put("modeuuid", uuid);
|
|
DataUtil.insertData(trainerMap, insertTableName);
|
|
DataUtil.refreshRight(uuid, insertTableName, formModeId, creatorId);
|
|
}
|
|
|
|
|
|
}
|