| | |
| | | import org.jeecg.modules.flowable.service.IFlowTaskService; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipment; |
| | | import org.jeecg.modules.mdc.service.IMdcEquipmentService; |
| | | import org.jeecg.modules.message.enums.DeployEnum; |
| | | import org.jeecg.modules.system.service.IMdcProductionService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private IFlowMyBusinessService flowMyBusinessService; |
| | | @Autowired |
| | | private PermissionService permissionService; |
| | | |
| | | @Value("${securedoc.whether}") |
| | | private String whether; |
| | | @Value("${securedoc.localFilePath}") |
| | | private String localFilePath; |
| | | @Autowired |
| | | private IDncPassLogService dncPassLogService; |
| | | @Value("${deploy.deployType}") |
| | | //工控网/涉密网部署 0为工控网 1为涉密网 |
| | | private String deployType; |
| | | @Value("${deploy.secretFolder}") |
| | | //涉密网传输nc文件夹 |
| | | private String secretFolder; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | |
| | | |
| | | } |
| | | handleFileTransfer(mdcEquipment, docFile); |
| | | handleFileProcessing(docFile, mdcEquipment, whether, localFilePath); |
| | | //注意----区分工控网与涉密网!!! 涉密网进行NC文件的拷贝,工控网负责进行解析NC文件 |
| | | if (deployType.equals(DeployEnum.SMW.getCode())) { |
| | | handleFileProcessing(docFile, mdcEquipment, secretFolder); |
| | | } |
| | | synchronizedFlagService.updateFlag(2); |
| | | return Result.OK("操作成功"); |
| | | } |
| | |
| | | docFile.getFileName(),docFile.getFileSuffix()); |
| | | } |
| | | } |
| | | } |
| | | //注意----区分工控网与涉密网!!! 涉密网进行NC文件的拷贝,工控网负责进行解析NC文件 |
| | | if (deployType.equals(DeployEnum.SMW.getCode())) { |
| | | handleFileProcessing(docFile, mdcEquipment, secretFolder); |
| | | } |
| | | return synchronizedFlagService.updateFlag(1); |
| | | }else if(up.getStatus() == 3) { |
| | |
| | | } |
| | | |
| | | //封装处理文件 |
| | | private void handleFileProcessing(DocFile docFile, MdcEquipment mdcEquipment, String whether, String localFilePath) { |
| | | if (whether.equals("true") && !docFile.getFileSuffix().equals("zip") && !docFile.getFileSuffix().equals("rar")) { |
| | | private void handleFileProcessing(DocFile docFile, MdcEquipment mdcEquipment, String secretFolder) { |
| | | if (!docFile.getFileSuffix().equals("zip") && !docFile.getFileSuffix().equals("rar")) { |
| | | String size = FileUtilS.fileSizeNC(docFile.getFilePath(), docFile.getFileEncodeName()); |
| | | List<String> strings = iMdcProductionService.findListParentTreeAll(mdcEquipment.getId()); |
| | | if (strings != null && !strings.isEmpty()) { |
| | | DncPassLog passInfoTxt = new DncPassLog(); |
| | | |
| | | String path = StringUtils.join(strings.toArray(), "/"); |
| | | Date dateFirst = DateUtil.getNow(); |
| | | passInfoTxt.setDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)); |
| | | /*查询最后一条记录*/ |
| | | //休眠 500毫秒 |
| | | DncPassLog dncPassLog = dncPassLogService.findDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)); |
| | | int fileTxt = 0, fileNc =0; |
| | | if (dncPassLog !=null) { |
| | | fileTxt = dncPassLog.getSequenceNumber() + 1; |
| | | } else { |
| | | fileTxt = 1; |
| | | } |
| | | fileNc = fileTxt + 1; |
| | | //处理文件名称 文件路径 |
| | | String sequence = String.format("%06d",fileTxt); |
| | | String sequenceNc = String.format("%06d",fileNc); |
| | | passInfoTxt.setSequenceNumber(fileTxt); |
| | | passInfoTxt.setSequenceOrder(sequence); |
| | | passInfoTxt.setCreateTime(dateFirst); |
| | | System.out.println(DateUtil.format(dateFirst,DateUtil.STR_DATE_TIME)); |
| | | passInfoTxt.setPassType("02"); |
| | | dncPassLogService.save(passInfoTxt); |
| | | |
| | | DncPassLog passInfoNc = new DncPassLog(); |
| | | passInfoNc.setSequenceNumber(fileNc); |
| | | passInfoNc.setSequenceOrder(sequenceNc); |
| | | passInfoNc.setDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)); |
| | | passInfoNc.setPassType("02"); |
| | | passInfoNc.setPassName(docFile.getFileName()); |
| | | try { |
| | | Thread.sleep(1000); |
| | | Date date = new Date(); |
| | | passInfoNc.setCreateTime(date); |
| | | System.out.println(DateUtil.format(date,DateUtil.STR_DATE_TIME)); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | dncPassLogService.save(passInfoNc); |
| | | NcTxtFilePathInfo ncTxt = new NcTxtFilePathInfo(); |
| | | ncTxt.setEquipmentId(mdcEquipment.getEquipmentId()); |
| | | ncTxt.setFileNcName("02A" + DateUtil.format(dateFirst, DateUtil.STR_YEARMONTHDAY)); |
| | | ncTxt.setFileTxtName("02A" + DateUtil.format(dateFirst, DateUtil.STR_YEARMONTHDAY)); |
| | | ncTxt.setFileNcName("10A"+DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)+sequenceNc); |
| | | ncTxt.setFileTxtName("10A"+DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)+sequence); |
| | | ncTxt.setFilePath(path + "/" + mdcEquipment.getEquipmentId() + "/"); |
| | | ncTxt.setOrigFileName(docFile.getFileName()); |
| | | ncTxt.setOrigFileSuffix(docFile.getFileSuffix()); |
| | | ncTxt.setFileAddOrDelete(1); |
| | | String loFilePath = localFilePath + ncTxt.getFileTxtName() + ".nc"; |
| | | String loFilePath = secretFolder +"/"+ ncTxt.getFileTxtName() + ".nc"; |
| | | try { |
| | | String allList = ncTxt.getFileTxtName() + "\n" |
| | | + ncTxt.getFileNcName() + "\n" |
| | |
| | | FileUtilS.fileWriterSql(loFilePath, allList); |
| | | boolean copyFileNc = FileUtilS.copyFileUpName(path + "/" + mdcEquipment.getEquipmentId() + "/send/" + |
| | | docFile.getFileName(), |
| | | localFilePath + ncTxt.getFileNcName(), |
| | | secretFolder +"/"+ncTxt.getFileNcName(), |
| | | docFile.getFileSuffix(), "NC"); |
| | | if (!copyFileNc) { |
| | | FileUtilS.deleteNcFile(loFilePath); |