package com.zt.life.modules.configItemChange.service; import cn.hutool.core.convert.Convert; import com.zt.common.db.query.QueryFilter; import com.zt.common.service.BaseService; import com.zt.life.export.dto.WordFile; import com.zt.life.export.service.WordFileService; import com.zt.life.modules.configItemChange.dao.ConfigItemChangeDao; import com.zt.life.modules.configItemChange.dto.ConfigItemChangeDto; import com.zt.life.modules.configItemChange.model.ConfigItemChange; import com.zt.life.modules.configItemWarehouse.dto.ConfigItemWarehouseDto; import com.zt.life.modules.configItemWarehouse.model.WarehouseCmAudit; import com.zt.life.modules.configItemWarehouse.model.WarehouseConfigItem; import com.zt.life.modules.configItemWarehouse.model.WarehouseQaAudit; import com.zt.life.modules.configItemWarehouse.service.WarehouseCmAuditService; import com.zt.life.modules.configItemWarehouse.service.WarehouseConfigItemService; import com.zt.life.modules.configItemWarehouse.service.WarehouseQaAuditService; import com.zt.life.modules.mainPart.utils.GetFilesPath; import com.zt.life.modules.mainPart.utils.GetShowDictList; import com.zt.life.modules.project.service.ProjectService; import com.zt.life.modules.testCheckOrder.model.TestCheckOrder; import com.zt.life.modules.testCheckOrder.service.TestCheckOrderService; import com.zt.life.sys.service.SysOssConfigService; import com.zt.modules.coderule.service.SysCodeRuleService; import com.zt.modules.oss.service.SysOssService; import com.zt.modules.workflow.dto.FlowInfoDto; import com.zt.modules.workflow.service.WorkflowService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.FileNotFoundException; import java.io.UnsupportedEncodingException; import java.util.HashMap; import java.util.List; import java.util.Map; /** * config_item_warehouse * * @author zt generator * @since 1.0.0 2023-11-27 */ @Service public class ConfigItemChangeService extends BaseService { @Autowired private SysOssConfigService sysOssConfigService; @Autowired private SysOssService sysOssService; @Autowired private WorkflowService workflowService; @Autowired private SysCodeRuleService sysCodeRuleService; @Autowired private ProjectService projectService; @Autowired private WarehouseCmAuditService cmAuditService; @Autowired private WarehouseQaAuditService qaAuditService; @Autowired private WarehouseConfigItemService configItemService; @Autowired private TestCheckOrderService testCheckOrderService; @Autowired private GetShowDictList getShowDictList; @Autowired private WordFileService wordFileService; @Autowired private GetFilesPath getFilesPath; /** * 分页查询 * * @param queryFilter * @return */ public List page(QueryFilter queryFilter) { List list = baseDao.getList(queryFilter.getQueryParams()); if (list.size() > 0) { workflowService.getRunFlow(list, "pzxbg"); } return list; } /** * 删除 * * @param ids */ public void delete(Long[] ids) { super.deleteLogic(ids); } public Boolean save(ConfigItemChangeDto configItemDto) { Long changeId = configItemDto.getConfigItemChange().getId(); if (changeId != null) baseDao.updateById(configItemDto.getConfigItemChange()); else { Map map = new HashMap<>(); map.put("funCode", "config_item_change"); map.put("projectId", configItemDto.getProjectId().toString()); configItemDto.getConfigItemChange().setProjectId(configItemDto.getProjectId()); configItemDto.getConfigItemChange().setCode(sysCodeRuleService.getNewCode(map)); baseDao.insert(configItemDto.getConfigItemChange()); changeId = configItemDto.getConfigItemChange().getId(); } for (WarehouseConfigItem configItem : configItemDto.getConfigChangeList()) { configItem.setWarehouseId(changeId); if (configItem.getId() != null) { configItemService.update(configItem); } else { configItem.setWarehouseId(changeId); configItem.setProjectId(configItemDto.getConfigItemChange().getProjectId()); configItemService.insert(configItem); } Long checkId = configItem.getCheckId(); if (checkId != null) { TestCheckOrder testCheckOrder = testCheckOrderService.get(checkId); if (testCheckOrder.getConfigItemId() == null) { Long configItemId = configItem.getId(); testCheckOrder.setConfigItemId(configItemId); testCheckOrderService.update(testCheckOrder); } } sysOssConfigService.updateOss(configItem.getId(), configItem.getFiles());// 保存附件 } for (WarehouseCmAudit cmAudit : configItemDto.getCmAuditList()) { cmAudit.setWarehouseId(changeId); if (cmAudit.getId() != null) { cmAuditService.update(cmAudit); } else { cmAudit.setWarehouseId(changeId); cmAuditService.insert(cmAudit); } } for (WarehouseQaAudit qaAudit : configItemDto.getQaAuditList()) { qaAudit.setWarehouseId(changeId); if (qaAudit.getId() != null) { qaAuditService.update(qaAudit); } else { qaAudit.setWarehouseId(changeId); qaAuditService.insert(qaAudit); } } Long bizId = configItemDto.getConfigItemChange().getId(); FlowInfoDto flowInfoDto = configItemDto.getFlowInfoDto(); if (flowInfoDto != null && flowInfoDto.getSubmitType() != null && "tj,bl".contains(flowInfoDto.getSubmitType())) { if ("tj".equals(flowInfoDto.getSubmitType())) { workflowService.startFlow(flowInfoDto.getFlowCode(), bizId); } workflowService.approvePass(flowInfoDto.getFlowCode(), bizId, flowInfoDto.getStepIdMark()); } return true; } public ConfigItemChangeDto getDto(Long projectId, Long changeId) { ConfigItemChangeDto data = new ConfigItemChangeDto(); if (changeId != null) { data.setId(changeId); ConfigItemChange configItemChange = this.get(changeId); data.setConfigItemChange(configItemChange); if (projectId == null) { projectId = configItemChange.getProjectId(); } List CmAuditList = cmAuditService.getList(changeId); data.setCmAuditList(CmAuditList); List QaAuditList = qaAuditService.getList(changeId); data.setQaAuditList(QaAuditList); List configChangeList = configItemService.getList(changeId); data.setConfigChangeList(configChangeList); } else { ConfigItemChange configItemChange = new ConfigItemChange(); data.setConfigItemChange(configItemChange); List cmList = baseDao.itemList("change_cm_audit"); List CmAuditList = cmList; data.setCmAuditList((List) CmAuditList); List qaList = baseDao.itemList("change_qa_audit"); List QaAuditList = qaList; data.setQaAuditList((List) QaAuditList); } if (projectId != null) { data.setProjectId(projectId); data.setProject(projectService.get(projectId)); } return data; } public void exportConfigChange(Long id, HttpServletRequest request, HttpServletResponse response) { try { ConfigItemChangeDto dataObj = this.getDto(null, id); String qaAuditorPath = "文件图片:" + getFilesPath.getSignPath(Convert.toLong(dataObj.getConfigItemChange().getQaAuditorId())); dataObj.getConfigItemChange().setQaAuditor(qaAuditorPath); String cmAuditorPath = "文件图片:" + getFilesPath.getSignPath(Convert.toLong(dataObj.getConfigItemChange().getCmAuditorId())); dataObj.getConfigItemChange().setCmAuditor(cmAuditorPath); String implementerPath = "文件图片:" + getFilesPath.getSignPath(Convert.toLong(dataObj.getConfigItemChange().getImplementerId())); dataObj.getConfigItemChange().setImplementer(implementerPath); String approvalSignPath = "文件图片:" + getFilesPath.getSignPath(Convert.toLong(dataObj.getConfigItemChange().getApprovalId())); dataObj.getConfigItemChange().setApprovalSign(approvalSignPath); String warehouseOperatorPath = "文件图片:" + getFilesPath.getSignPath(Convert.toLong(dataObj.getConfigItemChange().getWarehouseOperatorId())); dataObj.getConfigItemChange().setWarehouseOperator(warehouseOperatorPath); /*String outboundOperatorPath = "文件图片:"+getFilesPath.getSignPath(Convert.toLong(dataObj.getConfigItemChange().getOutboundOperatorId())); dataObj.getConfigItemChange().setOutboundOperator(outboundOperatorPath);*/ //通用字典列表字符串生成 String libraryTypeStr = getShowDictList.getShowDictList(dataObj.getConfigItemChange().getLibraryType(), "library_type", false); dataObj.getConfigItemChange().setLibraryType(libraryTypeStr); String QaAuditResultStr = getShowDictList.getShowDictList(dataObj.getConfigItemChange().getQaAuditResults(), "is_pass", false); dataObj.getConfigItemChange().setQaAuditResults(QaAuditResultStr); String CmAuditResultStr = getShowDictList.getShowDictList(dataObj.getConfigItemChange().getCmAuditResults(), "is_pass", false); dataObj.getConfigItemChange().setCmAuditResults(CmAuditResultStr); String ApprovalOpinionStr = getShowDictList.getShowDictList(dataObj.getConfigItemChange().getApprovalOpinions(), "is_agree", false); dataObj.getConfigItemChange().setApprovalOpinions(ApprovalOpinionStr); for (WarehouseCmAudit cmAuditList : dataObj.getCmAuditList()) { String value = cmAuditList.getExamineResult(); String ExamineResultStr = getShowDictList.getShowDictList(value, "tristate2", false); cmAuditList.setExamineResult(ExamineResultStr); } for (WarehouseQaAudit qaAuditList : dataObj.getQaAuditList()) { String value = qaAuditList.getExamineResult(); String ExamineResultStr = getShowDictList.getShowDictList(value, "tristate2", false); qaAuditList.setExamineResult(ExamineResultStr); } for (WarehouseConfigItem configItemList : dataObj.getConfigChangeList()) { String value = configItemList.getSecretClass(); String secretClassStr = getShowDictList.getShowDictList(value, "secret_class", false); configItemList.setSecretClass(secretClassStr); } WordFile wordFile = new WordFile(); wordFile.setModulePath("配置项变更申请单.docx"); wordFile.setWordName(dataObj.getProject().getSoftwareName() + "_配置项变更申请单.docx"); wordFileService.exportWordFile(request, dataObj, wordFile, response); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } } }