| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.whyc.config.EnumWorksheetType; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.ProductBomApprovingMapper; |
| | | import com.whyc.mapper.WorksheetLinkMapper; |
| | | import com.whyc.pojo.*; |
| | | import com.whyc.util.CommonUtil; |
| | | import com.whyc.util.FileUtil; |
| | | import com.whyc.util.WordUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | |
| | | @Autowired |
| | | private ProductHistoryService phService; |
| | | |
| | | @Autowired |
| | | private ProcedureDocApprovingService procedureDocApprovingService; |
| | | |
| | | @Autowired |
| | | private ProcedureDocService procedureDocService; |
| | | |
| | | @Transactional |
| | | public void audit(WorksheetLink link) { |
| | |
| | | public DocUser getApprovingUser(Integer mainId) { |
| | | return linkMapper.getApprovingUser(mainId); |
| | | } |
| | | |
| | | @Transactional |
| | | public Response confirmProductProcedureAndSOP(WorksheetLink link) throws IOException { |
| | | Integer mainId = linkMapper.selectById(link.getId()).getMainId(); |
| | | //更新子表 |
| | | linkMapper.updateById(link); |
| | | if(link.getLinkStatus() ==1){ |
| | | //查询当前单据子表是否已经全部同意 |
| | | QueryWrapper<WorksheetLink> query = Wrappers.query(); |
| | | query.eq("main_id",mainId); |
| | | List<WorksheetLink> linkList = linkMapper.selectList(query); |
| | | List<WorksheetLink> rejectList = linkList.stream().filter(linkFilter -> linkFilter.getLinkStatus() != 1).collect(Collectors.toList()); |
| | | if(rejectList == null){ |
| | | //都为1,已确认 |
| | | mainService.updateEndStatusById(mainId,"已确认",5); |
| | | //文件转移到审批完成后的正式路径 文件保存在/doc_file/procedure/xxx.doc |
| | | ProcedureDocApproving approving = procedureDocApprovingService.getByMainId(mainId); |
| | | String fileRelativePath = approving.getFile(); |
| | | String projectDir = CommonUtil.getProjectDir(); |
| | | String inFilePath = projectDir + File.separator + fileRelativePath; |
| | | String outFilePath = (projectDir + File.separator + fileRelativePath).replace("_approving",""); |
| | | WordUtil.fillValue(inFilePath,outFilePath,Arrays.asList(approving.getFzr(),approving.getBz(),approving.getZz(),approving.getPb())); |
| | | //流程文件数据转移 |
| | | ProcedureDoc procedureDoc = new ProcedureDoc(); |
| | | procedureDoc.setName(approving.getName()); |
| | | procedureDoc.setDescription(approving.getDescription()); |
| | | procedureDoc.setVersion(approving.getVersion()); |
| | | procedureDoc.setFzr(approving.getFzr()); |
| | | procedureDoc.setBz(approving.getBz()); |
| | | procedureDoc.setType(approving.getType()); |
| | | procedureDoc.setCreateTime(new Date()); |
| | | procedureDoc.setFile(fileRelativePath.replace("_approving","")); |
| | | procedureDocService.insert(procedureDoc); |
| | | } |
| | | }else{ |
| | | mainService.updateEndStatusById(mainId,"已驳回",0); |
| | | } |
| | | return new Response().set(1); |
| | | } |
| | | } |