qa-prevention-gwj/src/main/java/com/zcloud/service/xgf/impl/TrainingBatchServiceImpl.java

417 lines
16 KiB
Java
Raw Normal View History

2023-12-18 20:24:02 +08:00
package com.zcloud.service.xgf.impl;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
2023-12-20 14:49:01 +08:00
import com.zcloud.mapper.datasource.system.DepartmentMapper;
2023-12-18 20:24:02 +08:00
import com.zcloud.mapper.datasource.system.UsersMapper;
import com.zcloud.mapper.datasource.xgf.*;
import com.zcloud.service.xgf.TrainingBatchService;
import com.zcloud.util.*;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.text.DecimalFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
*
* luoxiaobao
* 2023-05-08
* www.zcloudchina.com
*/
@Service
@Transactional //开启事物
public class TrainingBatchServiceImpl implements TrainingBatchService {
2023-12-21 19:55:08 +08:00
@Resource
private TrainingBatchMapper trainingbatchMapper;
@Resource
private TrainUsersMapper trainUsersMapper;
@Resource
private XgfUserMapper xgfUserMapper;
@Resource
private FlowMapper flowMapper;
@Resource
private FlowDetailMapper flowDetailMapper;
@Resource
private UsersMapper usersMapper;
@Resource
private DepartmentMapper departmentMapper;
/**
*
*
* @param pd
* @throws Exception
*/
public void save(PageData pd) throws Exception {
/* 保存主题信息 */
String batch_id = UuidUtil.get32UUID();
String train_area = pd.getString("TRAIN_AREA");
pd.put("TRAINING_BATCH_ID", batch_id); //主键
pd.put("CREATOR", Jurisdiction.getUsername()); //添加人
pd.put("CREATTIME", DateUtil.date2Str(new Date())); //添加时间
pd.put("OPERATOR", Jurisdiction.getUsername()); //修改人
pd.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
pd.put("ISDELETE", 0); //是否删除 1-是 0-否
Calendar calendar = Calendar.getInstance();
DecimalFormat dft = new DecimalFormat("00");
int year = calendar.get(Calendar.YEAR);
String month = dft.format(calendar.get(Calendar.MONTH) + 1);
pd.put("CREATDATE", year + "-" + month);
PageData cpd = trainingbatchMapper.getCode(pd); //根据ID读取
String code = year + "-" + month + "-" + dft.format((Integer.parseInt(cpd.get("code").toString()) + 1));
pd.put("BATCH_NAME", code);
/*翻译*/
PageData condition = new PageData();
condition.put("USER_ID", pd.get("SUPERVISION_USER_ID"));
PageData supUser = usersMapper.getUserInfo(condition);
pd.put("SUPERVISION_USER_NAME", supUser.get("NAME"));
condition.clear();
condition.put("DEPARTMENT_ID", pd.get("SUPERVISION"));
PageData supDepartment = departmentMapper.getInfo(condition);
pd.put("SUPERVISION_DEPARTMENT_NAME", supDepartment.get("NAME"));
condition.clear();
condition.put("USER_ID", pd.get("MANAGER_USER_ID"));
PageData manUser = usersMapper.getUserInfo(condition);
pd.put("MANAGER_USER_NAME", manUser.get("NAME"));
condition.clear();
condition.put("DEPARTMENT_ID", pd.get("MANAGER"));
PageData manDepartment = departmentMapper.getInfo(condition);
pd.put("MANAGER_DEPARTMENT_NAME", manDepartment.get("NAME"));
// 2023-12-21 相关方功能限制,暂时移除集团单位审批节点 created by sparrow
if (StringUtils.isNotEmpty(pd.getString("TERRITORIALITY_USER_ID"))) {
condition.clear();
condition.put("USER_ID", pd.get("TERRITORIALITY_USER_ID"));
PageData terUser = usersMapper.getUserInfo(condition);
pd.put("TERRITORIALITY_USER_NAME", terUser == null ? "" : terUser.get("NAME"));
condition.clear();
condition.put("DEPARTMENT_ID", pd.get("TERRITORIALITY"));
PageData terDepartment = departmentMapper.getInfo(condition);
pd.put("TERRITORIALITY_DEPARTMENT_NAME", terDepartment == null ? "" : terDepartment.get("NAME"));
}
pd.put("IS_DELETE", "0");
pd.put("STEP_STATUS", "1");
trainingbatchMapper.save(pd);
String arrayDATA_ids[] = pd.getString("users").split(",");
Arrays.asList(arrayDATA_ids).forEach(id -> {
PageData user = new PageData();
user.put("TRAIN_USERS_ID", UuidUtil.get32UUID());
user.put("TRAINING_BATCH_ID", batch_id);
user.put("USER_ID", id);
user.put("TRAIN_AREA", train_area);
user.put("STATUS", 0);
user.put("SUPERVISION_STATE", 9);
user.put("MANAGER_STATE", 9);
user.put("TERRITORIALITY_STATE", 9);
user.put("STEP_STATUS", "1");
user.put("BELONG_TO_CORP", pd.get("BELONG_TO_CORP"));
user.put("BELONG_TO_CORP_NAME", pd.get("BELONG_TO_CORP_NAME"));
user.put("IS_DELETE", "0");
user.put("RESULT_STATUS", "1");
trainUsersMapper.save(user);
condition.clear();
condition.put("XGF_USER_ID", id);
PageData userEntity = xgfUserMapper.findById(condition);
userEntity.put("STATUS", "3");
userEntity.put("STUDY_STATUS", "9");
xgfUserMapper.edit(userEntity);
});
/* 保存审批流程信息 */
PageData flow = new PageData();
flow.put("FLOW_ID", Warden.get32UUID());
flow.put("TYPE", "0");
flow.put("CREATOR", Jurisdiction.getUSER_ID());
flow.put("CREATOR_NAME", Jurisdiction.getName());
flow.put("CREATOR_TIME", DateUtil.getTime());
flow.put("VALID_FLAG", "1");
flow.put("FOREIGN_KEY", pd.getString("TRAINING_BATCH_ID"));
flow.put("ISDELETE", "0");
flowMapper.save(flow);
/* 保存审批流程明细信息 */
PageData flowDetail = new PageData();
flowDetail.put("FLOW_DETAIL_ID", Warden.get32UUID());
flowDetail.put("FLOW_ID", flow.getString("FLOW_ID"));
flowDetail.put("STEP_FLAG", "1");
flowDetail.put("SORT", 0);
flowDetail.put("APPROVER_ID", Jurisdiction.getUSER_ID());
flowDetail.put("APPROVER_NAME", Jurisdiction.getName());
flowDetail.put("APPROVER_TIME", DateUtil.getTime());
flowDetail.put("APPROVER_CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
// TODO 未完成
flowDetail.put("APPROVER_CORPINFO_NAME", "");
flowDetail.put("PASS_FLAG", "1");
flowDetail.put("END_FLAG", "0");
flowDetail.put("ISDELETE", "0");
flowDetail.put("PARENT_ID", "0");
flowDetailMapper.save(flowDetail);
}
/**
*
*
* @param pd
* @throws Exception
*/
public void unflowTrain(PageData pd) throws Exception {
PageData trainBatch = new PageData();
String batch_id = UuidUtil.get32UUID();
trainBatch.put("TRAINING_BATCH_ID", batch_id); //主键
trainBatch.put("CREATOR", pd.getString("TRAIN_CORP_LEADER_NAME")); //添加人
trainBatch.put("CREATTIME", DateUtil.date2Str(new Date())); //添加时间
trainBatch.put("OPERATOR", pd.getString("TRAIN_CORP_LEADER_NAME")); //修改人
trainBatch.put("OPERATTIME", DateUtil.date2Str(new Date())); //修改时间
trainBatch.put("ISDELETE", 0); //是否删除 1-是 0-否
trainBatch.put("TYPE", 1);
trainBatch.put("USER_COUNT", pd.getString("USER_COUNT"));
trainBatch.put("AUDIT_STATUS", 0);
trainBatch.put("TRAIN_CORP_DEPT", pd.getString("TRAIN_CORP_DEPT"));
trainBatch.put("TRAIN_CORP_LEADER", pd.getString("TRAIN_CORP_LEADER"));
Calendar calendar = Calendar.getInstance();
DecimalFormat dft = new DecimalFormat("00");
int year = calendar.get(Calendar.YEAR);
String month = dft.format(calendar.get(Calendar.MONTH) + 1);
trainBatch.put("CREATDATE", year + "-" + month);
PageData cpd = trainingbatchMapper.getCode(trainBatch); //根据ID读取
String code = year + "-" + month + "-" + dft.format((Integer.parseInt(cpd.get("code").toString()) + 1));
trainBatch.put("BATCH_NAME", code);
trainingbatchMapper.save(trainBatch);
trainBatch.put("AUDIT_STATUS", "2");
this.audit(trainBatch);
String arrayDATA_IDS[] = pd.getString("users").split(",");
Arrays.asList(arrayDATA_IDS).forEach(id -> {
PageData user = new PageData();
user.put("TRAIN_USERS_ID", UuidUtil.get32UUID());
user.put("TRAINING_BATCH_ID", batch_id);
user.put("USER_ID", id);
user.put("TRAIN_CORPINFO_ID", pd.getString("FIRST_PARTY_ID"));
user.put("STATUS", 1);
user.put("START_DATE", DateUtil.date2Str(new Date()));
user.put("SUPERVISION_STATE", 9);
user.put("MANAGER_STATE", 9);
user.put("TERRITORIALITY_STATE", 9);
user.put("STEP_STATUS", "0");
trainUsersMapper.save(user);
});
xgfUserMapper.bantchUpdateStatus(1, arrayDATA_IDS);
}
/**
*
*
* @param pd
* @throws Exception
*/
public void delete(PageData pd) throws Exception {
trainingbatchMapper.delete(pd);
}
/**
*
*
* @param pd
* @throws Exception
*/
public void edit(PageData pd) throws Exception {
trainingbatchMapper.edit(pd);
}
public void audit(PageData pd) throws Exception {
if (Integer.parseInt(pd.getString("AUDIT_STATUS")) == -1) {
pd.put("STATUS", 0);
pd.put("ENTRUST_TIME", DateUtil.date2Str(new Date()));
xgfUserMapper.updateStatusByFlowTrain(pd);
trainingbatchMapper.audit(pd);
} else if (Integer.parseInt(pd.getString("AUDIT_STATUS")) == 2) {
pd.put("STATUS", 1);
pd.put("START_DATE", DateUtil.date2Str(new Date()));
pd.put("AUDIT_TIME", DateUtil.date2Str(new Date()));
xgfUserMapper.updateStatusByFlowTrain(pd);
trainUsersMapper.updateStatusByFlowTrain(pd);
trainingbatchMapper.audit(pd);
} else if (Integer.parseInt(pd.getString("AUDIT_STATUS")) == 3) {
pd.put("STATUS", 2);
pd.put("END_DATE", DateUtil.date2Str(new Date()));
pd.put("VERIFY_TIME", DateUtil.date2Str(new Date()));
xgfUserMapper.updateStatusByFlowTrain(pd);
trainUsersMapper.updateStatusByFlowTrain(pd);
trainingbatchMapper.audit(pd);
} else {
pd.put("ENTRUST_TIME", DateUtil.date2Str(new Date()));
trainingbatchMapper.audit(pd);
}
}
/**
*
*
* @param page
* @throws Exception
*/
public List<PageData> list(Page page) throws Exception {
return trainingbatchMapper.datalistPage(page);
}
/**
* ()
*
* @param pd
* @throws Exception
*/
public List<PageData> listAll(PageData pd) throws Exception {
return trainingbatchMapper.listAll(pd);
}
/**
* id
*
* @param pd
* @throws Exception
*/
public PageData findById(PageData pd) throws Exception {
return trainingbatchMapper.findById(pd);
}
/**
*
*
* @param ArrayDATA_IDS
* @throws Exception
*/
public void deleteAll(String[] ArrayDATA_IDS) throws Exception {
trainingbatchMapper.deleteAll(ArrayDATA_IDS);
}
/**
*
*
* @param pd
* @return
*/
@Override
public PageData getCode(PageData pd) throws Exception {
return trainingbatchMapper.getCode(pd);
}
public List<PageData> batchUserlistPage(Page page) throws Exception {
return trainingbatchMapper.batchUserlistPage(page);
}
@Override
public List<PageData> passUserlistPage(Page page) throws Exception {
return trainingbatchMapper.passUserlistPage(page);
}
@Override
public void graduation(PageData condition) {
trainingbatchMapper.graduation(condition);
xgfUserMapper.graduation(condition);
}
@Override
public void openClass(PageData info) {
List<PageData> list = Warden.getList(info.getString("list"));
PageData condition = new PageData();
condition.put("STATUS", info.getString("userStatus"));
condition.put("list", list.stream().filter(n -> "1".equals(n.getString("STATUS"))).map(n -> n.getString("USER_ID")).collect(Collectors.toList()));
xgfUserMapper.graduation(condition);
condition.clear();
condition.put("STATUS", info.getString("detailsStatus"));
condition.put("list", list.stream().filter(n -> "1".equals(n.getString("STATUS"))).map(n -> n.getString("TRAIN_USERS_ID")).collect(Collectors.toList()));
trainUsersMapper.graduation(condition);
}
@Override
public void openStudentClass(PageData info) {
2023-12-18 20:24:02 +08:00
// List<PageData> list = Warden.getList(info.getString("list"));
2023-12-21 19:55:08 +08:00
PageData condition = new PageData();
condition.put("STATUS", info.getString("userStatus"));
condition.put("USER_ID", info.getString("USER_ID"));
xgfUserMapper.graduationstudent(condition);
condition.clear();
condition.put("STATUS", info.getString("detailsStatus"));
condition.put("TRAIN_USERS_ID", info.getString("TRAIN_USERS_ID"));
trainUsersMapper.graduationstudent(condition);
}
@Override
public void updateClassMessage(PageData info) {
List<PageData> list = Warden.getList(info.getString("list"));
PageData condition = new PageData();
condition.put("list", list.stream().map(n -> n.getString("TRAIN_USERS_ID")).collect(Collectors.toList()));
if (StringUtils.isNotEmpty(info.getString("START_DATE"))) {
condition.put("START_DATE", DateUtil.getTime());
}
if (StringUtils.isNotEmpty(info.getString("END_DATE"))) {
condition.put("END_DATE", DateUtil.getTime());
}
trainUsersMapper.updateDate(condition);
}
@Override
public void saveFlow(PageData request) throws Exception {
/* 保存审批流程明细信息 */
PageData condition = new PageData();
condition.put("FLOW_ID", request.getString("FLOW_ID"));
condition.put("STEP_FLAG", "1");
PageData flow = flowDetailMapper.selectOne(condition);
flow.put("STEP_FLAG", "0");
flowDetailMapper.edit(flow);
PageData next_flow = new PageData();
next_flow.put("FLOW_DETAIL_ID", Warden.get32UUID());
next_flow.put("FLOW_ID", flow.getString("FLOW_ID"));
next_flow.put("STEP_FLAG", "1");
next_flow.put("SORT", (Integer) flow.get("SORT") + 1);
next_flow.put("APPROVER_ID", request.get("APPROVER_ID"));
next_flow.put("APPROVER_NAME", request.get("APPROVER_NAME"));
next_flow.put("APPROVER_TIME", DateUtil.getTime());
next_flow.put("APPROVER_CORPINFO_ID", request.get("APPROVER_CORPINFO_ID"));
next_flow.put("APPROVER_CORPINFO_NAME", request.get("APPROVER_CORPINFO_NAME"));
next_flow.put("PASS_FLAG", "1");
next_flow.put("END_FLAG", "0");
next_flow.put("ISDELETE", "0");
next_flow.put("PARENT_ID", flow.getString("FLOW_DETAIL_ID"));
flowDetailMapper.save(next_flow);
}
@Override
public List<PageData> findByUserId(PageData condition) throws Exception {
return trainingbatchMapper.findByUserId(condition);
}
2023-12-25 18:17:09 +08:00
@Override
public List<PageData> oldBatchList(Page page) throws Exception {
return trainingbatchMapper.oldlistPage(page);
}
2023-12-18 20:24:02 +08:00
}