diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/constant/MaterialConstants.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/constant/MaterialConstants.java index 57649dec..da2b618b 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/constant/MaterialConstants.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/constant/MaterialConstants.java @@ -88,6 +88,11 @@ public class MaterialConstants { /** 配件领料单号的开头字母 */ public static final String PART_LEASE_TASK_TYPE_LEASE = "LP"; + /** + * 领用发布 + */ + public static final String LEASE_PUBLISH = "LF"; + /** * 内部单位协议 */ diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/enums/LeaseTaskStatusEnum.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/enums/LeaseTaskStatusEnum.java index 5a51966f..8ed0b179 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/enums/LeaseTaskStatusEnum.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/enums/LeaseTaskStatusEnum.java @@ -13,7 +13,7 @@ public enum LeaseTaskStatusEnum { LEASE_TASK_ZERO(0, "待审核"), LEASE_TASK_SUBMIT(5, "待提交"), LEASE_TASK_TO_PUBLISHED(1, "待发布"), - LEASE_TASK_TO_AUDIT(2, "待审核"), + LEASE_TASK_TO_AUDIT(2, "已终结"), LEASE_TASK_IN_PROGRESS(3, "出库进行中"), LEASE_TASK_FINISHED(4, "出库已完成"); private final Integer status; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/controller/LeaseTaskController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/controller/LeaseTaskController.java index 66914395..522fbf30 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/controller/LeaseTaskController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/controller/LeaseTaskController.java @@ -144,6 +144,17 @@ public class LeaseTaskController extends BaseController { return success(service.getDetailsById(leaseApplyInfo)); } + /** + * 发布数据保存 + * @param leaseApplyRequestVo + * @return + */ + @ApiOperation(value = "发布数据保存") + @PostMapping("/addPublish") + public AjaxResult addPublish(@RequestBody LeaseApplyRequestVo leaseApplyRequestVo) { + return service.addPublish(leaseApplyRequestVo); + } + /** * 导出领料发布列表 * @param response diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseApplyDetails.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseApplyDetails.java index 839d29bb..56253512 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseApplyDetails.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseApplyDetails.java @@ -49,6 +49,9 @@ public class LeaseApplyDetails extends BaseEntity { @ApiModelProperty(value = "规格型号id") private Long typeId; + @ApiModelProperty(value = "规格型号id") + private Long newTypeId; + @ApiModelProperty(value = "三级id") private Long thirdTypeId; @@ -82,6 +85,9 @@ public class LeaseApplyDetails extends BaseEntity { @ApiModelProperty(value = "待发布数量") private BigDecimal pendingNum; + @ApiModelProperty(value = "本次发布数量") + private BigDecimal num; + /** 预领料数 */ @Excel(name = "预领数量") @ApiModelProperty(value = "预领料数") @@ -128,6 +134,24 @@ public class LeaseApplyDetails extends BaseEntity { @ApiModelProperty(value = "编码类型集合") private List 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) { this.id = id; this.parentId = parentId; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseTaskMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseTaskMapper.java index 45f110df..1add9fe3 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseTaskMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseTaskMapper.java @@ -112,4 +112,33 @@ public interface LeaseTaskMapper { * @return */ List selectPublishDetails(LeaseApplyInfo leaseApplyInfo); + + /** + * 根据taskId查询领用申请详情 + * @param parentId + * @return + */ + List 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); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/ILeaseTaskService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/ILeaseTaskService.java index cf5a26e0..77903b3c 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/ILeaseTaskService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/ILeaseTaskService.java @@ -107,5 +107,12 @@ public interface ILeaseTaskService { * @return */ LeaseApplyRequestVo getDetailsById(LeaseApplyInfo leaseApplyInfo); + + /** + * 发布数据保存 + * @param leaseApplyRequestVo + * @return + */ + AjaxResult addPublish(LeaseApplyRequestVo leaseApplyRequestVo); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseTaskServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseTaskServiceImpl.java index 31d47f5d..1c05204d 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseTaskServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseTaskServiceImpl.java @@ -596,4 +596,80 @@ public class LeaseTaskServiceImpl implements ILeaseTaskService { 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 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 = 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); + } } diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseTaskMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseTaskMapper.xml index 2d5fc734..a79193f8 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseTaskMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseTaskMapper.xml @@ -262,6 +262,44 @@ + + insert into lease_publish_details + + parent_id, + type_id, + new_type, + num, + lease_person, + phone, + create_by, + create_time, + update_by, + update_time, + remark, + unit_id, + project_id, + month_order, + publish_task, + + + #{parentId}, + #{typeId}, + #{newTypeId}, + #{num}, + #{leasePerson}, + #{phone}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + #{unitId}, + #{projectId}, + #{monthOrder}, + #{publishTask}, + + + update lease_apply_info @@ -611,6 +649,14 @@ where task_Id = #{taskId} + + update lease_apply_details + + publish_num = IFNULL(publish_num, 0) + #{num}, + + where parent_id = #{parentId} and type_id = #{typeId} + + + + + +