批次规则的修改

This commit is contained in:
秦鸿展
2026-01-29 13:50:03 +08:00
parent 7926235114
commit 49cdce7b9c
14 changed files with 288 additions and 17 deletions
@@ -45,6 +45,10 @@ public class BatchDetailApplicationService {
batchDetailDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
}
// 如果未指定isDisplay,默认只查询显示的数据(isDisplay=1
if (batchDetailDO.getIsDisplay() == null) {
batchDetailDO.setIsDisplay(1);
}
return batchDetailDomainService.queryList(batchDetailDO);
}
@@ -46,6 +46,10 @@ public class BatchDetail extends BaseVOEntity{
@Excel(name = "批次标签")
private String batchLabels;
@ApiModelProperty("字段名称")
@Excel(name = "字段名称")
private String fieldName;
@ApiModelProperty("输入控制: 1-必填 2-可选")
@Excel(name = "输入控制: 1-必填 2-可选")
private String inputControl;
@@ -58,6 +62,10 @@ public class BatchDetail extends BaseVOEntity{
@Excel(name = "属性选项")
private String attributeOption;
@ApiModelProperty("是否显示: 0-不显示 1-显示")
@Excel(name = "是否显示: 0-不显示 1-显示")
private Integer isDisplay;
@ApiModelProperty("备注")
@Excel(name = "备注")
private String remark;
@@ -62,13 +62,26 @@ public class BatchDetailImpl extends ServiceImpl<BatchDetailMapper, BatchDetail>
LoginUser loginUser = SecurityUtils.getLoginUser();
UserPo userPo = loginUser.getUserPo();
List<BatchDetailDO> batchDetailDOList = batchDO.getBatchDetailList();
//验证提交的数据是否存在重复
// 验证本次提交的数据是否存在重复(同一批次内不允许重复标签)
long count = batchDetailDOList.stream().map(BatchDetailDO::getBatchLabels).distinct().count();
if (batchDetailDOList.size() != count){
throw new ServiceException("批次标签不允许重复,请检查提交的数据");
}
// 查询当前批次原有的标签明细
List<BatchDetail> batchDetailDbList = batchDetailMapper.selectList(new QueryWrapper<BatchDetail>().lambda()
.eq(BatchDetail::getBatchId, batchDO.getBatchId()));
// 如果数据库里已经有明细,并且这次前端传过来的所有明细都没有明细ID,
// 说明前端没有带回原来的主键,这种情况我们视为“完全替换”:
// 先物理删除当前批次下所有旧的明细,再按本次数据重新插入,避免命中数据库唯一索引冲突。
boolean allNewWithoutId = CollectionUtil.isNotEmpty(batchDetailDOList)
&& batchDetailDOList.stream().allMatch(detail -> detail.getBatchDetailId() == null);
if (CollectionUtil.isNotEmpty(batchDetailDbList) && allNewWithoutId) {
batchDetailMapper.delete(new QueryWrapper<BatchDetail>().lambda()
.eq(BatchDetail::getBatchId, batchDO.getBatchId()));
batchDetailDbList = new ArrayList<>();
}
List<BatchDetail> batchDetailListSave = new ArrayList<>();
List<BatchDetail> batchDetailListSave2 = new ArrayList<>();
List<BatchDetail> batchDetailListUpdates = new ArrayList<>();
@@ -78,9 +91,11 @@ public class BatchDetailImpl extends ServiceImpl<BatchDetailMapper, BatchDetail>
BatchDetail batchDetailDb = batchDetailMap.get(batchDetailDO.getBatchDetailId());
if (batchDetailDb != null){
batchDetailDb.setBatchLabels(batchDetailDO.getBatchLabels());
batchDetailDb.setFieldName(batchDetailDO.getFieldName());
batchDetailDb.setInputControl(batchDetailDO.getInputControl());
batchDetailDb.setAttributeFormat(batchDetailDO.getAttributeFormat());
batchDetailDb.setAttributeOption(batchDetailDO.getAttributeOption());
batchDetailDb.setIsDisplay(batchDetailDO.getIsDisplay());
batchDetailDb.setRemark(batchDetailDO.getRemark());
batchDetailDb.setDelFlag(1);
batchDetailListUpdates.add(batchDetailDb);
@@ -45,6 +45,10 @@ public class BatchDetailPO extends BaseVOEntity{
@Excel(name = "批次标签")
private String batchLabels;
@ApiModelProperty("字段名称")
@Excel(name = "字段名称")
private String fieldName;
@ApiModelProperty("输入控制: 1-必填 2-可选")
@Excel(name = "输入控制: 1-必填 2-可选")
private String inputControl;
@@ -57,6 +61,10 @@ public class BatchDetailPO extends BaseVOEntity{
@Excel(name = "属性选项")
private String attributeOption;
@ApiModelProperty("是否显示: 0-不显示 1-显示")
@Excel(name = "是否显示: 0-不显示 1-显示")
private Integer isDisplay;
@ApiModelProperty("备注")
@Excel(name = "备注")
private String remark;
@@ -22,8 +22,8 @@ import java.util.List;
public class BatchDetailDO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("批次管理详情id")
private Long batchDetailId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
@@ -45,6 +45,14 @@ public class BatchDetailDO extends BaseVOEntity{
@Excel(name = "批次标签")
private String batchLabels;
@ApiModelProperty("字段名称")
@Excel(name = "字段名称")
private String fieldName;
@ApiModelProperty("是否显示: 0-不显示 1-显示")
@Excel(name = "是否显示: 0-不显示 1-显示")
private Integer isDisplay;
@ApiModelProperty("输入控制: 1-必填 2-可选")
@Excel(name = "输入控制: 1-必填 2-可选")
private String inputControl;
@@ -57,6 +65,8 @@ public class BatchDetailDO extends BaseVOEntity{
@Excel(name = "属性选项")
private String attributeOption;
@ApiModelProperty("备注")
@Excel(name = "备注")
private String remark;
@@ -44,6 +44,10 @@ public class BatchDetailDTO extends BaseVOEntity{
@Excel(name = "批次标签")
private String batchLabels;
@ApiModelProperty("字段名称")
@Excel(name = "字段名称")
private String fieldName;
@ApiModelProperty("输入控制: 1-必填 2-可选")
@Excel(name = "输入控制: 1-必填 2-可选")
private String inputControl;
@@ -56,6 +60,10 @@ public class BatchDetailDTO extends BaseVOEntity{
@Excel(name = "属性选项")
private String attributeOption;
@ApiModelProperty("是否显示: 0-不显示 1-显示")
@Excel(name = "是否显示: 0-不显示 1-显示")
private Integer isDisplay;
@ApiModelProperty("备注")
@Excel(name = "备注")
private String remark;
@@ -11,9 +11,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="topOrganizationId" column="top_organization_id" />
<result property="batchId" column="batch_id" />
<result property="batchLabels" column="batch_labels" />
<result property="fieldName" column="field_name" />
<result property="inputControl" column="input_control" />
<result property="attributeFormat" column="attribute_format" />
<result property="attributeOption" column="attribute_option" />
<result property="isDisplay" column="is_display" />
<result property="remark" column="remark" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
@@ -26,7 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectBatchDetailPo">
select batch_detail_id, organization_id, organization_name, top_organization_id, batch_id, batch_labels, input_control, attribute_format, attribute_option, remark, create_time, create_by, create_by_name, update_time, update_by, update_by_name, del_flag from batch_detail
select batch_detail_id, organization_id, organization_name, top_organization_id, batch_id, batch_labels, field_name, input_control, attribute_format, attribute_option, is_display, remark, create_time, create_by, create_by_name, update_time, update_by, update_by_name, del_flag from batch_detail
</sql>
<sql id="selectBatchDetailPo1">
@@ -46,6 +48,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="batchLabels != null and batchLabels != ''">
and batch_labels = #{batchLabels}
</if>
<if test="fieldName != null and fieldName != ''">
and field_name = #{fieldName}
</if>
<if test="inputControl != null ">
and input_control = #{inputControl}
</if>
@@ -55,6 +60,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="attributeOption != null and attributeOption != ''">
and attribute_option = #{attributeOption}
</if>
<if test="isDisplay != null ">
and is_display = #{isDisplay}
</if>
<if test="createByName != null and createByName != ''">
and create_by_name like concat('%', #{createByName}, '%')
</if>