From 6d280550e75a3284cf2923c9893cf72c34f505a9 Mon Sep 17 00:00:00 2001 From: mengjiao <3338049200@qq,com> Date: Thu, 6 Jun 2024 15:27:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?wms=E5=8C=85=E6=9D=90=E5=87=BA=E5=BA=93?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=96=B0=E5=A2=9E=E9=A1=B5=E9=9D=A2=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../op/wms/mapper/OdsProcureOutOrderMapper.java | 2 ++ .../service/impl/OdsProcureOrderServiceImpl.java | 2 +- .../mapper/wms/OdsProcureOutOrderMapper.xml | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/op-modules/op-wms/src/main/java/com/op/wms/mapper/OdsProcureOutOrderMapper.java b/op-modules/op-wms/src/main/java/com/op/wms/mapper/OdsProcureOutOrderMapper.java index df620749..cc3e4a12 100644 --- a/op-modules/op-wms/src/main/java/com/op/wms/mapper/OdsProcureOutOrderMapper.java +++ b/op-modules/op-wms/src/main/java/com/op/wms/mapper/OdsProcureOutOrderMapper.java @@ -86,4 +86,6 @@ public interface OdsProcureOutOrderMapper { String selectMachineCode(@Param("order")OdsProcureOutOrder odsProcureOutOrder); List selectmesPrepareDetailWhite(OdsProcureOutOrder odsProcureOutOrder); + + OdsProcureOutOrder selectmesPreparelike(OdsProcureOutOrder odsProcureOrder); } diff --git a/op-modules/op-wms/src/main/java/com/op/wms/service/impl/OdsProcureOrderServiceImpl.java b/op-modules/op-wms/src/main/java/com/op/wms/service/impl/OdsProcureOrderServiceImpl.java index 06f70ea7..3e2ac23a 100644 --- a/op-modules/op-wms/src/main/java/com/op/wms/service/impl/OdsProcureOrderServiceImpl.java +++ b/op-modules/op-wms/src/main/java/com/op/wms/service/impl/OdsProcureOrderServiceImpl.java @@ -286,7 +286,7 @@ public class OdsProcureOrderServiceImpl implements IOdsProcureOrderService { @DS("#header.poolName") public OdsProcureOutOrder PurchaseOrderOutboundPda(OdsProcureOutOrder odsProcureOrder) { //母单,其中list里面是对应的子单 - OdsProcureOutOrder odsProcureOutOrder = odsProcureOutOrderMapper.selectmesPrepare(odsProcureOrder); + OdsProcureOutOrder odsProcureOutOrder = odsProcureOutOrderMapper.selectmesPreparelike(odsProcureOrder); String machine= odsProcureOutOrderMapper.selectMachineCode(odsProcureOutOrder); if (odsProcureOutOrder != null) { List orderList = odsProcureOutOrderMapper.selectmesPrepareDetail(odsProcureOutOrder); diff --git a/op-modules/op-wms/src/main/resources/mapper/wms/OdsProcureOutOrderMapper.xml b/op-modules/op-wms/src/main/resources/mapper/wms/OdsProcureOutOrderMapper.xml index ca65d8fa..4160596e 100644 --- a/op-modules/op-wms/src/main/resources/mapper/wms/OdsProcureOutOrderMapper.xml +++ b/op-modules/op-wms/src/main/resources/mapper/wms/OdsProcureOutOrderMapper.xml @@ -431,4 +431,20 @@ WHERE mes_prepare_detail.prepare_id= #{ ID} + + + From 4f9f609e105281cd47f78cf567fcba2f12a72c44 Mon Sep 17 00:00:00 2001 From: A0010407 Date: Thu, 6 Jun 2024 16:02:22 +0800 Subject: [PATCH 2/2] =?UTF-8?q?2024-06-06=20=E8=B4=A8=E9=87=8F/=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F/=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=A8=A1?= =?UTF-8?q?=E5=9D=97-=E8=B4=A8=E9=87=8F=E6=9C=AA=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E6=A3=80=E9=AA=8C=E4=BB=BB=E5=8A=A1=E4=B8=80=E5=B0=8F=E6=97=B6?= =?UTF-8?q?=E5=90=8E=E5=86=8D=E6=AC=A1=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../op/system/api/RemoteQualityService.java | 3 + .../factory/RemoteQualityFallbackFactory.java | 5 + .../src/main/java/com/op/job/task/RyTask.java | 6 + .../QcCheckTaskDetailController.java | 11 ++ .../mapper/QcCheckTaskDetailMapper.java | 7 +- .../service/IQcCheckTaskDetailService.java | 4 + .../impl/QcCheckTaskDetailServiceImpl.java | 147 +++++++++++++++++- .../quality/QcCheckTaskDetailMapper.xml | 31 ++++ 8 files changed, 212 insertions(+), 2 deletions(-) diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/RemoteQualityService.java b/op-api/op-api-system/src/main/java/com/op/system/api/RemoteQualityService.java index d0e897c1..71e2a74c 100644 --- a/op-api/op-api-system/src/main/java/com/op/system/api/RemoteQualityService.java +++ b/op-api/op-api-system/src/main/java/com/op/system/api/RemoteQualityService.java @@ -41,4 +41,7 @@ public interface RemoteQualityService { @PostMapping("/qcWarehousing/createCPBatchTask") public R createCPBatchTask(); + + @PostMapping("/qcDetail/resendWXTask") + public R resendWXTask(); } diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteQualityFallbackFactory.java b/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteQualityFallbackFactory.java index 7d6ea765..05c34975 100644 --- a/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteQualityFallbackFactory.java +++ b/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteQualityFallbackFactory.java @@ -57,6 +57,11 @@ public class RemoteQualityFallbackFactory implements FallbackFactory selectNoCheckList(); + + int updateBatchConfirmTime(@Param("list") List list); } diff --git a/op-modules/op-quality/src/main/java/com/op/quality/service/IQcCheckTaskDetailService.java b/op-modules/op-quality/src/main/java/com/op/quality/service/IQcCheckTaskDetailService.java index 1b88f6be..0e8db397 100644 --- a/op-modules/op-quality/src/main/java/com/op/quality/service/IQcCheckTaskDetailService.java +++ b/op-modules/op-quality/src/main/java/com/op/quality/service/IQcCheckTaskDetailService.java @@ -2,6 +2,7 @@ package com.op.quality.service; import java.util.List; +import com.op.common.core.web.domain.AjaxResult; import com.op.quality.domain.QcCheckTaskDetail; /** @@ -58,4 +59,7 @@ public interface IQcCheckTaskDetailService { * @return 结果 */ public int deleteQcCheckTaskDetailByRecordId(String recordId); + + //质量检验任务提醒,一小时后微信二次发送 + AjaxResult resendWXTask(); } diff --git a/op-modules/op-quality/src/main/java/com/op/quality/service/impl/QcCheckTaskDetailServiceImpl.java b/op-modules/op-quality/src/main/java/com/op/quality/service/impl/QcCheckTaskDetailServiceImpl.java index e1e89c20..cc3d825a 100644 --- a/op-modules/op-quality/src/main/java/com/op/quality/service/impl/QcCheckTaskDetailServiceImpl.java +++ b/op-modules/op-quality/src/main/java/com/op/quality/service/impl/QcCheckTaskDetailServiceImpl.java @@ -1,14 +1,44 @@ package com.op.quality.service.impl; +import java.util.ArrayList; +import java.util.Date; import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import com.alibaba.fastjson2.JSONObject; import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; +import com.op.common.core.domain.R; import com.op.common.core.utils.DateUtils; +import com.op.common.core.utils.StringUtils; +import com.op.common.core.utils.bean.BeanUtils; +import com.op.common.core.web.domain.AjaxResult; +import com.op.quality.domain.*; +import com.op.quality.mapper.QcCheckTaskIncomeMapper; +import com.op.system.api.RemoteOpenService; +import com.op.system.api.RemoteUserService; +import com.op.system.api.domain.SysNoticeGroup; +import com.op.system.api.domain.SysUser; +import com.op.system.api.domain.dto.WechartDTO; +import com.op.system.api.domain.mes.ProOrderWorkorderDTO; +import com.op.system.api.domain.quality.QcUserMaterialDTO; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.op.quality.mapper.QcCheckTaskDetailMapper; -import com.op.quality.domain.QcCheckTaskDetail; import com.op.quality.service.IQcCheckTaskDetailService; +import org.springframework.util.CollectionUtils; + +import static com.op.common.core.web.domain.AjaxResult.error; +import static com.op.common.core.web.domain.AjaxResult.success; /** * 检验任务详情Service业务层处理 @@ -18,9 +48,22 @@ import com.op.quality.service.IQcCheckTaskDetailService; */ @Service public class QcCheckTaskDetailServiceImpl implements IQcCheckTaskDetailService { + protected Logger logger = LoggerFactory.getLogger(getClass()); + @Autowired private QcCheckTaskDetailMapper qcCheckTaskDetailMapper; + @Autowired + private RemoteUserService remoteUserService; + + @Autowired + private QcCheckTaskIncomeMapper qcCheckTaskIncomeMapper; + + @Autowired + private RemoteOpenService remoteOpenService; + + private static Pattern p2= Pattern.compile("<[^>]+>"); + /** * 查询检验任务详情 * @@ -94,4 +137,106 @@ public class QcCheckTaskDetailServiceImpl implements IQcCheckTaskDetailService { public int deleteQcCheckTaskDetailByRecordId(String recordId) { return qcCheckTaskDetailMapper.deleteQcCheckTaskDetailByRecordId(recordId); } + + /**质量检验任务提醒,一小时后微信二次发送**/ + @Override + public AjaxResult resendWXTask() { + + // 加载sf-cloud库的sys_datasource + SysUser sysUser = new SysUser(); + sysUser.setUserId(1L); + R>> dateSources0 = remoteUserService.getPoolNameList(sysUser); + List> dateSources = dateSources0.getData(); + ExecutorService executorService = new ThreadPoolExecutor( + dateSources.size(), + dateSources.size(), + 0L, TimeUnit.MILLISECONDS, + new LinkedBlockingQueue()); + try { + dateSources.forEach(dateSource -> { + logger.info("++++++++++++" + dateSource.get("poolName") + "++++质量检验任务提醒,一小时后微信二次发送开始++++++++++"); + Runnable run = () -> resendWXFunc(dateSource.get("poolName")); + executorService.execute(run); + }); + } catch (Exception e) { + logger.error("service == resendWXTask == exception", e); + return error("service == resendWXTask == exception"); + } finally { + executorService.shutdown(); + } + return success(); + } + + private void resendWXFunc(String poolName){ + DynamicDataSourceContextHolder.push(poolName); //这是数据源的key + List noCheckList = qcCheckTaskDetailMapper.selectNoCheckList(); + //发企业微信--------------------开始 + SysNoticeGroup noticeQo = new SysNoticeGroup(); + //筛选成品检验 id 7 + List noCheckListCP = noCheckList.stream().filter(condition -> condition.getCheckType().equals("checkTypeCP")).collect(Collectors.toList()); + String CP = StringUtils.join(noCheckListCP.stream().map(QcCheckReportIncome::getCheckNo).collect(Collectors.toList()).toArray(),","); + //批次成品检验 id 12 + List noCheckListCPPC = noCheckList.stream().filter(condition -> condition.getCheckType().equals("checkTypeCPPC")).collect(Collectors.toList()); + String CPPC = StringUtils.join(noCheckListCPPC.stream().map(QcCheckReportIncome::getCheckNo).collect(Collectors.toList()).toArray(),","); + //来料检验 id 6 + List noCheckListLL = noCheckList.stream().filter(condition -> condition.getCheckType().equals("checkTypeLL")).collect(Collectors.toList()); + String LL = StringUtils.join(noCheckListLL.stream().map(QcCheckReportIncome::getCheckNo).collect(Collectors.toList()).toArray(),","); + //过程巡检 id 20 + List noCheckListSCXJ = noCheckList.stream().filter(condition -> condition.getCheckType().equals("checkTypeSCXJ")).collect(Collectors.toList()); + String SCXJ = StringUtils.join(noCheckListSCXJ.stream().map(QcCheckReportIncome::getCheckNo).collect(Collectors.toList()).toArray(),","); + //首件检验 id 19 + List noCheckListSC = noCheckList.stream().filter(condition -> condition.getCheckType().equals("checkTypeSC")).collect(Collectors.toList()); + String SC = StringUtils.join(noCheckListSC.stream().map(QcCheckReportIncome::getCheckNo).collect(Collectors.toList()).toArray(),","); + + if(noCheckListCP != null || noCheckListCP.size() > 0) { + noticeQo.setNoticeId(7L); + sendWeChartMessage(noticeQo,CP,noCheckListCP.size()+"个成品检验",noCheckListCP); + } + if(noCheckListCPPC != null || noCheckListCPPC.size() > 0){ + noticeQo.setNoticeId(12L); + sendWeChartMessage(noticeQo,CPPC,noCheckListCPPC.size()+"个批次成品检验",noCheckListCPPC); + } + if(noCheckListLL != null || noCheckListLL.size() > 0){ + noticeQo.setNoticeId(6L); + sendWeChartMessage(noticeQo,LL,noCheckListLL.size()+"个来料检验",noCheckListLL); + } + if(noCheckListSCXJ != null || noCheckListSCXJ.size() > 0){ + noticeQo.setNoticeId(20L); + sendWeChartMessage(noticeQo,SCXJ,noCheckListSCXJ.size()+"个过程巡检",noCheckListSCXJ); + } + if(noCheckListSC != null || noCheckListSC.size() > 0){ + noticeQo.setNoticeId(19L); + sendWeChartMessage(noticeQo,SC,noCheckListSC.size()+"个首件检验",noCheckListSC); + } + } + + private void sendWeChartMessage(SysNoticeGroup noticeQo,String checkNoList,String message,List noCheckList){ + if(StringUtils.isNotEmpty(checkNoList)){ + List notices = qcCheckTaskIncomeMapper.getNoticesGroup(noticeQo); + if(!CollectionUtils.isEmpty(notices) && notices.size() > 0) { + List wecharts = new ArrayList<>(); + for (SysNoticeGroup noticedto : notices) { + WechartDTO wechart0 = new WechartDTO(); + wechart0.setUserId(noticedto.getWxId()); + String contentInfo = notices.get(0).getNoticeContent(); + contentInfo = contentInfo.replace("${checkNo}", checkNoList + "(批量检验任务二次提醒)"+"\n"); + Matcher m = p2.matcher(contentInfo); + contentInfo = m.replaceAll(""); + wechart0.setText(contentInfo); + wecharts.add(wechart0); + } + logger.info("任务编号为:"+ checkNoList + "的"+ message + ",企业微信二次提醒请求:" + JSONObject.toJSONString(wecharts)); + if (!CollectionUtils.isEmpty(wecharts)) { + new Thread(() -> { + AjaxResult result = remoteOpenService.sendWeChartMessage(wecharts); + logger.info("企业微信二次提醒结果:" + JSONObject.toJSONString(result)); + }).start(); + } + //发企业微信--------------------结束 + qcCheckTaskDetailMapper.updateBatchConfirmTime(noCheckList); + } + } + } + + } diff --git a/op-modules/op-quality/src/main/resources/mapper/quality/QcCheckTaskDetailMapper.xml b/op-modules/op-quality/src/main/resources/mapper/quality/QcCheckTaskDetailMapper.xml index 8ac51787..c445aa1f 100644 --- a/op-modules/op-quality/src/main/resources/mapper/quality/QcCheckTaskDetailMapper.xml +++ b/op-modules/op-quality/src/main/resources/mapper/quality/QcCheckTaskDetailMapper.xml @@ -189,4 +189,35 @@ #{recordId} + + + + + + + UPDATE qc_check_task + set confirm_time = getdate() + WHERE record_id = #{item.recordId} + and del_flag = '0' + and check_status = '0' + and confirm_time is null + + +