1、禅道bug#1517、#1521修复;2、新增 创建组织自动复制默认标签模板能力;

This commit is contained in:
gaoqr
2026-05-15 09:03:55 +08:00
parent bd67db98e4
commit 9b1a85afb5
11 changed files with 212 additions and 86 deletions
@@ -12,26 +12,26 @@ import lombok.Getter;
@Getter
@AllArgsConstructor
public enum LabelTemplateType {
/**
* 板材包裹
*/
PLATEPACKAGELABEL("platePackageLabel"),
// /**
// * 板材包裹
// */
// PLATEPACKAGELABEL("platePackageLabel"),
/**
* 物料
*/
MATERIALLABEL("materialLabel"),
/**
* 机台标签
*/
MACHINELABEL("machineLabel"),
/**
* 配件包裹标签
*/
PARTSPACKAGELABEL("partsPackageLabel"),
// /**
// * 机台标签
// */
// MACHINELABEL("machineLabel"),
//
// /**
// * 配件包裹标签
// */
// PARTSPACKAGELABEL("partsPackageLabel"),
//
/**
* 订单包裹标签
*/
@@ -13,9 +13,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
public class LabelTemplateTypeTest {
@Test
void test() {
assertEquals("platePackageLabel", LabelTemplateType.PLATEPACKAGELABEL.getType());
assertEquals("machineLabel", LabelTemplateType.MACHINELABEL.getType());
assertEquals("partsPackageLabel", LabelTemplateType.PARTSPACKAGELABEL.getType());
assertEquals("orderPackageLabel", LabelTemplateType.ORDERPACKAGELABEL.getType());
assertEquals("platePackageLabel", LabelTemplateType.ORDERPACKAGELABEL.getType());
assertEquals("materialLabel", LabelTemplateType.MATERIALLABEL.getType());
}
}
@@ -7,8 +7,11 @@ import jakarta.validation.constraints.Size;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* @author Gqr
@@ -31,7 +34,8 @@ public class ProductDelayPageReqVO extends PageParam {
private Integer delayDuration;
@Schema(description = "操作时间")
private LocalDate[] createTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "操作人")
@Size(max = 64, message = "{product.delay.page.operator.size}")
@@ -2,6 +2,7 @@ package com.cf.imes.module.system.controller.admin.organ.vo.organ;
import com.cf.imes.framework.common.pojo.PageParam;
import com.cf.imes.framework.common.validation.Mobile;
import com.cf.imes.framework.common.validation.NumberValid;
import com.cf.imes.module.system.validation.common.CommonStatus;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@@ -9,6 +10,12 @@ import lombok.EqualsAndHashCode;
import lombok.ToString;
import jakarta.validation.constraints.Size;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 组织分页 Request VO")
@Data
@@ -61,4 +68,23 @@ public class OrganPageReqVO extends PageParam {
@Size(max = 64, message = "区名称长度不能超过64个字符")
private String county;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@Schema(description = "组织有效日期")
private LocalDateTime[] expireTime;
@Schema(description = "备注")
@Length(max = 255, message = "备注长度不能超过255个字符")
private String remark;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@Schema(description = "产品有效日期")
private LocalDateTime[] endTime;
@Schema(description = "产品名称")
@Size(max = 64, message = "产品名称长度不能超过64个字符")
private String productName;
@Schema(description = "单价")
@NumberValid(name = "单价")
private Integer price;
}
@@ -46,6 +46,8 @@ public interface OrganMapper extends BaseMapperX<OrganizationDO> {
.eqIfPresent(OrganizationDO::getProvince, reqVO.getProvince())
.eqIfPresent(OrganizationDO::getCity, reqVO.getCity())
.eqIfPresent(OrganizationDO::getCounty, reqVO.getCounty())
.betweenIfPresent(OrganizationDO::getExpireTime, reqVO.getExpireTime())
.likeIfPresent(OrganizationDO::getRemark, reqVO.getRemark())
.and(CharSequenceUtil.isNotBlank(reqVO.getName()), wrapper ->{
wrapper.or(Boolean.TRUE).like(OrganizationDO::getName, reqVO.getName());
wrapper.or(CharSequenceUtil.isNotBlank(reqVO.getPyAll())).like(OrganizationDO::getPinyinFull, reqVO.getPyAll());
@@ -150,5 +152,12 @@ public interface OrganMapper extends BaseMapperX<OrganizationDO> {
.select(OrganizationDO::getId));
}
/**
* 带产品条件的组织分页查询
*
* @param page
* @param pageReqVO
* @return
*/
IPage<OrganizationDO> selectPageWithProductExpire(@Param("page") IPage<OrganizationDO> page, @Param("reqVO") OrganPageReqVO pageReqVO);
}
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.cf.imes.framework.common.exception.ServiceException;
import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.common.util.Assert.AssertUtils;
import com.cf.imes.framework.common.util.date.LocalDateTimeUtils;
import com.cf.imes.framework.common.util.object.BeanUtils;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.framework.mybatis.core.query.LambdaUpdateWrapperX;
@@ -150,6 +151,7 @@ public class ProductDelayServiceImpl implements ProductDelayService {
@Override
public PageResult<ProductDelayRespVO> getPage(ProductDelayPageReqVO pageReqVO) {
pageReqVO.setCreateTime(LocalDateTimeUtils.generateTimeSection(pageReqVO.getCreateTime()));
PageResult<ProductDelayRecordDO> productDelayRecordDOPageResult = productDelayRecordMapper.selectPage(pageReqVO);
return new PageResult<>(BeanUtils.toBean(productDelayRecordDOPageResult.getList(), ProductDelayRespVO.class), productDelayRecordDOPageResult.getTotal());
}
@@ -59,4 +59,11 @@ public interface LabelService {
Map<String, List<LabelRespVO>> getGroupList(Long organId);
List<LabelDO> list(String type);
/**
* 复制组织初始化标签
*
* @param organId
*/
void copyInitalLabel(Long organId);
}
@@ -1,6 +1,8 @@
package com.cf.imes.module.system.service.lable;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.cf.imes.framework.common.enums.DeletedCodeEnum;
import com.cf.imes.framework.common.enums.UserSettingTypeEnum;
import com.cf.imes.framework.common.exception.ServiceException;
import com.cf.imes.framework.common.pojo.PageResult;
@@ -10,12 +12,15 @@ import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.module.system.controller.admin.label.vo.LabelPageReqVO;
import com.cf.imes.module.system.controller.admin.label.vo.LabelRespVO;
import com.cf.imes.module.system.controller.admin.label.vo.LabelSaveReqVO;
import com.cf.imes.module.system.dal.dataobject.labeltemplate.LabelTemplateDO;
import com.cf.imes.module.system.dal.dataobject.lable.LabelDO;
import com.cf.imes.module.system.dal.dataobject.machine.MachineDO;
import com.cf.imes.module.system.dal.dataobject.setting.PackageConfigDO;
import com.cf.imes.module.system.dal.mysql.label.LabelMapper;
import com.cf.imes.module.system.dal.mysql.labeltemplate.LabelTemplateMapper;
import com.cf.imes.module.system.dal.mysql.machine.MachineMapper;
import com.cf.imes.module.system.dal.mysql.setting.PackageConfigMapper;
import com.cf.imes.module.system.enums.label.LabelTemplateType;
import com.fasterxml.jackson.databind.JsonNode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -46,6 +51,9 @@ public class LabelServiceImpl implements LabelService {
@Resource
private LabelMapper labelMapper;
@Resource
private LabelTemplateMapper labelTemplateMapper;
@Resource
private MachineMapper machineMapper;
@@ -168,5 +176,37 @@ public class LabelServiceImpl implements LabelService {
.stream().map( m -> m.setTemplate(unzipString(m.getTemplate()))).toList();
}
@Override
public void copyInitalLabel(Long organId) {
List<LabelDO> addList = new ArrayList<>();
LabelTemplateType[] values = LabelTemplateType.values();
for (LabelTemplateType value : values) {
String labelType = value.getType();
// 获取标签类型的默认模板
LabelTemplateDO labelTemplateDO = labelTemplateMapper.selectOne(new LambdaQueryWrapperX<LabelTemplateDO>()
.eq(LabelTemplateDO::getType, labelType)
.eq(LabelTemplateDO::getIsDefault, Boolean.TRUE)
.eq(LabelTemplateDO::getDeleted, DeletedCodeEnum.NOT_DELETED.getStatus())
.last("limit 1")
);
// 复制标签内容a
if (ObjectUtil.isNotNull(labelTemplateDO)) {
LabelDO labelDO = LabelDO.builder()
.type(labelType)
.name(labelTemplateDO.getName())
.remark(labelTemplateDO.getRemark())
.width(labelTemplateDO.getWidth())
.height(labelTemplateDO.getHeight())
.template(labelTemplateDO.getTemplate())
.build();
labelDO.setOrganId(organId);
addList.add(labelDO);
}
}
labelMapper.insertBatch(addList);
}
}
@@ -7,12 +7,14 @@ import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.cf.imes.framework.common.enums.CommonStatusEnum;
import com.cf.imes.framework.common.exception.ServiceException;
import com.cf.imes.framework.common.pojo.PageParam;
import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.common.util.collection.CollectionUtils;
import com.cf.imes.framework.common.util.date.DateUtils;
import com.cf.imes.framework.common.util.date.LocalDateTimeUtils;
import com.cf.imes.framework.common.util.i18n.core.util.I18nUtils;
import com.cf.imes.framework.common.util.json.JsonUtils;
import com.cf.imes.framework.common.util.object.BeanUtils;
@@ -42,7 +44,6 @@ import com.cf.imes.module.system.convert.organ.OrganConvert;
import com.cf.imes.module.system.dal.dataobject.dict.DictDataDO;
import com.cf.imes.module.system.dal.dataobject.lable.LabelDO;
import com.cf.imes.module.system.dal.dataobject.machine.MachineDO;
import com.cf.imes.module.system.dal.dataobject.machine.MachineLimitDO;
import com.cf.imes.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO;
import com.cf.imes.module.system.dal.dataobject.organ.OrganizationDO;
import com.cf.imes.module.system.dal.dataobject.permission.MenuDO;
@@ -51,7 +52,6 @@ import com.cf.imes.module.system.dal.dataobject.systemconfig.*;
import com.cf.imes.module.system.dal.dataobject.tokenconfig.TokenConfigDO;
import com.cf.imes.module.system.dal.mysql.dict.DictDataMapper;
import com.cf.imes.module.system.dal.mysql.label.LabelMapper;
import com.cf.imes.module.system.dal.mysql.machine.MachineLimitMapper;
import com.cf.imes.module.system.dal.mysql.machine.MachineMapper;
import com.cf.imes.module.system.dal.mysql.organ.OrganMapper;
import com.cf.imes.module.system.dal.mysql.systemconfig.*;
@@ -60,6 +60,7 @@ import com.cf.imes.module.system.enums.config.SystemConfigTypeEnum;
import com.cf.imes.module.system.enums.permission.RoleCodeEnum;
import com.cf.imes.module.system.framework.product.ProductProperties;
import com.cf.imes.module.system.service.funds.purchase.PurchaseService;
import com.cf.imes.module.system.service.lable.LabelService;
import com.cf.imes.module.system.service.organ.handler.OrganInfoHandler;
import com.cf.imes.module.system.service.organ.handler.OrganMenuHandler;
import com.cf.imes.module.system.service.permission.MenuService;
@@ -80,6 +81,7 @@ import org.springframework.validation.annotation.Validated;
import jakarta.annotation.Resource;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
@@ -125,9 +127,6 @@ public class OrganServiceImpl implements OrganService {
@Value("${chenfeng.organ.use-data-code:imes_prod}")
private String useDataCode;
@Resource
private MachineLimitMapper machineLimitMapper;
@Resource
private TokenConfigMapper tokenConfigMapper;
@@ -146,12 +145,6 @@ public class OrganServiceImpl implements OrganService {
@Resource
private SystemConfigFilterMapper systemConfigFilterMapper;
@Resource
private SystemConfigProcessMapper systemConfigProcessMapper;
@Resource
private SystemConfigDataMapper systemConfigDataMapper;
@Resource
private SystemConfigSchemeMapper systemConfigSchemeMapper;
@@ -164,6 +157,9 @@ public class OrganServiceImpl implements OrganService {
@Resource
private LabelMapper labelMapper;
@Resource
private LabelService labelService;
@Resource
private PurchaseService purchaseService;
@@ -243,14 +239,10 @@ public class OrganServiceImpl implements OrganService {
// 2、修改组织的管理员
organMapper.updateById(new OrganizationDO().setId(tenant.getId()).setContactUserId(userId));
// 往组织机台授权表新增信息
MachineLimitDO machineLimitDO = MachineLimitDO.builder()
.organId(organId)
.build();
machineLimitMapper.insert(machineLimitDO);
// 复制系统配置里的相关配置
copySystemConfig(organId);
// 复制默认标签
labelService.copyInitalLabel(organId);
// 创建产品购买记录
List<OrganCreateProductPurchaseReqVO> productPurchaseReqVOS = createReqVO.getProductPurchaseReqVOS();
@@ -486,6 +478,7 @@ public class OrganServiceImpl implements OrganService {
@Override
public PageResult<OrganizationDO> getOrganPage(OrganPageReqVO pageReqVO) {
pageReqVO.setExpireTime(LocalDateTimeUtils.generateTimeSection(pageReqVO.getExpireTime()));
if(CharSequenceUtil.isNotBlank(pageReqVO.getName())) {
pageReqVO.setPyFirstChar(PinYinUtils.convertFirstChar(pageReqVO.getName()));
pageReqVO.setPyAll(PinYinUtils.convertToPinyin(pageReqVO.getName()).replace(" ", ""));
@@ -494,7 +487,20 @@ public class OrganServiceImpl implements OrganService {
pageReqVO.setPyFirstChar(null);
pageReqVO.setPyAll(null);
}
return organMapper.selectPage(pageReqVO);
LocalDateTime[] endTime = pageReqVO.getEndTime();
if ((ObjectUtil.isNotNull(endTime) && endTime.length == 2) ||
ObjectUtil.isNotNull(pageReqVO.getProductName()) ||
ObjectUtil.isNotNull(pageReqVO.getPrice())) {
// 产品相关条件非空的情况下走带特定方法
pageReqVO.setEndTime(LocalDateTimeUtils.generateTimeSection(endTime));
PageDTO<OrganizationDO> page = new PageDTO<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
IPage<OrganizationDO> organizationDOIPage = organMapper.selectPageWithProductExpire(page, pageReqVO);
return new PageResult<>(organizationDOIPage.getRecords(), organizationDOIPage.getTotal());
} else {
return organMapper.selectPage(pageReqVO);
}
}
@Override
@@ -588,7 +594,11 @@ public class OrganServiceImpl implements OrganService {
return new PageResult<>(BeanUtils.toBean(organPage.getRecords(), OrganRespVO.class), organPage.getTotal());
}
// 系统配置数据复制
/**
* 复制系统配置
*
* @param organId
*/
private void copySystemConfig(Long organId) {
List<DictDataDO> dictDataDOS = dictDataMapper.selectListByStatusAndDictType(CommonStatusEnum.ENABLE.getStatus(), "copy_data_organ");
@@ -628,7 +638,7 @@ public class OrganServiceImpl implements OrganService {
}
// 板件分线
// 板件筛选
List<SystemConfigFilterDO> systemConfigFilterDOS = systemConfigFilterMapper.selectList(new LambdaQueryWrapperX<SystemConfigFilterDO>()
.eq(SystemConfigFilterDO::getOrganId, copyOrganId)
.eq(SystemConfigFilterDO::getDeleted, false)
@@ -647,48 +657,6 @@ public class OrganServiceImpl implements OrganService {
}
// 加工分线
List<SystemConfigProcessDO> systemConfigProcessDOS = systemConfigProcessMapper.selectList(new LambdaQueryWrapperX<SystemConfigProcessDO>()
.eq(SystemConfigProcessDO::getOrganId, copyOrganId)
.eq(SystemConfigProcessDO::getDeleted, false)
.eq(SystemConfigProcessDO::getType, SystemConfigTypeEnum.PROCESSING_SCREENING.getType()));
if(CollUtil.isNotEmpty(systemConfigProcessDOS)){
systemConfigProcessDOS.forEach(f->{
f.setId(null);
f.setOrganId(organId);
f.setCreateTime(null);
f.setCreator(null);
f.setUpdateTime(null);
f.setUpdater(null);
});
systemConfigProcessMapper.insertBatch(systemConfigProcessDOS);
}
// 数据处理
List<SystemConfigDataDO> systemConfigDataDOS = systemConfigDataMapper.selectList(new LambdaQueryWrapperX<SystemConfigDataDO>()
.eq(SystemConfigDataDO::getOrganId, copyOrganId)
.eq(SystemConfigDataDO::getDeleted, false)
.eq(SystemConfigDataDO::getType, SystemConfigTypeEnum.DATA_PROCESSING.getType()));
if(CollUtil.isNotEmpty(systemConfigDataDOS)){
systemConfigDataDOS.forEach(f->{
f.setId(null);
f.setOrganId(organId);
f.setCreateTime(null);
f.setCreator(null);
f.setUpdateTime(null);
f.setUpdater(null);
});
systemConfigDataMapper.insertBatch(systemConfigDataDOS);
}
// 加工方案,(需要复制的组织ID,需要添加数据的组织ID)
copyConfigSchemeMachineAndLabel(copyOrganId,organId);
// 封边条对应
List<SystemConfigSealedgeDO> systemConfigSealedgeDOS = systemConfigSealedgeMapper.selectList(new LambdaQueryWrapperX<SystemConfigSealedgeDO>()
.eq(SystemConfigSealedgeDO::getOrganId, copyOrganId)
@@ -90,4 +90,77 @@
</select>
<select id="selectPageWithProductExpire"
resultType="com.cf.imes.module.system.dal.dataobject.organ.OrganizationDO">
SELECT o.*
FROM system_organization o
<where>
o.deleted = false
<if test="reqVO.contactName != null and reqVO.contactName != ''">
AND o.contact_name LIKE CONCAT('%', #{reqVO.contactName}, '%')
</if>
<if test="reqVO.contactMobile != null and reqVO.contactMobile != ''">
AND o.contact_mobile LIKE CONCAT('%', #{reqVO.contactMobile}, '%')
</if>
<if test="reqVO.status != null">
AND o.status = #{reqVO.status}
</if>
<if test="reqVO.exactName != null and reqVO.exactName != ''">
AND o.name = #{reqVO.exactName}
</if>
<if test="reqVO.province != null and reqVO.province != ''">
AND o.province = #{reqVO.province}
</if>
<if test="reqVO.city != null and reqVO.city != ''">
AND o.city = #{reqVO.city}
</if>
<if test="reqVO.county != null and reqVO.county != ''">
AND o.county = #{reqVO.county}
</if>
<if test="reqVO.expireTime != null and reqVO.expireTime.length == 2">
AND o.expire_time BETWEEN #{reqVO.expireTime[0]} AND #{reqVO.expireTime[1]}
</if>
<if test="reqVO.remark != null and reqVO.remark != ''">
AND o.remark LIKE CONCAT('%', #{reqVO.remark}, '%')
</if>
<if test="reqVO.name != null and reqVO.name != ''">
AND (
o.name LIKE CONCAT('%', #{reqVO.name}, '%')
<if test="reqVO.pyAll != null and reqVO.pyAll != ''">
OR o.pinyin_full LIKE CONCAT('%', #{reqVO.pyAll}, '%')
</if>
<if test="reqVO.pyFirstChar != null and reqVO.pyFirstChar != ''">
OR o.pinyin_initial LIKE CONCAT('%', #{reqVO.pyFirstChar}, '%')
</if>
)
</if>
AND o.id IN (
SELECT pr.organ_id
FROM purchase_record pr
LEFT JOIN (
SELECT purchase_id, MAX(delay_time) as max_delay_time
FROM product_delay_record
WHERE deleted = false
GROUP BY purchase_id
) pdr ON pr.id = pdr.purchase_id
WHERE pr.initial = true
AND pr.deleted = false
AND pr.status = 1
<if test="reqVO.endTime != null">
AND COALESCE(pdr.max_delay_time, pr.end_time) >= #{reqVO.endTime[0]}
</if>
<if test="reqVO.endTime != null">
AND COALESCE(pdr.max_delay_time, pr.end_time) &lt;= #{reqVO.endTime[1]}
</if>
<if test="reqVO.productName != null and reqVO.productName != ''">
AND pr.product_name LIKE CONCAT('%', #{reqVO.productName}, '%')
</if>
<if test="reqVO.price != null">
AND pr.total_amount = #{reqVO.price}
</if>
)
</where>
ORDER BY o.id DESC
</select>
</mapper>
@@ -20,10 +20,8 @@ class LabelTemplateTypeValidatorTest extends BaseMockitoUnitTest {
@Test
void testValid() {
LabelTemplateTypeValidator validator = new LabelTemplateTypeValidator();
assertTrue(validator.isValid(LabelTemplateType.PLATEPACKAGELABEL.getType(), constraintValidatorContext));
assertTrue(validator.isValid(LabelTemplateType.MACHINELABEL.getType(), constraintValidatorContext));
assertTrue(validator.isValid(LabelTemplateType.PARTSPACKAGELABEL.getType(), constraintValidatorContext));
assertTrue(validator.isValid(LabelTemplateType.ORDERPACKAGELABEL.getType(), constraintValidatorContext));
assertTrue(validator.isValid(LabelTemplateType.MATERIALLABEL.getType(), constraintValidatorContext));
assertTrue(validator.isValid("", constraintValidatorContext));
assertFalse(validator.isValid("100", constraintValidatorContext));
}