Merge remote-tracking branch 'origin/master'

This commit is contained in:
jjLv 2024-11-11 13:14:33 +08:00
commit ee4131bad0
8 changed files with 166 additions and 29 deletions

View File

@ -4,6 +4,7 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.bonus.common.log.enums.OperaType; import com.bonus.common.log.enums.OperaType;
import com.bonus.material.common.annotation.PreventRepeatSubmit; import com.bonus.material.common.annotation.PreventRepeatSubmit;
import com.bonus.material.lease.domain.vo.LeaseApplyRequestVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -81,9 +82,9 @@ public class LeaseApplyInfoController extends BaseController {
@RequiresPermissions("lease:info:add") @RequiresPermissions("lease:info:add")
@SysLog(title = "领料任务", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增领料任务") @SysLog(title = "领料任务", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增领料任务")
@PostMapping @PostMapping
public AjaxResult add(@RequestBody LeaseApplyInfo leaseApplyInfo) { public AjaxResult add(@RequestBody LeaseApplyRequestVo leaseApplyRequestVo) {
try { try {
return toAjax(leaseApplyInfoService.insertLeaseApplyInfo(leaseApplyInfo)); return leaseApplyInfoService.insertLeaseApplyInfo(leaseApplyRequestVo);
} catch (Exception e) { } catch (Exception e) {
return error("系统错误, " + e.getMessage()); return error("系统错误, " + e.getMessage());
} }
@ -97,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

@ -0,0 +1,31 @@
package com.bonus.material.lease.domain.vo;
import com.bonus.common.core.annotation.Excel;
import com.bonus.common.core.web.domain.BaseEntity;
import com.bonus.material.lease.domain.LeaseApplyDetails;
import com.bonus.material.lease.domain.LeaseApplyInfo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import java.util.Date;
import java.util.List;
/**
* 领料任务对象 lease_apply_info
*
* @author xsheng
* @date 2024-10-16
*/
@Data
@ToString
public class LeaseApplyRequestVo extends BaseEntity {
private LeaseApplyInfo leaseApplyInfo;
private List<LeaseApplyDetails> leaseApplyDetailsList;
}

View File

@ -34,6 +34,8 @@ public interface LeaseApplyDetailsMapper {
*/ */
public int insertLeaseApplyDetails(LeaseApplyDetails leaseApplyDetails); public int insertLeaseApplyDetails(LeaseApplyDetails leaseApplyDetails);
public int insertLeaseApplyDetailsList(List<LeaseApplyDetails> leaseApplyDetails);
/** /**
* 修改领料任务详细 * 修改领料任务详细
* *
@ -57,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

@ -1,7 +1,10 @@
package com.bonus.material.lease.service; package com.bonus.material.lease.service;
import java.util.List; import java.util.List;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.lease.domain.LeaseApplyInfo; import com.bonus.material.lease.domain.LeaseApplyInfo;
import com.bonus.material.lease.domain.vo.LeaseApplyRequestVo;
/** /**
* 领料任务Service接口 * 领料任务Service接口
@ -29,18 +32,18 @@ public interface ILeaseApplyInfoService {
/** /**
* 新增领料任务 * 新增领料任务
* *
* @param leaseApplyInfo 领料任务 * @param leaseApplyRequestVo 领料任务
* @return 结果 * @return 结果
*/ */
public int insertLeaseApplyInfo(LeaseApplyInfo leaseApplyInfo); public AjaxResult insertLeaseApplyInfo(LeaseApplyRequestVo leaseApplyRequestVo);
/** /**
* 修改领料任务 * 修改领料任务
* *
* @param leaseApplyInfo 领料任务 * @param leaseApplyRequestVo 领料任务
* @return 结果 * @return 结果
*/ */
public int updateLeaseApplyInfo(LeaseApplyInfo leaseApplyInfo); public boolean updateLeaseApplyInfo(LeaseApplyRequestVo leaseApplyRequestVo);
/** /**
* 批量删除领料任务 * 批量删除领料任务

View File

@ -1,13 +1,30 @@
package com.bonus.material.lease.service.impl; package com.bonus.material.lease.service.impl;
import java.util.List; import java.util.List;
import com.bonus.common.biz.enums.PurchaseTaskStatusEnum;
import com.bonus.common.biz.enums.TmTaskTypeEnum;
import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.material.basic.domain.BmFileInfo;
import com.bonus.material.lease.domain.LeaseApplyDetails;
import com.bonus.material.lease.domain.vo.LeaseApplyRequestVo;
import com.bonus.material.lease.mapper.LeaseApplyDetailsMapper;
import com.bonus.material.purchase.domain.PurchaseCheckDetails;
import com.bonus.material.purchase.domain.dto.PurchaseCheckDto;
import com.bonus.material.task.domain.TmTask;
import com.bonus.material.task.mapper.TmTaskMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.bonus.material.lease.mapper.LeaseApplyInfoMapper; import com.bonus.material.lease.mapper.LeaseApplyInfoMapper;
import com.bonus.material.lease.domain.LeaseApplyInfo; import com.bonus.material.lease.domain.LeaseApplyInfo;
import com.bonus.material.lease.service.ILeaseApplyInfoService; import com.bonus.material.lease.service.ILeaseApplyInfoService;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
/** /**
* 领料任务Service业务层处理 * 领料任务Service业务层处理
@ -20,6 +37,14 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
@Autowired @Autowired
private LeaseApplyInfoMapper leaseApplyInfoMapper; private LeaseApplyInfoMapper leaseApplyInfoMapper;
@Autowired
private LeaseApplyDetailsMapper leaseApplyDetailsMapper;
@Resource
private TmTaskMapper tmTaskMapper;
public static final String LEASE_TASK_TYPE_LABEL = "L";
/** /**
* 查询领料任务 * 查询领料任务
* *
@ -45,30 +70,79 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
/** /**
* 新增领料任务 * 新增领料任务
* *
* @param leaseApplyInfo 领料任务 * @param leaseApplyRequestVo 领料任务
* @return 结果 * @return 结果
*/ */
@Override @Override
public int insertLeaseApplyInfo(LeaseApplyInfo leaseApplyInfo) { public AjaxResult insertLeaseApplyInfo(LeaseApplyRequestVo leaseApplyRequestVo) {
leaseApplyInfo.setCreateTime(DateUtils.getNowDate()); leaseApplyRequestVo.getLeaseApplyInfo().setCreateTime(DateUtils.getNowDate());
leaseApplyRequestVo.getLeaseApplyInfo().setCreateBy(SecurityUtils.getUsername());
try { try {
return leaseApplyInfoMapper.insertLeaseApplyInfo(leaseApplyInfo); int thisMonthMaxOrder = tmTaskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_LEASE.getTaskTypeId());
} catch (Exception e) { String taskCode = genderTaskCode(thisMonthMaxOrder);
throw new ServiceException("错误信息描述"); TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_LEASE.getTaskTypeId(),
PurchaseTaskStatusEnum.TO_NOTICE.getStatus(),
leaseApplyRequestVo.getLeaseApplyInfo().getCompanyId(), "1", thisMonthMaxOrder + 1, taskCode);
tmTask.setCreateTime(DateUtils.getNowDate());
tmTaskMapper.insertTmTask(tmTask);
Long taskId = tmTask.getTaskId();
leaseApplyRequestVo.getLeaseApplyInfo().setTaskId(taskId);
int count = leaseApplyInfoMapper.insertLeaseApplyInfo(leaseApplyRequestVo.getLeaseApplyInfo());
if (count > 0) {
return insertPurchaseCheckDetails(leaseApplyRequestVo.getLeaseApplyDetailsList(), taskId);
} else {
return AjaxResult.error("新增任务失败,lease_apply_info表插入0条");
} }
} catch (DataAccessException e) {
return AjaxResult.error("数据库操作失败:" + e.getMessage());
} catch (Exception e) {
return AjaxResult.error("新增任务失败:" + e.getMessage());
}
}
private AjaxResult insertPurchaseCheckDetails(List<LeaseApplyDetails> leaseApplyDetailsList, Long taskId) {
if (!CollectionUtils.isEmpty(leaseApplyDetailsList)) {
for (LeaseApplyDetails details : leaseApplyDetailsList) {
details.setParentId(taskId); // 设置领料taskId
//details.setStatus(PurchaseTaskStatusEnum.TO_NOTICE.getStatus());
}
// 批量插入详情数据
int count = leaseApplyDetailsMapper.insertLeaseApplyDetailsList(leaseApplyDetailsList);
if (count > 0) {
return AjaxResult.success("新增任务成功");
} else {
return AjaxResult.error("新增任务失败,lease_apply_detail详情表插入0条");
}
} else {
return AjaxResult.success("新增任务成功");
}
}
/**
* 生成任务编号并构造Tm_Task任务对象
* @param thisMonthMaxOrder 当月最大单号
* @return 任务对象
*/
private static String genderTaskCode(Integer thisMonthMaxOrder) {
return LEASE_TASK_TYPE_LABEL + DateUtils.getCurrentYear() + DateUtils.getCurrentMonth() + String.format("%06d", thisMonthMaxOrder + 1);
} }
/** /**
* 修改领料任务 * 修改领料任务
* *
* @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

@ -42,7 +42,7 @@ import javax.annotation.Resource;
@Service @Service
public class PurchaseCheckInfoServiceImpl implements IPurchaseCheckInfoService { public class PurchaseCheckInfoServiceImpl implements IPurchaseCheckInfoService {
public static final String TASK_TYPE_LABEL = "XG"; public static final String PURCHASE_TASK_TYPE_LABEL = "XG";
@Autowired @Autowired
private IBmConfigService bmConfigService; private IBmConfigService bmConfigService;
@ -178,7 +178,7 @@ public class PurchaseCheckInfoServiceImpl implements IPurchaseCheckInfoService {
purchaseCheckInfo.getPurchaseCheckInfo().setCreateBy(SecurityUtils.getUsername()); purchaseCheckInfo.getPurchaseCheckInfo().setCreateBy(SecurityUtils.getUsername());
try { try {
int thisMonthMaxOrder = tmTaskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_PURCHASE.getTaskTypeId()); int thisMonthMaxOrder = tmTaskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_PURCHASE.getTaskTypeId());
String taskCode = genderTaskCode(purchaseCheckInfo, thisMonthMaxOrder); String taskCode = genderTaskCode(thisMonthMaxOrder);
TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_PURCHASE.getTaskTypeId(), TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_PURCHASE.getTaskTypeId(),
PurchaseTaskStatusEnum.TO_NOTICE.getStatus(), PurchaseTaskStatusEnum.TO_NOTICE.getStatus(),
purchaseCheckInfo.getPurchaseCheckInfo().getCompanyId(), "1", thisMonthMaxOrder + 1, taskCode); purchaseCheckInfo.getPurchaseCheckInfo().getCompanyId(), "1", thisMonthMaxOrder + 1, taskCode);
@ -296,12 +296,11 @@ public class PurchaseCheckInfoServiceImpl implements IPurchaseCheckInfoService {
/** /**
* 生成任务编号并构造Tm_Task任务对象 * 生成任务编号并构造Tm_Task任务对象
* @param purchaseCheckInfo 新购验收任务数据
* @param thisMonthMaxOrder 当月最大单号 * @param thisMonthMaxOrder 当月最大单号
* @return 任务对象 * @return 任务对象
*/ */
private static String genderTaskCode(PurchaseCheckDto purchaseCheckInfo, Integer thisMonthMaxOrder) { private static String genderTaskCode(Integer thisMonthMaxOrder) {
return TASK_TYPE_LABEL + DateUtils.getCurrentYear() + DateUtils.getCurrentMonth() + String.format("%06d", thisMonthMaxOrder + 1); return PURCHASE_TASK_TYPE_LABEL + DateUtils.getCurrentYear() + DateUtils.getCurrentMonth() + String.format("%06d", thisMonthMaxOrder + 1);
} }
/** /**

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>
@ -73,10 +73,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim> </trim>
</insert> </insert>
<insert id="insertLeaseApplyDetailsList" keyColumn="id" keyProperty="id" parameterType="map" useGeneratedKeys="true">
insert into lease_apply_details
(parent_id, type_id, pre_num, al_num, `status`, create_by, create_time, update_by,
update_time, remark, company_id)
values
<foreach collection="list" item="item" separator=",">
(#{item.parentId,jdbcType=INTEGER}, #{item.typeId,jdbcType=INTEGER}, #{item.preNum,jdbcType=INTEGER},
#{item.alNum,jdbcType=INTEGER}, #{item.status,jdbcType=VARCHAR}, #{item.createBy,jdbcType=VARCHAR},
NOW(), #{item.updateBy,jdbcType=VARCHAR}, NOW(),
#{item.remark,jdbcType=VARCHAR}, #{item.companyId,jdbcType=INTEGER})
</foreach>
</insert>
<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>
@ -102,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>