认证工程师-分配填写人开发。

上报库导出明细,带历史Log
This commit is contained in:
wangzhijiang
2022-12-12 16:56:51 +08:00
parent e4cc5c5f51
commit e0f22e765e
7 changed files with 293 additions and 2 deletions
@@ -659,4 +659,16 @@ public class ParamsCollectManifestEOController extends JeroController<ParamsColl
public Result<?> mandatoryWithdraw(ParamsCollectManifestVO paramsCollectManifestVO) {
return this.paramsCollectManifestEOService.mandatoryWithdraw(paramsCollectManifestVO);
}
/**
* 认证工程师-分配填写人
* @param paramsCollectManifestVO
* @return
*/
@AutoLog(value = "参数项收集清单-认证工程师-分配填写人")
@ApiOperation(value="参数项收集清单-认证工程师-分配填写人", notes="参数项收集清单-认证工程师-分配填写人")
@PostMapping(value = "/certifiedEngineerUpdateDreBatch")
public Result<?> certifiedEngineerUpdateDreBatch(ParamsCollectManifestVO paramsCollectManifestVO) {
return this.paramsCollectManifestEOService.certifiedEngineerUpdateDreBatch(paramsCollectManifestVO);
}
}
@@ -190,4 +190,7 @@ public interface IParamsCollectManifestEOService extends IService<ParamsCollectM
// 认证工程师-强制撤回
Result<?> mandatoryWithdraw(ParamsCollectManifestVO paramsCollectManifestVO);
// 认证工程师-批量修改填写人
Result<?> certifiedEngineerUpdateDreBatch(ParamsCollectManifestVO paramsCollectManifestVO);
}
@@ -5219,6 +5219,193 @@ public class ParamsCollectManifestEOServiceImpl extends ServiceImpl<ParamsCollec
return Result.OK("强制撤回成功!");
}
@Override
public Result<?> certifiedEngineerUpdateDreBatch(ParamsCollectManifestVO paramsCollectManifestVO) {
if (StringUtils.isEmpty(paramsCollectManifestVO.getIds())
|| StringUtils.isEmpty(paramsCollectManifestVO.getDre())
|| StringUtils.isEmpty(paramsCollectManifestVO.getProjectId()) || StringUtils.isEmpty(paramsCollectManifestVO.getParamsManifestId())) {
throw new JeroBootException("参数不能为空!");
}
String paramsCollectManifestIds = paramsCollectManifestVO.getIds();
String dre = paramsCollectManifestVO.getDre();
String projectId = paramsCollectManifestVO.getProjectId();
String paramsManifestId = paramsCollectManifestVO.getParamsManifestId();
ParamsManifestEO paramsManifestEO = paramsManifestEOService.queryById(paramsManifestId); // 获取清单信息
ParamsManifestVO projectInfo = paramsManifestEOService.getProjectById(projectId, paramsManifestEO.getProjectVersion()); // 获取项目信息
paramsManifestEO.setProjectName(projectInfo.getProjectName());
String[] paramsCollectManifestIdArr = paramsCollectManifestIds.split(",");
List<ParamsCollectManifestEO> updateEOList = new ArrayList<>();
LambdaQueryWrapper<ParamsCollectManifestEO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(ParamsCollectManifestEO::getId, Arrays.asList(paramsCollectManifestIdArr))
.orderByAsc(ParamsCollectManifestEO::getDeadline).orderByAsc(ParamsCollectManifestEO::getNioNumber);
List<ParamsCollectManifestEO> paramsCollectManifestEOList = this.list(queryWrapper);
Date deadline = paramsCollectManifestEOList.get(0).getDeadline();
// 存放数据的前后填写与工程接口人信息
List<Map<String,Object>> paramsCollectManifestMapList = new ArrayList<>();
for (ParamsCollectManifestEO paramsCollectManifestEO : paramsCollectManifestEOList) {
// 如果新分发的填写人和原填写人一致,直接跳过。
if(StringUtils.equals(dre,paramsCollectManifestEO.getDre())){
continue;
}
Map<String,Object> paramsCollectManifestMap = new HashMap<>();
paramsCollectManifestMap.put("paramsCollectManifestId",paramsCollectManifestEO.getId());
paramsCollectManifestMap.put("dreUpdateFront",paramsCollectManifestEO.getDre());
paramsCollectManifestMap.put("dreUpdateAfter",dre);
paramsCollectManifestMap.put("sdt",paramsCollectManifestEO.getSdt());
paramsCollectManifestMap.put("paramsCollectManifestEO",paramsCollectManifestEO);
paramsCollectManifestMapList.add(paramsCollectManifestMap);
ParamsCollectManifestEO updateEO = new ParamsCollectManifestEO();
updateEO.setId(paramsCollectManifestEO.getId());
updateEO.setDre(dre); // 设置填写人
updateEO.setState(CollectManifestStateEnum.WAIT_FILL.getValue()); // 设置状态为:待填写
updateEOList.add(updateEO);
}
if(CollectionUtils.isNotEmpty(updateEOList)){
this.updateBatchById(updateEOList);
// 发送变更消息
this.sendChangeMessage(paramsCollectManifestMapList,paramsManifestEO,projectInfo,dre,deadline);
}
return Result.OK("分配填写人成功!");
}
/**
* 发送变更消息
* @param paramsCollectManifestMapList
* @param paramsManifestEO 清单信息
* @param projectInfo
* @param dre
* @param deadline
*/
public void sendChangeMessage(List<Map<String,Object>> paramsCollectManifestMapList,ParamsManifestEO paramsManifestEO,ParamsManifestVO projectInfo,String dre,Date deadline){
LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if(CollectionUtils.isNotEmpty(paramsCollectManifestMapList)){
// 工程接口人
Map<String, List<Map<String,Object>>> sdtGroupMap = paramsCollectManifestMapList.stream().collect(Collectors.groupingBy((m -> (m.get("sdt").toString()))));
for (Map.Entry<String, List<Map<String, Object>>> sdtMap : sdtGroupMap.entrySet()) {
String sdtUserName = sdtMap.getKey();
String nioNumbers = "";
List<Map<String, Object>> value = sdtMap.getValue();
for (Map<String, Object> map : value) {
ParamsCollectManifestEO paramsCollectManifestEO = JSONObject.parseObject(JSONObject.toJSONString(map.get("paramsCollectManifestEO")), ParamsCollectManifestEO.class);
String nioNumber = paramsCollectManifestEO.getNioNumber();
nioNumbers += nioNumber + ",";
}
if(StringUtils.isNotEmpty(nioNumbers)){
nioNumbers = nioNumbers.substring(0,nioNumbers.length()-1);
}
String cnContentUpper = "您参与填写的参数 " + nioNumbers + ",已被 " + currentUser.getUsername() + " 重新分发给 " + dre + "请及时查看。";
String enContentUpper = "The parameter " + nioNumbers + " you distributed have been re-assigned to " + currentUser.getUsername() + " by " + dre;
// 消息内容
SysUser sysUser = this.sysUserService.getUserByName(sdtUserName);
String[] thirdIds = new String[1];
thirdIds[0] = sysUser.getThirdId();
String urlParamsStr = parseUrlParams(paramsManifestEO);
String hrefFeishu = this.backUrl + "/ParameterItemCollection" + urlParamsStr;
FeishuMsg2Vo feishuMsgVo = new FeishuMsg2Vo();
feishuMsgVo.setTitle(MessageType2Enum.HOMO_PARAMETER_COLLECTION.getCn() + "/" + MessageType2Enum.HOMO_PARAMETER_COLLECTION.getEn());
feishuMsgVo.setCnContentUpper(cnContentUpper);
feishuMsgVo.setCnContentLower("项目: " + projectInfo.getProjectName() +
"\n发起人: " + currentUser.getUsername());
feishuMsgVo.setEnContentUpper(enContentUpper);
feishuMsgVo.setEnContentLower("Project: " + projectInfo.getProjectName() +
"\nInitiator: " + currentUser.getUsername());
feishuMsgVo.setUrl(hrefFeishu);
feishuMsgVo.setColor(MsgColorEnum.GREEN.getValue());
try {
this.feishuService.sendCard(thirdIds, feishuMsgVo);
} catch (IOException e) {
log.error("飞书消息推送失败");
}
}
// 修改前填写人
Map<String, List<Map<String,Object>>> dreUpdateFrontGroupMap = paramsCollectManifestMapList.stream().collect(Collectors.groupingBy((m -> (m.get("dreUpdateFront").toString()))));
for (Map.Entry<String, List<Map<String, Object>>> dreUpdateFrontMap : dreUpdateFrontGroupMap.entrySet()) {
String dreUpdateFront = dreUpdateFrontMap.getKey();
String nioNumbers = "";
List<Map<String, Object>> value = dreUpdateFrontMap.getValue();
for (Map<String, Object> map : value) {
ParamsCollectManifestEO paramsCollectManifestEO = JSONObject.parseObject(JSONObject.toJSONString(map.get("paramsCollectManifestEO")), ParamsCollectManifestEO.class);
String nioNumber = paramsCollectManifestEO.getNioNumber();
nioNumbers += nioNumber + ",";
}
if(StringUtils.isNotEmpty(nioNumbers)){
nioNumbers = nioNumbers.substring(0,nioNumbers.length()-1);
}
String cnContentUpper = "您参与填写的参数 " + nioNumbers + " 已被 "+ currentUser.getUsername() +" 撤回。";
String enContentUpper = "The parameter " + nioNumbers + " you filled in have been withdrawn by "+ currentUser.getUsername();
// 消息内容
SysUser sysUser = sysUserService.getUserByName(dreUpdateFront);
String[] thirdIds = new String[1];
thirdIds[0] = sysUser.getThirdId();
String urlParamsStr = parseUrlParams(paramsManifestEO);
String hrefFeishu = backUrl + "/ParameterItemCollection" + urlParamsStr;
FeishuMsg2Vo feishuMsgVo = new FeishuMsg2Vo();
feishuMsgVo.setTitle(MessageType2Enum.HOMO_PARAMETER_COLLECTION.getCn() + "/" + MessageType2Enum.HOMO_PARAMETER_COLLECTION.getEn());
feishuMsgVo.setCnContentUpper(cnContentUpper);
feishuMsgVo.setCnContentLower("项目: " + projectInfo.getProjectName() +
"\n发起人: " + currentUser.getUsername());
feishuMsgVo.setEnContentUpper(enContentUpper);
feishuMsgVo.setEnContentLower("Project: " + projectInfo.getProjectName() +
"\nInitiator: " + currentUser.getUsername());
feishuMsgVo.setUrl(hrefFeishu);
feishuMsgVo.setColor(MsgColorEnum.GREEN.getValue());
try {
this.feishuService.sendCard(thirdIds, feishuMsgVo);
} catch (IOException e) {
log.error("飞书消息推送失败");
}
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// 修改后填写人
Map<String, List<Map<String,Object>>> dreUpdateAfterGroupMap = paramsCollectManifestMapList.stream().collect(Collectors.groupingBy((m -> (m.get("dreUpdateAfter").toString()))));
for (Map.Entry<String, List<Map<String, Object>>> dreUpdateAfterMap : dreUpdateAfterGroupMap.entrySet()) {
String dreUpdateAfter = dreUpdateAfterMap.getKey();
// 消息内容
SysUser sysUser = sysUserService.getUserByName(dreUpdateAfter);
String[] thirdIds = new String[1];
thirdIds[0] = sysUser.getThirdId();
String urlParamsStr = parseUrlParams(paramsManifestEO);
String hrefFeishu = backUrl + "/ParameterItemCollection" + urlParamsStr;
FeishuMsg2Vo feishuMsgVo = new FeishuMsg2Vo();
feishuMsgVo.setTitle(MessageType2Enum.HOMO_PARAMETER_COLLECTION.getCn() + "/" + MessageType2Enum.HOMO_PARAMETER_COLLECTION.getEn());
feishuMsgVo.setCnContentUpper("您好,"+ currentUser.getUsername() +"向您分发了认证参数填写任务,请及时处理。");
feishuMsgVo.setCnContentLower("项目: " + projectInfo.getProjectName() +
"\n发起人: " + currentUser.getUsername() +
"\n截止时间: " + sdf.format(deadline));
feishuMsgVo.setEnContentUpper("Hello! "+ currentUser.getUsername() +" has assigned the task of filling in Homo Parameter to you. Please address it in a timely manner.");
feishuMsgVo.setEnContentLower("Project: " + projectInfo.getProjectName() +
"\nInitiator: " + currentUser.getUsername() +
"\nDue Date: " + sdf.format(deadline));
feishuMsgVo.setUrl(hrefFeishu);
feishuMsgVo.setColor(MsgColorEnum.GREEN.getValue());
try {
this.feishuService.sendCard(thirdIds, feishuMsgVo);
} catch (IOException e) {
log.error("飞书消息推送失败");
}
}
}
}
private void deadlineDateMap(Map<String, List<String>> today, ParamsCollectManifestEO collectManifestEO, String thirdId) {
List<String> stringList = today.get(thirdId);
if (ObjectUtils.isEmpty(stringList)) {
@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.modules.cert.report.entity.ParamsReportConfigDataEO;
import com.jero.modules.cert.report.entity.ParamsReportDetailEO;
import com.jero.modules.cert.report.vo.ParamsReportDetailVO;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -68,4 +70,7 @@ public interface IParamsReportDetailEOService extends IService<ParamsReportDetai
// 引用参考列时的查询
List<ParamsReportConfigDataEO> listInfoForReferencesCol(String paramsReportId, String paramsReportConfigId);
// 导出参数项历史Log信息
void exportParamsReportDetailLog(String cut, XSSFWorkbook workbook, String sheetHistoryName, List<Map<String, Object>> allParamsInfoList, XSSFCellStyle headerCellStyle,XSSFCellStyle bodyCellStyle);
}
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ZipUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
@@ -38,6 +39,7 @@ import com.jero.modules.split.common.ReadExcel;
import com.jero.modules.system.entity.SysDictItem;
import com.jero.modules.system.service.ISysDictItemService;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.util.HSSFColor;
@@ -600,8 +602,10 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
String fileName = fileOriName + ".xlsx";
// 设置表格相关属性
String sheetName = "参数项信息";
String sheetHistoryName = "历史记录";
if (CutEnum.EN.getValue().equals(paramsReportDetailVO.getCut())) {
sheetName = "Params data";
sheetHistoryName = "historical Record";
}
XSSFSheet sheetItems = workbook.createSheet(sheetName);
String[] titles = getWorkbookTitleForExport(paramsReportDetailVO); // 获取表头
@@ -670,6 +674,8 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
}
// 导出参数明细历史
this.exportParamsReportDetailLog(paramsReportDetailVO.getCut(), workbook, sheetHistoryName, allParamsInfoList,cellStyle1,cellStyle);
//下载关联文件内容
if (allRelevFileList != null && !allRelevFileList.isEmpty()) {
allRelevFileList = allRelevFileList.stream().distinct().collect(Collectors.toList());
@@ -714,6 +720,7 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
os.close(); // 后开先关
fis.close(); // 先开后关
} catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage(), e);
if (CutEnum.EN.getValue().equals(paramsReportDetailVO.getCut())) {
throw new JeroBootException("Failed to download file, please try again");
@@ -729,6 +736,79 @@ public class ParamsReportDetailEOServiceImpl extends ServiceImpl<ParamsReportDet
}
}
@Override
public void exportParamsReportDetailLog(String cut, XSSFWorkbook workbook, String sheetHistoryName, List<Map<String, Object>> allParamsInfoList,XSSFCellStyle headerCellStyle,XSSFCellStyle bodyCellStyle) {
// 处理历史log sheet里面的数据
XSSFSheet sheetHistory = workbook.createSheet(sheetHistoryName);
String[] historyHeaderArr = new String[]{"NIO编号","操作详情","备注","操作时间"};
if (StringUtils.equals(cut, CutEnum.EN.getValue())) {
historyHeaderArr = new String[]{"NIO Number", "Operation Details", "Comments", "Operation Time"};
}
XSSFRow historyRowFirst = sheetHistory.createRow(0);
for (int i = 0; i < historyHeaderArr.length; i++) {
XSSFCell cell = historyRowFirst.createCell(i);
XSSFRichTextString text = new XSSFRichTextString(historyHeaderArr[i]);
cell.setCellValue(text);
cell.setCellStyle(headerCellStyle);
// 设置单元格宽度
String[] ParamsValueArr = new String[]{"操作详情","备注"};
if (CutEnum.EN.getValue().equals(cut)) {
ParamsValueArr = new String[]{"Operation Details","Comments"};
}
String historyHeaderStr = historyHeaderArr[i];
boolean widthFlag = false;
for (int i1 = 0; i1 < ParamsValueArr.length; i1++) {
if(StringUtils.equals(historyHeaderStr,ParamsValueArr[i1])){
widthFlag = true;
}
}
if(widthFlag){
sheetHistory.setColumnWidth(i, 80 * 256);
}else {
sheetHistory.setColumnWidth(i, 20 * 256);
}
}
// 查询历史log信息
List<String> detailIdList = allParamsInfoList.stream().map(e -> e.get("id").toString()).distinct().collect(Collectors.toList());
QueryWrapper<ParamsReportDetailLogEO> detailLogQueryWrap = new QueryWrapper<>();
detailLogQueryWrap.lambda().in(ParamsReportDetailLogEO::getParamsReportDetailId,detailIdList);
detailLogQueryWrap.orderByDesc("params_report_detail_id");
List<ParamsReportDetailLogEO> detailLogList = this.paramsReportDetailLogEOService.list(detailLogQueryWrap);
if (CollectionUtils.isNotEmpty(detailLogList)) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
int historyRowNumber = 1;
for (int i = 0; i < detailLogList.size(); i++) {
String paramsReportDetailId = detailLogList.get(i).getParamsReportDetailId();
String nioNumber = allParamsInfoList.stream().filter(paramsInfo -> {
boolean flag = false;
if(StringUtils.equals(paramsInfo.get("id").toString(),paramsReportDetailId)){
flag = true;
}
return flag;
}).map(e -> e.get("nio_number").toString()).distinct().collect(Collectors.toList()).get(0);
String operatorDetails = detailLogList.get(i).getLogCnContent();
String operatorTime = sdf.format(detailLogList.get(i).getCreateTime());
if(StringUtils.equals(cut,CutEnum.EN.getValue())){
operatorDetails = detailLogList.get(i).getLogEnContent();
}
XSSFRow row1 = sheetHistory.createRow(historyRowNumber);
row1.createCell(0).setCellValue(nioNumber);
row1.createCell(1).setCellValue(operatorDetails);
row1.createCell(2).setCellValue(detailLogList.get(i).getRemarks());
row1.createCell(3).setCellValue(operatorTime);
for (int j = 0; j < 4; j++) {
row1.getCell(j).setCellStyle(bodyCellStyle);
}
historyRowNumber ++;
}
}
}
@Override
public List<Map<String, String>> getConfigLabelList(ParamsReportDetailVO paramsReportDetailVO) {
String paramsManifestId = paramsReportDetailVO.getParamsManifestId();
@@ -204,7 +204,7 @@ export default {
this.confirmLoading = false
this.$emit('GetgetLoginUserType')
this.$emit('GetgetTableList')
this.$emit('areaVisibleAssignedbyflag', false)
this.$emit('areaVisibleAssignedbyflaghomo', false)
}else{
this.confirmLoading = false
_this.$message.warning(_this.$t('operationFailed'))
@@ -319,7 +319,7 @@
<assigned-by-homo v-if='areaVisibleAssignedbyhomo' :selectedRowKeysArray='selectedRowKeysArray'
@GetgetTableList='GetgetTableList'
@GetgetLoginUserType='GetgetLoginUserType'
@areaVisibleAssignedbyflag='areaVisibleAssignedbyflag' @areaVisible='areaVisibleAssignedbyhomo = false'/>
@areaVisibleAssignedbyflaghomo='areaVisibleAssignedbyflaghomo' @areaVisible='areaVisibleAssignedbyhomo = false'/>
</a-modal>
<!-- 下发收集--->
<!-- <a-modal v-model="areaVisibleTaskCutOffTime" :title="$t('distributionAndCollection')" width='400px' :footer="null">-->
@@ -1780,6 +1780,10 @@
areaVisibleAssignedbyflag(val) {
this.areaVisibleAssignedby = val
},
// 认证分配填写人确定后弹框关闭
areaVisibleAssignedbyflaghomo(val) {
this.areaVisibleAssignedbyhomo = val
},
// 截止时间
// TaskCutOffTimeLibrary() {
// let dreTaskCutOffTimeLibrary = this.dreTaskCutOffTimeLibrary()