|
|
|
@ -11,9 +11,13 @@ 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 cn.hutool.core.date.DateUnit;
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
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;
|
|
|
|
@ -26,8 +30,11 @@ import com.op.quality.domain.*;
|
|
|
|
|
import com.op.quality.mapper.*;
|
|
|
|
|
import com.op.quality.service.IQcCheckTaskDefectService;
|
|
|
|
|
import com.op.quality.service.IQcCheckTaskUserService;
|
|
|
|
|
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.QcMaterialGroupDetailDTO;
|
|
|
|
|
import com.op.system.api.domain.quality.QcUserMaterialDTO;
|
|
|
|
@ -88,6 +95,11 @@ public class QcCheckTaskProduceServiceImpl implements IQcCheckTaskProduceService
|
|
|
|
|
@Autowired
|
|
|
|
|
private QcCheckTaskUserMapper qcCheckTaskUserMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private RemoteOpenService remoteOpenService;
|
|
|
|
|
|
|
|
|
|
private static Pattern p2= Pattern.compile("<[^>]+>");
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询生产过程检验任务
|
|
|
|
|
*
|
|
|
|
@ -189,6 +201,7 @@ public class QcCheckTaskProduceServiceImpl implements IQcCheckTaskProduceService
|
|
|
|
|
qcCheckTaskProduce.setCreateTime(nowDate);
|
|
|
|
|
qcCheckTaskProduce.setTypeCode("produce");//大检验节点
|
|
|
|
|
/**qc_task_user start**/
|
|
|
|
|
List<QcUserMaterialDTO> users = null;
|
|
|
|
|
if(StringUtils.isNotBlank(qcCheckTaskProduce.getCheckManName())){
|
|
|
|
|
String checkManName = qcCheckTaskProduce.getCheckManName();
|
|
|
|
|
String checkManCode = qcCheckTaskProduce.getCheckManCode();
|
|
|
|
@ -211,7 +224,7 @@ public class QcCheckTaskProduceServiceImpl implements IQcCheckTaskProduceService
|
|
|
|
|
qcCheckTaskProduce.setCheckManName("");
|
|
|
|
|
qcCheckTaskProduce.setCheckManCode("");
|
|
|
|
|
/**qc_user_material取默认检查人**/
|
|
|
|
|
List<QcUserMaterialDTO> users = qcCheckTaskIncomeMapper.getUserByCheckType(qcCheckTaskProduce.getCheckType());
|
|
|
|
|
users = qcCheckTaskIncomeMapper.getUserByCheckType(qcCheckTaskProduce.getCheckType());
|
|
|
|
|
if(!CollectionUtils.isEmpty(users)){
|
|
|
|
|
for(QcUserMaterialDTO user:users){
|
|
|
|
|
user.setId(IdUtils.fastSimpleUUID());
|
|
|
|
@ -269,7 +282,47 @@ public class QcCheckTaskProduceServiceImpl implements IQcCheckTaskProduceService
|
|
|
|
|
item.setFactoryCode(factoryCode);
|
|
|
|
|
item.setStatus("Y");
|
|
|
|
|
}
|
|
|
|
|
return qcCheckTaskDetailMapper.addBatch(items);
|
|
|
|
|
int bn = qcCheckTaskDetailMapper.addBatch(items);
|
|
|
|
|
|
|
|
|
|
//发企业微信--------------------开始
|
|
|
|
|
SysNoticeGroup noticeQo = new SysNoticeGroup();
|
|
|
|
|
if(qcCheckTaskProduce.getCheckType().equals("checkTypeSC")){
|
|
|
|
|
noticeQo.setNoticeId(19L);
|
|
|
|
|
}else if(qcCheckTaskProduce.getCheckType().equals("checkTypeSCXJ")){
|
|
|
|
|
noticeQo.setNoticeId(20L);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<SysNoticeGroup> notices = qcCheckTaskIncomeMapper.getNoticesGroup(noticeQo);
|
|
|
|
|
if(!CollectionUtils.isEmpty(notices)) {
|
|
|
|
|
|
|
|
|
|
List<WechartDTO> wecharts = new ArrayList<>();
|
|
|
|
|
//去主库查微信id
|
|
|
|
|
DynamicDataSourceContextHolder.push("master");// 这是数据源的key
|
|
|
|
|
List<String> userCodes = users.stream()
|
|
|
|
|
.map(QcUserMaterialDTO::getUserCode)
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
List<String> wxids = qcCheckTaskIncomeMapper.getWxId(userCodes);
|
|
|
|
|
for (String wxid : wxids) {
|
|
|
|
|
WechartDTO wechart0 = new WechartDTO();
|
|
|
|
|
wechart0.setUserId(wxid);
|
|
|
|
|
String contentInfo = notices.get(0).getNoticeContent();
|
|
|
|
|
contentInfo = contentInfo.replace("${checkNo}", qcCheckTaskProduce.getCheckNo() + "\n");
|
|
|
|
|
Matcher m = p2.matcher(contentInfo);
|
|
|
|
|
contentInfo = m.replaceAll("");
|
|
|
|
|
wechart0.setText(contentInfo);
|
|
|
|
|
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 bn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|