领料接口优化

This commit is contained in:
sxu 2024-11-11 10:18:32 +08:00
parent 04fee2f74a
commit b4bab9459e
6 changed files with 37 additions and 18 deletions

View File

@ -98,9 +98,9 @@ public class LeaseApplyInfoController extends BaseController {
@RequiresPermissions("lease:info:edit") @RequiresPermissions("lease:info:edit")
@SysLog(title = "领料任务", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改领料任务") @SysLog(title = "领料任务", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改领料任务")
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody LeaseApplyInfo leaseApplyInfo) { public AjaxResult edit(@RequestBody LeaseApplyRequestVo leaseApplyRequestVo) {
try { try {
return toAjax(leaseApplyInfoService.updateLeaseApplyInfo(leaseApplyInfo)); return toAjax(leaseApplyInfoService.updateLeaseApplyInfo(leaseApplyRequestVo));
} catch (Exception e) { } catch (Exception e) {
return error("系统错误, " + e.getMessage()); return error("系统错误, " + e.getMessage());
} }

View File

@ -25,7 +25,7 @@ public class LeaseApplyDetails extends BaseEntity {
/** 任务ID */ /** 任务ID */
@Excel(name = "任务ID") @Excel(name = "任务ID")
@ApiModelProperty(value = "任务ID") @ApiModelProperty(value = "任务ID")
private Long parenntId; private Long parentId;
/** 规格ID */ /** 规格ID */
@Excel(name = "规格ID") @Excel(name = "规格ID")

View File

@ -59,4 +59,6 @@ public interface LeaseApplyDetailsMapper {
* @return 结果 * @return 结果
*/ */
public int deleteLeaseApplyDetailsByIds(Long[] ids); public int deleteLeaseApplyDetailsByIds(Long[] ids);
public int deleteLeaseApplyDetailsByParentIds(Long[] ids);
} }

View File

@ -40,10 +40,10 @@ public interface ILeaseApplyInfoService {
/** /**
* 修改领料任务 * 修改领料任务
* *
* @param leaseApplyInfo 领料任务 * @param leaseApplyRequestVo 领料任务
* @return 结果 * @return 结果
*/ */
public int updateLeaseApplyInfo(LeaseApplyInfo leaseApplyInfo); public boolean updateLeaseApplyInfo(LeaseApplyRequestVo leaseApplyRequestVo);
/** /**
* 批量删除领料任务 * 批量删除领料任务

View File

@ -103,7 +103,7 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
private AjaxResult insertPurchaseCheckDetails(List<LeaseApplyDetails> leaseApplyDetailsList, Long taskId) { private AjaxResult insertPurchaseCheckDetails(List<LeaseApplyDetails> leaseApplyDetailsList, Long taskId) {
if (!CollectionUtils.isEmpty(leaseApplyDetailsList)) { if (!CollectionUtils.isEmpty(leaseApplyDetailsList)) {
for (LeaseApplyDetails details : leaseApplyDetailsList) { for (LeaseApplyDetails details : leaseApplyDetailsList) {
details.setParenntId(taskId); // 设置领料taskId details.setParentId(taskId); // 设置领料taskId
//details.setStatus(PurchaseTaskStatusEnum.TO_NOTICE.getStatus()); //details.setStatus(PurchaseTaskStatusEnum.TO_NOTICE.getStatus());
} }
// 批量插入详情数据 // 批量插入详情数据
@ -130,14 +130,19 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
/** /**
* 修改领料任务 * 修改领料任务
* *
* @param leaseApplyInfo 领料任务 * @param leaseApplyRequestVo 领料任务
* @return 结果 * @return 结果
*/ */
@Override @Override
public int updateLeaseApplyInfo(LeaseApplyInfo leaseApplyInfo) { public boolean updateLeaseApplyInfo(LeaseApplyRequestVo leaseApplyRequestVo) {
leaseApplyInfo.setUpdateTime(DateUtils.getNowDate()); leaseApplyRequestVo.getLeaseApplyInfo().setUpdateTime(DateUtils.getNowDate());
leaseApplyRequestVo.getLeaseApplyInfo().setUpdateBy(SecurityUtils.getUsername());
try { try {
return leaseApplyInfoMapper.updateLeaseApplyInfo(leaseApplyInfo); Long[] ids = new Long[]{leaseApplyRequestVo.getLeaseApplyInfo().getId()};
leaseApplyDetailsMapper.deleteLeaseApplyDetailsByParentIds(ids);
insertPurchaseCheckDetails(leaseApplyRequestVo.getLeaseApplyDetailsList(), leaseApplyRequestVo.getLeaseApplyInfo().getTaskId());
leaseApplyInfoMapper.updateLeaseApplyInfo(leaseApplyRequestVo.getLeaseApplyInfo());
return true;
} catch (Exception e) { } catch (Exception e) {
throw new ServiceException("错误信息描述"); throw new ServiceException("错误信息描述");
} }

View File

@ -5,7 +5,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.bonus.material.lease.mapper.LeaseApplyDetailsMapper"> <mapper namespace="com.bonus.material.lease.mapper.LeaseApplyDetailsMapper">
<resultMap type="com.bonus.material.lease.domain.LeaseApplyDetails" id="LeaseApplyDetailsResult"> <resultMap type="com.bonus.material.lease.domain.LeaseApplyDetails" id="LeaseApplyDetailsResult">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="parenntId" column="parennt_id" /> <result property="parentId" column="parent_id" />
<result property="typeId" column="type_id" /> <result property="typeId" column="type_id" />
<result property="preNum" column="pre_num" /> <result property="preNum" column="pre_num" />
<result property="auditNum" column="audit_num" /> <result property="auditNum" column="audit_num" />
@ -20,13 +20,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectLeaseApplyDetailsVo"> <sql id="selectLeaseApplyDetailsVo">
select id, parennt_id, type_id, pre_num, audit_num, al_num, status, create_by, create_time, update_by, update_time, remark, company_id from lease_apply_details select id, parent_id, type_id, pre_num, audit_num, al_num, status, create_by, create_time, update_by, update_time, remark, company_id from lease_apply_details
</sql> </sql>
<select id="selectLeaseApplyDetailsList" parameterType="com.bonus.material.lease.domain.LeaseApplyDetails" resultMap="LeaseApplyDetailsResult"> <select id="selectLeaseApplyDetailsList" parameterType="com.bonus.material.lease.domain.LeaseApplyDetails" resultMap="LeaseApplyDetailsResult">
<include refid="selectLeaseApplyDetailsVo"/> <include refid="selectLeaseApplyDetailsVo"/>
<where> <where>
<if test="parenntId != null "> and parennt_id = #{parenntId}</if> <if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="typeId != null "> and type_id = #{typeId}</if> <if test="typeId != null "> and type_id = #{typeId}</if>
<if test="preNum != null "> and pre_num = #{preNum}</if> <if test="preNum != null "> and pre_num = #{preNum}</if>
<if test="auditNum != null "> and audit_num = #{auditNum}</if> <if test="auditNum != null "> and audit_num = #{auditNum}</if>
@ -44,7 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertLeaseApplyDetails" parameterType="com.bonus.material.lease.domain.LeaseApplyDetails" useGeneratedKeys="true" keyProperty="id"> <insert id="insertLeaseApplyDetails" parameterType="com.bonus.material.lease.domain.LeaseApplyDetails" useGeneratedKeys="true" keyProperty="id">
insert into lease_apply_details insert into lease_apply_details
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="parenntId != null">parennt_id,</if> <if test="parentId != null">parent_id,</if>
<if test="typeId != null">type_id,</if> <if test="typeId != null">type_id,</if>
<if test="preNum != null">pre_num,</if> <if test="preNum != null">pre_num,</if>
<if test="auditNum != null">audit_num,</if> <if test="auditNum != null">audit_num,</if>
@ -58,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="companyId != null">company_id,</if> <if test="companyId != null">company_id,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="parenntId != null">#{parenntId},</if> <if test="parentId != null">#{parentId},</if>
<if test="typeId != null">#{typeId},</if> <if test="typeId != null">#{typeId},</if>
<if test="preNum != null">#{preNum},</if> <if test="preNum != null">#{preNum},</if>
<if test="auditNum != null">#{auditNum},</if> <if test="auditNum != null">#{auditNum},</if>
@ -75,11 +75,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertLeaseApplyDetailsList" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true"> <insert id="insertLeaseApplyDetailsList" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
insert into lease_apply_details insert into lease_apply_details
(parennt_id, type_id, pre_num, al_num, `status`, create_by, create_time, update_by, (parent_id, type_id, pre_num, al_num, `status`, create_by, create_time, update_by,
update_time, remark, company_id) update_time, remark, company_id)
values values
<foreach collection="list" item="item" separator=","> <foreach collection="list" item="item" separator=",">
(#{item.parenntId,jdbcType=INTEGER}, #{item.typeId,jdbcType=INTEGER}, #{item.preNum,jdbcType=INTEGER}, (#{item.parentId,jdbcType=INTEGER}, #{item.typeId,jdbcType=INTEGER}, #{item.preNum,jdbcType=INTEGER},
#{item.alNum,jdbcType=INTEGER}, #{item.status,jdbcType=VARCHAR}, #{item.createBy,jdbcType=VARCHAR}, #{item.alNum,jdbcType=INTEGER}, #{item.status,jdbcType=VARCHAR}, #{item.createBy,jdbcType=VARCHAR},
NOW(), #{item.updateBy,jdbcType=VARCHAR}, NOW(), NOW(), #{item.updateBy,jdbcType=VARCHAR}, NOW(),
#{item.remark,jdbcType=VARCHAR}, #{item.companyId,jdbcType=INTEGER}) #{item.remark,jdbcType=VARCHAR}, #{item.companyId,jdbcType=INTEGER})
@ -89,7 +89,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateLeaseApplyDetails" parameterType="com.bonus.material.lease.domain.LeaseApplyDetails"> <update id="updateLeaseApplyDetails" parameterType="com.bonus.material.lease.domain.LeaseApplyDetails">
update lease_apply_details update lease_apply_details
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="parenntId != null">parennt_id = #{parenntId},</if> <if test="parentId != null">parent_id = #{parentId},</if>
<if test="typeId != null">type_id = #{typeId},</if> <if test="typeId != null">type_id = #{typeId},</if>
<if test="preNum != null">pre_num = #{preNum},</if> <if test="preNum != null">pre_num = #{preNum},</if>
<if test="auditNum != null">audit_num = #{auditNum},</if> <if test="auditNum != null">audit_num = #{auditNum},</if>
@ -115,4 +115,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
<delete id="deleteLeaseApplyDetailsByParentIds" parameterType="Long">
delete from lease_apply_details where parent_id in (
select task_id
from lease_apply_info
where
id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
)
</delete>
</mapper> </mapper>