fix():redis刷新数据库

This commit is contained in:
Allenxy
2025-11-01 16:28:28 +08:00
parent 1b96f2127b
commit c2e9e15c36
7 changed files with 47 additions and 32 deletions

View File

@@ -49,7 +49,7 @@ public enum WebOperateMatEnum implements IEnum<String>, IOperateMat<WebOperateMa
MatmapDTO porCoil = MatmapUtil.getMatmap(form.getPorIdx()); MatmapDTO porCoil = MatmapUtil.getMatmap(form.getPorIdx());
if (MatmapUtil.already(porCoil)) { if (MatmapUtil.already(porCoil)) {
ONLINE.syncPlanStatus(form.getPlanId()); ONLINE.syncPlanStatus(form.getPlanId(), form.getEntryMatId());
WebSocketUtil.sendSignalMsg(form, true); WebSocketUtil.sendSignalMsg(form, true);
// 如果开卷机和焊机的钢卷相同,则将计划状态变更为生产中 // 如果开卷机和焊机的钢卷相同,则将计划状态变更为生产中
MatmapDTO welderCoil = MatmapUtil.getMatmap(DeviceEnum.WELDER.getIdx()); MatmapDTO welderCoil = MatmapUtil.getMatmap(DeviceEnum.WELDER.getIdx());
@@ -58,7 +58,8 @@ public enum WebOperateMatEnum implements IEnum<String>, IOperateMat<WebOperateMa
BeanFactory.getBean(TrackService.class).webOperateMat(form); BeanFactory.getBean(TrackService.class).webOperateMat(form);
} }
} else { } else {
ONLINE.syncPlanStatus(form.getPlanId()); ONLINE.syncPlanStatus(form.getPlanId(), form.getEntryMatId());
;
MatmapUtil.setMatmap(form.getPorIdx(), form.getEntryMatId(), form.getPlanId(), form.getPlanNo()); MatmapUtil.setMatmap(form.getPorIdx(), form.getEntryMatId(), form.getPlanId(), form.getPlanNo());
WebSocketUtil.sendSignalMsg(form); WebSocketUtil.sendSignalMsg(form);
} }
@@ -72,7 +73,8 @@ public enum WebOperateMatEnum implements IEnum<String>, IOperateMat<WebOperateMa
public void operate(WebOperateMatForm form) { public void operate(WebOperateMatForm form) {
// 开卷机卸卷,变更计划状态为READY,清除matmap // 开卷机卸卷,变更计划状态为READY,清除matmap
if (Objects.nonNull(form.getPorIdx())) { if (Objects.nonNull(form.getPorIdx())) {
UNLOAD.syncPlanStatus(form.getPlanId()); UNLOAD.syncPlanStatus(form.getPlanId(), form.getEntryMatId());
;
MatmapUtil.clearMatmap(form.getPorIdx()); MatmapUtil.clearMatmap(form.getPorIdx());
// 删除工艺规程 // 删除工艺规程
BeanFactory.getBean(RedisCacheManager.class).delCoilSetup(form.getEntryMatId()); BeanFactory.getBean(RedisCacheManager.class).delCoilSetup(form.getEntryMatId());
@@ -107,14 +109,16 @@ public enum WebOperateMatEnum implements IEnum<String>, IOperateMat<WebOperateMa
PRODUCING("生产中") { PRODUCING("生产中") {
@Override @Override
public void operate(WebOperateMatForm form) { public void operate(WebOperateMatForm form) {
PRODUCING.syncPlanStatus(form.getPlanId()); PRODUCING.syncPlanStatus(form.getPlanId(), form.getEntryMatId());
;
WebSocketUtil.sendSignalMsg(form); WebSocketUtil.sendSignalMsg(form);
} }
}, },
PRODUCT("生产完成") { PRODUCT("生产完成") {
@Override @Override
public void operate(WebOperateMatForm form) { public void operate(WebOperateMatForm form) {
PRODUCT.syncPlanStatus(form.getPlanId()); PRODUCT.syncPlanStatus(form.getPlanId(), form.getEntryMatId());
;
if (Objects.isNull(form.getCoilLength()) || form.getCoilLength() <= 0) { if (Objects.isNull(form.getCoilLength()) || form.getCoilLength() <= 0) {
form.setCoilLength(9999d); form.setCoilLength(9999d);
} }
@@ -135,7 +139,8 @@ public enum WebOperateMatEnum implements IEnum<String>, IOperateMat<WebOperateMa
BLOCK("卸卷并封闭") { BLOCK("卸卷并封闭") {
@Override @Override
public void operate(WebOperateMatForm form) { public void operate(WebOperateMatForm form) {
BLOCK.syncPlanStatus(form.getPlanId()); BLOCK.syncPlanStatus(form.getPlanId(), form.getEntryMatId());
;
MatmapUtil.clearMatmap(form.getPorIdx()); MatmapUtil.clearMatmap(form.getPorIdx());
// 删除工艺规程 // 删除工艺规程
BeanFactory.getBean(RedisCacheManager.class).delCoilSetup(form.getEntryMatId()); BeanFactory.getBean(RedisCacheManager.class).delCoilSetup(form.getEntryMatId());
@@ -149,7 +154,7 @@ public enum WebOperateMatEnum implements IEnum<String>, IOperateMat<WebOperateMa
ArrayList<String> status = Lists.newArrayList(PlanStatusEnum.ONLINE.name()); ArrayList<String> status = Lists.newArrayList(PlanStatusEnum.ONLINE.name());
CrmPdiPlanService planClient = BeanFactory.getBean(CrmPdiPlanService.class); CrmPdiPlanService planClient = BeanFactory.getBean(CrmPdiPlanService.class);
CrmPdiPlanVO plan = planClient.getByCoilIdAndOperId(form.getEntryMatId()); CrmPdiPlanVO plan = planClient.getByCoilIdAndOperId(form.getEntryMatId());
if (Objects.nonNull(plan) ) { if (Objects.nonNull(plan)) {
Assert.isTrue(!status.contains(plan.getStatus()), "当前状态[{}]不支持甩尾", plan.getStatus()); Assert.isTrue(!status.contains(plan.getStatus()), "当前状态[{}]不支持甩尾", plan.getStatus());
} }
MatmapUtil.clearMatmap(form.getPorIdx()); MatmapUtil.clearMatmap(form.getPorIdx());
@@ -185,12 +190,13 @@ public enum WebOperateMatEnum implements IEnum<String>, IOperateMat<WebOperateMa
* *
* @param planId 计划id * @param planId 计划id
*/ */
private void syncPlanStatus(String planId) { private void syncPlanStatus(String planId, String matId) {
CrmPdiPlanService planClient = BeanFactory.getBean(CrmPdiPlanService.class); CrmPdiPlanService planClient = BeanFactory.getBean(CrmPdiPlanService.class);
planClient.changeStatus(ChangePlanStatusForm.builder() planClient.changeStatus(ChangePlanStatusForm.builder()
.operation(this.name()) .operation(this.name())
.id(planId) .id(planId)
.matId(matId)
.build()); .build());
} }
@@ -231,7 +237,7 @@ public enum WebOperateMatEnum implements IEnum<String>, IOperateMat<WebOperateMa
returnMapper.insert(tailCoil); returnMapper.insert(tailCoil);
} else { } else {
// 整卷回退删除已有产出 // 整卷回退删除已有产出
BeanFactory.getBean(PdoExCoilService.class).deleteExistPdo(form.getEntryMatId(),form.getPlanId()); BeanFactory.getBean(PdoExCoilService.class).deleteExistPdo(form.getEntryMatId(), form.getPlanId());
} }
planClient.changeStatus(ChangePlanStatusForm.builder() planClient.changeStatus(ChangePlanStatusForm.builder()

View File

@@ -26,6 +26,9 @@ public class ChangePlanStatusForm implements Serializable {
@NotNull(message = "计划id不能为空") @NotNull(message = "计划id不能为空")
@Schema(description = "计划id集合") @Schema(description = "计划id集合")
private String id; private String id;
@Schema(description = "计划id集合")
private String matId;
@Schema(description = "半卷回退新卷号") @Schema(description = "半卷回退新卷号")
private String returnMatId; private String returnMatId;
@Schema(description = "回退重量") @Schema(description = "回退重量")

View File

@@ -6,23 +6,14 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fizz.business.domain.CrmPdiPlan; import com.fizz.business.domain.CrmPdiPlan;
import com.fizz.business.domain.ModCoilMap; import com.fizz.business.form.ChangePlanStatusForm;
import com.fizz.business.domain.ProMatmap; import com.fizz.business.form.PlanQueryForm;
import com.fizz.business.form.*;
import com.fizz.business.mapper.CrmPdiPlanMapper; import com.fizz.business.mapper.CrmPdiPlanMapper;
import com.fizz.business.service.CrmPdiPlanService; import com.fizz.business.service.CrmPdiPlanService;
import com.fizz.business.service.ModCoilMapService;
import com.fizz.business.service.ModSetupResultService;
import com.fizz.business.service.ProMatmapService;
import com.fizz.business.vo.CrmPdiPlanVO; import com.fizz.business.vo.CrmPdiPlanVO;
import com.fizz.business.vo.ModSetupResultVO;
import com.fizz.business.vo.PdiPlanSetupInfoVO;
import com.ruoyi.common.utils.StringUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
@@ -143,7 +134,7 @@ public class CrmPdiPlanServiceImpl extends ServiceImpl<CrmPdiPlanMapper, CrmPdiP
@Override @Override
public CrmPdiPlan getFirstUnProducedCoil() { public CrmPdiPlan getFirstUnProducedCoil() {
return this.lambdaQuery() return this.lambdaQuery()
.eq(CrmPdiPlan::getStatus, 0) // 0 表示未生产 .in(CrmPdiPlan::getStatus, "NEW","READY") // 0 表示未生产
.orderByAsc(CrmPdiPlan::getSeqid) // 按顺序号排序,取第一个 .orderByAsc(CrmPdiPlan::getSeqid) // 按顺序号排序,取第一个
.last("limit 1") .last("limit 1")
.one(); .one();
@@ -152,7 +143,11 @@ public class CrmPdiPlanServiceImpl extends ServiceImpl<CrmPdiPlanMapper, CrmPdiP
@Override @Override
public void changeStatus(ChangePlanStatusForm build) { public void changeStatus(ChangePlanStatusForm build) {
CrmPdiPlan pdiPlan = baseMapper.selectById(build.getId()); QueryWrapper<CrmPdiPlan> wrapper = new QueryWrapper<>();
wrapper.eq("coilid", build.getMatId());
wrapper.eq("planid", build.getId());
CrmPdiPlan pdiPlan = baseMapper.selectOne(wrapper);
if (pdiPlan == null) { if (pdiPlan == null) {
log.error("未找到ID为{}的计划记录", build.getId()); log.error("未找到ID为{}的计划记录", build.getId());
@@ -160,7 +155,8 @@ public class CrmPdiPlanServiceImpl extends ServiceImpl<CrmPdiPlanMapper, CrmPdiP
} }
pdiPlan.setStatus(build.getOperation()); pdiPlan.setStatus(build.getOperation());
baseMapper.updateById(pdiPlan);
log.info("计划状态更新成功ID: {}, 新状态: {}", build.getId(), build.getOperation()); log.info("计划状态更新成功ID: {}, 新状态: {}", build.getId(), build.getOperation());
} }

View File

@@ -13,6 +13,7 @@ import com.fizz.business.form.AdjustPosForm;
import com.fizz.business.form.L1OperateMatForm; import com.fizz.business.form.L1OperateMatForm;
import com.fizz.business.form.WebOperateMatForm; import com.fizz.business.form.WebOperateMatForm;
import com.fizz.business.service.CrmPdiPlanService; import com.fizz.business.service.CrmPdiPlanService;
import com.fizz.business.service.ProMatmapService;
import com.fizz.business.service.TrackService; import com.fizz.business.service.TrackService;
import com.fizz.business.service.client.RedisCacheManager; import com.fizz.business.service.client.RedisCacheManager;
import com.fizz.business.utils.CalcUtil; import com.fizz.business.utils.CalcUtil;
@@ -45,6 +46,9 @@ public class TrackServiceImpl implements TrackService {
@Autowired @Autowired
RedisCacheManager redisCacheManager; RedisCacheManager redisCacheManager;
@Autowired
ProMatmapService proMatmapService;
@Autowired @Autowired
CrmPdiPlanService crmPdiPlanService; CrmPdiPlanService crmPdiPlanService;
@@ -53,6 +57,7 @@ public class TrackServiceImpl implements TrackService {
log.info("web operate mat: {}", JSON.toJSONString(form)); log.info("web operate mat: {}", JSON.toJSONString(form));
form.getOperation().operate(form); form.getOperation().operate(form);
proMatmapService.flushMatmap();
} }
@Override @Override
@@ -60,6 +65,7 @@ public class TrackServiceImpl implements TrackService {
log.info("l1 operate mat: {}", JSON.toJSONString(form)); log.info("l1 operate mat: {}", JSON.toJSONString(form));
form.getOperation().operate(form); form.getOperation().operate(form);
proMatmapService.flushMatmap();
} }
@Override @Override

View File

@@ -59,7 +59,7 @@ public class MatmapUtil {
} }
public static boolean already(MatmapDTO matmap) { public static boolean already(MatmapDTO matmap) {
return Objects.nonNull(matmap) && StrUtil.isNotBlank(matmap.getMatId()); return Objects.nonNull(matmap) && Objects.nonNull(matmap.getMatId());
} }
public static void setMatId(int index, String matId) { public static void setMatId(int index, String matId) {

View File

@@ -5,8 +5,8 @@
<mapper namespace="com.fizz.business.mapper.ProMatmapMapper"> <mapper namespace="com.fizz.business.mapper.ProMatmapMapper">
<update id="flushMatmap"> <insert id="flushMatmap">
insert into track_ca1_romtb_matmap ( insert into pro_matmap (
pos_idx, mat_id, plan_no, plan_id pos_idx, mat_id, plan_no, plan_id
) )
values values
@@ -14,7 +14,9 @@
(#{item.posIdx}, #{item.matId}, #{item.planNo}, #{item.planId}) (#{item.posIdx}, #{item.matId}, #{item.planNo}, #{item.planId})
</foreach> </foreach>
on duplicate key update on duplicate key update
mat_id = VALUES(mat_id),plan_no = VALUES(plan_no),plan_id = VALUES(plan_id) mat_id = VALUES(mat_id),
</update> plan_no = VALUES(plan_no),
plan_id = VALUES(plan_id)
</insert>
</mapper> </mapper>

View File

@@ -5,8 +5,8 @@
<mapper namespace="com.fizz.business.mapper.ProMatmapMapper"> <mapper namespace="com.fizz.business.mapper.ProMatmapMapper">
<update id="flushMatmap"> <insert id="flushMatmap">
insert into track_ca1_romtb_matmap ( insert into pro_matmap (
pos_idx, mat_id, plan_no, plan_id pos_idx, mat_id, plan_no, plan_id
) )
values values
@@ -14,7 +14,9 @@
(#{item.posIdx}, #{item.matId}, #{item.planNo}, #{item.planId}) (#{item.posIdx}, #{item.matId}, #{item.planNo}, #{item.planId})
</foreach> </foreach>
on duplicate key update on duplicate key update
mat_id = VALUES(mat_id),plan_no = VALUES(plan_no),plan_id = VALUES(plan_id) mat_id = VALUES(mat_id),
</update> plan_no = VALUES(plan_no),
plan_id = VALUES(plan_id)
</insert>
</mapper> </mapper>