mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
自定义板编号手动复位功能实现
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
package com.cf.imes.module.executor.api.customplateno;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.module.executor.api.customplateno.dto.CustomPlateNoRuleDTO;
|
||||
import com.cf.imes.module.executor.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
* @since 2024/11/28 18:18
|
||||
*/
|
||||
@FeignClient(name = ApiConstants.NAME)
|
||||
@Tag(name = "RPC 服务 - 生产单自定义板编号序号")
|
||||
public interface OrderCustomPlateNoApi {
|
||||
String PREFIX = ApiConstants.PREFIX + "/order/customplateno";
|
||||
|
||||
@PostMapping(PREFIX + "/initValue")
|
||||
@Operation(summary = "复位/清零生产单下的序号")
|
||||
CommonResult<Boolean> resetOrderSeq(@RequestBody CustomPlateNoRuleDTO ruleDTO);
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package com.cf.imes.module.executor.api.customplateno.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 系统配置-自定义板编号setting项 vo
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/11/15 10:33
|
||||
*/
|
||||
@Data
|
||||
public class CustomPlateNoRuleDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -5691595836226548840L;
|
||||
|
||||
/**
|
||||
* 系统配置 - 自定义板编号配置 id
|
||||
*/
|
||||
@NotNull(message = "配置id不能为空")
|
||||
private Long configId;
|
||||
/**
|
||||
* 规则编码
|
||||
*/
|
||||
private String ruleCode;
|
||||
|
||||
/**
|
||||
* 规则值
|
||||
*/
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 初始值
|
||||
*/
|
||||
private Integer initValue;
|
||||
|
||||
/**
|
||||
* 位数
|
||||
*/
|
||||
private Integer length;
|
||||
|
||||
/**
|
||||
* 是否左补零
|
||||
*/
|
||||
private boolean leftFillZero;
|
||||
|
||||
/**
|
||||
* 步长
|
||||
*/
|
||||
private Integer incrementStep;
|
||||
|
||||
/**
|
||||
* 复位/清零模式
|
||||
*/
|
||||
@NotNull(message = "复位模式不能为空")
|
||||
private Integer resetMode;
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.cf.imes.module.executor.api.customplateno;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||
import com.cf.imes.module.executor.api.customplateno.dto.CustomPlateNoRuleDTO;
|
||||
import com.cf.imes.module.executor.service.customplatenorule.CustomPlateNoGenerateRuleService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Gqr
|
||||
* @since 2024/11/28 18:24
|
||||
*/
|
||||
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
||||
@Validated
|
||||
public class OrderCustomPlateNoApiImpl implements OrderCustomPlateNoApi {
|
||||
|
||||
@Resource
|
||||
List<CustomPlateNoGenerateRuleService> customPlateNoGenerateRuleServices;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult<Boolean> resetOrderSeq(CustomPlateNoRuleDTO ruleDTO) {
|
||||
for (CustomPlateNoGenerateRuleService ruleService : customPlateNoGenerateRuleServices) {
|
||||
if (ruleService.match(ruleDTO.getRuleCode())) {
|
||||
ruleService.reset(ruleDTO);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -186,6 +186,8 @@ public class PlateDO extends BaseDO {
|
||||
*/
|
||||
private Boolean deleted;
|
||||
|
||||
private String customPlateNo;
|
||||
|
||||
/**
|
||||
* 房间名
|
||||
*/
|
||||
@@ -199,5 +201,5 @@ public class PlateDO extends BaseDO {
|
||||
private String bodyName;
|
||||
|
||||
@TableField(exist = false)
|
||||
private StringBuilder customPlateNo;
|
||||
private StringBuilder customPlateNoBuilder;
|
||||
}
|
||||
+3
-3
@@ -105,10 +105,10 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe
|
||||
// 遍历规则列表
|
||||
for (CustomPlateNoRuleVO plateNoRule : orgCustomPlateNoRuleVOList) {
|
||||
if (ObjectUtil.equal(CustomPlateNoRuleCodeEnum.CUSTOM.getRuleCode(), plateNoRule.getRuleCode())) {
|
||||
plateDO.getCustomPlateNo().append(plateNoRule.getValue());
|
||||
plateDO.getCustomPlateNoBuilder().append(plateNoRule.getValue());
|
||||
}
|
||||
if (ObjectUtil.equal(CustomPlateNoRuleCodeEnum.DATE.getRuleCode(), plateNoRule.getRuleCode())) {
|
||||
plateDO.getCustomPlateNo().append(plateNoRule.getNow().format(DateTimeFormatter.ofPattern(plateNoRule.getValue())));
|
||||
plateDO.getCustomPlateNoBuilder().append(plateNoRule.getNow().format(DateTimeFormatter.ofPattern(plateNoRule.getValue())));
|
||||
}
|
||||
// 遍历规则生成服务列表,获取对应的规则服务
|
||||
for (CustomPlateNoGenerateRuleService ruleService : ruleServices) {
|
||||
@@ -118,7 +118,7 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe
|
||||
}
|
||||
}
|
||||
}
|
||||
plateDO.setPlateNo(plateDO.getCustomPlateNo().toString());
|
||||
plateDO.setCustomPlateNo(plateDO.getCustomPlateNoBuilder().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+4
@@ -1,12 +1,16 @@
|
||||
package com.cf.imes.module.executor.service.customplateno.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class OrderCustomPlateNoSeqBodyVO implements Serializable {
|
||||
private static final long serialVersionUID = 2686882895438975156L;
|
||||
/**
|
||||
|
||||
+4
@@ -1,13 +1,17 @@
|
||||
package com.cf.imes.module.executor.service.customplateno.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class OrderCustomPlateNoSeqRoomVO implements Serializable {
|
||||
private static final long serialVersionUID = -127388898531267048L;
|
||||
/**
|
||||
|
||||
+42
-2
@@ -2,8 +2,16 @@ package com.cf.imes.module.executor.service.customplatenorule;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
||||
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.module.executor.api.customplateno.dto.CustomPlateNoRuleDTO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
|
||||
import com.cf.imes.module.executor.dal.mysql.order.OrderMapper;
|
||||
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoGenerateConfigVO;
|
||||
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleVO;
|
||||
import com.cf.imes.module.executor.service.customplateno.vo.OrderCustomPlateNoSeqBodyVO;
|
||||
@@ -14,6 +22,7 @@ import com.cf.imes.module.system.enums.customplateno.CustomPlateNoRuleCodeEnum;
|
||||
import com.cf.imes.module.system.enums.customplateno.ResetModeEnum;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -28,6 +37,10 @@ import static com.cf.imes.module.executor.enums.ErrorCodeConstants.CUSTOM_PLATEN
|
||||
*/
|
||||
@Service("bodyNoGenerateRuleService")
|
||||
public class BodyNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleService {
|
||||
|
||||
@Resource
|
||||
private OrderMapper orderMapper;
|
||||
|
||||
@Override
|
||||
public boolean match(String ruleCode) {
|
||||
return ObjectUtil.equal(CustomPlateNoRuleCodeEnum.BODYNO.getRuleCode(), ruleCode);
|
||||
@@ -72,6 +85,33 @@ public class BodyNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
|
||||
return generateConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset(CustomPlateNoRuleDTO ruleDTO) {
|
||||
// 查询所有使用当前配置id的生产单列表
|
||||
Long configId = ruleDTO.getConfigId();
|
||||
List<OrderDO> orderDOS = orderMapper.selectList(
|
||||
new LambdaQueryWrapper<OrderDO>().eq(OrderDO::getCustomPlatenoConfigId, configId).eq(OrderDO::getOrganId, OrganContextHolder.getOrganId()));
|
||||
|
||||
ResetModeEnum resetModeEnum = ResetModeEnum.getByMode(ruleDTO.getResetMode());
|
||||
// 根据复位模式更新生产单的序号
|
||||
for (OrderDO orderDO : orderDOS) {
|
||||
OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = JSON.parseObject(orderDO.getCustomPlatenoSeq(), OrderCustomPlateNoSeqVO.class);
|
||||
if (ObjectUtil.isNotNull(orderCustomPlateNoSeqVO)) {
|
||||
if (ObjectUtil.equal(ResetModeEnum.ORDER, resetModeEnum)) {
|
||||
orderCustomPlateNoSeqVO.setBodyNoSeq(ruleDTO.getInitValue());
|
||||
} else if (ObjectUtil.equal(ResetModeEnum.ROOM, resetModeEnum)) {
|
||||
List<OrderCustomPlateNoSeqRoomVO> rooms = orderCustomPlateNoSeqVO.getRooms();
|
||||
if (CollUtil.isNotEmpty(rooms)) {
|
||||
for (OrderCustomPlateNoSeqRoomVO roomVO : rooms) {
|
||||
roomVO.setBodyNoSeq(ruleDTO.getInitValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
orderMapper.update(new LambdaUpdateWrapper<OrderDO>().eq(OrderDO::getId, orderDO.getId()).set(OrderDO::getCustomPlatenoSeq, JsonUtils.zipString(JSON.toJSONString(orderCustomPlateNoSeqVO))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按生产单复位模式下的板编号生成
|
||||
*
|
||||
@@ -123,7 +163,7 @@ public class BodyNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
|
||||
|
||||
// 补零
|
||||
String noPartAfterFillZero = fillZero(bodyNoSeq, plateNoRule);
|
||||
plateDO.getCustomPlateNo().append(noPartAfterFillZero);
|
||||
plateDO.getCustomPlateNoBuilder().append(noPartAfterFillZero);
|
||||
// 累加后同步到json:柜体下累加到多少了
|
||||
bodySeqVo.setBodyNoSeq(bodyNoSeq);
|
||||
|
||||
@@ -189,7 +229,7 @@ public class BodyNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
|
||||
|
||||
// 补零
|
||||
String noPartAfterFillZero = fillZero(roomBodyNoSeq, plateNoRule);
|
||||
plateDO.getCustomPlateNo().append(noPartAfterFillZero);
|
||||
plateDO.getCustomPlateNoBuilder().append(noPartAfterFillZero);
|
||||
// 累加后同步到json中,room下柜体累加到多少了
|
||||
roomBodySeqVo.setBodyNoSeq(roomBodyNoSeq);
|
||||
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
//import cn.hutool.core.util.ObjectUtil;
|
||||
//import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
|
||||
//import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoGenerateConfigVO;
|
||||
//import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleVO;
|
||||
//import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleDTO;
|
||||
//import com.cf.imes.module.system.enums.customplateno.CustomPlateNoRuleCodeEnum;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
@@ -23,7 +23,7 @@
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, List<PlateDO> plateDOList) {
|
||||
// public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleDTO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, List<PlateDO> plateDOList) {
|
||||
// for (PlateDO plateDO : plateDOList) {
|
||||
// plateDO.getCustomPlateNo().append(plateNoRule.getValue());
|
||||
// }
|
||||
|
||||
+8
@@ -1,5 +1,6 @@
|
||||
package com.cf.imes.module.executor.service.customplatenorule;
|
||||
|
||||
import com.cf.imes.module.executor.api.customplateno.dto.CustomPlateNoRuleDTO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
|
||||
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoGenerateConfigVO;
|
||||
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleVO;
|
||||
@@ -46,4 +47,11 @@ public interface CustomPlateNoGenerateRuleService {
|
||||
}
|
||||
return String.valueOf(curr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 复位
|
||||
*
|
||||
* @param ruleDTO
|
||||
*/
|
||||
void reset(CustomPlateNoRuleDTO ruleDTO);
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
//import cn.hutool.core.util.ObjectUtil;
|
||||
//import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
|
||||
//import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoGenerateConfigVO;
|
||||
//import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleVO;
|
||||
//import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleDTO;
|
||||
//import com.cf.imes.module.system.enums.customplateno.CustomPlateNoRuleCodeEnum;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
@@ -24,7 +24,7 @@
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, List<PlateDO> plateDOList) {
|
||||
// public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleDTO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, List<PlateDO> plateDOList) {
|
||||
// for (PlateDO plateDO : plateDOList) {
|
||||
// plateDO.getCustomPlateNo().append(plateNoRule.getNow().format(DateTimeFormatter.ofPattern(plateNoRule.getValue())));
|
||||
// }
|
||||
|
||||
+32
-2
@@ -1,8 +1,16 @@
|
||||
package com.cf.imes.module.executor.service.customplatenorule;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
||||
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.module.executor.api.customplateno.dto.CustomPlateNoRuleDTO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
|
||||
import com.cf.imes.module.executor.dal.mysql.order.OrderMapper;
|
||||
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoGenerateConfigVO;
|
||||
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleVO;
|
||||
import com.cf.imes.module.executor.service.customplateno.vo.OrderCustomPlateNoSeqVO;
|
||||
@@ -11,7 +19,9 @@ import com.cf.imes.module.system.enums.customplateno.CustomPlateNoRuleCodeEnum;
|
||||
import com.cf.imes.module.system.enums.customplateno.ResetModeEnum;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.CUSTOM_PLATENO_GENERATE_ORDERNO_RULE_NOT_SUPPORT_RESETMODE;
|
||||
@@ -29,6 +39,9 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
private static final DateTimeFormatter MONTH_FORMATTER = DateTimeFormatter.ofPattern("yyyyMM");
|
||||
private static final DateTimeFormatter DAY_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
|
||||
@Resource
|
||||
private OrderMapper orderMapper;
|
||||
|
||||
@Override
|
||||
public boolean match(String ruleCode) {
|
||||
return ObjectUtil.equal(CustomPlateNoRuleCodeEnum.ORDERNO.getRuleCode(), ruleCode);
|
||||
@@ -58,7 +71,7 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
if (ObjectUtil.isNotNull(orderNoSeq)) {
|
||||
// 补零
|
||||
String noPartAfterFill = this.fillZero(orderNoSeq, plateNoRule);
|
||||
plateDO.getCustomPlateNo().append(noPartAfterFill);
|
||||
plateDO.getCustomPlateNoBuilder().append(noPartAfterFill);
|
||||
return generateConfig;
|
||||
}
|
||||
// 机构下的自定义板编号序号
|
||||
@@ -73,7 +86,7 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
}
|
||||
// 补零
|
||||
String noPartAfterFill = this.fillZero(currOrderNoSeq, plateNoRule);
|
||||
plateDO.getCustomPlateNo().append(noPartAfterFill);
|
||||
plateDO.getCustomPlateNoBuilder().append(noPartAfterFill);
|
||||
|
||||
// 累加后的值同步到当前生产单序号和机构序号中
|
||||
orderCustomPlateNoSeqVO.setOrderNoSeq(currOrderNoSeq);
|
||||
@@ -81,6 +94,23 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
return generateConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset(CustomPlateNoRuleDTO ruleDTO) {
|
||||
// 查询所有使用当前配置id的生产单列表
|
||||
Long configId = ruleDTO.getConfigId();
|
||||
List<OrderDO> orderDOS = orderMapper.selectList(
|
||||
new LambdaQueryWrapper<OrderDO>().eq(OrderDO::getCustomPlatenoConfigId, configId).eq(OrderDO::getOrganId, OrganContextHolder.getOrganId()));
|
||||
|
||||
// 更新生产单的序号
|
||||
for (OrderDO orderDO : orderDOS) {
|
||||
OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = JSON.parseObject(orderDO.getCustomPlatenoSeq(), OrderCustomPlateNoSeqVO.class);
|
||||
if (ObjectUtil.isNotNull(orderCustomPlateNoSeqVO)) {
|
||||
orderCustomPlateNoSeqVO.setOrderNoSeq(ruleDTO.getInitValue());
|
||||
orderMapper.update(new LambdaUpdateWrapper<OrderDO>().eq(OrderDO::getId, orderDO.getId()).set(OrderDO::getCustomPlatenoSeq, JsonUtils.zipString(JSON.toJSONString(orderCustomPlateNoSeqVO))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 基于复位模式的板编号生成
|
||||
*
|
||||
|
||||
+74
-4
@@ -2,8 +2,16 @@ package com.cf.imes.module.executor.service.customplatenorule;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
||||
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.module.executor.api.customplateno.dto.CustomPlateNoRuleDTO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
|
||||
import com.cf.imes.module.executor.dal.mysql.order.OrderMapper;
|
||||
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoGenerateConfigVO;
|
||||
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleVO;
|
||||
import com.cf.imes.module.executor.service.customplateno.vo.OrderCustomPlateNoSeqBodyVO;
|
||||
@@ -14,6 +22,7 @@ import com.cf.imes.module.system.enums.customplateno.CustomPlateNoRuleCodeEnum;
|
||||
import com.cf.imes.module.system.enums.customplateno.ResetModeEnum;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -32,6 +41,9 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
private static final DateTimeFormatter MONTH_FORMATTER = DateTimeFormatter.ofPattern("yyyyMM");
|
||||
private static final DateTimeFormatter DAY_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
|
||||
@Resource
|
||||
private OrderMapper orderMapper;
|
||||
|
||||
@Override
|
||||
public boolean match(String ruleCode) {
|
||||
return ObjectUtil.equal(CustomPlateNoRuleCodeEnum.PLATENO.getRuleCode(), ruleCode);
|
||||
@@ -74,6 +86,64 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset(CustomPlateNoRuleDTO ruleDTO) {
|
||||
// 查询所有使用当前配置id的生产单列表
|
||||
Long configId = ruleDTO.getConfigId();
|
||||
List<OrderDO> orderDOS = orderMapper.selectList(
|
||||
new LambdaQueryWrapper<OrderDO>().eq(OrderDO::getCustomPlatenoConfigId, configId).eq(OrderDO::getOrganId, OrganContextHolder.getOrganId()));
|
||||
|
||||
Integer initValue = ruleDTO.getInitValue();
|
||||
ResetModeEnum resetModeEnum = ResetModeEnum.getByMode(ruleDTO.getResetMode());
|
||||
// 根据复位模式更新生产单的序号
|
||||
for (OrderDO orderDO : orderDOS) {
|
||||
OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = JSON.parseObject(orderDO.getCustomPlatenoSeq(), OrderCustomPlateNoSeqVO.class);
|
||||
if (ObjectUtil.isNotNull(orderCustomPlateNoSeqVO)) {
|
||||
if (ObjectUtil.equal(ResetModeEnum.ORDER, resetModeEnum)) {
|
||||
orderCustomPlateNoSeqVO.setPlateNoSeq(initValue);
|
||||
} else if (ObjectUtil.equal(ResetModeEnum.ROOM, resetModeEnum)) {
|
||||
resetRoomPlateSeq(orderCustomPlateNoSeqVO.getRooms(), initValue);
|
||||
} else if (ObjectUtil.equal(ResetModeEnum.BODY, resetModeEnum)) {
|
||||
resetBodyPlateSeq(orderCustomPlateNoSeqVO.getRooms(), initValue);
|
||||
}
|
||||
orderMapper.update(new LambdaUpdateWrapper<OrderDO>().eq(OrderDO::getId, orderDO.getId()).set(OrderDO::getCustomPlatenoSeq, JsonUtils.zipString(JSON.toJSONString(orderCustomPlateNoSeqVO))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 复位生产单下房间中的板件序号
|
||||
*
|
||||
* @param rooms
|
||||
* @param initValue
|
||||
*/
|
||||
private void resetRoomPlateSeq(List<OrderCustomPlateNoSeqRoomVO> rooms, Integer initValue) {
|
||||
if (CollUtil.isNotEmpty(rooms)) {
|
||||
for (OrderCustomPlateNoSeqRoomVO roomVO : rooms) {
|
||||
roomVO.setPlateNoSeq(initValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 复位生产单下柜体中的板件序号
|
||||
*
|
||||
* @param rooms
|
||||
* @param initValue
|
||||
*/
|
||||
private void resetBodyPlateSeq(List<OrderCustomPlateNoSeqRoomVO> rooms, Integer initValue) {
|
||||
if (CollUtil.isNotEmpty(rooms)) {
|
||||
for (OrderCustomPlateNoSeqRoomVO roomVO : rooms) {
|
||||
List<OrderCustomPlateNoSeqBodyVO> bodys = roomVO.getBodys();
|
||||
if (CollUtil.isNotEmpty(bodys)) {
|
||||
for (OrderCustomPlateNoSeqBodyVO bodyVO : bodys) {
|
||||
bodyVO.setPlateNoSeq(initValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按年/月/日复位模式下的板编号生成
|
||||
*/
|
||||
@@ -95,7 +165,7 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
}
|
||||
// 补零
|
||||
String noPartAfterFillZero = fillZero(orderNoSeq, plateNoRule);
|
||||
plateDO.getCustomPlateNo().append(noPartAfterFillZero);
|
||||
plateDO.getCustomPlateNoBuilder().append(noPartAfterFillZero);
|
||||
|
||||
orgCustomPlateNoSeqRespDTO.setPlateNoSeq(orderNoSeq);
|
||||
return generateConfig;
|
||||
@@ -126,7 +196,7 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
}
|
||||
// 跨板件累加步长,补零
|
||||
orderPlateNoSeq += incrementStep;
|
||||
plateDO.getCustomPlateNo().append(fillZero(orderPlateNoSeq, plateNoRule));
|
||||
plateDO.getCustomPlateNoBuilder().append(fillZero(orderPlateNoSeq, plateNoRule));
|
||||
// 累加后的值同步到当前生产单序号中
|
||||
orderCustomPlateNoSeqVO.setPlateNoSeq(orderPlateNoSeq);
|
||||
return generateConfig;
|
||||
@@ -164,7 +234,7 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
// 累加后的值同步到当前生产单序号中
|
||||
roomSeqVo.setPlateNoSeq(roomPlateNoSeq);
|
||||
// 补零
|
||||
plateDO.getCustomPlateNo().append(fillZero(roomPlateNoSeq, plateNoRule));
|
||||
plateDO.getCustomPlateNoBuilder().append(fillZero(roomPlateNoSeq, plateNoRule));
|
||||
return generateConfig;
|
||||
}
|
||||
|
||||
@@ -226,7 +296,7 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
bodySeqVO.setPlateNoSeq(bodyPlateNoSeq);
|
||||
// 补零
|
||||
String noPartAfterFillZero = fillZero(bodyPlateNoSeq, plateNoRule);
|
||||
plateDO.getCustomPlateNo().append(noPartAfterFillZero);
|
||||
plateDO.getCustomPlateNoBuilder().append(noPartAfterFillZero);
|
||||
return generateConfig;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -5,7 +5,7 @@
|
||||
//import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
||||
//import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
|
||||
//import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoGenerateConfigVO;
|
||||
//import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleVO;
|
||||
//import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleDTO;
|
||||
//import com.cf.imes.module.executor.service.customplateno.vo.OrderCustomPlateNoSeqProcessGroupVO;
|
||||
//import com.cf.imes.module.executor.service.customplateno.vo.OrderCustomPlateNoSeqRoomVO;
|
||||
//import com.cf.imes.module.executor.service.customplateno.vo.OrderCustomPlateNoSeqVO;
|
||||
@@ -37,7 +37,7 @@
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, List<PlateDO> plateDOList) {
|
||||
// public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleDTO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, List<PlateDO> plateDOList) {
|
||||
// // 初始化配置
|
||||
// initConfig(generateConfig);
|
||||
// // 按复位模式走不同的生成方式
|
||||
@@ -85,7 +85,7 @@
|
||||
// * @param plateDOList 板件列表
|
||||
// * @return
|
||||
// */
|
||||
// private CustomPlateNoGenerateConfigVO generateNoByOrderResetMode(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, List<PlateDO> plateDOList) {
|
||||
// private CustomPlateNoGenerateConfigVO generateNoByOrderResetMode(Long orderId, CustomPlateNoRuleDTO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, List<PlateDO> plateDOList) {
|
||||
// Integer initValue = plateNoRule.getInitValue() - plateNoRule.getIncrementStep();
|
||||
// // 生产单下的序号
|
||||
// OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = generateConfig.getOrderCustomPlateNoSeqVO();
|
||||
@@ -143,7 +143,7 @@
|
||||
// * @param plateDOList
|
||||
// * @return
|
||||
// */
|
||||
// private CustomPlateNoGenerateConfigVO generateNoByRoomResetMode(CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, List<PlateDO> plateDOList) {
|
||||
// private CustomPlateNoGenerateConfigVO generateNoByRoomResetMode(CustomPlateNoRuleDTO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, List<PlateDO> plateDOList) {
|
||||
// Integer initValue = plateNoRule.getInitValue() - plateNoRule.getIncrementStep();
|
||||
// // 生产单下的序号
|
||||
// OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = generateConfig.getOrderCustomPlateNoSeqVO();
|
||||
|
||||
+30
-1
@@ -2,7 +2,15 @@ package com.cf.imes.module.executor.service.customplatenorule;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.cf.imes.framework.common.util.json.JsonUtils;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.module.executor.api.customplateno.dto.CustomPlateNoRuleDTO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
||||
import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
|
||||
import com.cf.imes.module.executor.dal.mysql.order.OrderMapper;
|
||||
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoGenerateConfigVO;
|
||||
import com.cf.imes.module.executor.service.customplateno.vo.CustomPlateNoRuleVO;
|
||||
import com.cf.imes.module.executor.service.customplateno.vo.OrderCustomPlateNoSeqRoomVO;
|
||||
@@ -11,6 +19,7 @@ import com.cf.imes.module.system.api.customplateno.dto.CustomPlateNoSeqDTO;
|
||||
import com.cf.imes.module.system.enums.customplateno.CustomPlateNoRuleCodeEnum;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -23,6 +32,9 @@ import java.util.Optional;
|
||||
*/
|
||||
@Service("roomNoGenerateRuleService")
|
||||
public class RoomNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleService {
|
||||
@Resource
|
||||
private OrderMapper orderMapper;
|
||||
|
||||
@Override
|
||||
public boolean match(String ruleCode) {
|
||||
return ObjectUtil.equal(CustomPlateNoRuleCodeEnum.ROOMNO.getRuleCode(), ruleCode);
|
||||
@@ -93,13 +105,30 @@ public class RoomNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
|
||||
|
||||
// 补零
|
||||
String noPartAfterFillZero = fillZero(roomNoSeq, plateNoRule);
|
||||
plateDO.getCustomPlateNo().append(noPartAfterFillZero);
|
||||
plateDO.getCustomPlateNoBuilder().append(noPartAfterFillZero);
|
||||
// 累加后同步到json:房间下累加到多少了
|
||||
roomSeqVo.setRoomNoSeq(roomNoSeq);
|
||||
|
||||
return generateConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset(CustomPlateNoRuleDTO ruleDTO) {
|
||||
// 查询所有使用当前配置id的生产单列表
|
||||
Long configId = ruleDTO.getConfigId();
|
||||
List<OrderDO> orderDOS = orderMapper.selectList(
|
||||
new LambdaQueryWrapper<OrderDO>().eq(OrderDO::getCustomPlatenoConfigId, configId).eq(OrderDO::getOrganId, OrganContextHolder.getOrganId()));
|
||||
|
||||
// 更新生产单的序号
|
||||
for (OrderDO orderDO : orderDOS) {
|
||||
OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = JSON.parseObject(orderDO.getCustomPlatenoSeq(), OrderCustomPlateNoSeqVO.class);
|
||||
if (ObjectUtil.isNotNull(orderCustomPlateNoSeqVO)) {
|
||||
orderCustomPlateNoSeqVO.setRoomNoSeq(ruleDTO.getInitValue());
|
||||
orderMapper.update(new LambdaUpdateWrapper<OrderDO>().eq(OrderDO::getId, orderDO.getId()).set(OrderDO::getCustomPlatenoSeq, JsonUtils.zipString(JSON.toJSONString(orderCustomPlateNoSeqVO))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据房间名从生产单序号json中获取房间序号列表
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user