From 0003a83af8d4035655ff6875b943eda625786339 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 1 Jul 2025 10:41:41 +0800 Subject: [PATCH] =?UTF-8?q?spotbugs=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ext/mes/pcn/apiservice/mqtt/PcnMqttClient.java | 3 +- .../serviceimpl/busi/MesProduceSnPrintService.java | 2 +- .../serviceimpl/busi/MesWorkOrderService.java | 2 ++ ...eckVolvoRackNoAndPartNoStrategyServiceImpl.java | 2 +- .../MesWorkOrderOfflineRestoreDispatchService.java | 5 +-- .../strategy/ChengDuVolvoPartPrintStrategy.java | 2 +- pom.xml | 36 +++++++++++++++++++++- spotbugs-exclude.xml | 16 ++++++++++ spotbugs-include.xml | 8 +++++ 9 files changed, 66 insertions(+), 10 deletions(-) create mode 100644 spotbugs-exclude.xml create mode 100644 spotbugs-include.xml diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/mqtt/PcnMqttClient.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/mqtt/PcnMqttClient.java index 4c6fe2b..9e816c8 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/mqtt/PcnMqttClient.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/mqtt/PcnMqttClient.java @@ -131,14 +131,13 @@ public class PcnMqttClient { MqttTopic mqttTopic = PcnMqttClient.getClient().getTopic(topic); if (null == mqttTopic) { log.error("== MyMqttClient ==> topic is not exist"); + return; } MqttDeliveryToken token;//Delivery:配送 synchronized (this) {//注意:这里一定要同步,否则,在多线程publish的情况下,线程会发生死锁,分析见文章最后补充 try { token = mqttTopic.publish(message);//也是发送到执行队列中,等待执行线程执行,将消息发送到消息中间件 token.waitForCompletion(1000L); - } catch (MqttPersistenceException e) { - e.printStackTrace(); } catch (MqttException e) { e.printStackTrace(); } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesProduceSnPrintService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesProduceSnPrintService.java index 1dc41e1..d779658 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesProduceSnPrintService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesProduceSnPrintService.java @@ -357,7 +357,7 @@ public class MesProduceSnPrintService implements IMesProduceSnPrintService { //模板信息丢失抛出异常 if (labelTemplate == null) { - workOrderCutDb.setRemark(String.format("请检查裁片方案,裁片方案[%s]模板代码[%s]无效!", cutScheme.getCutCode(), cutScheme.getTemplateCode())); + workOrderCutDb.setRemark(String.format("请检查裁片方案,裁片方案[%s]模板代码[%s]无效!", cutScheme != null ? cutScheme.getCutCode() : "", cutScheme != null ? cutScheme.getTemplateCode() : "")); workOrderCutDb.setSystemSyncStatus(CommonEnumUtil.FALSE); ConvertBean.serviceModelUpdate(workOrderCutDb, workOrderCut.getModifyUser()); continue; diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java index 3c9bb6f..cb846cc 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesWorkOrderService.java @@ -951,6 +951,7 @@ public class MesWorkOrderService implements IMesWorkOrderService { d = df.parse(lotNo); } catch (ParseException e) { e.printStackTrace(); + return ""; } Calendar cal = Calendar.getInstance(); cal.setTime(d); @@ -1808,6 +1809,7 @@ public class MesWorkOrderService implements IMesWorkOrderService { d = df.parse(lotNo); } catch (ParseException e) { e.printStackTrace(); + return ""; } Calendar cal = Calendar.getInstance(); cal.setTime(d); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/shippingscan/strategy/MesShippingCheckVolvoRackNoAndPartNoStrategyServiceImpl.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/shippingscan/strategy/MesShippingCheckVolvoRackNoAndPartNoStrategyServiceImpl.java index 0f54054..29032d2 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/shippingscan/strategy/MesShippingCheckVolvoRackNoAndPartNoStrategyServiceImpl.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/shippingscan/strategy/MesShippingCheckVolvoRackNoAndPartNoStrategyServiceImpl.java @@ -114,7 +114,7 @@ public class MesShippingCheckVolvoRackNoAndPartNoStrategyServiceImpl implements } MesCustSortInfo custSoftInfo = custSoftInfoRDao.getById(Long.parseLong(workOrder.getWorkOrderSource())); if (custSoftInfo == null || !Objects.equals(detail.getCustInfoSeq(), custSoftInfo.getCustInfoSeq())) { - throw new ImppBusiException(String.format("发运单【%s】启用明细顺序防错,序号【%s】前还有未扫描的发运单明细,请检查数据!", orderManagement.getShippingCode(), custSoftInfo.getCustInfoSeq())); + throw new ImppBusiException(String.format("发运单【%s】启用明细顺序防错,序号【%s】前还有未扫描的发运单明细,请检查数据!", orderManagement.getShippingCode(), custSoftInfo != null ? custSoftInfo.getCustInfoSeq() : "")); } } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/job/MesWorkOrderOfflineRestoreDispatchService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/job/MesWorkOrderOfflineRestoreDispatchService.java index 52f513b..f929bc1 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/job/MesWorkOrderOfflineRestoreDispatchService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/job/MesWorkOrderOfflineRestoreDispatchService.java @@ -174,8 +174,7 @@ public class MesWorkOrderOfflineRestoreDispatchService implements IMesWorkOrderO } //工单装配件离线数据根据工位进行分组 - Map> cellMap = CollectionUtils.isEmpty(workOrderAssemblyOfflineList) ? null : - workOrderAssemblyOfflineList.stream().filter(o -> null != o).collect(Collectors.groupingBy(MesWorkOrderAssemblyOffline::getWorkCellCode)); + Map> cellMap = workOrderAssemblyOfflineList.stream().filter(o -> null != o).collect(Collectors.groupingBy(MesWorkOrderAssemblyOffline::getWorkCellCode)); //解析加工记录工位字段信息 拼接新增过的工位加工记录 [{"id":"1","workCellCode":"100-10"},{"id":"2","workCellCode":"100-20"}....] List productionRecordOfflineModelList = StringUtils.isEmpty(workOrderOffline.getProductionRecord()) ? new ArrayList<>() : JSONObject.parseArray(workOrderOffline.getProductionRecord(), MesProductionRecordOfflineModel.class); @@ -284,9 +283,7 @@ public class MesWorkOrderOfflineRestoreDispatchService implements IMesWorkOrderO productionRecordOfflineModelList.add(new MesProductionRecordOfflineModel(entry.getKey(), productionRecord.getId().toString())); workOrderOffline.setProductionRecord(JSONObject.toJSONString(productionRecordOfflineModelList)); } - } - } private void saveProductionRecordReportStatus(String organizeCode, MesWorkOrderOffline workOrderOffline) { diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/ChengDuVolvoPartPrintStrategy.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/ChengDuVolvoPartPrintStrategy.java index bfb6621..a3fbb1b 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/ChengDuVolvoPartPrintStrategy.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/ChengDuVolvoPartPrintStrategy.java @@ -98,7 +98,7 @@ public class ChengDuVolvoPartPrintStrategy implements IPrintTemplateStrategyServ private Map getPrintContextMap(MesProduceSn produceSn, MesWorkOrder workOrder) { if (workOrder == null || StringUtils.isEmpty(workOrder.getWorkOrderSource())) { - MesPcnException.throwBusiException("客户条码[%s]对应的工单信息缺少来源!", workOrder.getCustSn()); + MesPcnException.throwBusiException("客户条码[%s]对应的工单信息缺少来源!", workOrder != null ? workOrder.getCustSn() : ""); } MesCustSortInfo custSoftInfo = custSoftInfoRDao.getById(Long.parseLong(workOrder.getWorkOrderSource())); diff --git a/pom.xml b/pom.xml index e55d478..31c4724 100644 --- a/pom.xml +++ b/pom.xml @@ -34,7 +34,7 @@ 1.0.1-YZ 1.0.0-yfai 1.0.0.1-patch - 1.0.3-yfai + 1.0.4-yfai 2.17.1 @@ -210,6 +210,40 @@ maven-surefire-plugin ${maven-surefire-plugin.version} + + com.github.spotbugs + spotbugs-maven-plugin + 4.8.3.1 + + + + spotbugs-check + package + + check + + + + + + + spotbugs-exclude.xml + + + false + + true + true + + + + + com.github.spotbugs + spotbugs + 4.8.4 + + + ${project.artifactId}-${project.version} diff --git a/spotbugs-exclude.xml b/spotbugs-exclude.xml new file mode 100644 index 0000000..033ae4e --- /dev/null +++ b/spotbugs-exclude.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spotbugs-include.xml b/spotbugs-include.xml new file mode 100644 index 0000000..cf7e67d --- /dev/null +++ b/spotbugs-include.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file