mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-13 05:12:07 +08:00
Merge branch 'main' of http://192.168.1.205:9980/cf_devdept2/cf_imes_server
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;
|
||||
}
|
||||
+24
-9
@@ -60,7 +60,9 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe
|
||||
CustomPlateNoGenerateConfigVO generateConfig = getGenerateConfig(orderId);
|
||||
// 如果没有查到配置规则就不做后续生成操作了
|
||||
List<CustomPlateNoRuleVO> orgCustomPlateNoRuleVOList = generateConfig.getOrgCustomPlateNoRuleVOList();
|
||||
if (CollUtil.isEmpty(orgCustomPlateNoRuleVOList)) {
|
||||
// 如果没有查到机构下配置就不做后续生成操作了
|
||||
Long orgCustomPlateNoConfigId = generateConfig.getOrgCustomPlateNoConfigId();
|
||||
if (ObjectUtil.isNull(orgCustomPlateNoConfigId) || CollUtil.isEmpty(orgCustomPlateNoRuleVOList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -69,12 +71,15 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe
|
||||
orgCustomPlateNoRuleVOList.forEach(rule -> rule.setNow(now));
|
||||
|
||||
// 2、遍历小板列表,生成板编号
|
||||
for (PlateDO plateDO : plateDOList) {
|
||||
loopGenerateNo(orderId, plateDO, orgCustomPlateNoRuleVOList, generateConfig);
|
||||
for (int i = 0; i < plateDOList.size(); i++) {
|
||||
PlateDO plateDO = plateDOList.get(i);
|
||||
loopGenerateNo(orderId, plateDO, orgCustomPlateNoRuleVOList, generateConfig, i == 0);
|
||||
}
|
||||
|
||||
// 3、保存生产单序号json
|
||||
// 3、保存生产单序号json、设置生产单所用配置id
|
||||
orderDO.setCustomPlatenoSeq(JSON.toJSONString(generateConfig.getOrderCustomPlateNoSeqVO()));
|
||||
orderDO.setCustomPlatenoConfigId(orgCustomPlateNoConfigId);
|
||||
// 机构下序号配置同步
|
||||
CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO = generateConfig.getOrgCustomPlateNoSeqRespDTO();
|
||||
orgCustomPlateNoSeqRespDTO.setLastOrderNo(orderId);
|
||||
orgCustomPlateNoSeqRespDTO.setLastYear(Integer.parseInt(YEAR_FORMATTER.format(now)));
|
||||
@@ -94,27 +99,36 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe
|
||||
* @param plateDO
|
||||
* @param orgCustomPlateNoRuleVOList
|
||||
* @param generateConfig
|
||||
* @param
|
||||
*/
|
||||
private void loopGenerateNo(Long orderId, PlateDO plateDO, List<CustomPlateNoRuleVO> orgCustomPlateNoRuleVOList, CustomPlateNoGenerateConfigVO generateConfig) {
|
||||
private void loopGenerateNo(Long orderId, PlateDO plateDO, List<CustomPlateNoRuleVO> orgCustomPlateNoRuleVOList, CustomPlateNoGenerateConfigVO generateConfig, boolean firstPlate) {
|
||||
// 遍历规则列表
|
||||
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) {
|
||||
if (ruleService.match(plateNoRule.getRuleCode())) {
|
||||
generateConfig = ruleService.generateNo(orderId, plateNoRule, generateConfig, plateDO);
|
||||
generateConfig = ruleService.generateNo(orderId, plateNoRule, generateConfig, plateDO, firstPlate);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
plateDO.setPlateNo(plateDO.getCustomPlateNo().toString());
|
||||
plateDO.setCustomPlateNo(plateDO.getCustomPlateNoBuilder().toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据生产单id获取生成需要的配置
|
||||
*
|
||||
* @param orderId
|
||||
* @return 1、生产单下的序号
|
||||
* 2、机构下的序号
|
||||
* 3、机构下全局配置的规则
|
||||
*/
|
||||
private CustomPlateNoGenerateConfigVO getGenerateConfig(Long orderId) {
|
||||
// 生成自定义版编号所需配置
|
||||
CustomPlateNoGenerateConfigVO customPlateNoGenerateConfigVO = new CustomPlateNoGenerateConfigVO();
|
||||
@@ -132,6 +146,7 @@ public class CustomPlateNoGenerateServiceImpl implements CustomPlateNoGenerateSe
|
||||
customPlateNoRuleVOS = Optional.ofNullable(orgCustomPlateNoConfig)
|
||||
.map(config -> JSON.parseArray(config.getSetting(), CustomPlateNoRuleVO.class))
|
||||
.orElse(List.of());
|
||||
customPlateNoGenerateConfigVO.setOrgCustomPlateNoConfigId(orgCustomPlateNoConfig.getId());
|
||||
}
|
||||
|
||||
OrderDO order = orderService.getOrder(orderId);
|
||||
|
||||
+5
@@ -24,6 +24,11 @@ public class CustomPlateNoGenerateConfigVO implements Serializable {
|
||||
*/
|
||||
private List<CustomPlateNoRuleVO> orgCustomPlateNoRuleVOList;
|
||||
|
||||
/**
|
||||
* 机构下自定义板编号-系统配置id
|
||||
*/
|
||||
private Long orgCustomPlateNoConfigId;
|
||||
|
||||
/**
|
||||
* 机构下的自定义板编号序号
|
||||
*/
|
||||
|
||||
+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;
|
||||
/**
|
||||
|
||||
+60
-20
@@ -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,27 +37,15 @@ 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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO) {
|
||||
// 初始化配置
|
||||
initConfig(generateConfig);
|
||||
// 按复位模式走不同的生成方式
|
||||
ResetModeEnum resetModeEnum = ResetModeEnum.getByMode(plateNoRule.getResetMode());
|
||||
if (ObjectUtil.equal(ResetModeEnum.ORDER, resetModeEnum)) {
|
||||
generateConfig = generateNoByOrderResetMode(orderId, plateNoRule, generateConfig, plateDO);
|
||||
} else if (ObjectUtil.equal(ResetModeEnum.ROOM, resetModeEnum)) {
|
||||
generateConfig = generateNoByRoomResetMode(plateNoRule, generateConfig, plateDO);
|
||||
} else {
|
||||
throw ServiceExceptionUtil.exception(CUSTOM_PLATENO_GENERATE_BODY_RULE_NOT_SUPPORT_RESETMODE, plateNoRule.getResetMode());
|
||||
}
|
||||
return generateConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化生成所需配置
|
||||
*
|
||||
@@ -72,6 +69,49 @@ public class BodyNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO, boolean firstPlate) {
|
||||
// 初始化配置
|
||||
initConfig(generateConfig);
|
||||
// 按复位模式走不同的生成方式
|
||||
ResetModeEnum resetModeEnum = ResetModeEnum.getByMode(plateNoRule.getResetMode());
|
||||
if (ObjectUtil.equal(ResetModeEnum.ORDER, resetModeEnum)) {
|
||||
generateConfig = generateNoByOrderResetMode(orderId, plateNoRule, generateConfig, plateDO, firstPlate);
|
||||
} else if (ObjectUtil.equal(ResetModeEnum.ROOM, resetModeEnum)) {
|
||||
generateConfig = generateNoByRoomResetMode(plateNoRule, generateConfig, plateDO);
|
||||
} else {
|
||||
throw ServiceExceptionUtil.exception(CUSTOM_PLATENO_GENERATE_BODY_RULE_NOT_SUPPORT_RESETMODE, plateNoRule.getResetMode());
|
||||
}
|
||||
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))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按生产单复位模式下的板编号生成
|
||||
*
|
||||
@@ -81,7 +121,7 @@ public class BodyNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
|
||||
* @param plateDO 板件列表
|
||||
* @return
|
||||
*/
|
||||
private CustomPlateNoGenerateConfigVO generateNoByOrderResetMode(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO) {
|
||||
private CustomPlateNoGenerateConfigVO generateNoByOrderResetMode(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO, boolean firstPlate) {
|
||||
Integer incrementStep = plateNoRule.getIncrementStep();
|
||||
Integer initValue = plateNoRule.getInitValue() - incrementStep;
|
||||
// 生产单下的序号
|
||||
@@ -94,7 +134,7 @@ public class BodyNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
|
||||
List<OrderCustomPlateNoSeqBodyVO> bodys = orderCustomPlateNoSeqVO.getBodys();
|
||||
// 上次导入的生产单号
|
||||
Long lastOrderNo = orgCustomPlateNoSeqRespDTO.getLastOrderNo();
|
||||
if (ObjectUtil.isNotNull(lastOrderNo) && ObjectUtil.notEqual(orderId, lastOrderNo)) {
|
||||
if (firstPlate && (ObjectUtil.isNull(lastOrderNo) || ObjectUtil.notEqual(orderId, lastOrderNo))) {
|
||||
// 跨单复位到初始值
|
||||
orderBodyNoSeq = initValue;
|
||||
}
|
||||
@@ -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());
|
||||
// }
|
||||
|
||||
+12
-2
@@ -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;
|
||||
@@ -23,11 +24,13 @@ public interface CustomPlateNoGenerateRuleService {
|
||||
* 生成编号
|
||||
*
|
||||
* @param orderId 生产单号
|
||||
* @param plateDO 板材列表
|
||||
* @param plateNoRule 生成规则
|
||||
* @param generateConfig 生成所需要的配置
|
||||
* @param plateDO 板材列表
|
||||
* @param firstPlate 是否循环的第一块板,只有第一块板需要做是否跨单判断,后续都是一个单内
|
||||
* @return 生成后改变的配置
|
||||
*/
|
||||
CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO);
|
||||
CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO, boolean firstPlate);
|
||||
|
||||
/**
|
||||
* 左补零
|
||||
@@ -44,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())));
|
||||
// }
|
||||
|
||||
+64
-26
@@ -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,8 +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 java.time.LocalDateTime;
|
||||
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;
|
||||
@@ -30,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);
|
||||
@@ -49,7 +61,7 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO) {
|
||||
public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO, boolean firstPlate) {
|
||||
// 初始化配置
|
||||
initConfig(generateConfig);
|
||||
// 生产单下的序号
|
||||
@@ -59,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;
|
||||
}
|
||||
// 机构下的自定义板编号序号
|
||||
@@ -68,14 +80,13 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
int currOrderNoSeq = Optional.ofNullable(orgCustomPlateNoSeqRespDTO.getOrderNoSeq()).orElse(plateNoRule.getInitValue() - plateNoRule.getIncrementStep());
|
||||
// 上次导入的生产单号
|
||||
Long lastOrderNo = orgCustomPlateNoSeqRespDTO.getLastOrderNo();
|
||||
if (ObjectUtil.isNull(lastOrderNo) || ObjectUtil.notEqual(orderId, lastOrderNo)) {
|
||||
// 跨单
|
||||
if (firstPlate && (ObjectUtil.isNull(lastOrderNo) || ObjectUtil.notEqual(orderId, lastOrderNo))) {
|
||||
// 根据复位模式计算序号
|
||||
currOrderNoSeq = generateNoByResetMode(currOrderNoSeq, ResetModeEnum.getByMode(plateNoRule.getResetMode()), plateNoRule, orgCustomPlateNoSeqRespDTO);
|
||||
}
|
||||
// 补零
|
||||
String noPartAfterFill = this.fillZero(currOrderNoSeq, plateNoRule);
|
||||
plateDO.getCustomPlateNo().append(noPartAfterFill);
|
||||
plateDO.getCustomPlateNoBuilder().append(noPartAfterFill);
|
||||
|
||||
// 累加后的值同步到当前生产单序号和机构序号中
|
||||
orderCustomPlateNoSeqVO.setOrderNoSeq(currOrderNoSeq);
|
||||
@@ -83,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))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 基于复位模式的板编号生成
|
||||
*
|
||||
@@ -93,20 +121,15 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
* @return 循环累加后的序号
|
||||
*/
|
||||
private int generateNoByResetMode(int orderNoSeq, ResetModeEnum resetModeEnum, CustomPlateNoRuleVO plateNoRule, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO) {
|
||||
// 机构全局序号下的上一次年月日记录
|
||||
int year = orgCustomPlateNoSeqRespDTO.getLastYear();
|
||||
int month = orgCustomPlateNoSeqRespDTO.getLastMonth();
|
||||
int day = orgCustomPlateNoSeqRespDTO.getLastDay();
|
||||
|
||||
// 根据不同复位模式生成序号
|
||||
if (ObjectUtil.equal(ResetModeEnum.DIGIT, resetModeEnum)) {
|
||||
orderNoSeq = resetByLength(orderNoSeq, plateNoRule);
|
||||
} else if (ObjectUtil.equal(ResetModeEnum.YEAR, resetModeEnum)) {
|
||||
orderNoSeq = resetByYear(orderNoSeq, year, plateNoRule);
|
||||
orderNoSeq = resetByYear(orderNoSeq, orgCustomPlateNoSeqRespDTO, plateNoRule);
|
||||
} else if (ObjectUtil.equal(ResetModeEnum.MONTH, resetModeEnum)) {
|
||||
orderNoSeq = resetByMonth(orderNoSeq, month, plateNoRule);
|
||||
orderNoSeq = resetByMonth(orderNoSeq, orgCustomPlateNoSeqRespDTO, plateNoRule);
|
||||
} else if (ObjectUtil.equal(ResetModeEnum.DAY, resetModeEnum)) {
|
||||
orderNoSeq = resetByDay(orderNoSeq, day, plateNoRule);
|
||||
orderNoSeq = resetByDay(orderNoSeq, orgCustomPlateNoSeqRespDTO, plateNoRule);
|
||||
} else {
|
||||
throw ServiceExceptionUtil.exception(CUSTOM_PLATENO_GENERATE_ORDERNO_RULE_NOT_SUPPORT_RESETMODE, plateNoRule.getResetMode());
|
||||
}
|
||||
@@ -136,14 +159,19 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
* 按年复位
|
||||
*
|
||||
* @param curr
|
||||
* @param year
|
||||
* @param orgCustomPlateNoSeqRespDTO
|
||||
* @param plateNoRule
|
||||
* @return
|
||||
*/
|
||||
private int resetByYear(int curr, int year, CustomPlateNoRuleVO plateNoRule) {
|
||||
LocalDateTime now = plateNoRule.getNow();
|
||||
private int resetByYear(int curr, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO, CustomPlateNoRuleVO plateNoRule) {
|
||||
// 上一次的年
|
||||
Integer lastYear = orgCustomPlateNoSeqRespDTO.getLastYear();
|
||||
Integer initValue = plateNoRule.getInitValue();
|
||||
if (ObjectUtil.notEqual(String.valueOf(year), now.format(YEAR_FORMATTER))) {
|
||||
String nowYearFormat = plateNoRule.getNow().format(YEAR_FORMATTER);
|
||||
if (ObjectUtil.notEqual(String.valueOf(lastYear), nowYearFormat)) {
|
||||
// 跨年,把上一次的年设成当前年,后续不再跨年
|
||||
orgCustomPlateNoSeqRespDTO.setLastYear(Integer.parseInt(nowYearFormat));
|
||||
// 复位
|
||||
return initValue;
|
||||
}
|
||||
return curr + plateNoRule.getIncrementStep();
|
||||
@@ -153,14 +181,19 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
* 按月复位
|
||||
*
|
||||
* @param curr
|
||||
* @param month
|
||||
* @param orgCustomPlateNoSeqRespDTO
|
||||
* @param plateNoRule
|
||||
* @return
|
||||
*/
|
||||
private int resetByMonth(int curr, int month, CustomPlateNoRuleVO plateNoRule) {
|
||||
LocalDateTime now = plateNoRule.getNow();
|
||||
private int resetByMonth(int curr, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO, CustomPlateNoRuleVO plateNoRule) {
|
||||
// 上一次的月
|
||||
Integer lastMonth = orgCustomPlateNoSeqRespDTO.getLastMonth();
|
||||
Integer initValue = plateNoRule.getInitValue();
|
||||
if (ObjectUtil.notEqual(String.valueOf(month), now.format(MONTH_FORMATTER))) {
|
||||
String nowMonthFormat = plateNoRule.getNow().format(MONTH_FORMATTER);
|
||||
if (ObjectUtil.notEqual(String.valueOf(lastMonth), nowMonthFormat)) {
|
||||
// 跨月,把上一次的月设成当前月,后续不再跨月
|
||||
orgCustomPlateNoSeqRespDTO.setLastMonth(Integer.parseInt(nowMonthFormat));
|
||||
// 复位
|
||||
return initValue;
|
||||
}
|
||||
return curr + plateNoRule.getIncrementStep();
|
||||
@@ -170,14 +203,19 @@ public class OrderNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
* 按天复位
|
||||
*
|
||||
* @param curr
|
||||
* @param day
|
||||
* @param orgCustomPlateNoSeqRespDTO
|
||||
* @param plateNoRule
|
||||
* @return
|
||||
*/
|
||||
private int resetByDay(int curr, int day, CustomPlateNoRuleVO plateNoRule) {
|
||||
LocalDateTime now = plateNoRule.getNow();
|
||||
private int resetByDay(int curr, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO, CustomPlateNoRuleVO plateNoRule) {
|
||||
// 上一次的天
|
||||
Integer lastDay = orgCustomPlateNoSeqRespDTO.getLastDay();
|
||||
Integer initValue = plateNoRule.getInitValue();
|
||||
if (ObjectUtil.notEqual(String.valueOf(day), now.format(DAY_FORMATTER))) {
|
||||
String nowDayFormat = plateNoRule.getNow().format(DAY_FORMATTER);
|
||||
if (ObjectUtil.notEqual(String.valueOf(lastDay), nowDayFormat)) {
|
||||
// 跨月,把上一次的月设成当前月,后续不再跨月
|
||||
orgCustomPlateNoSeqRespDTO.setLastDay(Integer.parseInt(nowDayFormat));
|
||||
// 复位
|
||||
return initValue;
|
||||
}
|
||||
return curr + plateNoRule.getIncrementStep();
|
||||
|
||||
+127
-48
@@ -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,7 +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 java.time.LocalDateTime;
|
||||
import javax.annotation.Resource;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -33,19 +41,40 @@ 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化生成所需配置
|
||||
*
|
||||
* @param generateConfigVO
|
||||
*/
|
||||
private void initConfig(CustomPlateNoGenerateConfigVO generateConfigVO) {
|
||||
OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = generateConfigVO.getOrderCustomPlateNoSeqVO();
|
||||
if (ObjectUtil.isNull(orderCustomPlateNoSeqVO)) {
|
||||
orderCustomPlateNoSeqVO = new OrderCustomPlateNoSeqVO();
|
||||
generateConfigVO.setOrderCustomPlateNoSeqVO(orderCustomPlateNoSeqVO);
|
||||
}
|
||||
List<OrderCustomPlateNoSeqRoomVO> rooms = orderCustomPlateNoSeqVO.getRooms();
|
||||
if (CollUtil.isEmpty(rooms)) {
|
||||
rooms = new ArrayList<>();
|
||||
orderCustomPlateNoSeqVO.setRooms(rooms);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO) {
|
||||
public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO, boolean firstPlate) {
|
||||
// 初始化配置
|
||||
initConfig(generateConfig);
|
||||
// 按复位模式走不同的生成方式
|
||||
ResetModeEnum resetModeEnum = ResetModeEnum.getByMode(plateNoRule.getResetMode());
|
||||
if (ObjectUtil.equal(ResetModeEnum.ORDER, resetModeEnum)) {
|
||||
return generateNoByOrderResetMode(orderId, plateNoRule, generateConfig, plateDO);
|
||||
return generateNoByOrderResetMode(orderId, plateNoRule, generateConfig, plateDO, firstPlate);
|
||||
} else if (ObjectUtil.equal(ResetModeEnum.ROOM, resetModeEnum)) {
|
||||
return generateNoByRoomResetMode(plateNoRule, generateConfig, plateDO);
|
||||
} else if (ObjectUtil.equal(ResetModeEnum.BODY, resetModeEnum)) {
|
||||
@@ -57,16 +86,70 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按年/月/日复位模式下的板编号生成
|
||||
*/
|
||||
private CustomPlateNoGenerateConfigVO generateNoByDateResetMode(ResetModeEnum resetModeEnum, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO) {
|
||||
// 机构下的自定义板编号序号
|
||||
CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO = generateConfig.getOrgCustomPlateNoSeqRespDTO();
|
||||
// 上一次自定义编号生成的年月日
|
||||
int year = orgCustomPlateNoSeqRespDTO.getLastYear();
|
||||
int month = orgCustomPlateNoSeqRespDTO.getLastMonth();
|
||||
int day = orgCustomPlateNoSeqRespDTO.getLastDay();
|
||||
// 从全局配置获取当前序号,取不到用初始值
|
||||
Integer orderNoSeq = orgCustomPlateNoSeqRespDTO.getPlateNoSeq();
|
||||
if (ObjectUtil.isNull(orderNoSeq)) {
|
||||
@@ -74,16 +157,15 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
}
|
||||
|
||||
if (ObjectUtil.equal(ResetModeEnum.YEAR, resetModeEnum)) {
|
||||
orderNoSeq = resetByYear(orderNoSeq, year, plateNoRule);
|
||||
orderNoSeq = resetByYear(orderNoSeq, orgCustomPlateNoSeqRespDTO, plateNoRule);
|
||||
} else if (ObjectUtil.equal(ResetModeEnum.MONTH, resetModeEnum)) {
|
||||
orderNoSeq = resetByMonth(orderNoSeq, month, plateNoRule);
|
||||
orderNoSeq = resetByMonth(orderNoSeq, orgCustomPlateNoSeqRespDTO, plateNoRule);
|
||||
} else if (ObjectUtil.equal(ResetModeEnum.DAY, resetModeEnum)) {
|
||||
orderNoSeq = resetByDay(orderNoSeq, day, plateNoRule);
|
||||
orderNoSeq = resetByDay(orderNoSeq, orgCustomPlateNoSeqRespDTO, plateNoRule);
|
||||
}
|
||||
// 跨板件累加步长,补零
|
||||
orderNoSeq += plateNoRule.getIncrementStep();
|
||||
// 补零
|
||||
String noPartAfterFillZero = fillZero(orderNoSeq, plateNoRule);
|
||||
plateDO.getCustomPlateNo().append(noPartAfterFillZero);
|
||||
plateDO.getCustomPlateNoBuilder().append(noPartAfterFillZero);
|
||||
|
||||
orgCustomPlateNoSeqRespDTO.setPlateNoSeq(orderNoSeq);
|
||||
return generateConfig;
|
||||
@@ -97,7 +179,7 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
* @param generateConfig
|
||||
* @param plateDO
|
||||
*/
|
||||
private CustomPlateNoGenerateConfigVO generateNoByOrderResetMode(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO) {
|
||||
private CustomPlateNoGenerateConfigVO generateNoByOrderResetMode(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO, boolean firstPlate) {
|
||||
Integer incrementStep = plateNoRule.getIncrementStep();
|
||||
Integer initValue = plateNoRule.getInitValue() - incrementStep;
|
||||
// 生产单下的序号
|
||||
@@ -108,13 +190,13 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
Integer orderPlateNoSeq = Optional.ofNullable(orderCustomPlateNoSeqVO.getPlateNoSeq()).orElse(initValue);
|
||||
// 上次导入的生产单号
|
||||
Long lastOrderNo = orgCustomPlateNoSeqRespDTO.getLastOrderNo();
|
||||
if (ObjectUtil.isNotNull(lastOrderNo) && ObjectUtil.notEqual(orderId, lastOrderNo)) {
|
||||
if (firstPlate && (ObjectUtil.isNull(lastOrderNo) || ObjectUtil.notEqual(orderId, lastOrderNo))) {
|
||||
// 跨单复位到初始值
|
||||
orderPlateNoSeq = initValue;
|
||||
}
|
||||
// 跨板件累加步长,补零
|
||||
orderPlateNoSeq += incrementStep;
|
||||
plateDO.getCustomPlateNo().append(fillZero(orderPlateNoSeq, plateNoRule));
|
||||
plateDO.getCustomPlateNoBuilder().append(fillZero(orderPlateNoSeq, plateNoRule));
|
||||
// 累加后的值同步到当前生产单序号中
|
||||
orderCustomPlateNoSeqVO.setPlateNoSeq(orderPlateNoSeq);
|
||||
return generateConfig;
|
||||
@@ -152,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;
|
||||
}
|
||||
|
||||
@@ -214,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;
|
||||
}
|
||||
|
||||
@@ -240,36 +322,23 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化生成所需配置
|
||||
*
|
||||
* @param generateConfigVO
|
||||
*/
|
||||
private void initConfig(CustomPlateNoGenerateConfigVO generateConfigVO) {
|
||||
OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = generateConfigVO.getOrderCustomPlateNoSeqVO();
|
||||
if (ObjectUtil.isNull(orderCustomPlateNoSeqVO)) {
|
||||
orderCustomPlateNoSeqVO = new OrderCustomPlateNoSeqVO();
|
||||
generateConfigVO.setOrderCustomPlateNoSeqVO(orderCustomPlateNoSeqVO);
|
||||
}
|
||||
List<OrderCustomPlateNoSeqRoomVO> rooms = orderCustomPlateNoSeqVO.getRooms();
|
||||
if (CollUtil.isEmpty(rooms)) {
|
||||
rooms = new ArrayList<>();
|
||||
orderCustomPlateNoSeqVO.setRooms(rooms);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按年复位
|
||||
*
|
||||
* @param curr
|
||||
* @param year
|
||||
* @param orgCustomPlateNoSeqRespDTO
|
||||
* @param plateNoRule
|
||||
* @return
|
||||
*/
|
||||
private int resetByYear(int curr, int year, CustomPlateNoRuleVO plateNoRule) {
|
||||
LocalDateTime now = plateNoRule.getNow();
|
||||
private int resetByYear(int curr, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO, CustomPlateNoRuleVO plateNoRule) {
|
||||
// 上一次的年
|
||||
Integer lastYear = orgCustomPlateNoSeqRespDTO.getLastYear();
|
||||
Integer initValue = plateNoRule.getInitValue();
|
||||
if (ObjectUtil.notEqual(String.valueOf(year), now.format(YEAR_FORMATTER))) {
|
||||
String nowYearFormat = plateNoRule.getNow().format(YEAR_FORMATTER);
|
||||
if (ObjectUtil.notEqual(String.valueOf(lastYear), nowYearFormat)) {
|
||||
// 跨年,把上一次的年设成当前年,后续不再跨年
|
||||
orgCustomPlateNoSeqRespDTO.setLastYear(Integer.parseInt(nowYearFormat));
|
||||
// 复位
|
||||
return initValue;
|
||||
}
|
||||
return curr + plateNoRule.getIncrementStep();
|
||||
@@ -279,14 +348,19 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
* 按月复位
|
||||
*
|
||||
* @param curr
|
||||
* @param month
|
||||
* @param orgCustomPlateNoSeqRespDTO
|
||||
* @param plateNoRule
|
||||
* @return
|
||||
*/
|
||||
private int resetByMonth(int curr, int month, CustomPlateNoRuleVO plateNoRule) {
|
||||
LocalDateTime now = plateNoRule.getNow();
|
||||
private int resetByMonth(int curr, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO, CustomPlateNoRuleVO plateNoRule) {
|
||||
// 上一次的月
|
||||
Integer lastMonth = orgCustomPlateNoSeqRespDTO.getLastMonth();
|
||||
Integer initValue = plateNoRule.getInitValue();
|
||||
if (ObjectUtil.notEqual(String.valueOf(month), now.format(MONTH_FORMATTER))) {
|
||||
String nowMonthFormat = plateNoRule.getNow().format(MONTH_FORMATTER);
|
||||
if (ObjectUtil.notEqual(String.valueOf(lastMonth), nowMonthFormat)) {
|
||||
// 跨月,把上一次的月设成当前月,后续不再跨月
|
||||
orgCustomPlateNoSeqRespDTO.setLastMonth(Integer.parseInt(nowMonthFormat));
|
||||
// 复位
|
||||
return initValue;
|
||||
}
|
||||
return curr + plateNoRule.getIncrementStep();
|
||||
@@ -296,14 +370,19 @@ public class PlateNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRule
|
||||
* 按天复位
|
||||
*
|
||||
* @param curr
|
||||
* @param day
|
||||
* @param orgCustomPlateNoSeqRespDTO
|
||||
* @param plateNoRule
|
||||
* @return
|
||||
*/
|
||||
private int resetByDay(int curr, int day, CustomPlateNoRuleVO plateNoRule) {
|
||||
LocalDateTime now = plateNoRule.getNow();
|
||||
private int resetByDay(int curr, CustomPlateNoSeqDTO orgCustomPlateNoSeqRespDTO, CustomPlateNoRuleVO plateNoRule) {
|
||||
// 上一次的天
|
||||
Integer lastDay = orgCustomPlateNoSeqRespDTO.getLastDay();
|
||||
Integer initValue = plateNoRule.getInitValue();
|
||||
if (ObjectUtil.notEqual(String.valueOf(day), now.format(DAY_FORMATTER))) {
|
||||
String nowDayFormat = plateNoRule.getNow().format(DAY_FORMATTER);
|
||||
if (ObjectUtil.notEqual(String.valueOf(lastDay), nowDayFormat)) {
|
||||
// 跨月,把上一次的月设成当前月,后续不再跨月
|
||||
orgCustomPlateNoSeqRespDTO.setLastDay(Integer.parseInt(nowDayFormat));
|
||||
// 复位
|
||||
return initValue;
|
||||
}
|
||||
return curr + plateNoRule.getIncrementStep();
|
||||
|
||||
+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();
|
||||
|
||||
+48
-13
@@ -1,7 +1,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.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;
|
||||
@@ -10,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;
|
||||
@@ -22,13 +32,34 @@ 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化生成所需配置
|
||||
*
|
||||
* @param generateConfigVO
|
||||
*/
|
||||
private static void initConfig(CustomPlateNoGenerateConfigVO generateConfigVO) {
|
||||
OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = generateConfigVO.getOrderCustomPlateNoSeqVO();
|
||||
if (ObjectUtil.isNull(orderCustomPlateNoSeqVO)) {
|
||||
orderCustomPlateNoSeqVO = new OrderCustomPlateNoSeqVO();
|
||||
generateConfigVO.setOrderCustomPlateNoSeqVO(orderCustomPlateNoSeqVO);
|
||||
}
|
||||
List<OrderCustomPlateNoSeqRoomVO> rooms = orderCustomPlateNoSeqVO.getRooms();
|
||||
if (CollUtil.isEmpty(rooms)) {
|
||||
rooms = new ArrayList<>();
|
||||
orderCustomPlateNoSeqVO.setRooms(rooms);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO) {
|
||||
public CustomPlateNoGenerateConfigVO generateNo(Long orderId, CustomPlateNoRuleVO plateNoRule, CustomPlateNoGenerateConfigVO generateConfig, PlateDO plateDO, boolean firstPlate) {
|
||||
Integer incrementStep = plateNoRule.getIncrementStep();
|
||||
Integer initValue = plateNoRule.getInitValue() - incrementStep;
|
||||
// 初始化配置
|
||||
@@ -43,7 +74,7 @@ public class RoomNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
|
||||
List<OrderCustomPlateNoSeqRoomVO> rooms = orderCustomPlateNoSeqVO.getRooms();
|
||||
// 上次导入的生产单号
|
||||
Long lastOrderNo = orgCustomPlateNoSeqRespDTO.getLastOrderNo();
|
||||
if (ObjectUtil.isNotNull(lastOrderNo) && ObjectUtil.notEqual(orderId, lastOrderNo)) {
|
||||
if (firstPlate && (ObjectUtil.isNull(lastOrderNo) || ObjectUtil.notEqual(orderId, lastOrderNo))) {
|
||||
// 跨单复位到初始值
|
||||
orderRoomNoSeq = initValue;
|
||||
}
|
||||
@@ -74,23 +105,27 @@ public class RoomNoGenerateRuleServiceImpl implements CustomPlateNoGenerateRuleS
|
||||
|
||||
// 补零
|
||||
String noPartAfterFillZero = fillZero(roomNoSeq, plateNoRule);
|
||||
plateDO.getCustomPlateNo().append(noPartAfterFillZero);
|
||||
plateDO.getCustomPlateNoBuilder().append(noPartAfterFillZero);
|
||||
// 累加后同步到json:房间下累加到多少了
|
||||
roomSeqVo.setRoomNoSeq(roomNoSeq);
|
||||
|
||||
return generateConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化生成所需配置
|
||||
*
|
||||
* @param generateConfigVO
|
||||
*/
|
||||
private static void initConfig(CustomPlateNoGenerateConfigVO generateConfigVO) {
|
||||
OrderCustomPlateNoSeqVO orderCustomPlateNoSeqVO = generateConfigVO.getOrderCustomPlateNoSeqVO();
|
||||
if (ObjectUtil.isNull(orderCustomPlateNoSeqVO)) {
|
||||
orderCustomPlateNoSeqVO = new OrderCustomPlateNoSeqVO();
|
||||
generateConfigVO.setOrderCustomPlateNoSeqVO(orderCustomPlateNoSeqVO);
|
||||
@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))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+23
-6
@@ -48,6 +48,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@@ -109,6 +110,8 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
||||
|
||||
private static final String ES_SELECT_DATA_ERROR = "优化生产ES文档查询异常: ";
|
||||
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
@Override
|
||||
public List<PlateOptimize> getPlateListByPlanId(Long planId) {
|
||||
return planMapper.selectPlateListByPlanId(planId,getUserOrganId());
|
||||
@@ -144,6 +147,8 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
||||
|
||||
AssertUtils.notEmpty(planDO,PLAN_NOT_EXISTS);
|
||||
|
||||
Date date = new Date();
|
||||
|
||||
// todo 目前只解决了非混单的情况,混单情况待解决
|
||||
List<OptimizeBoardModelDO> optimizeBoardModelDOS = buildBoardByPlanId(planId, ORDER_REMAIN_PLATE_MODEL, 10);
|
||||
|
||||
@@ -182,9 +187,9 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
||||
}
|
||||
|
||||
|
||||
for (Long goods : goodsNo) {
|
||||
plateNo.addAll(outputList.stream().filter(f -> f.getBi().equals(goods)).map(BlockPlaceInfo::getBo).distinct().toList());
|
||||
}
|
||||
goodsNo.forEach(g->
|
||||
plateNo.addAll(outputList.stream().filter(f -> f.getBi().equals(g)).map(BlockPlaceInfo::getBo).distinct().toList())
|
||||
);
|
||||
|
||||
|
||||
List<PlateDO> plateDOS = plateMapper.selectPlateByPlateNo(plateNo.stream().distinct().toList(), getUserOrganId());
|
||||
@@ -217,6 +222,10 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
||||
|
||||
long cutedBoardNumber = cutedBoardList.size();
|
||||
|
||||
if(CollUtil.isEmpty(cutedBoardList)){
|
||||
cutedBoardNumber = 0;
|
||||
}
|
||||
|
||||
// 将需要更新更新的数据更新到原数据中
|
||||
cutedBoardInfo.setCutedBoardNumber(cutedBoardNumber);
|
||||
cutedBoardInfo.setCutedBoardList(cutedBoardList);
|
||||
@@ -225,6 +234,7 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
||||
// 更新开料相关的数据
|
||||
HashMap<String, Object> objectObjectHashMap = new HashMap<>();
|
||||
objectObjectHashMap.put("cutedBoardInfo",cutedBoardInfo);
|
||||
objectObjectHashMap.put("updateTime",simpleDateFormat.format(date));
|
||||
|
||||
try {
|
||||
|
||||
@@ -293,6 +303,8 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
||||
return;
|
||||
}
|
||||
|
||||
Date date = new Date();
|
||||
|
||||
PlanDO planDO = planMapper.selectById(planId);
|
||||
|
||||
AssertUtils.notEmpty(planDO,PLAN_NOT_EXISTS);
|
||||
@@ -326,6 +338,9 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
||||
// 减去取消开料的大板数量
|
||||
cutedBoardNumber -= goodsNo.size();
|
||||
|
||||
if(CollUtil.isEmpty(cutedBoardList)){
|
||||
cutedBoardNumber = 0;
|
||||
}
|
||||
|
||||
// 将需要更新更新的数据更新到原数据中
|
||||
cutedBoardInfo.setCutedBoardNumber(cutedBoardNumber);
|
||||
@@ -335,6 +350,7 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
||||
// 更新开料相关的数据
|
||||
HashMap<String, Object> objectObjectHashMap = new HashMap<>();
|
||||
objectObjectHashMap.put("cutedBoardInfo", cutedBoardInfo);
|
||||
objectObjectHashMap.put("updateTime",simpleDateFormat.format(date));
|
||||
|
||||
try {
|
||||
|
||||
@@ -377,9 +393,10 @@ public class OptimizePlanServiceImpl implements OptimizePlanService {
|
||||
|
||||
List<String> plateNo = new ArrayList<>();
|
||||
|
||||
for (Long aLong : goodsNo) {
|
||||
plateNo.addAll(asJsonObject.stream().filter(f->f.getBi().equals(aLong)).map(PlatePlaceInfo::getBo).toList());
|
||||
}
|
||||
|
||||
goodsNo.forEach(g->{
|
||||
plateNo.addAll(asJsonObject.stream().filter(f->f.getBi().equals(g)).map(PlatePlaceInfo::getBo).toList());
|
||||
});
|
||||
|
||||
List<Long> orderIds = plateMapper.selectPlateByPlateNo(plateNo, getUserOrganId()).stream().map(PlateDO::getOrderId).toList();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user