| | |
| | | import org.jeecg.modules.dnc.entity.Cutter; |
| | | import org.jeecg.modules.dnc.entity.DocFile; |
| | | import org.jeecg.modules.dnc.entity.DocInfo; |
| | | import org.jeecg.modules.dnc.entity.GuideCardBatch; |
| | | import org.jeecg.modules.dnc.exception.ExceptionCast; |
| | | import org.jeecg.modules.dnc.mapper.CutterMapper; |
| | | import org.jeecg.modules.dnc.response.CommonCode; |
| | | import org.jeecg.modules.dnc.service.ICutterService; |
| | | import org.jeecg.modules.dnc.service.IDocFileService; |
| | | import org.jeecg.modules.dnc.service.IDocInfoService; |
| | | import org.jeecg.modules.dnc.service.IGuideCardBatchService; |
| | | import org.jeecg.modules.dnc.utils.ValidateUtil; |
| | | import org.jeecg.modules.dnc.utils.file.FileUtilS; |
| | | import org.jeecg.modules.system.service.ISysDictService; |
| | | import org.jeecg.modules.tms.entity.PreparationOrderDetail; |
| | | import org.jeecg.modules.tms.entity.dto.PreparationOrderAndDetailDto; |
| | | import org.jeecg.modules.tms.service.IPreparationOrderService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | private IDocFileService docFileService; |
| | | |
| | | @Autowired |
| | | private ISysDictService sysDictService; |
| | | private IGuideCardBatchService guideCardBatchService; |
| | | |
| | | @Autowired |
| | | private IPreparationOrderService preparationOrderService; |
| | | /** |
| | | * 新增刀具信息 |
| | | * @param cutter |
| | |
| | | return Result.error("未发现刀具的参数信息注释,无法提取刀具信息"); |
| | | } |
| | | this.saveBatch(newCutterList); |
| | | //TODO发送刀具管理数据 |
| | | return Result.OK("提取刀具信息成功"); |
| | | }else { |
| | | return Result.error("未发现刀具的参数信息注释,无法提取刀具信息"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Result<?> sendToCutterSystem(String docId,String attributionId,Integer attributionType){ |
| | | List<Cutter> cutterList = this.list(new QueryWrapper<Cutter>() |
| | | .eq("doc_id", docId) |
| | | .eq(StrUtil.isNotEmpty(attributionId),"attribution_id",attributionId) |
| | | .eq("attribution_type",attributionType)); |
| | | if (cutterList == null || cutterList.isEmpty()) { |
| | | return Result.error("未发现刀具信息,无法发送到刀具系统"); |
| | | } |
| | | if (cutterList.stream().anyMatch(item -> item.getCutterCode() == null)) { |
| | | return Result.error("未发现刀具编号信息,无法发送到刀具系统"); |
| | | } |
| | | //获取最新数控程序加工确认表 |
| | | List<GuideCardBatch> guideCardBatchList = guideCardBatchService.list(new QueryWrapper<GuideCardBatch>() |
| | | .eq("doc_id", docId) |
| | | .isNotNull("serial_number") |
| | | .orderByDesc("SUBSTRING(serial_number, LEN(serial_number)-3, 4)")); |
| | | if (guideCardBatchList == null || guideCardBatchList.isEmpty()) { |
| | | return Result.error("未发现程序加工确认表信息,无法发送到刀具系统"); |
| | | } |
| | | GuideCardBatch guideCardBatch = guideCardBatchList.get(0); |
| | | PreparationOrderAndDetailDto dto = new PreparationOrderAndDetailDto(); |
| | | dto.setPartDrawingNo(guideCardBatch.getPartsCode()); |
| | | dto.setPartName(guideCardBatch.getPartsName()); |
| | | dto.setPartMaterial(guideCardBatch.getMaterielDesp()); |
| | | dto.setProductionProcessesNo(guideCardBatch.getProcessWorkCode()); |
| | | dto.setBatchCode(guideCardBatch.getProcessingBatch()); |
| | | dto.setMachiningCount(guideCardBatch.getProcessingQuantity()); |
| | | dto.setEquipmentCode(guideCardBatch.getProcessingEquipment()); |
| | | dto.setNcName(guideCardBatch.getDocName()); |
| | | List<PreparationOrderDetail> detailList = new ArrayList<>(); |
| | | cutterList.forEach(item -> { |
| | | PreparationOrderDetail detail = new PreparationOrderDetail(); |
| | | detail.setToolCode(item.getToolsId()); |
| | | detailList.add(detail); |
| | | }); |
| | | dto.setPreparationOrderDetailList(detailList); |
| | | preparationOrderService.addPreparationOrderFromDnc(dto); |
| | | return Result.OK("发送到刀具系统成功"); |
| | | } |
| | | |
| | | public List<Cutter> extractToolAfterM6(DocInfo docInfo, List<String> ncLines) { |
| | | List<Cutter> cutterList = new ArrayList<>(); |
| | | String currentToolCode = null; // 用于追踪当前换刀指令的刀具号 |