fix():redis刷新数据库
This commit is contained in:
@@ -49,7 +49,7 @@ public enum WebOperateMatEnum implements IEnum<String>, IOperateMat<WebOperateMa
|
||||
MatmapDTO porCoil = MatmapUtil.getMatmap(form.getPorIdx());
|
||||
if (MatmapUtil.already(porCoil)) {
|
||||
|
||||
ONLINE.syncPlanStatus(form.getPlanId());
|
||||
ONLINE.syncPlanStatus(form.getPlanId(), form.getEntryMatId());
|
||||
WebSocketUtil.sendSignalMsg(form, true);
|
||||
// 如果开卷机和焊机的钢卷相同,则将计划状态变更为生产中
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
ONLINE.syncPlanStatus(form.getPlanId());
|
||||
ONLINE.syncPlanStatus(form.getPlanId(), form.getEntryMatId());
|
||||
;
|
||||
MatmapUtil.setMatmap(form.getPorIdx(), form.getEntryMatId(), form.getPlanId(), form.getPlanNo());
|
||||
WebSocketUtil.sendSignalMsg(form);
|
||||
}
|
||||
@@ -72,7 +73,8 @@ public enum WebOperateMatEnum implements IEnum<String>, IOperateMat<WebOperateMa
|
||||
public void operate(WebOperateMatForm form) {
|
||||
// 开卷机卸卷,变更计划状态为READY,清除matmap
|
||||
if (Objects.nonNull(form.getPorIdx())) {
|
||||
UNLOAD.syncPlanStatus(form.getPlanId());
|
||||
UNLOAD.syncPlanStatus(form.getPlanId(), form.getEntryMatId());
|
||||
;
|
||||
MatmapUtil.clearMatmap(form.getPorIdx());
|
||||
// 删除工艺规程
|
||||
BeanFactory.getBean(RedisCacheManager.class).delCoilSetup(form.getEntryMatId());
|
||||
@@ -107,14 +109,16 @@ public enum WebOperateMatEnum implements IEnum<String>, IOperateMat<WebOperateMa
|
||||
PRODUCING("生产中") {
|
||||
@Override
|
||||
public void operate(WebOperateMatForm form) {
|
||||
PRODUCING.syncPlanStatus(form.getPlanId());
|
||||
PRODUCING.syncPlanStatus(form.getPlanId(), form.getEntryMatId());
|
||||
;
|
||||
WebSocketUtil.sendSignalMsg(form);
|
||||
}
|
||||
},
|
||||
PRODUCT("生产完成") {
|
||||
@Override
|
||||
public void operate(WebOperateMatForm form) {
|
||||
PRODUCT.syncPlanStatus(form.getPlanId());
|
||||
PRODUCT.syncPlanStatus(form.getPlanId(), form.getEntryMatId());
|
||||
;
|
||||
if (Objects.isNull(form.getCoilLength()) || form.getCoilLength() <= 0) {
|
||||
form.setCoilLength(9999d);
|
||||
}
|
||||
@@ -135,7 +139,8 @@ public enum WebOperateMatEnum implements IEnum<String>, IOperateMat<WebOperateMa
|
||||
BLOCK("卸卷并封闭") {
|
||||
@Override
|
||||
public void operate(WebOperateMatForm form) {
|
||||
BLOCK.syncPlanStatus(form.getPlanId());
|
||||
BLOCK.syncPlanStatus(form.getPlanId(), form.getEntryMatId());
|
||||
;
|
||||
MatmapUtil.clearMatmap(form.getPorIdx());
|
||||
// 删除工艺规程
|
||||
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());
|
||||
CrmPdiPlanService planClient = BeanFactory.getBean(CrmPdiPlanService.class);
|
||||
CrmPdiPlanVO plan = planClient.getByCoilIdAndOperId(form.getEntryMatId());
|
||||
if (Objects.nonNull(plan) ) {
|
||||
if (Objects.nonNull(plan)) {
|
||||
Assert.isTrue(!status.contains(plan.getStatus()), "当前状态[{}]不支持甩尾", plan.getStatus());
|
||||
}
|
||||
MatmapUtil.clearMatmap(form.getPorIdx());
|
||||
@@ -185,12 +190,13 @@ public enum WebOperateMatEnum implements IEnum<String>, IOperateMat<WebOperateMa
|
||||
*
|
||||
* @param planId 计划id
|
||||
*/
|
||||
private void syncPlanStatus(String planId) {
|
||||
private void syncPlanStatus(String planId, String matId) {
|
||||
CrmPdiPlanService planClient = BeanFactory.getBean(CrmPdiPlanService.class);
|
||||
|
||||
planClient.changeStatus(ChangePlanStatusForm.builder()
|
||||
.operation(this.name())
|
||||
.id(planId)
|
||||
.matId(matId)
|
||||
.build());
|
||||
}
|
||||
|
||||
@@ -231,7 +237,7 @@ public enum WebOperateMatEnum implements IEnum<String>, IOperateMat<WebOperateMa
|
||||
returnMapper.insert(tailCoil);
|
||||
} else {
|
||||
// 整卷回退删除已有产出
|
||||
BeanFactory.getBean(PdoExCoilService.class).deleteExistPdo(form.getEntryMatId(),form.getPlanId());
|
||||
BeanFactory.getBean(PdoExCoilService.class).deleteExistPdo(form.getEntryMatId(), form.getPlanId());
|
||||
}
|
||||
|
||||
planClient.changeStatus(ChangePlanStatusForm.builder()
|
||||
|
||||
@@ -26,6 +26,9 @@ public class ChangePlanStatusForm implements Serializable {
|
||||
@NotNull(message = "计划id不能为空")
|
||||
@Schema(description = "计划id集合")
|
||||
private String id;
|
||||
@Schema(description = "计划id集合")
|
||||
private String matId;
|
||||
|
||||
@Schema(description = "半卷回退新卷号")
|
||||
private String returnMatId;
|
||||
@Schema(description = "回退重量")
|
||||
|
||||
@@ -6,23 +6,14 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fizz.business.domain.CrmPdiPlan;
|
||||
import com.fizz.business.domain.ModCoilMap;
|
||||
import com.fizz.business.domain.ProMatmap;
|
||||
import com.fizz.business.form.*;
|
||||
import com.fizz.business.form.ChangePlanStatusForm;
|
||||
import com.fizz.business.form.PlanQueryForm;
|
||||
import com.fizz.business.mapper.CrmPdiPlanMapper;
|
||||
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.ModSetupResultVO;
|
||||
import com.fizz.business.vo.PdiPlanSetupInfoVO;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -143,7 +134,7 @@ public class CrmPdiPlanServiceImpl extends ServiceImpl<CrmPdiPlanMapper, CrmPdiP
|
||||
@Override
|
||||
public CrmPdiPlan getFirstUnProducedCoil() {
|
||||
return this.lambdaQuery()
|
||||
.eq(CrmPdiPlan::getStatus, 0) // 0 表示未生产
|
||||
.in(CrmPdiPlan::getStatus, "NEW","READY") // 0 表示未生产
|
||||
.orderByAsc(CrmPdiPlan::getSeqid) // 按顺序号排序,取第一个
|
||||
.last("limit 1")
|
||||
.one();
|
||||
@@ -152,7 +143,11 @@ public class CrmPdiPlanServiceImpl extends ServiceImpl<CrmPdiPlanMapper, CrmPdiP
|
||||
@Override
|
||||
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) {
|
||||
log.error("未找到ID为{}的计划记录", build.getId());
|
||||
@@ -160,7 +155,8 @@ public class CrmPdiPlanServiceImpl extends ServiceImpl<CrmPdiPlanMapper, CrmPdiP
|
||||
}
|
||||
|
||||
pdiPlan.setStatus(build.getOperation());
|
||||
|
||||
|
||||
baseMapper.updateById(pdiPlan);
|
||||
log.info("计划状态更新成功,ID: {}, 新状态: {}", build.getId(), build.getOperation());
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.fizz.business.form.AdjustPosForm;
|
||||
import com.fizz.business.form.L1OperateMatForm;
|
||||
import com.fizz.business.form.WebOperateMatForm;
|
||||
import com.fizz.business.service.CrmPdiPlanService;
|
||||
import com.fizz.business.service.ProMatmapService;
|
||||
import com.fizz.business.service.TrackService;
|
||||
import com.fizz.business.service.client.RedisCacheManager;
|
||||
import com.fizz.business.utils.CalcUtil;
|
||||
@@ -45,6 +46,9 @@ public class TrackServiceImpl implements TrackService {
|
||||
@Autowired
|
||||
RedisCacheManager redisCacheManager;
|
||||
|
||||
@Autowired
|
||||
ProMatmapService proMatmapService;
|
||||
|
||||
@Autowired
|
||||
CrmPdiPlanService crmPdiPlanService;
|
||||
|
||||
@@ -53,6 +57,7 @@ public class TrackServiceImpl implements TrackService {
|
||||
|
||||
log.info("web operate mat: {}", JSON.toJSONString(form));
|
||||
form.getOperation().operate(form);
|
||||
proMatmapService.flushMatmap();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,6 +65,7 @@ public class TrackServiceImpl implements TrackService {
|
||||
|
||||
log.info("l1 operate mat: {}", JSON.toJSONString(form));
|
||||
form.getOperation().operate(form);
|
||||
proMatmapService.flushMatmap();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -59,7 +59,7 @@ public class MatmapUtil {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
<mapper namespace="com.fizz.business.mapper.ProMatmapMapper">
|
||||
|
||||
|
||||
<update id="flushMatmap">
|
||||
insert into track_ca1_romtb_matmap (
|
||||
<insert id="flushMatmap">
|
||||
insert into pro_matmap (
|
||||
pos_idx, mat_id, plan_no, plan_id
|
||||
)
|
||||
values
|
||||
@@ -14,7 +14,9 @@
|
||||
(#{item.posIdx}, #{item.matId}, #{item.planNo}, #{item.planId})
|
||||
</foreach>
|
||||
on duplicate key update
|
||||
mat_id = VALUES(mat_id),plan_no = VALUES(plan_no),plan_id = VALUES(plan_id)
|
||||
</update>
|
||||
mat_id = VALUES(mat_id),
|
||||
plan_no = VALUES(plan_no),
|
||||
plan_id = VALUES(plan_id)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@@ -5,8 +5,8 @@
|
||||
<mapper namespace="com.fizz.business.mapper.ProMatmapMapper">
|
||||
|
||||
|
||||
<update id="flushMatmap">
|
||||
insert into track_ca1_romtb_matmap (
|
||||
<insert id="flushMatmap">
|
||||
insert into pro_matmap (
|
||||
pos_idx, mat_id, plan_no, plan_id
|
||||
)
|
||||
values
|
||||
@@ -14,7 +14,9 @@
|
||||
(#{item.posIdx}, #{item.matId}, #{item.planNo}, #{item.planId})
|
||||
</foreach>
|
||||
on duplicate key update
|
||||
mat_id = VALUES(mat_id),plan_no = VALUES(plan_no),plan_id = VALUES(plan_id)
|
||||
</update>
|
||||
mat_id = VALUES(mat_id),
|
||||
plan_no = VALUES(plan_no),
|
||||
plan_id = VALUES(plan_id)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user