| | |
| | | public Response addDefective(DefectiveProducts defective, List<MultipartFile> multipartFileList) throws IOException { |
| | | //初次录入状态为0 |
| | | defective.setConfirmStatus(0); |
| | | Date date = new Date(); |
| | | //压缩包的路径及格式为: doc_file/defective/username_time.zip |
| | | String senderName = ActionUtil.getUser().getName(); |
| | | String senderId =ActionUtil.getUser().getId().toString(); |
| | | defective.setSenderId(Integer.parseInt(senderId)); |
| | | long time = date.getTime(); |
| | | Integer senderId =ActionUtil.getUser().getId().intValue(); |
| | | defective.setSenderId(senderId); |
| | | if(defective.getStartTime()==null){ |
| | | //保存 |
| | | defective.setStartTime(new Date()); |
| | | } |
| | | String time = ActionUtil.sdfwithday.format(defective.getStartTime()); |
| | | //String feedbackZipPath = "defective" + File.separator + username + "_" + time+".zip"; |
| | | String rootFile = CommonUtil.getRootFile(); |
| | | if(multipartFileList!=null && multipartFileList.size()!=0){ |
| | |
| | | defective.setFileUrl("doc_file" + File.separator + defectiveDirSuffix); |
| | | } |
| | | |
| | | if(defective.getStartTime()==null){ |
| | | //保存 |
| | | defective.setStartTime(date); |
| | | } |
| | | |
| | | mapper.insert(defective); |
| | | //发送邮件 |
| | | String receiverIds = defective.getReceiverIds(); |
| | |
| | | |
| | | //处理不良品 |
| | | @Transactional |
| | | public Response updateDefective(DefectiveProductsHistory defectiveHis) { |
| | | public Response updateDefective(DefectiveProductsHistory defectiveHis, List<MultipartFile> multipartFileList) { |
| | | //获取上一次记录信息 |
| | | QueryWrapper qwrapper=new QueryWrapper(); |
| | | qwrapper.eq("id",defectiveHis.getDeftId()); |
| | | qwrapper.last("limit 1"); |
| | | DefectiveProducts defective=mapper.selectOne(qwrapper); |
| | | //获取 |
| | | Integer senderId = defective.getSenderId(); |
| | | String senderName = null; |
| | | |
| | | List<DocUser> docUsers = userMapper.selectList(null); |
| | | for (DocUser docUser:docUsers){ |
| | | if(docUser.getId().intValue() == senderId){ |
| | | senderName = docUser.getName(); |
| | | break; |
| | | } |
| | | } |
| | | defective.setSenderName(senderName); |
| | | //修改当前表记录 |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | wrapper.set("receiver_ids",defectiveHis.getReceiverIds()); |
| | |
| | | mapper.update(null,wrapper); |
| | | |
| | | //记录处理记录 |
| | | defectiveHisService.updateDefective(defectiveHis); |
| | | defectiveHisService.updateDefective(defective,defectiveHis,multipartFileList); |
| | | |
| | | //发送邮件 |
| | | String receiverIds = defectiveHis.getReceiverIds(); |
| | | String[] receiverIdsSplit = receiverIds.split(","); |
| | | List<String> receiverMailList = new LinkedList<>(); |
| | | |
| | | //获取 |
| | | Integer senderId = defective.getSenderId(); |
| | | String senderName = null; |
| | | |
| | | List<DocUser> docUsers = userMapper.selectList(null); |
| | | for (DocUser docUser:docUsers){ |
| | | if(docUser.getId().intValue() == senderId){ |
| | | senderName = docUser.getName(); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | for (String receiverId:receiverIdsSplit){ |
| | | for (DocUser docUser:docUsers){ |
| | |
| | | } |
| | | } |
| | | |
| | | String subject = "【不良品记录】-"+senderName; |
| | | String subject = "【不良品处理记录】-"+senderName; |
| | | String content = defective.getContent(); |
| | | |
| | | MailDTO mailDTO = new MailDTO(); |
| | |
| | | //记录处理记录 |
| | | DefectiveProductsHistory defectiveHis=new DefectiveProductsHistory(); |
| | | defectiveHis.setDeftId(deftId); |
| | | defectiveHis.setDelId(ActionUtil.getUser().getId().intValue()); |
| | | defectiveHis.setConfirmStatus(3); |
| | | defectiveHis.setBadProduct(0); |
| | | defectiveHisService.updateDefective(defectiveHis); |
| | | defectiveHisService.stopDefective(defectiveHis); |
| | | return new Response().set(1,true); |
| | | } |
| | | } |