| | |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.config.EnumWorksheetType; |
| | | import com.whyc.dto.MailDTO; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.dto.WorksheetMainDTO; |
| | | import com.whyc.dto.WorksheetMainDTO2; |
| | |
| | | import com.whyc.util.CommonUtil; |
| | | import com.whyc.util.Zip4jUtil; |
| | | import org.aspectj.util.FileUtil; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.mail.MessagingException; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.text.SimpleDateFormat; |
| | |
| | | |
| | | @Autowired |
| | | private ProductHistoryService productHistoryService; |
| | | |
| | | @Autowired |
| | | private MailService mailService; |
| | | |
| | | @Autowired |
| | | private ProcedureDocApprovingService procedureDocApprovingService; |
| | | |
| | | @Transactional |
| | | public boolean submit(WorksheetMain main, DocUser user) throws IOException { |
| | |
| | | |
| | | } |
| | | |
| | | public Response addProductProcedureAndSOP(ProcedureDocApproving approving, DocUser user) throws IOException, MessagingException { |
| | | WorksheetMain main = new WorksheetMain(); |
| | | //存储上传信息到主表,节点表 |
| | | //文件保存在/doc_file/procedure_approving/xxx.doc |
| | | MultipartFile multipartFile = approving.getMultipartFile(); |
| | | String originalFilename = multipartFile.getOriginalFilename(); |
| | | String rootFile = CommonUtil.getRootFile(); |
| | | Date date = new Date(); |
| | | String suffixFilePath = "procedure_approving" + File.separator + date.getTime() + "_" + originalFilename; |
| | | String outFilePath = rootFile + suffixFilePath; |
| | | File outFile = new File(outFilePath); |
| | | multipartFile.transferTo(outFile); |
| | | |
| | | main.setTitle(approving.getName()); |
| | | main.setDescription(approving.getDescription()); |
| | | main.setCreateUserId(user.getId()); |
| | | main.setBeginTime(date); |
| | | main.setStatus(1); |
| | | if(approving.getType()==1){ |
| | | main.setType(EnumWorksheetType.ProductProcedure.getType()); |
| | | }else{ |
| | | main.setType(EnumWorksheetType.SOP.getType()); |
| | | } |
| | | mainMapper.insert(main); |
| | | |
| | | List<WorksheetLink> links = new LinkedList<>(); |
| | | WorksheetLink baseLink = new WorksheetLink(); |
| | | WorksheetLink linkFzr = new WorksheetLink(); |
| | | WorksheetLink linkBz = new WorksheetLink(); |
| | | WorksheetLink linkZz = new WorksheetLink(); |
| | | WorksheetLink linkPb = new WorksheetLink(); |
| | | |
| | | baseLink.setMainId(main.getId()); |
| | | baseLink.setLinkStatus(0); |
| | | baseLink.setCreateTime(date); |
| | | |
| | | BeanUtils.copyProperties(baseLink,linkFzr); |
| | | BeanUtils.copyProperties(baseLink,linkBz); |
| | | BeanUtils.copyProperties(baseLink,linkZz); |
| | | BeanUtils.copyProperties(baseLink,linkPb); |
| | | |
| | | linkFzr.setDealUserId(approving.getFzr()); |
| | | linkBz.setDealUserId(approving.getBz()); |
| | | linkZz.setDealUserId(approving.getZz()); |
| | | linkPb.setDealUserId(approving.getPb()); |
| | | links.add(linkFzr); |
| | | links.add(linkBz); |
| | | links.add(linkZz); |
| | | links.add(linkPb); |
| | | linkMapper.insertBatchSomeColumn(links); |
| | | |
| | | //流程文档审批子表存入 |
| | | approving.setFile("doc_file"+ File.separator + suffixFilePath); |
| | | approving.setMainId(main.getId()); |
| | | procedureDocApprovingService.insert(approving); |
| | | //发送邮件给四个确认人 |
| | | QueryWrapper<DocUser> query = Wrappers.query(); |
| | | query.select("mail").in("id",approving.getFzr(),approving.getBz(),approving.getZz(),approving.getPb()); |
| | | List<DocUser> docUsers = userMapper.selectList(query); |
| | | List<String> userMailList = docUsers.stream().map(DocUser::getMail).collect(Collectors.toList()); |
| | | |
| | | MailDTO mailDTO = new MailDTO(); |
| | | mailDTO.setMailList(userMailList); |
| | | if(approving.getType()==1){ |
| | | mailDTO.setTitle("【流程卡确认】"+main.getTitle()); |
| | | mailDTO.setContent(user.getName()+"在文档管理平台上传了产品流程卡,请及时确认"); |
| | | }else{ |
| | | mailDTO.setTitle("【SOP确认】"+main.getTitle()); |
| | | mailDTO.setContent(user.getName()+"在文档管理平台上传了SOP,请及时确认"); |
| | | } |
| | | mailService.sendMail(mailDTO); |
| | | |
| | | return new Response().setII(1,"上传完成"); |
| | | } |
| | | } |