企业微信质检提醒+批次编辑升级

master
zhaoxiaolin 8 months ago
parent ef2cae1d7b
commit 4c42e02780

@ -1,5 +1,6 @@
package com.op.plan.domain; package com.op.plan.domain;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -231,6 +232,7 @@ public class ProOrderWorkorder extends TreeEntity {
// 车数 // 车数
private Integer carNum; private Integer carNum;
private Integer sortNo; private Integer sortNo;
private BigDecimal umrez;
public Integer getCarNum() { public Integer getCarNum() {
return carNum; return carNum;
@ -267,6 +269,14 @@ public class ProOrderWorkorder extends TreeEntity {
// 供湿料计划使用 // 供湿料计划使用
private String bucketName1; private String bucketName1;
public BigDecimal getUmrez() {
return umrez;
}
public void setUmrez(BigDecimal umrez) {
this.umrez = umrez;
}
public String getMaterialName1() { public String getMaterialName1() {
return materialName1; return materialName1;
} }

@ -1155,21 +1155,6 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
String username = SecurityUtils.getUsername(); String username = SecurityUtils.getUsername();
List<ProOrderWorkorder> workOrders = proOrderWorkorderMapper.selectWorkOrderIdByBatch(workOrderCode); List<ProOrderWorkorder> workOrders = proOrderWorkorderMapper.selectWorkOrderIdByBatch(workOrderCode);
// 系数
Long coefficient = 1L;
if(workOrders.size()==2){
// 获取子母工单数量
Optional<Long> pQuantity = workOrders.stream().filter(item -> "0".equals(item.getParentOrder()))
.findFirst().map(ProOrderWorkorder::getQuantitySplit);
Optional<Long> cQuantity = workOrders.stream().filter(item -> !"0".equals(item.getParentOrder()))
.findFirst().map(ProOrderWorkorder::getQuantitySplit);
if (pQuantity.isPresent() && cQuantity.isPresent()) {
coefficient = cQuantity.get() / pQuantity.get();
}
}else if(workOrders.size()==3){
//TODO;
}
int count = 0; int count = 0;
for (int m=0;m<workOrders.size();m++) { for (int m=0;m<workOrders.size();m++) {
@ -1188,15 +1173,11 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
if(proOrderWorkorderBatch.getNewBatchQuantity() != null){ if(proOrderWorkorderBatch.getNewBatchQuantity() != null){
Long newBatchQuantity = proOrderWorkorderBatch.getNewBatchQuantity(); Long newBatchQuantity = proOrderWorkorderBatch.getNewBatchQuantity();
if(m==0 || m== workOrders.size()-1){
if(m==0){
// 设置子工单数量 // 设置子工单数量
batch.setBatchQuantity(newBatchQuantity); batch.setBatchQuantity(newBatchQuantity);
}else{ }else{
BigDecimal pQuantity = new BigDecimal(workOrders.get(m).getQuantitySplit()); batch.setBatchQuantity(workOrders.get(m+1).getUmrez()
BigDecimal cQuantity = new BigDecimal(workOrders.get(m-1).getQuantitySplit());
batch.setBatchQuantity(pQuantity.divide(cQuantity)
.multiply(new BigDecimal(newBatchQuantity)).longValue()); .multiply(new BigDecimal(newBatchQuantity)).longValue());
} }
} }
@ -1234,19 +1215,14 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
if(proOrderWorkorderBatch.getNewBatchQuantity() != null){ if(proOrderWorkorderBatch.getNewBatchQuantity() != null){
Long newBatchQuantity = proOrderWorkorderBatch.getNewBatchQuantity(); Long newBatchQuantity = proOrderWorkorderBatch.getNewBatchQuantity();
if(m==0){ if(m==0 || m== workOrders.size()-1){
// 设置子工单数量 // 设置子工单数量
batch.setNewBatchQuantity(newBatchQuantity); batch.setNewBatchQuantity(newBatchQuantity);
}else{ }else{
BigDecimal pQuantity = new BigDecimal(workOrders.get(m).getQuantitySplit()); batch.setNewBatchQuantity(workOrders.get(m+1).getUmrez()
BigDecimal cQuantity = new BigDecimal(workOrders.get(m-1).getQuantitySplit());
batch.setNewBatchQuantity(pQuantity.divide(cQuantity)
.multiply(new BigDecimal(newBatchQuantity)).longValue()); .multiply(new BigDecimal(newBatchQuantity)).longValue());
} }
} }
count += proOrderWorkorderBatchMapper.updateWorkorderBatch(batch); count += proOrderWorkorderBatchMapper.updateWorkorderBatch(batch);
} }
// 更新质检任务表 // 更新质检任务表

@ -627,12 +627,14 @@
</select> </select>
<select id="selectWorkOrderIdByBatch" resultType="com.op.plan.domain.ProOrderWorkorder"> <select id="selectWorkOrderIdByBatch" resultType="com.op.plan.domain.ProOrderWorkorder">
select workorder_id workorderId, select pow.workorder_id workorderId,
quantity_split quantitySplit, pow.quantity_split quantitySplit,
parent_order parentOrder pow.parent_order parentOrder,
from pro_order_workorder bp.umrez
where belong_work_order = #{workorderCode} and del_flag = '0' from pro_order_workorder pow
order by workorder_code_sap desc left join base_product bp on bp.product_code = pow.product_code
where pow.belong_work_order = #{workorderCode} and pow.del_flag = '0'
order by pow.workorder_code_sap desc
</select> </select>
<insert id="createPrepareDetails"> <insert id="createPrepareDetails">

@ -281,7 +281,7 @@ public class QcCheckTaskIncomeServiceImpl<QcCheckUnqualifiedService> implements
} }
int s = qcCheckTaskDetailMapper.addBatch(items); int s = qcCheckTaskDetailMapper.addBatch(items);
//发企业微信--------------------开始(跟班组无关) //发企业微信--------------------开始
SysNoticeGroup noticeQo = new SysNoticeGroup(); SysNoticeGroup noticeQo = new SysNoticeGroup();
noticeQo.setNoticeId(6L); noticeQo.setNoticeId(6L);
List<SysNoticeGroup> notices = qcCheckTaskIncomeMapper.getNoticesGroup(noticeQo); List<SysNoticeGroup> notices = qcCheckTaskIncomeMapper.getNoticesGroup(noticeQo);

@ -11,9 +11,13 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; 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.DateUnit;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.op.common.core.domain.R; 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.mapper.*;
import com.op.quality.service.IQcCheckTaskDefectService; import com.op.quality.service.IQcCheckTaskDefectService;
import com.op.quality.service.IQcCheckTaskUserService; import com.op.quality.service.IQcCheckTaskUserService;
import com.op.system.api.RemoteOpenService;
import com.op.system.api.RemoteUserService; 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.SysUser;
import com.op.system.api.domain.dto.WechartDTO;
import com.op.system.api.domain.mes.ProOrderWorkorderDTO; import com.op.system.api.domain.mes.ProOrderWorkorderDTO;
import com.op.system.api.domain.quality.QcMaterialGroupDetailDTO; import com.op.system.api.domain.quality.QcMaterialGroupDetailDTO;
import com.op.system.api.domain.quality.QcUserMaterialDTO; import com.op.system.api.domain.quality.QcUserMaterialDTO;
@ -88,6 +95,11 @@ public class QcCheckTaskProduceServiceImpl implements IQcCheckTaskProduceService
@Autowired @Autowired
private QcCheckTaskUserMapper qcCheckTaskUserMapper; 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.setCreateTime(nowDate);
qcCheckTaskProduce.setTypeCode("produce");//大检验节点 qcCheckTaskProduce.setTypeCode("produce");//大检验节点
/**qc_task_user start**/ /**qc_task_user start**/
List<QcUserMaterialDTO> users = null;
if(StringUtils.isNotBlank(qcCheckTaskProduce.getCheckManName())){ if(StringUtils.isNotBlank(qcCheckTaskProduce.getCheckManName())){
String checkManName = qcCheckTaskProduce.getCheckManName(); String checkManName = qcCheckTaskProduce.getCheckManName();
String checkManCode = qcCheckTaskProduce.getCheckManCode(); String checkManCode = qcCheckTaskProduce.getCheckManCode();
@ -211,7 +224,7 @@ public class QcCheckTaskProduceServiceImpl implements IQcCheckTaskProduceService
qcCheckTaskProduce.setCheckManName(""); qcCheckTaskProduce.setCheckManName("");
qcCheckTaskProduce.setCheckManCode(""); qcCheckTaskProduce.setCheckManCode("");
/**qc_user_material取默认检查人**/ /**qc_user_material取默认检查人**/
List<QcUserMaterialDTO> users = qcCheckTaskIncomeMapper.getUserByCheckType(qcCheckTaskProduce.getCheckType()); users = qcCheckTaskIncomeMapper.getUserByCheckType(qcCheckTaskProduce.getCheckType());
if(!CollectionUtils.isEmpty(users)){ if(!CollectionUtils.isEmpty(users)){
for(QcUserMaterialDTO user:users){ for(QcUserMaterialDTO user:users){
user.setId(IdUtils.fastSimpleUUID()); user.setId(IdUtils.fastSimpleUUID());
@ -269,7 +282,47 @@ public class QcCheckTaskProduceServiceImpl implements IQcCheckTaskProduceService
item.setFactoryCode(factoryCode); item.setFactoryCode(factoryCode);
item.setStatus("Y"); 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;
} }
/** /**

Loading…
Cancel
Save