diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/domain/SysNoticeGroup.java b/op-api/op-api-system/src/main/java/com/op/system/api/domain/SysNoticeGroup.java index 1b8ad09b..f8d41353 100644 --- a/op-api/op-api-system/src/main/java/com/op/system/api/domain/SysNoticeGroup.java +++ b/op-api/op-api-system/src/main/java/com/op/system/api/domain/SysNoticeGroup.java @@ -46,6 +46,34 @@ public class SysNoticeGroup extends BaseEntity { private String[] groupNames; + private String userCode; + private String noticeContent; + private String wxId; + + public String getWxId() { + return wxId; + } + + public void setWxId(String wxId) { + this.wxId = wxId; + } + + public String getUserCode() { + return userCode; + } + + public void setUserCode(String userCode) { + this.userCode = userCode; + } + + public String getNoticeContent() { + return noticeContent; + } + + public void setNoticeContent(String noticeContent) { + this.noticeContent = noticeContent; + } + public void setId(String id) { this.id = id; } diff --git a/op-modules/op-mes/src/main/resources/mapper/mes/MesMapper.xml b/op-modules/op-mes/src/main/resources/mapper/mes/MesMapper.xml index 27c259b3..67be04af 100644 --- a/op-modules/op-mes/src/main/resources/mapper/mes/MesMapper.xml +++ b/op-modules/op-mes/src/main/resources/mapper/mes/MesMapper.xml @@ -434,7 +434,8 @@ select shift_code shiftId,min(change_time) startTime,work_date,device_code deviceCode from mes_changeshift_info where device_code = #{equipmentCode} - and CONVERT(varchar(10),change_time, 120) in (${ymd}) + + and work_date in (${ymd}) group by shift_code,work_date,device_code ) t order by t.startTime diff --git a/op-modules/op-quality/src/main/java/com/op/quality/mapper/QcCheckTaskIncomeMapper.java b/op-modules/op-quality/src/main/java/com/op/quality/mapper/QcCheckTaskIncomeMapper.java index cb0a3676..7d8b3553 100644 --- a/op-modules/op-quality/src/main/java/com/op/quality/mapper/QcCheckTaskIncomeMapper.java +++ b/op-modules/op-quality/src/main/java/com/op/quality/mapper/QcCheckTaskIncomeMapper.java @@ -2,11 +2,14 @@ package com.op.quality.mapper; import java.util.Date; import java.util.List; +import java.util.Map; import com.op.quality.domain.*; import com.op.system.api.domain.SysDictData; +import com.op.system.api.domain.SysNoticeGroup; import com.op.system.api.domain.SysUser; import com.op.system.api.domain.quality.QcUserMaterialDTO; +import org.apache.ibatis.annotations.MapKey; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -114,4 +117,13 @@ public interface QcCheckTaskIncomeMapper { List getCheckLocList(QcDefectType qcDefectType); List getTodayIncomeLists(); + + List getNotices(SysNoticeGroup noticeQo); + + List getWxId(@Param("list") List users); + + @MapKey("userCode") + Map getWxIdMap(List userCodes); + + List getNoticesGroup(SysNoticeGroup noticeQo); } diff --git a/op-modules/op-quality/src/main/java/com/op/quality/service/impl/QcCheckTaskIncomeServiceImpl.java b/op-modules/op-quality/src/main/java/com/op/quality/service/impl/QcCheckTaskIncomeServiceImpl.java index a807a5fe..fbfd4d83 100644 --- a/op-modules/op-quality/src/main/java/com/op/quality/service/impl/QcCheckTaskIncomeServiceImpl.java +++ b/op-modules/op-quality/src/main/java/com/op/quality/service/impl/QcCheckTaskIncomeServiceImpl.java @@ -17,7 +17,10 @@ import com.op.common.security.utils.SecurityUtils; import com.op.quality.domain.*; import com.op.quality.mapper.*; import com.op.quality.service.*; +import com.op.system.api.RemoteOpenService; +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.quality.QcUserMaterialDTO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -66,8 +69,8 @@ public class QcCheckTaskIncomeServiceImpl implements @Autowired private IQcCheckTaskUserService qcCheckTaskUserService; -// @Autowired -// private RemoteOpenService remoteOpenService; + @Autowired + private RemoteOpenService remoteOpenService; @Autowired private QMSFileMapper qmsFileMapper; @@ -192,6 +195,7 @@ public class QcCheckTaskIncomeServiceImpl implements //String typeCode = qcCheckTaskIncomeMapper.getTypeCode(qcCheckTaskIncome.getCheckType()); qcCheckTaskIncome.setTypeCode("material");//大检验节点 /**qc_task_user start**/ + List users = null; if(StringUtils.isNotBlank(qcCheckTaskIncome.getCheckManName())){//管理系统创建任务 String checkManName = qcCheckTaskIncome.getCheckManName(); String checkManCode = qcCheckTaskIncome.getCheckManCode(); @@ -216,7 +220,7 @@ public class QcCheckTaskIncomeServiceImpl implements qcCheckTaskIncome.setCheckManName(""); qcCheckTaskIncome.setCheckManCode(""); /**qc_user_material取默认检查人**/ - List users = qcCheckTaskIncomeMapper.getCheckUser(qcCheckTaskIncome); + users = qcCheckTaskIncomeMapper.getCheckUser(qcCheckTaskIncome); if(CollectionUtils.isEmpty(users)){ QcUserMaterialDTO dto0 = new QcUserMaterialDTO(); dto0.setId(IdUtils.fastSimpleUUID()); @@ -264,7 +268,37 @@ public class QcCheckTaskIncomeServiceImpl implements item.setFactoryCode(factoryCode); item.setStatus("N"); } - return qcCheckTaskDetailMapper.addBatch(items); + int s = qcCheckTaskDetailMapper.addBatch(items); + + //发企业微信--------------------开始(跟班组无关) + SysNoticeGroup noticeQo = new SysNoticeGroup(); + noticeQo.setNoticeId(6L); + List notices = qcCheckTaskIncomeMapper.getNotices(noticeQo); + if(!CollectionUtils.isEmpty(notices)) { + List wecharts = new ArrayList<>(); + //去主库查微信id + DynamicDataSourceContextHolder.push("master");// 这是数据源的key + List userCodes = users.stream() + .map(QcUserMaterialDTO::getUserCode) + .collect(Collectors.toList()); + List wxids = qcCheckTaskIncomeMapper.getWxId(userCodes); + for (String wxid : wxids) { + WechartDTO wechart0 = new WechartDTO(); + wechart0.setUserId(wxid); + wechart0.setText(notices.get(0).getNoticeContent()); + wecharts.add(wechart0); + } + logger.info("来料检验企业微信提醒请求:" + JSONObject.toJSONString(wecharts)); + if (!CollectionUtils.isEmpty(wecharts)) { + new Thread(() -> { + AjaxResult result = remoteOpenService.sendWeChartMessage(wecharts); + logger.info("来料检验企业微信提醒结果:" + JSONObject.toJSONString(result)); + + }).start(); + } + //发企业微信--------------------结束 + } + return s; } /** @@ -583,7 +617,7 @@ public class QcCheckTaskIncomeServiceImpl implements } @Override - @Transactional(rollbackFor = Exception.class) + //@Transactional(rollbackFor = Exception.class) public int commitCheckResults(QcCheckTaskIncome qcCheckTaskIncome) { List details = qcCheckTaskIncome.getQcCheckTaskDetails(); @@ -780,6 +814,45 @@ public class QcCheckTaskIncomeServiceImpl implements unqualified.setUser("999999"); qcCheckUnqualifiedService.updateQcCheckUnqualified(unqualified); } + + //发企业微信--------------------开始(跟班组有关) + SysNoticeGroup noticeQo = new SysNoticeGroup(); + noticeQo.setNoticeId(9L); + List notices = qcCheckTaskIncomeMapper.getNoticesGroup(noticeQo); + if(!CollectionUtils.isEmpty(notices)) { + List wecharts = new ArrayList<>(); + //去主库查微信id + DynamicDataSourceContextHolder.push("master");// 这是数据源的key + List userCodes = notices.stream() + .map(SysNoticeGroup::getUserCode) + .collect(Collectors.toList()); + //Map wxidsMap = qcCheckTaskIncomeMapper.getWxIdMap(userCodes); + for (SysNoticeGroup noticedto : notices) { +// SysUser sysUser = wxidsMap.get(noticedto.getUserCode()); +// if (sysUser != null) { + WechartDTO wechart0 = new WechartDTO(); + wechart0.setUserId(noticedto.getWxId()); + String contentInfo = noticedto.getNoticeContent(); + contentInfo = contentInfo.replace("${materialCode}", qcCheckTaskIncome.getMaterialCode()) + .replace("${materialName}", qcCheckTaskIncome.getMaterialName()) + //.replace("${incomeBatchNo}", qcCheckTaskIncome.getIncomeBatchNo()) + //.replace("${orderNo}", qcCheckTaskIncome.getOrderNo()) + ; + wechart0.setText(contentInfo); + wecharts.add(wechart0); + //} + + } + logger.info("来料检验企业微信提醒请求:" + JSONObject.toJSONString(wecharts)); + if (!CollectionUtils.isEmpty(wecharts)) { + new Thread(() -> { + AjaxResult wxresult = remoteOpenService.sendWeChartMessage(wecharts); + logger.info("来料检验企业微信提醒结果:" + JSONObject.toJSONString(wxresult)); + + }).start(); + } + //发企业微信--------------------结束 + } } return 1 ; } diff --git a/op-modules/op-quality/src/main/resources/mapper/quality/QcCheckTaskIncomeMapper.xml b/op-modules/op-quality/src/main/resources/mapper/quality/QcCheckTaskIncomeMapper.xml index f959db80..b9636d23 100644 --- a/op-modules/op-quality/src/main/resources/mapper/quality/QcCheckTaskIncomeMapper.xml +++ b/op-modules/op-quality/src/main/resources/mapper/quality/QcCheckTaskIncomeMapper.xml @@ -476,6 +476,42 @@ where check_type = 'checkTypeLL' and CONVERT(varchar(10),GETDATE(), 120) = CONVERT(varchar(10),create_time, 120) + + + + diff --git a/op-modules/op-system/src/main/java/com/op/system/service/impl/SysUserServiceImpl.java b/op-modules/op-system/src/main/java/com/op/system/service/impl/SysUserServiceImpl.java index d483ecf3..8b824b07 100644 --- a/op-modules/op-system/src/main/java/com/op/system/service/impl/SysUserServiceImpl.java +++ b/op-modules/op-system/src/main/java/com/op/system/service/impl/SysUserServiceImpl.java @@ -311,11 +311,11 @@ public class SysUserServiceImpl implements ISysUserService { userPostMapper.deleteUserPostByUserId(userId); // 新增用户与岗位管理 insertUserPost(user); - // 加工厂数据权限 - HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); - String key = "#header.poolName"; - user.setDeptId(Long.parseLong(request.getHeader(key.substring(8)).replace("ds_",""))); - insertUserDB(user); +// // 加工厂数据权限(会把之前分配的给覆盖掉有问题) +// HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); +// String key = "#header.poolName"; +// user.setDeptId(Long.parseLong(request.getHeader(key.substring(8)).replace("ds_",""))); +// insertUserDB(user); return userMapper.updateUser(user); }