申请发布

This commit is contained in:
mashuai 2025-03-05 10:28:10 +08:00
parent 97213e6e60
commit 96985a751d
8 changed files with 222 additions and 6 deletions

View File

@ -88,6 +88,11 @@ public class MaterialConstants {
/** 配件领料单号的开头字母 */ /** 配件领料单号的开头字母 */
public static final String PART_LEASE_TASK_TYPE_LEASE = "LP"; public static final String PART_LEASE_TASK_TYPE_LEASE = "LP";
/**
* 领用发布
*/
public static final String LEASE_PUBLISH = "LF";
/** /**
* 内部单位协议 * 内部单位协议
*/ */

View File

@ -13,7 +13,7 @@ public enum LeaseTaskStatusEnum {
LEASE_TASK_ZERO(0, "待审核"), LEASE_TASK_ZERO(0, "待审核"),
LEASE_TASK_SUBMIT(5, "待提交"), LEASE_TASK_SUBMIT(5, "待提交"),
LEASE_TASK_TO_PUBLISHED(1, "待发布"), LEASE_TASK_TO_PUBLISHED(1, "待发布"),
LEASE_TASK_TO_AUDIT(2, "待审核"), LEASE_TASK_TO_AUDIT(2, "已终结"),
LEASE_TASK_IN_PROGRESS(3, "出库进行中"), LEASE_TASK_IN_PROGRESS(3, "出库进行中"),
LEASE_TASK_FINISHED(4, "出库已完成"); LEASE_TASK_FINISHED(4, "出库已完成");
private final Integer status; private final Integer status;

View File

@ -144,6 +144,17 @@ public class LeaseTaskController extends BaseController {
return success(service.getDetailsById(leaseApplyInfo)); return success(service.getDetailsById(leaseApplyInfo));
} }
/**
* 发布数据保存
* @param leaseApplyRequestVo
* @return
*/
@ApiOperation(value = "发布数据保存")
@PostMapping("/addPublish")
public AjaxResult addPublish(@RequestBody LeaseApplyRequestVo leaseApplyRequestVo) {
return service.addPublish(leaseApplyRequestVo);
}
/** /**
* 导出领料发布列表 * 导出领料发布列表
* @param response * @param response

View File

@ -49,6 +49,9 @@ public class LeaseApplyDetails extends BaseEntity {
@ApiModelProperty(value = "规格型号id") @ApiModelProperty(value = "规格型号id")
private Long typeId; private Long typeId;
@ApiModelProperty(value = "规格型号id")
private Long newTypeId;
@ApiModelProperty(value = "三级id") @ApiModelProperty(value = "三级id")
private Long thirdTypeId; private Long thirdTypeId;
@ -82,6 +85,9 @@ public class LeaseApplyDetails extends BaseEntity {
@ApiModelProperty(value = "待发布数量") @ApiModelProperty(value = "待发布数量")
private BigDecimal pendingNum; private BigDecimal pendingNum;
@ApiModelProperty(value = "本次发布数量")
private BigDecimal num;
/** 预领料数 */ /** 预领料数 */
@Excel(name = "预领数量") @Excel(name = "预领数量")
@ApiModelProperty(value = "预领料数") @ApiModelProperty(value = "预领料数")
@ -128,6 +134,24 @@ public class LeaseApplyDetails extends BaseEntity {
@ApiModelProperty(value = "编码类型集合") @ApiModelProperty(value = "编码类型集合")
private List<MaCodeVo> maCodeVoList; private List<MaCodeVo> maCodeVoList;
@ApiModelProperty(value = "往来单位id")
private Long unitId;
@ApiModelProperty(value = "工程id")
private Long projectId;
@ApiModelProperty(value = "领料人")
private String leasePerson;
@ApiModelProperty(value = "联系方式")
private String phone;
@ApiModelProperty(value = "任务当月序号 例如:1 插入及查询时请携带任务类型")
private Integer monthOrder;
@ApiModelProperty(value = "发布批次")
private String publishTask;
public LeaseApplyDetails(Long id, Long parentId, Long typeId, BigDecimal preNum, BigDecimal auditNum, BigDecimal alNum, String status, Long companyId) { public LeaseApplyDetails(Long id, Long parentId, Long typeId, BigDecimal preNum, BigDecimal auditNum, BigDecimal alNum, String status, Long companyId) {
this.id = id; this.id = id;
this.parentId = parentId; this.parentId = parentId;

View File

@ -112,4 +112,33 @@ public interface LeaseTaskMapper {
* @return * @return
*/ */
List<LeaseApplyDetails> selectPublishDetails(LeaseApplyInfo leaseApplyInfo); List<LeaseApplyDetails> selectPublishDetails(LeaseApplyInfo leaseApplyInfo);
/**
* 根据taskId查询领用申请详情
* @param parentId
* @return
*/
List<LeaseApplyDetails> selectLeaseApplyDetailsById(Long parentId);
/**
* 领用申请发布详情保存
* @param applyDetails
* @return
*/
int addPublish(LeaseApplyDetails applyDetails);
/**
* 领用申请发布详情修改
* @param applyDetails
* @return
*/
int updatePublish(LeaseApplyDetails applyDetails);
/**
* 根据当前年月查询最大序号
* @param year
* @param month
* @return
*/
int getMonthMaxOrderByDate(@Param("year") String year, @Param("month") String month);
} }

View File

@ -107,5 +107,12 @@ public interface ILeaseTaskService {
* @return * @return
*/ */
LeaseApplyRequestVo getDetailsById(LeaseApplyInfo leaseApplyInfo); LeaseApplyRequestVo getDetailsById(LeaseApplyInfo leaseApplyInfo);
/**
* 发布数据保存
* @param leaseApplyRequestVo
* @return
*/
AjaxResult addPublish(LeaseApplyRequestVo leaseApplyRequestVo);
} }

View File

@ -596,4 +596,80 @@ public class LeaseTaskServiceImpl implements ILeaseTaskService {
throw new RuntimeException("Failed to select lease apply info", e); throw new RuntimeException("Failed to select lease apply info", e);
} }
} }
/**
* 发布数据保存
* @param leaseApplyRequestVo
* @return
*/
@Override
public AjaxResult addPublish(LeaseApplyRequestVo leaseApplyRequestVo) {
if (leaseApplyRequestVo == null || leaseApplyRequestVo.getLeaseApplyInfo() == null
|| CollectionUtils.isEmpty(leaseApplyRequestVo.getLeaseApplyDetailsList())) {
return AjaxResult.error("参数不能为空");
}
try {
int result = 0;
LeaseApplyInfo leaseApplyInfo = leaseApplyRequestVo.getLeaseApplyInfo();
List<LeaseApplyDetails> leaseApplyDetailsList = leaseApplyRequestVo.getLeaseApplyDetailsList();
Long parentId = leaseApplyDetailsList.get(0).getParentId();
int thisMonthMaxOrder = mapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth());
for (LeaseApplyDetails applyDetails : leaseApplyDetailsList) {
// 根据parentId及typeId更新lease_apply_details表的发布数量
result = mapper.updatePublish(applyDetails);
if (result == 0) {
return AjaxResult.error("发布失败,请联系管理员");
}
applyDetails.setUnitId(leaseApplyInfo.getUnitId());
applyDetails.setProjectId(leaseApplyInfo.getProjectId());
applyDetails.setLeasePerson(leaseApplyInfo.getLeasePerson() != null ? leaseApplyInfo.getLeasePerson() : "");
applyDetails.setPhone(leaseApplyInfo.getPhone() != null ? leaseApplyInfo.getPhone() : "");
applyDetails.setCreateBy(SecurityUtils.getUserId().toString());
applyDetails.setCreateTime(DateUtils.getNowDate());
applyDetails.setMonthOrder(thisMonthMaxOrder + 1);
String publishTask = genderPublishTask(thisMonthMaxOrder);
applyDetails.setPublishTask(publishTask);
result = mapper.addPublish(applyDetails);
if (result == 0) {
return AjaxResult.error("发布失败,请联系管理员");
}
}
List<LeaseApplyDetails> leaseApplyDetails = mapper.selectLeaseApplyDetailsById(parentId);
boolean allMatch = true;
if (!CollectionUtils.isEmpty(leaseApplyDetails)) {
for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) {
if (leaseApplyDetail.getPreNum().compareTo(leaseApplyDetail.getPublishNum()) != 0) {
allMatch = false;
break;
}
}
}
if (allMatch) {
TmTask tmTask = new TmTask();
tmTask.setTaskId(leaseApplyInfo.getTaskId());
tmTask.setTaskStatus(LeaseTaskStatusEnum.LEASE_TASK_IN_PROGRESS.getStatus());
result = tmTaskMapper.updateTmTask(tmTask);
if (result == 0) {
return AjaxResult.error("发布失败,请联系管理员");
}
}
return AjaxResult.success("发布成功");
} catch (Exception e) {
log.error(e.getMessage());
return AjaxResult.error("发布失败,请联系管理员");
}
}
/**
* 生成发布批次任务
* @param thisMonthMaxOrder
* @return
*/
private String genderPublishTask(int thisMonthMaxOrder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date nowDate = DateUtils.getNowDate();
String format = dateFormat.format(nowDate);
String result = format.replace("-", "");
return MaterialConstants.LEASE_PUBLISH + result + String.format("-%03d", thisMonthMaxOrder + 1);
}
} }

View File

@ -262,6 +262,44 @@
</foreach> </foreach>
</insert> </insert>
<insert id="addPublish">
insert into lease_publish_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="parentId != null">parent_id,</if>
<if test="typeId != null">type_id,</if>
<if test="newTypeId != null">new_type,</if>
<if test="num != null">num,</if>
<if test="leasePerson != null">lease_person,</if>
<if test="phone != null">phone,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="unitId != null">unit_id,</if>
<if test="projectId != null">project_id,</if>
<if test="monthOrder != null">month_order,</if>
<if test="publishTask != null and publishTask != ''">publish_task,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="parentId != null">#{parentId},</if>
<if test="typeId != null">#{typeId},</if>
<if test="newTypeId != null">#{newTypeId},</if>
<if test="num != null">#{num},</if>
<if test="leasePerson != null">#{leasePerson},</if>
<if test="phone != null">#{phone},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="unitId != null">#{unitId},</if>
<if test="projectId != null">#{projectId},</if>
<if test="monthOrder != null">#{monthOrder},</if>
<if test="publishTask != null and publishTask != ''">#{publishTask},</if>
</trim>
</insert>
<update id="updateLeaseApplyInfo"> <update id="updateLeaseApplyInfo">
update lease_apply_info update lease_apply_info
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
@ -611,6 +649,14 @@
where task_Id = #{taskId} where task_Id = #{taskId}
</update> </update>
<update id="updatePublish">
update lease_apply_details
<trim prefix="SET" suffixOverrides=",">
<if test="num != null">publish_num = IFNULL(publish_num, 0) + #{num},</if>
</trim>
where parent_id = #{parentId} and type_id = #{typeId}
</update>
<select id="getApplyInfo" resultType="com.bonus.common.biz.domain.lease.LeaseApplyInfo"> <select id="getApplyInfo" resultType="com.bonus.common.biz.domain.lease.LeaseApplyInfo">
select select
lai.code as code,lai.lease_person as leasePerson,lai.phone as phone,lai.create_by as createBy, lai.code as code,lai.lease_person as leasePerson,lai.phone as phone,lai.create_by as createBy,
@ -699,11 +745,9 @@
lai.unit_id,lai.project_id,bu.unit_name, bp.pro_name, tt.task_status as taskStatus, lai.unit_id,lai.project_id,bu.unit_name, bp.pro_name, tt.task_status as taskStatus,
case tt.task_status case tt.task_status
when 0 then '待审核' when 1 then '未完成'
when 1 then '待审核' when 2 then '已终结'
when 2 then '审核中'
when 3 then '已完成' when 3 then '已完成'
when 4 then '已完成'
end as taskStatusName, end as taskStatusName,
IFNULL(sum(lad.pre_num),0) as preCountNum, IFNULL(sum(lad.pre_num),0) as preCountNum,
IFNULL(sum(lad.al_num),0) as alNum, IFNULL(sum(lad.al_num),0) as alNum,
@ -723,7 +767,7 @@
left join ma_type mt on lad.type_id = mt.type_id and mt.del_flag = '0' left join ma_type mt on lad.type_id = mt.type_id and mt.del_flag = '0'
left join ma_type mt1 on mt.parent_id = mt1.type_id and mt1.del_flag = '0' left join ma_type mt1 on mt.parent_id = mt1.type_id and mt1.del_flag = '0'
where tt.task_type = '19' where tt.task_type = '19'
and tt.task_status = '1' and tt.task_status in (1, 2, 3)
<if test="taskId != null ">and lai.task_id = #{taskId}</if> <if test="taskId != null ">and lai.task_id = #{taskId}</if>
<if test="statusList != null and statusList.size() > 0"> <if test="statusList != null and statusList.size() > 0">
and tt.task_status in and tt.task_status in
@ -739,4 +783,24 @@
GROUP BY lai.id GROUP BY lai.id
ORDER BY tt.task_status,tt.create_time desc ORDER BY tt.task_status,tt.create_time desc
</select> </select>
<select id="selectLeaseApplyDetailsById" resultType="com.bonus.material.lease.domain.LeaseApplyDetails">
SELECT
parent_id AS parentId,
type_id AS typeId,
IFNULL( SUM(pre_num), 0 ) AS preNum,
IFNULL( SUM(publish_num), 0 ) AS publishNum
FROM
lease_apply_details
WHERE
parent_id = #{parentId}
GROUP BY
parent_id
</select>
<select id="getMonthMaxOrderByDate" resultType="java.lang.Integer">
select COALESCE(max(month_order), 0) from lease_publish_details
where
month(create_time) = #{month} and year(create_time) = #{year}
</select>
</mapper> </mapper>