已删除1个文件
已添加5个文件
已重命名1个文件
已修改18个文件
| | |
| | | <version>4.0.28</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>org.apache.cxf</groupId> |
| | | <artifactId>cxf-rt-frontend-jaxws</artifactId> |
| | | <version>4.1.3</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>org.apache.cxf</groupId> |
| | | <artifactId>cxf-rt-transports-http</artifactId> |
| | | <version>4.1.3</version> |
| | | </dependency> |
| | | |
| | | |
| | | <dependency> |
| | | <groupId>com.sun.xml.bind</groupId> |
| | | <artifactId>jaxb-xjc</artifactId> |
| | | <version>4.0.5</version> |
| | | </dependency> |
| | | <!-- <dependency> |
| | | <groupId>com.sun.xml.bind</groupId> |
| | | <artifactId>jaxb-core</artifactId> |
| | | <version>2.3.0.1</version> |
| | | </dependency> |
| | | |
| | | |
| | | <dependency> |
| | | <groupId>com.sun.xml.bind</groupId> |
| | | <artifactId>jaxb-impl</artifactId> |
| | | <version>4.0.5</version> |
| | | <scope>runtime</scope> |
| | | </dependency>--> |
| | | </dependencies> |
| | | <build> |
| | | <plugins> |
| | |
| | | * é夿´¾å·¥å¤©æ°éªè¯é´éå¤©æ° |
| | | */ |
| | | public static String TASK_EXPIRE_DAYS = "taskExpireDays"; |
| | | /** |
| | | * é®ä»¶éç¥å¼å¯æ å¿ï¼1ï¼å¼å¯ï¼0ï¼å
³é |
| | | */ |
| | | public static String EMAIL_NOTIFY_FLAG = "emailNotifyFlag"; |
| | | |
| | | /** |
| | | * é®ä»¶æéæ å¿ ï¼å¼ |
| | | */ |
| | | public static String EMAIL_NOTIFY_FLAG_ON = "1"; |
| | | /** |
| | | * é®ä»¶æéæ å¿ ï¼å
³ |
| | | */ |
| | | public static String EMAIL_NOTIFY_FLAG_OFF = "1"; |
| | | } |
| | |
| | | public class RemindController { |
| | | |
| | | @Autowired |
| | | NcProgramApprovedService ncProgramApprovedService; |
| | | private NcProgramApprovedService ncProgramApprovedService; |
| | | @Autowired |
| | | private FlowBusinessService businessService; |
| | | @Autowired |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.springblade.mdm.commons.service; |
| | | |
| | | import lombok.Data; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | @Configuration |
| | | @ConfigurationProperties(prefix = "mail-remind") |
| | | @Data |
| | | public class InternalEmailProperties { |
| | | |
| | | private String senderAccount; |
| | | private String mailServiceAddr; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.springblade.mdm.commons.service; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.apache.cxf.endpoint.Client; |
| | | import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory; |
| | | @Service |
| | | @Slf4j |
| | | public class InternalEmailService { |
| | | @Autowired |
| | | private InternalEmailProperties internalEmailProperties; |
| | | |
| | | public void send(String fromid,String toids, String ccids, String bccids, String subject, String content, String[] paths) { |
| | | try { |
| | | |
| | | // åå»ºå¨æå®¢æ·ç«¯å·¥å |
| | | JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); |
| | | |
| | | // å建客æ·ç«¯ |
| | | //Client client = dcf.createClient("http://localhost:8080/services/EmailService?wsdl"); |
| | | Object[] result; |
| | | try (Client client = dcf.createClient(internalEmailProperties.getMailServiceAddr())) { |
| | | // è°ç¨æ¹æ³ |
| | | result = client.invoke("sendInternalMail", fromid, toids, ccids, bccids, subject, content, null); |
| | | |
| | | // å¤çååº |
| | | if (result != null && result.length > 0) { |
| | | System.out.println("ååº: " + result[0]); |
| | | } |
| | | } |
| | | }catch(Exception e) { |
| | | log.error("å
é¨é®ä»¶åé失败",e); |
| | | } |
| | | } |
| | | } |
| | |
| | | public class ParamService{ |
| | | public static String NETWORK_TYPE= "networkType"; |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 审æ¹ç¨æ·è§è²å«ååæ°keyï¼éå·åé |
| | | */ |
| | |
| | | import org.springblade.mdm.program.service.NcNodeService; |
| | | import org.springblade.mdm.program.service.NcProgramApprovedService; |
| | | import org.springblade.mdm.program.service.ProgramAnnotationService; |
| | | import org.springblade.mdm.program.service.programannotation.AnnotationProperties; |
| | | import org.springblade.mdm.program.service.programannotation.AnnotationUtil; |
| | | import org.springblade.mdm.program.service.programannotation.MachineAnnotationConfig; |
| | | import org.springblade.mdm.utils.EntityUtil; |
| | | import org.springblade.system.feign.ISysClient; |
| | | import org.springblade.system.pojo.entity.DictBiz; |
| | |
| | | @Component("normalCureFinishDataHandler") |
| | | public class NormalCureFinishDataHandler implements FinishDataHandler { |
| | | @Autowired |
| | | private NcProgramApprovedService approvedService; |
| | | @Autowired |
| | | private ApproveRecordService approveRecordService; |
| | | private MachineAnnotationConfig config; |
| | | |
| | | @Autowired |
| | | private FlowProgramFileService flowProgramFileService; |
| | | @Autowired |
| | |
| | | byte[] bytes = IOUtils.toByteArray(ins); |
| | | ByteArrayInputStream byteInputStream = new ByteArrayInputStream(bytes); |
| | | |
| | | InputStream finishedStream = programAnnotationService.setGHAnnotation(byteInputStream,controlSystem,annoDicts); |
| | | |
| | | //InputStream finishedStream = programAnnotationService.setGHAnnotation(byteInputStream,controlSystem,annoDicts); |
| | | List<DictBiz> annoDictList = programAnnotationService.getAnnotionDictList(); |
| | | AnnotationProperties annoProps = config.getConfigMap().get(controlSystem); |
| | | if(annoProps == null){ |
| | | annoProps = AnnotationProperties.getDefault(); |
| | | } |
| | | InputStream finishedStream =AnnotationUtil.setAnnotationAndGetInputStream(byteInputStream, "GH", annoProps.getStatusLineIndex(), controlSystem, annoDictList); |
| | | try(finishedStream) { |
| | | finishedStream.reset(); |
| | | BladeFile bfile = ossTemplate.putFile(flowProgramFile.getName(), finishedStream); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * è®¡ç®æææ |
| | | * @return |
| | |
| | | /** |
| | | * æµç¨ä¸å¡å®ç°ç±» |
| | | * |
| | | * @author Chill |
| | | * @author yangys |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | |
| | | import org.springblade.mdm.commons.service.ParamService; |
| | | import org.springblade.mdm.machinefile.entity.MachineFile; |
| | | import org.springblade.mdm.program.service.ProgramAnnotationService; |
| | | import org.springblade.mdm.program.service.programannotation.AnnotationUtil; |
| | | import org.springblade.mdm.utils.FileContentUtil; |
| | | import org.springblade.system.pojo.entity.DictBiz; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | } |
| | | bis.reset(); |
| | | String statusLine = FileContentUtil.readLineAt(ins,ProgramAnnotationService.STATUS_LINE_INDEX); |
| | | if(programAnnotationService.isAnnotation(statusLine,controlSystem,annotatiionList)){ |
| | | if(AnnotationUtil.isAnnotation(statusLine,controlSystem,annotatiionList)){ |
| | | String progStatusTxt = programAnnotationService.removeAnnotation(controlSystem,statusLine,annotatiionList); |
| | | if(ProgramAnnotationService.SQ.equals(progStatusTxt)){ |
| | | programStatus = MachineFile.PROGRAM_STATUS_TRY; |
| | |
| | | import com.alibaba.excel.annotation.write.style.HeadRowHeight; |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | import org.springblade.mdm.commons.vo.BaseVO; |
| | | |
| | | import java.util.Date; |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @Data |
| | | @ColumnWidth(25) |
| | | @HeadRowHeight(20) |
| | | @ContentRowHeight(18) |
| | | @Setter |
| | | @Getter |
| | | public class MachineBackFileExcelVO extends BaseVO { |
| | | |
| | | @ExcelProperty("æä»¶åç§°") |
| | |
| | | import org.springblade.mdm.program.entity.NcNode; |
| | | import org.springblade.mdm.program.entity.NcProgramExchange; |
| | | import org.springblade.mdm.program.mapper.NcProgramExchangeMapper; |
| | | import org.springblade.mdm.program.service.programannotation.AnnotationProcessor; |
| | | import org.springblade.mdm.program.service.programannotation.DefaultProcessor; |
| | | import org.springblade.mdm.program.service.programannotation.FanucProcessor; |
| | | import org.springblade.mdm.program.service.programannotation.MachineAnnotationConfig; |
| | | import org.springblade.mdm.program.service.programannotation.*; |
| | | import org.springblade.mdm.program.vo.DncSendBackData; |
| | | import org.springblade.mdm.program.vo.DncSendBackFile; |
| | | import org.springblade.mdm.program.vo.ProgramAnnotation; |
| | |
| | | private final ParamService paramService; |
| | | private final MachineAnnotationConfig machineAnnotationConfig; |
| | | |
| | | private final FanucProcessor fanucProcessor; |
| | | private final DefaultProcessor defaultProcessor; |
| | | /** |
| | | * å离åæä»¶æ«å°¾ç模å¼ï¼P+æ°å |
| | | */ |
| | |
| | | InputStream ins = zipFile.getInputStream(entry); |
| | | ByteArrayInputStream bais = new ByteArrayInputStream(IOUtils.toByteArray(ins));; |
| | | progData.setFileBackTime(DateUtil.fromInstant(entry.getLastModifiedTime().toInstant())); |
| | | //machineAnnotationConfig.getConfigMap().get(machine.getcon) |
| | | Pattern fanucPattern = Pattern.compile("^[oO]\\d{4}"); |
| | | String testLine = FileContentUtil.readLineAt(bais,2);//TODO,fanucè¿è¡æ¯ä¸åè·¯å¾ï¼å
¶ä»æºå¨æ¯ç¶æ |
| | | |
| | | AnnotationProperties defAnnoProperties =AnnotationProperties.getDefault(); |
| | | statusLine = FileContentUtil.readLineAt(bais,defAnnoProperties.getStatusLineIndex());//ç¶ææ³¨éè¡ |
| | | bais.reset(); |
| | | //boolean isFanuc = fanucPattern.matcher(testLine).matches(); |
| | | boolean isFanuc = !StringUtils.containsAny(testLine,"(SQ)","(GH)","(PL)"); |
| | | if(isFanuc){ |
| | | statusLine = FileContentUtil.readLineAt(bais,3);//fanucçç¶æè¯»ç¬¬4è¡ |
| | | }else{ |
| | | statusLine = testLine; |
| | | } |
| | | |
| | | if(statusLine.contains("SQ")){ |
| | | //è¯å |
| | | programPackageNode = ncNodeService.getLastEditionTryingProgramPackage(packageName);//,processEdition |
| | | programPackageNode = ncNodeService.getLastEditionTryingProgramPackage(packageName);//TODO è¿éæ ¹æ®æºåºç»ï¼å¦ä½è·åï¼æ ¹æ®ä¸åè·¯å¾è·åæºåºï¼è¿èè·åï¼ï¼,processEdition |
| | | }else if(statusLine.contains("GH")){ |
| | | //åºå |
| | | //TODO åºåï¼æ ¹æ¬ä¸éè¦åä¼ ï¼åºè¯¥æç¤ºæ¥éãæè
ä¸è¿å
¥åè¡¨ï¼æå表ä¸ä¸å¯éåå
¥åº |
| | | programPackageNode = ncNodeService.getLastEditionCuredProgramPackage(packageName); |
| | | }else if(statusLine.contains("PL")){ |
| | | //å离 |
| | | programPackageNode =ncNodeService.getLastEditionDeviationProgramPackage(packageName); |
| | | }else{ |
| | | //æ¥è¯¢æ¯å¦è½¦åºï¼æ¯è½¦åºå¯ä»¥æ¾è¿ï¼æè¯åå¤ç |
| | | //æ¥è¯¢æ¯å¦è½¦åº/ç°åºç¼å¶ï¼æ¯è½¦åºå¯ä»¥æ¾è¿ï¼æè¯åå¤çï¼ |
| | | //TODO ç°åºç¼å¶çç¨åºï¼æå
æ¶å¿
须卿件ä¸å¢å ä¸åè·¯å¾ï¼å å
¥åï¼ |
| | | programPackageNode = ncNodeService.getLastEditionTryingProgramPackage(packageName); |
| | | if(programPackageNode!=null){ |
| | | Machine machine = machineService.getByCode(programPackageNode.getMachineCode()); |
| | | String chechuangVal = paramService.turninngValue(); |
| | | if(StringUtils.equals(machine.getMachineSpec(),chechuangVal)){ |
| | | //è½¦åº |
| | | ProgramAnnotation pa = programAnnotationService.getProgramAnnotationFormat(machine.getControlSystem(),annotionDictList); |
| | | ProgramAnnotation pa = AnnotationUtil.getProgramAnnotationFormat(machine.getControlSystem(),annotionDictList); |
| | | statusLine = pa.addAnnotation(ProgramAnnotationService.SQ); |
| | | } |
| | | } |
| | |
| | | import org.jetbrains.annotations.NotNull; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.mdm.program.service.programannotation.AnnotationUtil; |
| | | import org.springblade.mdm.program.vo.ProgramAnnotation; |
| | | import org.springblade.mdm.utils.FileContentUtil; |
| | | import org.springblade.system.feign.IDictBizClient; |
| | |
| | | * @param annotationList æ³¨éæ³¨éåå
¸é¡¹å表 |
| | | * @return |
| | | */ |
| | | /* |
| | | public boolean isAnnotation(String line,String systemDictVal,List<DictBiz> annotationList){ |
| | | ProgramAnnotation progAnnotation = this.getProgramAnnotationFormat(systemDictVal,annotationList); |
| | | |
| | |
| | | public String generateAnnotation(String oriTest,String systemDictVal,List<DictBiz> annotationList) { |
| | | ProgramAnnotation progAnnotation = this.getProgramAnnotationFormat(systemDictVal,annotationList); |
| | | return progAnnotation.addAnnotation(oriTest); |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * æå注éä¸çææ¬ |
| | |
| | | * @param text æ¸
餿³¨éæ è®° |
| | | * @return æ¸
é¤åçææ¬ |
| | | */ |
| | | |
| | | public String removeAnnotation(String systemDictVal,String text){ |
| | | List<DictBiz> annoDicts = getAnnotionDictList(); |
| | | return removeAnnotation(systemDictVal,text,annoDicts); |
| | | } |
| | | |
| | | public String removeAnnotation(String systemDictVal,String text,List<DictBiz> annotatiionList){ |
| | | ProgramAnnotation panno = this.getProgramAnnotationFormat(systemDictVal,annotatiionList); |
| | | ProgramAnnotation panno = AnnotationUtil.getProgramAnnotationFormat(systemDictVal,annotatiionList); |
| | | return panno.cleanAnnotation(text); |
| | | } |
| | | /** |
| | |
| | | * @return å 好注éç |
| | | * @throws IOException |
| | | */ |
| | | /* |
| | | public InputStream setGHAnnotation(InputStream inputStream, String systemDictVal,List<DictBiz> annoDictList) throws IOException { |
| | | return setAnnotationAndGetInputStream(inputStream, systemDictVal, annoDictList, GH, STATUS_LINE_INDEX); |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 设置åç¦»åæ³¨é |
| | |
| | | * @return å 好注éçè¾å
¥æµ |
| | | * @throws IOException è®¿é®æµå¯è½æåºå¼å¸¸ |
| | | */ |
| | | /* |
| | | public InputStream setPldAnnotation(String deviation,InputStream inputStream,String systemDictVal,List<DictBiz> annoDictList) throws IOException { |
| | | return setAnnotationAndGetInputStream(inputStream, systemDictVal, annoDictList, deviation, STATUS_DEVIATION_INDEX); |
| | | } |
| | | |
| | | */ |
| | | /* |
| | | @NotNull |
| | | private InputStream setAnnotationAndGetInputStream(InputStream inputStream, String systemDictVal, List<DictBiz> annoDictList, String text, int lineIndex) throws IOException { |
| | | InputStream finishedStream; |
| | |
| | | return finishedStream; |
| | | } |
| | | |
| | | */ |
| | | |
| | | /** |
| | | * 为è¾å
¥æµè®¾ç½®åéç®å½(第äºè¡)åç¶æï¼ç¬¬ä¸è¡ï¼ |
| | |
| | | * @return å 好åéè·¯å¾åç¶æææ¬çè¾å
¥æµ |
| | | * @throws IOException |
| | | */ |
| | | /* |
| | | public InputStream setSendDirAndStatusAnnotation(String sendPath,String statusText,InputStream inputStream, String systemDictVal) throws IOException { |
| | | List<DictBiz> annoDicts = getAnnotionDictList(); |
| | | |
| | |
| | | } |
| | | |
| | | return finishedStream; |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * è§£æåºæºåºç¨åºæ³¨éçæ ¼å¼ |
| | |
| | | * @param annoDictList é
ç½®çæ³¨éåå
¸æ°æ® |
| | | * @return |
| | | */ |
| | | /* |
| | | ProgramAnnotation getProgramAnnotationFormat(String systemDictVal,List<DictBiz> annoDictList){ |
| | | String begin; |
| | | String end; |
| | |
| | | programAnnotation.setBegin(begin); |
| | | programAnnotation.setEnd(end); |
| | | return programAnnotation; |
| | | } |
| | | }*/ |
| | | } |
| | | |
| | | |
| | |
| | | import org.springblade.mdm.utils.FileContentUtil; |
| | | import org.springblade.system.pojo.entity.DictBiz; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.IOException; |
| | |
| | | ByteArrayInputStream byteInputStream = new ByteArrayInputStream(IOUtils.toByteArray(inputStream)); |
| | | |
| | | //1å å
¥åéè·¯å¾ç注é |
| | | String sendPathAnnotation = generateAnnotation(annoData.getSendPath(),getControlSystem(),annoDicts);//å äºæ³¨éä¹åçææ¬ |
| | | String sendPathAnnotation = AnnotationUtil.generateAnnotation(annoData.getSendPath(),getControlSystem(),annoDicts);//å äºæ³¨éä¹åçææ¬ |
| | | |
| | | String sendDirLine = FileContentUtil.readLineAt(byteInputStream,annotationProperties.getSendPathLineIndex());//第2è¡æ¯åéè·¯å¾ |
| | | byteInputStream.reset(); |
| | |
| | | byteInputStream.reset(); |
| | | |
| | | InputStream insAfterSetSendDir ; |
| | | if(isAnnotation(sendDirLine,getControlSystem(),annoDicts)){ |
| | | if(AnnotationUtil.isAnnotation(sendDirLine,getControlSystem(),annoDicts)){ |
| | | insAfterSetSendDir = FileContentUtil.replaceAtLine(byteInputStream,annotationProperties.getSendPathLineIndex(),sendPathAnnotation); |
| | | }else{ |
| | | insAfterSetSendDir = FileContentUtil.insertLine(byteInputStream,annotationProperties.getSendPathLineIndex(),sendPathAnnotation); |
| | |
| | | |
| | | insAfterSetSendDir.reset(); |
| | | //å å
¥ç¶ææ³¨éè¡ |
| | | String statusAnnotation = generateAnnotation(annoData.getProgramStatus(),getControlSystem(),annoDicts);//注éåçç¶æææ¬ |
| | | if(isAnnotation(statusLine,getControlSystem(),annoDicts)){ |
| | | String statusAnnotation = AnnotationUtil.generateAnnotation(annoData.getProgramStatus(),getControlSystem(),annoDicts);//注éåçç¶æææ¬ |
| | | if(AnnotationUtil.isAnnotation(statusLine,getControlSystem(),annoDicts)){ |
| | | finishedStream = FileContentUtil.replaceAtLine(insAfterSetSendDir,annotationProperties.getStatusLineIndex(),statusAnnotation); |
| | | }else{ |
| | | finishedStream = FileContentUtil.insertLine(insAfterSetSendDir,annotationProperties.getStatusLineIndex(),statusAnnotation); |
| | |
| | | import java.util.Optional; |
| | | |
| | | public interface AnnotationProcessor { |
| | | static final String DEFAULT_ANNOTATION_SETTING = "(,)"; |
| | | |
| | | default String generateAnnotation(String oriTest, String systemDictVal, List<DictBiz> annotationList) { |
| | | ProgramAnnotation progAnnotation = this.getProgramAnnotationFormat(systemDictVal,annotationList); |
| | | return progAnnotation.addAnnotation(oriTest); |
| | | } |
| | | default boolean isAnnotation(String line,String systemDictVal,List<DictBiz> annotationList){ |
| | | ProgramAnnotation progAnnotation = this.getProgramAnnotationFormat(systemDictVal,annotationList); |
| | | |
| | | line = StringUtils.trim(line);//å»é¦å°¾ç©ºæ ¼ |
| | | return progAnnotation.isAnnotation(line); |
| | | } |
| | | |
| | | default ProgramAnnotation getProgramAnnotationFormat(String systemDictVal,List<DictBiz> annoDictList){ |
| | | String begin; |
| | | String end; |
| | | |
| | | Optional<DictBiz> dictOpt = annoDictList.stream().filter(dict -> {return dict.getDictKey().equals(systemDictVal);}).findFirst(); |
| | | String annotationSetting = DEFAULT_ANNOTATION_SETTING; |
| | | if(dictOpt.isPresent()) { |
| | | annotationSetting = dictOpt.get().getRemark(); |
| | | } |
| | | String[] arr = StringUtils.split(annotationSetting,","); |
| | | if(arr.length == 2){ |
| | | begin = arr[0]; |
| | | end = arr[1]; |
| | | }else if(arr.length == 1){ |
| | | begin = arr[0]; |
| | | end = ""; |
| | | }else{ |
| | | throw new ServiceException("æ³¨éæ ¼å¼é
ç½®é误ï¼åºè¯¥ä¸º1å°2段ï¼ä¸é´ç¨éå·åé"); |
| | | } |
| | | |
| | | ProgramAnnotation programAnnotation = new ProgramAnnotation(); |
| | | programAnnotation.setBegin(begin); |
| | | programAnnotation.setEnd(end); |
| | | return programAnnotation; |
| | | } |
| | | void setControlSystem(String controlSystemDictVal); |
| | | void setAnnotationProperties(AnnotationProperties annotationProperties); |
| | | String getControlSystem(); |
| | |
| | | @Data |
| | | public class AnnotationProperties { |
| | | private String beanId; |
| | | private int programNameLineIndex; |
| | | private int sendPathLineIndex; |
| | | private int statusLineIndex; |
| | | private int deviationLineIndex; |
| | | |
| | | public static AnnotationProperties getDefault(){ |
| | | AnnotationProperties def = new AnnotationProperties(); |
| | | def.setProgramNameLineIndex(1); |
| | | def.setSendPathLineIndex(2); |
| | | def.setStatusLineIndex(3); |
| | | def.setDeviationLineIndex(4); |
| | | return def; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.springblade.mdm.program.service.programannotation; |
| | | |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.mdm.program.vo.ProgramAnnotation; |
| | | import org.springblade.mdm.utils.FileContentUtil; |
| | | import org.springblade.system.pojo.entity.DictBiz; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | |
| | | public class AnnotationUtil { |
| | | static String DEFAULT_ANNOTATION_SETTING = "(,)"; |
| | | |
| | | public static ProgramAnnotation getProgramAnnotationFormat(String systemDictVal, List<DictBiz> annoDictList){ |
| | | String begin; |
| | | String end; |
| | | |
| | | Optional<DictBiz> dictOpt = annoDictList.stream().filter(dict -> {return dict.getDictKey().equals(systemDictVal);}).findFirst(); |
| | | String annotationSetting = DEFAULT_ANNOTATION_SETTING; |
| | | if(dictOpt.isPresent()) { |
| | | annotationSetting = dictOpt.get().getRemark(); |
| | | } |
| | | String[] arr = StringUtils.split(annotationSetting,","); |
| | | if(arr.length == 2){ |
| | | begin = arr[0]; |
| | | end = arr[1]; |
| | | }else if(arr.length == 1){ |
| | | begin = arr[0]; |
| | | end = ""; |
| | | }else{ |
| | | throw new ServiceException("æ³¨éæ ¼å¼é
ç½®é误ï¼åºè¯¥ä¸º1å°2段ï¼ä¸é´ç¨éå·åé"); |
| | | } |
| | | |
| | | ProgramAnnotation programAnnotation = new ProgramAnnotation(); |
| | | programAnnotation.setBegin(begin); |
| | | programAnnotation.setEnd(end); |
| | | return programAnnotation; |
| | | } |
| | | |
| | | public static boolean isAnnotation(String line,String systemDictVal,List<DictBiz> annotationList){ |
| | | ProgramAnnotation progAnnotation = AnnotationUtil.getProgramAnnotationFormat(systemDictVal,annotationList); |
| | | |
| | | line = StringUtils.trim(line);//å»é¦å°¾ç©ºæ ¼ |
| | | return progAnnotation.isAnnotation(line); |
| | | } |
| | | |
| | | public static String generateAnnotation(String oriTest, String systemDictVal, List<DictBiz> annotationList) { |
| | | ProgramAnnotation progAnnotation = AnnotationUtil.getProgramAnnotationFormat(systemDictVal,annotationList); |
| | | return progAnnotation.addAnnotation(oriTest); |
| | | } |
| | | |
| | | public static InputStream setAnnotationAndGetInputStream(InputStream inputStream, String text, int lineIndex, String systemDictVal, List<DictBiz> annoDictList) throws IOException { |
| | | InputStream finishedStream; |
| | | try(inputStream){ |
| | | ByteArrayInputStream byteInputStream = new ByteArrayInputStream(IOUtils.toByteArray(inputStream)); |
| | | |
| | | String annoTxt = generateAnnotation(text,systemDictVal,annoDictList);//å äºæ³¨éä¹åçææ¬ |
| | | |
| | | String lineText = FileContentUtil.readLineAt(byteInputStream, lineIndex); |
| | | byteInputStream.reset(); |
| | | |
| | | if(isAnnotation(lineText,systemDictVal,annoDictList)){ |
| | | finishedStream = FileContentUtil.replaceAtLine(byteInputStream, lineIndex,annoTxt); |
| | | }else{ |
| | | finishedStream = FileContentUtil.insertLine(byteInputStream, lineIndex,annoTxt); |
| | | } |
| | | finishedStream.reset(); |
| | | } |
| | | |
| | | return finishedStream; |
| | | } |
| | | |
| | | } |
| | |
| | | package org.springblade.mdm.program.service.programannotation; |
| | | |
| | | import com.qiniu.util.IOUtils; |
| | | import org.apache.commons.io.FilenameUtils; |
| | | import org.springblade.mdm.program.service.ProgramAnnotationService; |
| | | import org.springblade.mdm.utils.FileContentUtil; |
| | | import org.springblade.system.pojo.entity.DictBiz; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.util.List; |
| | | |
| | | |
| | | @Component("defaultProcessor") |
| | |
| | | @Autowired |
| | | private ProgramAnnotationService programAnnotationService; |
| | | private String controlSystem; |
| | | private AnnotationProperties annotationPropreties; |
| | | |
| | | |
| | | @Override |
| | | public InputStream setAnnotation(AnnotationData annoData, InputStream inputStream) throws IOException { |
| | | List<DictBiz> annoDicts = programAnnotationService.getAnnotionDictList(); |
| | | ByteArrayInputStream bais = new ByteArrayInputStream(IOUtils.toByteArray(inputStream)); |
| | | |
| | | String line = FileContentUtil.readLineAt(bais, annotationProperties.getProgramNameLineIndex()); |
| | | bais.reset(); |
| | | boolean isAnnotation = AnnotationUtil.isAnnotation(line,controlSystem,annoDicts); |
| | | InputStream insAfter; |
| | | //å å
¥ç¨åºå注éè¡ |
| | | String proNameLine = AnnotationUtil.generateAnnotation(FilenameUtils.removeExtension(annoData.getFilename()),getControlSystem(),annoDicts); |
| | | if(isAnnotation){ |
| | | insAfter = FileContentUtil.replaceAtLine(bais, annotationProperties.getProgramNameLineIndex(),proNameLine); |
| | | }else{ |
| | | insAfter = FileContentUtil.insertLine(bais, annotationProperties.getProgramNameLineIndex(),proNameLine); |
| | | } |
| | | |
| | | return super.setAnnotation(annoData, insAfter); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void setControlSystem(String controlSystemDictVal) { |
| | | this.controlSystem = controlSystemDictVal; |
| | | } |
| | | |
| | | @Override |
| | | public void setAnnotationProperties(AnnotationProperties annotationProperties) { |
| | | this.annotationPropreties= annotationProperties; |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Autowired |
| | | private ProgramAnnotationService programAnnotationService; |
| | | private String controlSystem; |
| | | //AnnotationProperties annotationProperties; |
| | | private Pattern PATTERN = Pattern.compile("^[oO]\\d{4}"); |
| | | private final int O_LINE = 1; |
| | | @Override |
| | |
| | | InputStream ins1; |
| | | if(oMatched){ |
| | | List<DictBiz> annoDicts = programAnnotationService.getAnnotionDictList(); |
| | | String newline = line + generateAnnotation(FilenameUtils.removeExtension(annoData.getFilename()),getControlSystem(),annoDicts); |
| | | String newline = line + AnnotationUtil.generateAnnotation(FilenameUtils.removeExtension(annoData.getFilename()),getControlSystem(),annoDicts); |
| | | ins1 = FileContentUtil.replaceAtLine(bais,O_LINE,newline); |
| | | }else{ |
| | | ins1 = bais; |
| | |
| | | AnnotationProcessor processor; |
| | | if(props != null){ |
| | | processor = SpringUtil.getBean(props.getBeanId()); |
| | | processor.setAnnotationProperties(props); |
| | | }else{ |
| | | processor = SpringUtil.getBean(DefaultProcessor.class); |
| | | processor.setAnnotationProperties(AnnotationProperties.getDefault()); |
| | | } |
| | | processor.setAnnotationProperties(props); |
| | | |
| | | return processor; |
| | | } |
| | | } |
| | |
| | | |
| | | @Setter |
| | | @Getter |
| | | @EqualsAndHashCode |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class NcNodeVO extends BaseVO { |
| | | @Schema(description = "èç¹åç§°") |
| | | private String name; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.springblade.mdm.task; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.flowable.engine.TaskService; |
| | | import org.flowable.task.api.TaskQuery; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.mdm.basesetting.producedivision.entity.MdmUser; |
| | | import org.springblade.mdm.basesetting.producedivision.service.MdmUserService; |
| | | import org.springblade.mdm.commons.contants.ParamConstants; |
| | | import org.springblade.mdm.commons.service.InternalEmailProperties; |
| | | import org.springblade.mdm.commons.service.InternalEmailService; |
| | | import org.springblade.mdm.commons.service.ParamService; |
| | | import org.springblade.mdm.program.service.NcProgramApprovedService; |
| | | import org.springblade.mdm.program.vo.NcProgramExportDncPageVO; |
| | | import org.springblade.mdm.program.vo.NcProgramExportDncQueryVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.scheduling.annotation.EnableScheduling; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å
é¨é®ä»¶ä»»å¡æé宿¶ä»»å¡ |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | @EnableScheduling |
| | | public class InternalEmailNotifyTask { |
| | | @Autowired |
| | | private MdmUserService mdmUserService; |
| | | @Autowired |
| | | private ParamService paramService; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private InternalEmailService internalEmailService; |
| | | @Autowired |
| | | private NcProgramApprovedService ncProgramApprovedService; |
| | | @Autowired |
| | | private InternalEmailProperties internalEmailProperties; |
| | | //@Value("${mail-remind.sender-account:xxx}") |
| | | //private String senderAccount; |
| | | |
| | | @Scheduled(cron = "${task.cron.innernal_email_notify:0 0 9 * * ?}") |
| | | public void execute() { |
| | | String notifyFlag = paramService.getParamValue(ParamConstants.EMAIL_NOTIFY_FLAG,ParamConstants.EMAIL_NOTIFY_FLAG_OFF); |
| | | |
| | | if("1".equals(notifyFlag)){ |
| | | //ç¶æä¸ºå¼å¯ï¼æ§è¡é®ä»¶éç¥ |
| | | queryAllUserTodo(); |
| | | } |
| | | |
| | | } |
| | | |
| | | void queryAllUserTodo(){ |
| | | List<MdmUser> allUsers = mdmUserService.list(); |
| | | |
| | | for(MdmUser user : allUsers){ |
| | | queryAndSendNotify(user); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ç¨æ·todoå¹¶åééç¥é®ä»¶ |
| | | * @param user |
| | | */ |
| | | private void queryAndSendNotify(MdmUser user) { |
| | | long flowTodoCount = queryFlowTodo(user.getId()); |
| | | long expTodoCount = queryExportTodo(user.getId()); |
| | | if(flowTodoCount + expTodoCount > 0){ |
| | | sendRemindEmail(flowTodoCount,expTodoCount,user.getAccount()); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * åéæéé®ä»¶ |
| | | * @param flowTodoCount |
| | | * @param expTodoCount |
| | | * @param userAccount |
| | | */ |
| | | void sendRemindEmail(long flowTodoCount,long expTodoCount,String userAccount){ |
| | | String content = buildMailConent(flowTodoCount,expTodoCount); |
| | | internalEmailService.send(this.internalEmailProperties.getSenderAccount(),userAccount,null,null,"MDMç¨åºç®¡ç任塿é",content,null); |
| | | } |
| | | String buildMailConent(long flowTodoCount,long expTodoCount){ |
| | | String content= String.format("æ¨å
±æ%sæ¡ä»»å¡å¾
å¤ç",(flowTodoCount+expTodoCount)); |
| | | if(flowTodoCount>0){ |
| | | content += "ï¼"+flowTodoCount+"æ¡ä¸ºå¾
å®¡æ¹æµç¨"; |
| | | } |
| | | if(flowTodoCount>0){ |
| | | content += "ï¼"+expTodoCount+"æ¡ä¸ºå¾
导åºå·¥æ§ç½ç¨åº"; |
| | | } |
| | | |
| | | return content+"ã"; |
| | | } |
| | | |
| | | private long queryFlowTodo(long userId){ |
| | | String userIdStr = "" + userId; |
| | | |
| | | TaskQuery todoQuery = taskService.createTaskQuery().taskAssignee(userIdStr).active().includeProcessVariables(); |
| | | |
| | | return todoQuery.count(); |
| | | } |
| | | |
| | | private long queryExportTodo(long userId){ |
| | | |
| | | NcProgramExportDncQueryVO query = new NcProgramExportDncQueryVO(); |
| | | query.setCurrent(1); |
| | | query.setSize(1); |
| | | |
| | | List<String> userRoleAliasList = Func.toStrList(",", AuthUtil.getUserRole());//è§è²å«åï¼å¤ä¸ªè§è²éå·åé |
| | | String managerRole = paramService.getProgramManagerRoleAlias(); |
| | | if(!userRoleAliasList.contains(managerRole) && !AuthUtil.isAdministrator() && !AuthUtil.isAdmin()){ |
| | | //éæ°æ§ç®¡çåè§è²ã管çåï¼éå¶æªåªè½å¯¼åºèªå·±çç¨åº |
| | | query.setUserId(userId); |
| | | } |
| | | |
| | | IPage<NcProgramExportDncPageVO> pages = ncProgramApprovedService.exportDncPageQuery(query); |
| | | return pages.getTotal(); |
| | | |
| | | } |
| | | } |
| | |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.mail.MessagingException; |
| | | import jakarta.xml.soap.SOAPException; |
| | | import jakarta.xml.ws.WebServiceContext; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.apache.neethi.AssertionBuilderFactory; |
| | | import org.apache.ws.commons.schema.XmlSchemaSerializer; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.mdm.basesetting.machine.entity.Machine; |
| | | import org.springblade.mdm.commons.service.EmailService; |
| | | import org.springblade.mdm.commons.service.InternalEmailService; |
| | | import org.springblade.mdm.flow.service.WIthdrawService; |
| | | import org.springblade.mdm.machinefile.entity.MachineFile; |
| | | import org.springblade.mdm.machinefile.service.MachineFileScanService; |
| | | import org.springblade.mdm.program.entity.NcNode; |
| | | import org.springblade.mdm.program.service.NcNodeService; |
| | | import org.springblade.mdm.program.service.ProgramAnnotationService; |
| | | import org.springblade.mdm.task.InternalEmailNotifyTask; |
| | | import org.springblade.mdm.task.MachineFileScanTask; |
| | | import org.springblade.mdm.utils.FileContentUtil; |
| | | import org.springblade.system.feign.IDictBizClient; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.wsdl.WSDLException; |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | |
| | | @Autowired |
| | | private IDictBizClient bizDictClient; |
| | | @Autowired |
| | | private EmailService mailService; |
| | | private InternalEmailService mailService; |
| | | @Autowired |
| | | private MachineFileScanService machineFileScanService; |
| | | @Autowired |
| | | private WIthdrawService withdrawService; |
| | | @Autowired |
| | | private InternalEmailNotifyTask notifyTask; |
| | | /** |
| | | * æ°å¢ |
| | | */ |
| | |
| | | return R.success(); |
| | | } |
| | | |
| | | @GetMapping("/repalce-anno") |
| | | @Operation(summary = "æ¿æ¢æ³¨é", description = "testæ«æ") |
| | | public R<List<String>> repalceAnno() throws IOException { |
| | | InputStream res; |
| | | try(FileInputStream fis = new FileInputStream("d:/b.txt");) { |
| | | res = programAnnotationService.setSendDirAndStatusAnnotation("D:/mysend", "PL", fis,"FANUC"); |
| | | } |
| | | List<String> lines = null; |
| | | if(res!=null) { |
| | | try(res) { |
| | | lines = IOUtils.readLines(res, "utf-8"); |
| | | } |
| | | } |
| | | return R.data(lines); |
| | | } |
| | | |
| | | @GetMapping("/dict-biz") |
| | | @Operation(summary = "biz", description = "testæ«æ") |
| | |
| | | machineFileScanService.scanMachineFile(); |
| | | } |
| | | |
| | | @GetMapping("/notify") |
| | | public void emailNotify(){ |
| | | SOAPException s; |
| | | notifyTask.execute(); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.springblade.mdm.commons.service; |
| | | |
| | | import org.junit.jupiter.api.Test; |
| | | |
| | | public class InternalEmailServiceTest { |
| | | |
| | | @Test |
| | | public void testSend(){ |
| | | InternalEmailService service = new InternalEmailService(); |
| | | |
| | | service.send("from","to","cc","bcc","é®ä»¶æé","æ¨æé£æ¡ä»»å¡è¦å¤ç",new String[]{"Path1"}); |
| | | } |
| | | |
| | | } |
| ÎļþÃû´Ó blade-service/blade-mdm/src/test/java/org/springblade/mdm/program/service/ProgramAnnotationServiceTest.java ÐÞ¸Ä |
| | |
| | | package org.springblade.mdm.program.service; |
| | | package org.springblade.mdm.program.service.programannotation; |
| | | |
| | | import org.junit.jupiter.api.Assertions; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.springblade.mdm.program.service.ProgramAnnotationService; |
| | | import org.springblade.system.pojo.entity.DictBiz; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | public class ProgramAnnotationServiceTest { |
| | | public class AnnotationUtilTest { |
| | | |
| | | @Test |
| | | public void testIsAnnotation(){ |
| | |
| | | xmz.setRemark("*-,"); |
| | | |
| | | List<DictBiz> dictList = Arrays.asList(fanucDict, xmz); |
| | | Assertions.assertTrue(s.isAnnotation("(abc)","FANUC", dictList)); |
| | | Assertions.assertFalse(s.isAnnotation("*-","FANUC",dictList)); |
| | | Assertions.assertTrue(s.isAnnotation("*-","XIMENZI", dictList)); |
| | | Assertions.assertTrue(AnnotationUtil.isAnnotation("(abc)","FANUC", dictList)); |
| | | Assertions.assertFalse(AnnotationUtil.isAnnotation("*-","FANUC",dictList)); |
| | | Assertions.assertTrue(AnnotationUtil.isAnnotation("*-","XIMENZI", dictList)); |
| | | } |
| | | |
| | | @Test |
| | |
| | | xmz.setRemark("*-,"); |
| | | List<DictBiz> dictList = Arrays.asList(fanucDict, xmz); |
| | | |
| | | Assertions.assertEquals("(A)",s.generateAnnotation("A","FANUC",dictList)); |
| | | Assertions.assertEquals("(A)",AnnotationUtil.generateAnnotation("A","FANUC",dictList)); |
| | | |
| | | Assertions.assertEquals("*-A",s.generateAnnotation("A","XIMENZI",dictList)); |
| | | Assertions.assertEquals("*-A",AnnotationUtil.generateAnnotation("A","XIMENZI",dictList)); |
| | | } |
| | | } |