opt:需求单删除优化为逻辑删除

This commit is contained in:
zhangzq
2026-08-04 15:01:04 +08:00
parent de960cdf17
commit a287bb265a
4 changed files with 14 additions and 6 deletions

View File

@@ -56,6 +56,9 @@ public class PmDemand extends Model<PmDemand> {
@TableField("production_line") @TableField("production_line")
private String production_line; private String production_line;
@TableField("is_deleted")
private Integer is_deleted;
private String sn; private String sn;
@TableField("create_at") @TableField("create_at")

View File

@@ -17,6 +17,7 @@
<result property="targetArea" column="target_area"/> <result property="targetArea" column="target_area"/>
<result property="targetHouseCode" column="target_house_code"/> <result property="targetHouseCode" column="target_house_code"/>
<result property="carrierType" column="carrier_type"/> <result property="carrierType" column="carrier_type"/>
<result property="isDeleted" column="is_deleted"/>
<result property="productionLine" column="production_line"/> <result property="productionLine" column="production_line"/>
<result property="sn" column="sn"/> <result property="sn" column="sn"/>
<result property="createAt" column="create_at"/> <result property="createAt" column="create_at"/>
@@ -26,7 +27,7 @@
<select id="queryPage" resultMap="DemandDtoMap"> <select id="queryPage" resultMap="DemandDtoMap">
select * select *
from pm_demand from pm_demand
<where> where is_deleted = 0
<if test="query.id != null and query.id != ''"> <if test="query.id != null and query.id != ''">
and id = #{query.id} and id = #{query.id}
</if> </if>
@@ -54,7 +55,6 @@
<if test="query.endTime != null and query.endTime != ''"> <if test="query.endTime != null and query.endTime != ''">
and create_time &lt;= #{query.endTime} and create_time &lt;= #{query.endTime}
</if> </if>
</where>
order by priority desc, create_time desc order by priority desc, create_time desc
</select> </select>
</mapper> </mapper>

View File

@@ -27,4 +27,5 @@ public class PmDemandDto implements Serializable {
private String sn; private String sn;
private String createAt; private String createAt;
private String inventoryDis; private String inventoryDis;
private Integer isDeleted;
} }

View File

@@ -112,15 +112,18 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
demand.setCarrier_type(param.getCarrierType()); demand.setCarrier_type(param.getCarrierType());
demand.setProduction_line(param.getProductionLine()); demand.setProduction_line(param.getProductionLine());
demand.setSn(param.getSn()); demand.setSn(param.getSn());
demand.setIs_deleted(0);
demand.setCreate_at(DateUtil.now()); demand.setCreate_at(DateUtil.now());
this.save(demand); this.save(demand);
} }
@Override @Override
public void batchCreate(List<PmDemandParam> param) { public void batchCreate(List<PmDemandParam> param) {
final List<String> collect = param.stream().map(PmDemandParam::getId).collect(Collectors.toList()); final List<String> orders = param.stream().map(PmDemandParam::getWorkOrder).collect(Collectors.toList());
final List<PmDemand> pmDemands = this.listByIds(collect); final int count = this.count(new LambdaQueryWrapper<PmDemand>()
if (!CollectionUtils.isEmpty(pmDemands)){ .in(PmDemand::getWork_order, orders)
.eq(PmDemand::getIs_deleted,0));
if (count>0){
throw new BadRequestException("MES推送需求单失败需求单已存在"); throw new BadRequestException("MES推送需求单失败需求单已存在");
} }
for (PmDemandParam pmDemandParam : param) { for (PmDemandParam pmDemandParam : param) {
@@ -158,7 +161,8 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
if (CollectionUtils.isEmpty(ids)) { if (CollectionUtils.isEmpty(ids)) {
return; return;
} }
this.removeByIds(ids); this.update(new LambdaUpdateWrapper<PmDemand>().in(PmDemand::getId,ids)
.set(PmDemand::getIs_deleted,1));
} }