| | |
| | | @Service |
| | | @Slf4j |
| | | public class EmailService { |
| | | @Autowired |
| | | private JavaMailSender mailSender; |
| | | |
| | | public void sendSimpleEmail(String to, String subject, String text) { |
| | | SimpleMailMessage message = new SimpleMailMessage(); |
| | | message.setTo(to); |
| | | message.setSubject(subject); |
| | | message.setText(text); |
| | | message.setFrom("zhangxiaoxu@qianwen.ltd"); |
| | | |
| | | mailSender.send(message); |
| | | log.info("Simple email sent to: {}", to); |
| | | } |
| | | |
| | | public void sendHtmlEmail(String to, String subject, String htmlContent) |
| | | throws MessagingException { |
| | | MimeMessage message = mailSender.createMimeMessage(); |
| | | MimeMessageHelper helper = new MimeMessageHelper(message, true, "UTF-8"); |
| | | |
| | | helper.setTo(to); |
| | | helper.setSubject(subject); |
| | | helper.setText(htmlContent, true); // true 表示 HTML å
容 |
| | | helper.setFrom("zhangxiaoxu@qianwen.ltd"); |
| | | |
| | | mailSender.send(message); |
| | | log.info("HTML email sent to: {}", to); |
| | | } |
| | | |
| | | public void sendEmailWithAttachment(String to, String subject, String text, |
| | | File attachment) throws MessagingException { |
| | | MimeMessage message = mailSender.createMimeMessage(); |
| | | MimeMessageHelper helper = new MimeMessageHelper(message, true); |
| | | |
| | | helper.setTo(to); |
| | | helper.setSubject(subject); |
| | | helper.setText(text); |
| | | helper.setFrom("noreply@example.com"); |
| | | |
| | | // æ·»å éä»¶ |
| | | FileSystemResource file = new FileSystemResource(attachment); |
| | | helper.addAttachment(attachment.getName(), file); |
| | | |
| | | mailSender.send(message); |
| | | log.info("Email with attachment sent to: {}", to); |
| | | } |
| | | } |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | private final TaskDispatchService taskDispatchService; |
| | | private final BatchDispatchService dispatchService; |
| | | private final ReplaceFlowCompleteService replaceFlowCompleteService; |
| | | private final TempFlowCompleteService tempFlowCompleteService; |
| | | /** |
| | | * å起派工æµç¨ |
| | | */ |
| | |
| | | } |
| | | |
| | | AbstractFlowCompleteService getActualService(String processInstanceId){ |
| | | ProcessInstance inst = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); |
| | | ProcessInstance inst = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).includeProcessVariables().singleResult(); |
| | | if(inst.getProcessDefinitionKey().equals(FlowContants.TRY_PROCESS_KEY) || inst.getProcessDefinitionKey().equals(FlowContants.CURE_PROCESS_KEY) |
| | | || inst.getProcessDefinitionKey().equals(FlowContants.UNLOCK_PROCESS_KEY)){ |
| | | String isTempFlow = Func.toStr(inst.getProcessVariables().get(FlowContants.IS_TEMP_FLOW)); |
| | | if(FlowContants.N.equals(isTempFlow)){ |
| | | return tryFlowCompleteService; |
| | | }else{ |
| | | return tempFlowCompleteService; |
| | | } |
| | | }else if(inst.getProcessDefinitionKey().equals(FlowContants.REPLACE_PROCESS_KEY)){ |
| | | return replaceFlowCompleteService; |
| | | }else{ |
| | |
| | | vars.put(FlowContants.TITLE,startVO.getTitle()); |
| | | |
| | | //ä¸´æ¶æµç¨æ å¿ï¼æç¡®æå®Yï¼å±äºä¸´æ¶æµç¨ |
| | | vars.put(FlowContants.IS_TEMP_FLOW,FlowContants.Y.equals(startVO.getIsTempFlow())?FlowContants.Y:FlowContants.N); |
| | | |
| | | //æºåºç¼å· |
| | | vars.put(FlowContants.MACHINE_CODE,startVO.getMachineCode()); |
| | | String workshop = nodeDeptQueryService.getWorkshopNameByMachineCode(startVO.getMachineCode()); |
| | |
| | | String programPkgName = NcNodeService.genProgramName(startVO.getDrawingNo(),startVO.getProcessNo()); |
| | | vars.put(FlowContants.PROGRAM_PACKAGE_NAME,programPkgName); |
| | | |
| | | NcNode curedProgramPackage = ncNodeService.getCuredProgramPackage(programPkgName,startVO.getMachineCode()); |
| | | vars.put(FlowContants.IS_TEMP_FLOW,FlowContants.Y.equals(startVO.getIsTempFlow())?FlowContants.Y:FlowContants.N); |
| | | NcNode curedProgramPackage = null; |
| | | if(FlowContants.N.equals(startVO.getIsTempFlow())) { |
| | | curedProgramPackage = ncNodeService.getCuredProgramPackage(programPkgName, startVO.getMachineCode()); |
| | | //设置æ¯å¦æåºåç¨åºæ è®° |
| | | vars.put(FlowContants.HAS_CURED_PROGRAM,curedProgramPackage != null ? FlowContants.Y:FlowContants.N); |
| | | //å·¥åºç次æ¯å¦ä¸è´ï¼æ¯å¦å¨æææå
|
| | |
| | | vars.put(FlowContants.IS_PROCESS_EDITION_SAME, FlowContants.Y); |
| | | vars.put(FlowContants.VALIDITY_PERIOD, FlowContants.Y); |
| | | } |
| | | |
| | | }else{ |
| | | //ä¸´æ¶æµç¨ï¼ä¸ç®¡åºå |
| | | vars.put(FlowContants.HAS_CURED_PROGRAM,FlowContants.N); |
| | | } |
| | | String myProcessName = "è¯åä¸åæµç¨"; |
| | | if(vars.getOrDefault(FlowContants.HAS_CURED_PROGRAM,FlowContants.N).equals(FlowContants.Y)){ |
| | | if(vars.getOrDefault(FlowContants.IS_TEMP_FLOW,FlowContants.N).equals(FlowContants.Y)){ |
| | | myProcessName = "è¯åè¡¥å
æµç¨"; |
| | | }else if(StringUtils.isNotBlank(startVO.getDeviation()) ){ |
| | | myProcessName = "å离å"; |
| | | }else if(vars.getOrDefault(FlowContants.HAS_CURED_PROGRAM,FlowContants.N).equals(FlowContants.Y)){ |
| | | myProcessName = "åºåä¸åæµç¨"; |
| | | } |
| | | if(StringUtils.isNotBlank(startVO.getDeviation()) ){ |
| | | myProcessName = "å离å"; |
| | | } |
| | | |
| | | vars.put(FlowContants.MY_PROCESS_NAME, myProcessName); |
| | | |
| | | String businessKey = "0";//ä¸å¡è¡¨key |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.springblade.mdm.flow.service.execute; |
| | | |
| | | import org.flowable.task.api.Task; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springblade.mdm.flow.constants.FlowContants; |
| | | import org.springblade.mdm.flow.service.FlowCommonService; |
| | | import org.springblade.mdm.flow.service.FlowProgramFileService; |
| | | import org.springblade.mdm.flow.service.FlowProgramProperties; |
| | | import org.springblade.mdm.program.service.NcNodeAutoCreateService; |
| | | import org.springblade.mdm.program.service.NcNodeService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * è¯åæµç¨å®æä»»å¡çå®ç° |
| | | */ |
| | | @Service("tempFlowCompleteService") |
| | | public class TempFlowCompleteService extends AbstractFlowCompleteService { |
| | | @Autowired |
| | | private FlowProgramFileService flowProgramFileService; |
| | | @Autowired |
| | | private NcNodeService ncNodeService; |
| | | @Autowired |
| | | private FlowCommonService flowCommonService; |
| | | |
| | | @Transactional |
| | | @Override |
| | | public void completeTask(String taskId, String processInstanceId, String comment, Map<String, Object> variables) { |
| | | Task task = currentTask(taskId); |
| | | String operateResult = this.getApproveResult(variables); |
| | | |
| | | |
| | | if (StringUtil.isNoneBlank(processInstanceId, comment)) { |
| | | taskService.addComment(taskId, processInstanceId, comment); |
| | | } |
| | | // éç©ºå¤æ |
| | | if (Func.isEmpty(variables)) { |
| | | variables = Kv.create(); |
| | | } |
| | | variables.put(FlowContants.LAST_STEP_USER_NICKNAME, AuthUtil.getNickName()); |
| | | |
| | | if(!variables.containsKey("assignee")) { |
| | | throw new ServiceException("请æå®æµç¨ä¸ä¸æ¥å¤ç人"); |
| | | } |
| | | addApproveRecord(taskId,comment,variables); |
| | | |
| | | taskService.complete(taskId, variables); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | String operateResult = this.getApproveResult(variables); |
| | | |
| | | if(task.getTaskDefinitionKey().equals("programmingTask")) {//ç¼å¶èç¹ |
| | | flowProgramFileService.checkProgramFiles(processInstanceId,"Y".equals(operateResult)); |
| | | flowProgramFileService.checkProgramFiles(processInstanceId,FlowContants.Y.equals(operateResult)); |
| | | } |
| | | if (StringUtil.isNoneBlank(processInstanceId, comment)) { |
| | | taskService.addComment(taskId, processInstanceId, comment); |
| | |
| | | @GetMapping("/sendmail") |
| | | @Operation(summary = "sendmail", description = "sendmail") |
| | | public R<Void> sendmail(String code) throws IOException, MessagingException { |
| | | mailService.sendHtmlEmail("zhangxiaoxu@qianwen.ltd","testtitle"+code,"abcç¦ç¦ç¦"); |
| | | mailService.sendHtmlEmail("y_ys79@sina.com","testtitle"+code,"abcç¦ç¦ç¦"); |
| | | |
| | | return R.success(); |
| | | } |
| | | |
| | |
| | | * @param programProperties ç¨åºå±æ§ï¼åèµ·æ¶å¡«åç |
| | | */ |
| | | public static void checkFilename(String filename, FlowProgramProperties programProperties){ |
| | | if(FlowContants.IS_TEMP_FLOW.equals(programProperties.getIsTempFlow())){ |
| | | if(FlowContants.Y.equals(programProperties.getIsTempFlow())){ |
| | | //临æ¶ç¨åºä¸åæµç¨ï¼ä¸æ£æ¥æä»¶ååæ³æ§ |
| | | return; |
| | | } |