ecology-develop/src/weaver/interfaces/hzzx/action/TrainingManageEndAction.java

234 lines
10 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package weaver.interfaces.hzzx.action;
import com.alibaba.fastjson.JSON;
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/03/27
* @version: 1.0
*/
public class TrainingManageEndAction implements Action {
RecordSet rs = new RecordSet();
@Override
public String execute(RequestInfo requestInfo) {
try {
String trainingEffectFlowId = TrainingManageCreateFlowAction.FLOW_ID;
String trainingEffectTableName = DataUtil.getTableNameById(trainingEffectFlowId);
String requestId = requestInfo.getRequestid();
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 pxfhgdyq = mainDataMap.get("pxfhgdyq");
String pxxgpgfs = mainDataMap.get("pxxgpgfs");
String pxmc = mainDataMap.get("pxmc");
rs.writeLog("pxfhgdyq==" + pxfhgdyq + "pxxgpgfs==" + pxxgpgfs);
if (!"0".equals(pxfhgdyq) || StringUtils.isBlank(pxxgpgfs)) {
return SUCCESS;
}
//查询培训基本信息
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("xzk", rs.getString("xzk"));
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"));
}
switch (pxxgpgfs) {
case "0":
// 培训效果评估表
assessment(String.valueOf(creatorId), requestId, trainingEffectTableName, mainDataMap, trainInfoMap);
break;
case "1":
case "2":
//考试、考核
exam(String.valueOf(creatorId), mainDataMap, trainInfoMap, pxxgpgfs);
default:
break;
}
Map<String, String> trainerMap = new HashMap<>();
trainerMap.put("pxmc", pxmc);
trainerMap.put("pxqssj", mainDataMap.get("sjpxjhkssj"));
trainerMap.put("pxjssj", mainDataMap.get("sjpxjhjssj"));
trainerMap.put("pxzt", trainInfoMap.get("xzk"));
trainerMap.put("pxzzdw", mainDataMap.get("pxzzbm"));
// 写入培训授课信息
for (Map<String, String> detailData : detailDataList) {
String pxsnb = detailData.get("pxsnb");
rs.writeLog("pxsnb==" + 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 mainDataMap
*/
private void assessment(String creatorId, String requestId, String trainingEffectTableName, Map<String, String> mainDataMap, Map<String, String> trainInfoMap) throws Exception {
// 查询流程归档的人
rs.executeQuery("select a.xm from " + trainingEffectTableName + " a inner join workflow_requestbase b on a.requestid =b.requestid and b.currentnodetype =3 where a.lc= ? ", requestId);
List<String> userIdList = new ArrayList<>();
while (rs.next()) {
userIdList.add(rs.getString("xm"));
}
rs.writeLog("userIdList==" + JSON.toJSONString(userIdList));
String insertTableName = "uf_pxxx";
ResourceComInfo resourceComInfo = new ResourceComInfo();
Map<String, String> trainEmployeesMap = new HashMap<>();
trainEmployeesMap.put("pxmc", mainDataMap.get("pxmc"));
trainEmployeesMap.put("pxqssj", mainDataMap.get("sjpxjhkssj"));
trainEmployeesMap.put("pxjssj", mainDataMap.get("sjpxjhjssj"));
trainEmployeesMap.put("pxzt", trainInfoMap.get("xzk"));
trainEmployeesMap.put("pxxs", trainInfoMap.get("xs"));
trainEmployeesMap.put("pxjf", trainInfoMap.get("jf"));
trainEmployeesMap.put("pxzzdw", mainDataMap.get("pxzzbm"));
int formModeId = DataUtil.getModeIdByTableName(insertTableName);
trainEmployeesMap.put("formmodeid", String.valueOf(formModeId));
DataUtil.buildModeInsertFields(trainEmployeesMap, creatorId);
for (String userId : userIdList) {
Map<String, String> insertMap = new HashMap<>(trainEmployeesMap);
insertMap.put("xm", userId);
insertMap.put("gh", resourceComInfo.getWorkcode(userId));
// 插入数据
String uuid = UUID.randomUUID().toString();
insertMap.put("modeuuid", uuid);
rs.writeLog("insertMap==" + JSON.toJSONString(insertMap));
DataUtil.insertData(insertMap, insertTableName);
DataUtil.refreshRight(uuid, insertTableName, formModeId, creatorId);
// 更新个人签到台账
rs.executeUpdate("update uf_grqdtz set pxxgpgbsftj = 0 where xm = ? and pxmc = ? ", userId, mainDataMap.get("pxmc"));
}
}
private void exam(String creatorId, Map<String, String> mainDataMap, Map<String, String> trainInfoMap, String type) throws Exception {
String drlzy = mainDataMap.get("drlzy");
List<String> userIdList = new ArrayList<>();
if (StringUtils.isNotBlank(drlzy)) {
String[] userIds = drlzy.split(",");
userIdList.addAll(Arrays.asList(userIds));
}
rs.writeLog("userIdList==" + JSON.toJSONString(userIdList));
String sql = "update uf_grqdtz set kssftg = 0 where xm = ? and pxmc = ? ";
if ("2".equals(type)) {
sql = "update uf_grqdtz set khsftg = 0 where xm = ? and pxmc = ? ";
}
String insertTableName = "uf_pxxx";
ResourceComInfo resourceComInfo = new ResourceComInfo();
Map<String, String> trainEmployeesMap = new HashMap<>();
trainEmployeesMap.put("pxmc", mainDataMap.get("pxmc"));
trainEmployeesMap.put("pxqssj", mainDataMap.get("sjpxjhkssj"));
trainEmployeesMap.put("pxjssj", mainDataMap.get("sjpxjhjssj"));
trainEmployeesMap.put("pxzt", trainInfoMap.get("xzk"));
trainEmployeesMap.put("pxxs", trainInfoMap.get("xs"));
trainEmployeesMap.put("pxjf", trainInfoMap.get("jf"));
trainEmployeesMap.put("pxzzdw", mainDataMap.get("pxzzbm"));
int formModeId = DataUtil.getModeIdByTableName(insertTableName);
trainEmployeesMap.put("formmodeid", String.valueOf(formModeId));
DataUtil.buildModeInsertFields(trainEmployeesMap, creatorId);
for (String userId : userIdList) {
Map<String, String> insertMap = new HashMap<>(trainEmployeesMap);
insertMap.put("xm", userId);
insertMap.put("gh", resourceComInfo.getWorkcode(userId));
// 插入数据
String uuid = UUID.randomUUID().toString();
insertMap.put("modeuuid", uuid);
rs.writeLog("insertMap==" + JSON.toJSONString(insertMap));
DataUtil.insertData(insertMap, insertTableName);
DataUtil.refreshRight(uuid, insertTableName, formModeId, creatorId);
// 更新个人签到台账
rs.executeUpdate(sql, userId, mainDataMap.get("pxmc"));
}
}
/**
* 插入培训授课信息
*
* @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);
rs.writeLog("trainerMap==" + JSON.toJSONString(trainerMap));
DataUtil.insertData(trainerMap, insertTableName);
DataUtil.refreshRight(uuid, insertTableName, formModeId, creatorId);
}
}