| | |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.flowable.engine.HistoryService; |
| | | import org.springblade.core.excel.util.ExcelUtil; |
| | | import org.springblade.core.mp.support.Condition; |
| | |
| | | @Tag(name = "现场编制导出", description = "现场编制导出") |
| | | public class ProgramOnMachineExportController { |
| | | |
| | | private FlowCommonService flowCommonService; |
| | | private ProgramOnMachineExportService programOnMachineService; |
| | | private final TaskDispatchService taskDispatchService; |
| | | private final HistoryService historyService; |
| | | |
| | | @GetMapping("/finished-page") |
| | | @ApiOperationSupport(order = 3) |
| | | @Operation(summary = "已审批列表", description = "已审批列表") |
| | | @Operation(summary = "现场编制待导出列表", description = "现场编制待导出列表") |
| | | public R<IPage<FlowVO>> finishedPage(ProgramOnMachineQueryVO queryVO) { |
| | | IPage<FlowVO> pages = programOnMachineService.finishedPage(Condition.getPage(queryVO), queryVO); |
| | | return R.data(pages); |
| | |
| | | excel.setMachineCode(Func.toStr(vars.get(FlowVariableConstant.MACHINE_CODE))); |
| | | excel.setProcessInstanceId(record.getProcessInstanceId()); |
| | | excel.setDeviation(Func.toStr(record.getVariables().get(FlowVariableConstant.DEVIATION))); |
| | | if(StringUtils.isNotBlank(excel.getDeviation())) { |
| | | excel.setDeviationSerial(taskDispatchService.getDeviationSerial(Func.toStr(vars.get(FlowVariableConstant.PROGRAM_NO))) + "");//更改单序号 |
| | | } |
| | | list.add(excel); |
| | | }); |
| | | ExcelUtil.export(response, "现场编制记录" + DateUtil.time(), "现场编制记录", list, ProgramOnMachineExcel.class); |
| | |
| | | private String processEdition; |
| | | @ExcelProperty("临时更改单") |
| | | private String deviation; |
| | | |
| | | @ExcelProperty("临时更改单序号") |
| | | private String deviationSerial; |
| | | @ColumnWidth(20) |
| | | @ExcelProperty("机床编号") |
| | | private String machineCode; |
| | | |
| | | @ColumnWidth(20) |
| | | @ColumnWidth(38) |
| | | @ExcelProperty("流程编号") |
| | | private String processInstanceId; |
| | | |
| | |
| | | public static final int EXCEPTION_NOT_MATCH_RECORD = 5; |
| | | |
| | | /** |
| | | * 不匹配下发记录临时更改单部分 |
| | | */ |
| | | public static final int EXCEPTION_NOT_MATCH_SEND_LG = 6; |
| | | /** |
| | | * 文件名 |
| | | */ |
| | | private String name; |
| | |
| | | case EXCEPTION_LOST_FILES -> "文件确失"; |
| | | case EXCEPTION_NOT_MATCH_SEND_SEG_COUNT -> "段数与下发记录不匹配"; |
| | | case EXCEPTION_NOT_MATCH_RECORD -> "无记录匹配";//试切下发,现场编程都不匹配 |
| | | case EXCEPTION_NOT_MATCH_SEND_LG -> "临时更改单不匹配"; |
| | | default -> "正常"; |
| | | }; |
| | | } |
| | |
| | | private final OssTemplate ossTemplate; |
| | | private final MachineFileService machineFileService; |
| | | private final MachineService machineService; |
| | | private final MachineAnnotationConfig annoConfig; |
| | | private final AnnotationProcessorHelper annotationProcessorHelper; |
| | | private final ProgramAnnotationService programAnnotationService; |
| | | /** |
| | | * 导出到涉密网 |
| | |
| | | os.close(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * j将输入流加入zip |
| | | * @param zipOut zip文件输出里路 |
| | | * @param inputStream 文件的输入流 |
| | | * @param entryName entryName |
| | | * @param filename 原始文件名 |
| | | * @param machineCode 机床代码 |
| | | * @throws IOException 异常 |
| | | */ |
| | | public void addInputStreamToZip(ZipOutputStream zipOut, InputStream inputStream, String entryName,String filename,String machineCode) |
| | | throws IOException { |
| | | // 创建新的 ZIP 条目 |
| | |
| | | */ |
| | | InputStream setAnnotations(InputStream inputStream,String filename,String machineCode) throws IOException { |
| | | Machine machine = this.machineService.getByCode(machineCode); |
| | | AnnotationProcessor annoProcessor = ProcessorHelper.getProcessor(machine.getControlSystem(),annoConfig); |
| | | AnnotationProcessor annoProcessor = annotationProcessorHelper.getProcessor(machine.getControlSystem()); |
| | | |
| | | AnnotationData annoData = new AnnotationData(); |
| | | annoData.setFilename(filename); |
| | |
| | | |
| | | AnnotationProperties annoProps = annoProcessor.getAnnotationProperties(); |
| | | |
| | | ByteArrayInputStream bais = new ByteArrayInputStream(IOUtils.toByteArray(inputStream)); |
| | | String statusLine = FileContentUtil.readLineAt(bais,annoProps.getStatusLineIndex()); |
| | | ByteArrayInputStream byteInsStream = new ByteArrayInputStream(IOUtils.toByteArray(inputStream)); |
| | | String statusLine = FileContentUtil.readLineAt(byteInsStream,annoProps.getStatusLineIndex()); |
| | | String text = programAnnotationService.removeAnnotation(machine.getControlSystem(),statusLine); |
| | | |
| | | if(AnnotationUtil.isStatusContent(text)){ |
| | |
| | | //没有按试切处理 |
| | | annoData.setProgramStatus(AnnotationUtil.SQ); |
| | | } |
| | | bais.reset(); |
| | | byteInsStream.reset(); |
| | | // |
| | | return annoProcessor.putAnnotation(annoData,bais); |
| | | return annoProcessor.putAnnotation(annoData,byteInsStream); |
| | | } |
| | | } |
| | | |
| | |
| | | import com.qiniu.util.IOUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.codec.digest.DigestUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.mdm.basesetting.machine.entity.Machine; |
| | |
| | | //非文本 |
| | | excepType = MachineFile.EXCEPTION_NOT_TEXT; |
| | | }else{ |
| | | Matcher matcher = RegExpConstants.PROGRAM_FILE_PATTERN.matcher(machineFile.getName()); |
| | | |
| | | boolean filenameValid = matcher.find(); |
| | | //Matcher matcher = RegExpConstants.PROGRAM_FILE_PATTERN.matcher(machineFile.getName()); |
| | | ProgramNameVO progNameVO = ProgramFileNameParser.parseProgramName(machineFile.getName()); |
| | | boolean filenameValid = progNameVO.isValidFilename(); |
| | | if(!filenameValid){ |
| | | excepType = MachineFile.EXCEPTION_BAD_FILENAME; |
| | | }else { |
| | | ProgramNameVO progNameVO = ProgramFileNameParser.parseProgramName(machineFile.getName()); |
| | | |
| | | String prefix = progNameVO.logicProgramName()+"-"; |
| | | long matchCount = allFilesInDir.stream().filter(file -> file.getName().startsWith(prefix)).count(); |
| | | if(matchCount != progNameVO.getSegmentCount()){//文件段数缺失 |
| | |
| | | if(progNameVO.getSegmentCount() != sendProgNameVO.getSegmentCount()){ |
| | | //段数不匹配下发记录 |
| | | excepType = MachineFile.EXCEPTION_NOT_MATCH_SEND_SEG_COUNT; |
| | | }else if(!StringUtils.equals(sendProgNameVO.getLgPart(),progNameVO.getLgPart())){ |
| | | excepType = MachineFile.EXCEPTION_NOT_MATCH_SEND_LG; |
| | | } |
| | | }else{ |
| | | matchSendRecord = false; |
| | |
| | | |
| | | if(!matchSendRecord){//如果文件未下发过,查看是否有现场编程记录 |
| | | byteStream.reset(); |
| | | //TODO 下面这些应该都没有,因为时现场编程 |
| | | String planStatusLine = AnnotationUtil.removeAnnotation(machine.getControlSystem(),FileContentUtil.readLineAt(byteStream,annoProps.getStatusLineIndex()),programAnnotationService.getAnnotionDictList()); |
| | | |
| | | String lgNo;//更改单号 |
| | |
| | | .eq(ProgramOnMachine::getDrawingNo,progNameVO.getDrawingNo()) |
| | | .eq(ProgramOnMachine::getProcessNo,progNameVO.getProcessNo()) |
| | | .eq(ProgramOnMachine::getProcessEdition,progNameVO.getProcessEdition()) |
| | | .eq(lgNo != null,ProgramOnMachine::getDeviation,lgNo)//临时更改单匹配 |
| | | .eq(lgNo != null,ProgramOnMachine::getDeviation,lgNo)//TODO 临时更改单序号匹配 |
| | | |
| | | .eq(ProgramOnMachine::getMachineCode,machineFile.getMachineCode()).count(); |
| | | |
| | |
| | | public R<IPage<NcProgramExportDncPageVO>> page(NcProgramExportDncQueryVO query) { |
| | | String userRole = AuthUtil.getUserRole();//角色别名,多个角色逗号分隔 |
| | | List<String> userRoleAliasList = Func.toStrList(",", userRole); |
| | | |
| | | /* |
| | | String managerRole = paramService.getProgramManagerRoleAlias(); |
| | | if(!userRoleAliasList.contains(managerRole) && !AuthUtil.isAdministrator() && !AuthUtil.isAdmin()){ |
| | | //非数控管理员角色、管理员,限制未只能导出自己的程序 |
| | | query.setUserId(AuthUtil.getUserId()); |
| | | } |
| | | |
| | | }*/ |
| | | query.setUserId(AuthUtil.getUserId()); |
| | | query.setUserDeptIds(Func.toLongList(AuthUtil.getDeptId())); |
| | | return R.data(ncProgramApprovedService.exportDncPageQuery(query)); |
| | | } |
| | | |
| | |
| | | * 临时更改单 |
| | | */ |
| | | private String deviation; |
| | | |
| | | /** |
| | | * 临时更改单序号 |
| | | */ |
| | | private String deviationSerial; |
| | | /** |
| | | * 流程实例id |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 导出dnc分页列表查询,查询审批通过的程序数据 |
| | | * @param page |
| | | * @param query |
| | | * @return |
| | | * @param page 分页信息 |
| | | * @param query 查询数据 |
| | | * @return 分页数据 |
| | | */ |
| | | IPage<NcProgramExportDncPageVO> exportDncPageQuery(@Param("page")IPage<NcProgramExportDncPageVO> page, @Param("query") NcProgramExportDncQueryVO query); |
| | | } |
| | |
| | | <result column="update_time" property="updateTime"/> |
| | | <result column="is_deleted" property="isDeleted"/> |
| | | </resultMap> |
| | | <!--导出工控网分页查询--> |
| | | <select id="exportDncPageQuery" resultType="org.springblade.mdm.program.vo.NcProgramExportDncPageVO"> |
| | | select a.id,a.title,n.name,a.nc_node_id,n.process_no,n.process_edition,n.drawing_no,n.drawing_no_edition,n.process_name,a.create_time,a.update_time,u.name exporter |
| | | from mdm_nc_program_approved a |
| | | inner join mdm_nc_node_his n on a.nc_node_id=n.id |
| | | left join blade_user u on a.update_user=u.id |
| | | |
| | | <where> |
| | | a.is_deleted=0 and a.status=#{query.status} |
| | | <if test="query.name!=null and query.name!=''"> |
| | |
| | | <if test="query.createTimeEnd!=null"> |
| | | and a.create_time <= #{query.createTimeEnd} |
| | | </if> |
| | | <if test="query.userId!=null"> |
| | | <if test="query.queryType == 'self'"> |
| | | and a.programmer_id = #{query.userId} |
| | | </if> |
| | | <if test="query.queryType=='group'"> |
| | | and a.programmer_id IN |
| | | ( |
| | | select id from blade_user where |
| | | <foreach collection="query.userDeptIds" item="deptId" open="(" separator="or" close=")" > |
| | | dept_id like #{deptId} |
| | | </foreach> |
| | | ) |
| | | |
| | | </if> |
| | | </where> |
| | | order by a.create_time desc |
| | | </select> |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.mp.base.BizServiceImpl; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.mdm.basesetting.producedivision.mapper.MdmUserMapper; |
| | | import org.springblade.mdm.program.entity.NcProgramApproved; |
| | | import org.springblade.mdm.program.mapper.NcProgramApprovedMapper; |
| | | import org.springblade.mdm.program.vo.NcProgramExportDncPageVO; |
| | |
| | | query.setStatus(NcProgramApproved.STATUS_NOT_EXPORT); |
| | | } |
| | | |
| | | |
| | | return this.getBaseMapper().exportDncPageQuery(Condition.getPage(query),query); |
| | | } |
| | | |
| | |
| | | import org.springblade.core.mp.support.Query; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 分页拆线呢 |
| | |
| | | public class NcProgramExportDncQueryVO extends Query { |
| | | @Schema(description = "程序名称") |
| | | private String name; |
| | | @Schema(description = "查询范围") |
| | | private String queryType; |
| | | |
| | | @Schema(description = "通过时间开始") |
| | | private Date createTimeBegin; |
| | | @Schema(description = "通过时间截止") |
| | |
| | | |
| | | @Schema(description = "用户id,非管理员指定该id,只能查询自己的程序记录") |
| | | private Long userId; |
| | | @Schema(description = "用户部门id,用于查询本部门的数据") |
| | | private List<Long> userDeptIds; |
| | | } |
| | |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | import java.time.LocalDate; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | |
| | | |
| | | |
| | | |
| | | fname = "T-9-B-5-3.txt"; |
| | | fname = "T-9-B-5-3.TXT"; |
| | | vo = ProgramFileNameParser.parseProgramName(fname); |
| | | Assertions.assertEquals(5,vo.getSegmentCount()); |
| | | Assertions.assertEquals(3,vo.getSegmentNo()); |
| | |
| | | |
| | | Assertions.assertEquals("9",vo.getProcessNo()); |
| | | Assertions.assertEquals("T",vo.getDrawingNo()); |
| | | |
| | | fname = "T1-9-B-5-3.nc"; |
| | | vo = ProgramFileNameParser.parseProgramName(fname); |
| | | Assertions.assertEquals("T1",vo.getDrawingNo()); |
| | | Assertions.assertEquals("9",vo.getProcessNo()); |
| | | Assertions.assertEquals("B",vo.getProcessEdition()); |
| | | } |
| | | } |
| | |
| | | `drawing_no` varchar(100) NULL COMMENT '零组件编号/图号', |
| | | `process_no` varchar(100) NULL COMMENT '工序号', |
| | | `process_edition` varchar(40) DEFAULT NULL COMMENT '工序版次', |
| | | `machine_code` varchar(100) DEFAULT NULL COMMENT '设备编号/机床编号', |
| | | `machine_code` varchar(100) DEFAULT NULL COMMENT '机床编号', |
| | | `deviation` varchar(100) DEFAULT NULL COMMENT '临时更改单', |
| | | `process_instance_id` varchar(64) DEFAULT NULL COMMENT '流程实例id', |
| | | `status` int DEFAULT NULL COMMENT '业务状态', |
| | | `create_dept` bigint DEFAULT NULL COMMENT '创建单位', |