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

master
zhaoxiaolin 8 months ago
parent ef2cae1d7b
commit 4c42e02780

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

@ -1155,21 +1155,6 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
String username = SecurityUtils.getUsername();
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;
for (int m=0;m<workOrders.size();m++) {
@ -1188,15 +1173,11 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
if(proOrderWorkorderBatch.getNewBatchQuantity() != null){
Long newBatchQuantity = proOrderWorkorderBatch.getNewBatchQuantity();
if(m==0){
if(m==0 || m== workOrders.size()-1){
// 设置子工单数量
batch.setBatchQuantity(newBatchQuantity);
}else{
BigDecimal pQuantity = new BigDecimal(workOrders.get(m).getQuantitySplit());
BigDecimal cQuantity = new BigDecimal(workOrders.get(m-1).getQuantitySplit());
batch.setBatchQuantity(pQuantity.divide(cQuantity)
batch.setBatchQuantity(workOrders.get(m+1).getUmrez()
.multiply(new BigDecimal(newBatchQuantity)).longValue());
}
}
@ -1234,19 +1215,14 @@ public class ProOrderWorkorderServiceImpl implements IProOrderWorkorderService {
if(proOrderWorkorderBatch.getNewBatchQuantity() != null){
Long newBatchQuantity = proOrderWorkorderBatch.getNewBatchQuantity();
if(m==0){
if(m==0 || m== workOrders.size()-1){
// 设置子工单数量
batch.setNewBatchQuantity(newBatchQuantity);
}else{
BigDecimal pQuantity = new BigDecimal(workOrders.get(m).getQuantitySplit());
BigDecimal cQuantity = new BigDecimal(workOrders.get(m-1).getQuantitySplit());
batch.setNewBatchQuantity(pQuantity.divide(cQuantity)
batch.setNewBatchQuantity(workOrders.get(m+1).getUmrez()
.multiply(new BigDecimal(newBatchQuantity)).longValue());
}
}
count += proOrderWorkorderBatchMapper.updateWorkorderBatch(batch);
}
// 更新质检任务表

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

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

@ -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;
}
/**

Loading…
Cancel
Save