| | |
| | | package com.zt.life.modules.itemCirculatOrder.service; |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import com.zt.common.service.BaseService; |
| | | import com.zt.core.sys.dto.DictDto; |
| | | import com.zt.core.sys.dto.DictItemDto; |
| | | import com.zt.core.sys.dto.DictLeafDto; |
| | | import com.zt.life.export.dto.WordFile; |
| | | import com.zt.life.export.service.WordFileService; |
| | | import com.zt.life.modules.configItemWarehouse.model.ConfigItemWarehouse; |
| | | import com.zt.life.modules.itemCirculatOrder.dao.ItemCirculatOrderDao; |
| | | import com.zt.life.modules.itemCirculatOrder.dto.ItemCirculatOrderDto; |
| | | import com.zt.life.modules.itemCirculatOrder.model.ItemCirculatOrder; |
| | | import com.zt.life.modules.itemCirculatOrder.model.ItemCirculatOrderTechnical; |
| | | import com.zt.life.modules.project.dto.SoftwareTestOrderDto; |
| | | import com.zt.life.modules.mainPart.utils.GetShowDictList; |
| | | import com.zt.life.modules.mainPart.utils.GetFilesPath; |
| | | import com.zt.life.modules.project.model.*; |
| | | import com.zt.life.modules.project.service.ProjectService; |
| | | import com.zt.life.modules.project.service.SoftwareTestOrderService; |
| | | import com.zt.life.modules.sysBaseInfo.service.TestAgencyInfoService; |
| | | import com.zt.life.sys.dto.OssDto; |
| | | 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 com.zt.common.db.query.QueryFilter; |
| | | import javax.annotation.Resource; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | /** |
| | | * item_circulat_order |
| | | * |
| | | * @author zt generator |
| | | * @author zt generator |
| | | * @since 1.0.0 2023-11-22 |
| | | */ |
| | | @Service |
| | | public class ItemCirculatOrderService extends BaseService<ItemCirculatOrderDao, ItemCirculatOrder> { |
| | | public class ItemCirculatOrderService extends BaseService<ItemCirculatOrderDao, ItemCirculatOrder> { |
| | | @Autowired |
| | | private SysOssConfigService sysOssConfigService; |
| | | |
| | |
| | | private ItemCirculatOrderTechnicalService technicalService; |
| | | |
| | | @Autowired |
| | | private SoftwareTestOrderService softwareTestOrderService; |
| | | private WorkflowService workflowService; |
| | | |
| | | @Autowired |
| | | private GetShowDictList getShowDictList; |
| | | |
| | | @Autowired |
| | | private WordFileService wordFileService; |
| | | |
| | | @Autowired |
| | | private GetFilesPath getFilesPath; |
| | | |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | |
| | | * @return |
| | | */ |
| | | public List<ItemCirculatOrder> page(QueryFilter queryFilter) { |
| | | return baseDao.getList(queryFilter.getQueryParams()); |
| | | List<ItemCirculatOrder> list= baseDao.getList(queryFilter.getQueryParams()); |
| | | if (list.size() > 0) { |
| | | workflowService.getRunFlow(list, "wplz"); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | /**yi |
| | | * 删除 |
| | | * |
| | | * @param ids |
| | |
| | | } |
| | | |
| | | public Boolean save(ItemCirculatOrderDto itemCirculatOrderDto) { |
| | | Long circulatOrderid = itemCirculatOrderDto.getCirculatOrder().getId(); |
| | | if (circulatOrderid != null) |
| | | Long circulatOrderId = itemCirculatOrderDto.getCirculatOrder().getId(); |
| | | if (circulatOrderId != null) |
| | | baseDao.updateById(itemCirculatOrderDto.getCirculatOrder()); |
| | | else { |
| | | Map<String, String> map = new HashMap<>(); |
| | | map.put("funCode", "item_circulat_order"); |
| | | map.put("projectId",itemCirculatOrderDto.getProjectId().toString()); |
| | | map.put("projectId", itemCirculatOrderDto.getProjectId().toString()); |
| | | itemCirculatOrderDto.getCirculatOrder().setProjectId(itemCirculatOrderDto.getProjectId()); |
| | | itemCirculatOrderDto.getCirculatOrder().setCode(sysCodeRuleService.getNewCode(map)); |
| | | baseDao.insert(itemCirculatOrderDto.getCirculatOrder()); |
| | | circulatOrderid = itemCirculatOrderDto.getCirculatOrder().getId(); |
| | | circulatOrderId = itemCirculatOrderDto.getCirculatOrder().getId(); |
| | | } |
| | | |
| | | for (ItemCirculatOrderTechnical circulatOrderTechnical : itemCirculatOrderDto.getTechnicalList()) { |
| | | circulatOrderTechnical.setCirculatOrderId(circulatOrderid); |
| | | circulatOrderTechnical.setCirculatOrderId(circulatOrderId); |
| | | if (circulatOrderTechnical.getId() != null) { |
| | | technicalService.update(circulatOrderTechnical); |
| | | } else { |
| | | circulatOrderTechnical.setCirculatOrderId(circulatOrderid); |
| | | circulatOrderTechnical.setCirculatOrderId(circulatOrderId); |
| | | technicalService.insert(circulatOrderTechnical); |
| | | } |
| | | sysOssConfigService.updateOss(circulatOrderTechnical.getId(), circulatOrderTechnical.getFiles());// 保存附件 |
| | | } |
| | | |
| | | if (itemCirculatOrderDto.getTestAgencyInfo().getId() == 10000) { |
| | | itemCirculatOrderDto.getTestAgencyInfo().setId(circulatOrderid); |
| | | itemCirculatOrderDto.getTestAgencyInfo().setId(circulatOrderId); |
| | | testAgencyInfoService.insert(itemCirculatOrderDto.getTestAgencyInfo()); |
| | | } else { |
| | | testAgencyInfoService.update(itemCirculatOrderDto.getTestAgencyInfo()); |
| | | } |
| | | sysOssConfigService.updateOss(itemCirculatOrderDto.getId(), itemCirculatOrderDto.getFiles());// 保存附件 |
| | | |
| | | Long bizId = itemCirculatOrderDto.getCirculatOrder().getId(); |
| | | FlowInfoDto flowInfoDto = itemCirculatOrderDto.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 ItemCirculatOrderDto getDto(Long projectId, Long circulatOrderid) { |
| | | public ItemCirculatOrderDto getDto(Long projectId, Long circulatOrderId) { |
| | | ItemCirculatOrderDto data = new ItemCirculatOrderDto(); |
| | | if (circulatOrderid != null) { |
| | | data.setId(circulatOrderid); |
| | | ItemCirculatOrder itemCirculatOrder = this.get(circulatOrderid); |
| | | if (circulatOrderId != null) { |
| | | data.setId(circulatOrderId); |
| | | ItemCirculatOrder itemCirculatOrder = this.get(circulatOrderId); |
| | | data.setCirculatOrder(itemCirculatOrder); |
| | | if (projectId == null) { |
| | | projectId = itemCirculatOrder.getProjectId(); |
| | | } |
| | | |
| | | projectId = itemCirculatOrder.getProjectId(); |
| | | data.setTestAgencyInfo(testAgencyInfoService.get(circulatOrderId)); |
| | | |
| | | data.setTestAgencyInfo(testAgencyInfoService.get(circulatOrderid)); |
| | | |
| | | List<ItemCirculatOrderTechnical> technicalList = technicalService.getList(circulatOrderid); |
| | | List<ItemCirculatOrderTechnical> technicalList = technicalService.getList(circulatOrderId); |
| | | data.setTechnicalList(technicalList); |
| | | |
| | | } else { |
| | | ItemCirculatOrder itemCirculatOrder =new ItemCirculatOrder(); |
| | | ItemCirculatOrder itemCirculatOrder = new ItemCirculatOrder(); |
| | | data.setCirculatOrder(itemCirculatOrder); |
| | | List<?> resultList = baseDao.itemList(projectId); |
| | | List<?> resultList = technicalService.itemList(projectId); |
| | | List<?> technicalList = resultList; |
| | | data.setTechnicalList((List<ItemCirculatOrderTechnical>) technicalList); |
| | | |
| | | } |
| | | |
| | | if (projectId != null) { |
| | | data.setProjectId(projectId); |
| | | data.setProject(projectService.get(projectId)); |
| | | Project project = projectService.get(projectId); |
| | | String type = project.getSoftwareType(); |
| | | if (type == "3") { |
| | | type = "2"; |
| | | } else { |
| | | type = "1"; |
| | | } |
| | | project.setSoftwareType(type); |
| | | data.setProject(project); |
| | | } |
| | | |
| | | if (data.getTestAgencyInfo() == null) |
| | | data.setTestAgencyInfo(testAgencyInfoService.get(10000L)); |
| | | |
| | | if (circulatOrderId != null) { |
| | | for (ItemCirculatOrderTechnical technical : data.getTechnicalList()) { |
| | | Long technicalId = technical.getId(); |
| | | OssDto ossDto = sysOssConfigService.getOssByBusiType(technicalId, "circulat_order"); |
| | | if (ossDto != null) { |
| | | technical.setFiles(ossDto); |
| | | } |
| | | } |
| | | } |
| | | return data; |
| | | } |
| | | |
| | | public void exportCirculatOrder(Long id, HttpServletRequest request, HttpServletResponse response) { |
| | | try { |
| | | ItemCirculatOrderDto dataObj = this.getDto(null, id); |
| | | |
| | | String acceptorPath = "文件图片:"+ getFilesPath.getSignPath(Convert.toLong(dataObj.getCirculatOrder().getItemAcceptorId())); |
| | | dataObj.getCirculatOrder().setItemAcceptor(acceptorPath); |
| | | String detectorPath = "文件图片:"+getFilesPath.getSignPath(Convert.toLong(dataObj.getCirculatOrder().getCalibratDetectorId())); |
| | | dataObj.getCirculatOrder().setCalibratDetector(detectorPath); |
| | | String issuerPath = "文件图片:"+getFilesPath.getSignPath(Convert.toLong(dataObj.getCirculatOrder().getItemIssuerId())); |
| | | dataObj.getCirculatOrder().setItemIssuer(issuerPath); |
| | | //通用字典列表字符串生成 |
| | | String itemRequireStr = getShowDictList.getShowDictList(dataObj.getCirculatOrder().getItemRequire(), "is_or_not", false); |
| | | dataObj.getCirculatOrder().setItemRequireStr(itemRequireStr); |
| | | |
| | | String acceptSituationStr = getShowDictList.getShowDictList(dataObj.getCirculatOrder().getAcceptSituation(), "is_or_not", false); |
| | | dataObj.getCirculatOrder().setAcceptSituationStr(acceptSituationStr); |
| | | |
| | | String detectSituationStr = getShowDictList.getShowDictList(dataObj.getCirculatOrder().getDetectSituation(), "is_or_not", false); |
| | | dataObj.getCirculatOrder().setDetectSituationStr(detectSituationStr); |
| | | |
| | | String issueSituationStr = getShowDictList.getShowDictList(dataObj.getCirculatOrder().getIssueSituation(), "is_or_not", false); |
| | | dataObj.getCirculatOrder().setIssueSituationStr(issueSituationStr); |
| | | |
| | | for (ItemCirculatOrderTechnical technical : dataObj.getTechnicalList()) { |
| | | String value = technical.getSecretClass(); |
| | | String secretClassStr = getShowDictList.getShowDictList(value, "secret_class", false); |
| | | technical.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(); |
| | | } |
| | | } |
| | | |
| | | } |