From 759a4e22ff74a1fc3cc6ae63c2187beb02f7f716 Mon Sep 17 00:00:00 2001 From: "liang.chao" Date: Thu, 28 Mar 2024 18:11:48 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=86=E6=96=99=E5=87=BA=E5=BA=93=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sgzb/base/api/domain/LeaseOutDetails.java | 87 +++++++--- .../controller/LeaseOutDetailsController.java | 26 ++- .../sgzb/app/domain/LeaseApplyDetails.java | 4 + .../com/bonus/sgzb/app/domain/TmTask.java | 3 + .../app/mapper/LeaseApplyDetailsMapper.java | 1 + .../app/mapper/LeaseOutDetailsMapper.java | 2 + .../app/service/LeaseOutDetailsService.java | 3 + .../impl/LeaseOutDetailsServiceImpl.java | 158 +++++++++++++----- .../mapper/app/LeaseApplyDetailsMapper.xml | 20 +++ .../mapper/app/LeaseOutDetailsMapper.xml | 6 + 10 files changed, 238 insertions(+), 72 deletions(-) diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/LeaseOutDetails.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/LeaseOutDetails.java index 3647d661..ba3ec9a2 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/LeaseOutDetails.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/LeaseOutDetails.java @@ -10,6 +10,7 @@ import java.util.Date; /** * 领料出库详情表 + * * @TableName lease_out_details * @Version 1.0 * @Author 阮世耀 @@ -25,90 +26,134 @@ public class LeaseOutDetails implements Serializable { @ApiModelProperty(value = "id") private Integer id; - /** 父级ID */ + /** + * 父级ID + */ @ApiModelProperty(value = "父级ID") private Integer parentId; - /** 任务ID */ + /** + * 任务ID + */ @ApiModelProperty(value = "任务ID") private Integer taskId; - /** 任务编码 */ + /** + * 任务编码 + */ @ApiModelProperty(value = "任务编码") private String code; - /** 单位名称 */ + /** + * 单位名称 + */ @ApiModelProperty(value = "单位名称") private String unitName; - /** 工程名称 */ + /** + * 工程名称 + */ @ApiModelProperty(value = "工程名称") private String proName; - /** 规格ID */ + /** + * 规格ID + */ @ApiModelProperty(value = "规格ID") private Integer typeId; - /** 规格名称 */ + /** + * 规格名称 + */ @ApiModelProperty(value = "规格名称") private String typeName; - /** maId */ + /** + * maId + */ @ApiModelProperty(value = "maId") private Integer maId; - /** 机具编号 */ + /** + * 机具编号 + */ @ApiModelProperty(value = "机具编号") private String maCode; - /** 协议ID */ + /** + * 协议ID + */ @ApiModelProperty(value = "协议ID") private String agreementId; - /** 预领数量 */ + /** + * 预领数量 + */ @ApiModelProperty(value = "预领数量") private Double preNum; - /** 审批数量 */ + /** + * 审批数量 + */ @ApiModelProperty(value = "审批数量") private Double auditNum; - /** 出库数量 */ + /** + * 出库数量 + */ @ApiModelProperty(value = "出库数量") private Double outNum; - /** 出库类型 */ + /** + * 出库类型 + */ @ApiModelProperty(value = "出库类型") private String outType; - /** 创建者 */ + /** + * 创建者 + */ @ApiModelProperty(value = "创建者") private String createBy; - /** 创建时间 */ + /** + * 创建时间 + */ @ApiModelProperty(value = "创建时间") @JSONField(format = "yyyy-MM-dd HH:mm:ss") private Date createTime; - /** 更新者 */ + /** + * 更新者 + */ @ApiModelProperty(value = "更新者") private String updateBy; - /** 更新时间 */ + /** + * 更新时间 + */ @ApiModelProperty(value = "更新时间") @JSONField(format = "yyyy-MM-dd HH:mm:ss") private Date updateTime; - /** 备注 */ + /** + * 备注 + */ @ApiModelProperty(value = "备注") private String remark; - /** 车牌号 */ + /** + * 车牌号 + */ @ApiModelProperty(value = "车牌号") private String carCode; - /** 数据所属组织 */ + /** + * 数据所属组织 + */ @ApiModelProperty(value = "数据所属组织") private Integer companyId; + @ApiModelProperty(value = "出库类型") + private Integer manageType; } \ No newline at end of file diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/controller/LeaseOutDetailsController.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/controller/LeaseOutDetailsController.java index e637ba33..4af94772 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/controller/LeaseOutDetailsController.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/controller/LeaseOutDetailsController.java @@ -1,6 +1,7 @@ package com.bonus.sgzb.app.controller; import com.bonus.sgzb.app.domain.LeaseApplyDetails; +import com.bonus.sgzb.app.domain.TmTask; import com.bonus.sgzb.app.service.LeaseOutDetailsService; import com.bonus.sgzb.base.api.domain.LeaseOutDetails; import com.bonus.sgzb.base.api.domain.MaMachine; @@ -73,40 +74,53 @@ public class LeaseOutDetailsController extends BaseController { /** - * 根据code编码查询设备信息 + * 根据code编码查询设备信息(app) * * @param maCode 机具编码 * @return 设备信息 */ - @Log(title = "根据code编码获取设备信息", businessType = BusinessType.QUERY) + @Log(title = "根据code编码获取设备信息(app)", businessType = BusinessType.QUERY) @GetMapping("/getMaMachineByCode") public TableDataInfo getMaMachineByCode(@RequestParam(value = "maCode") String maCode) { return getDataTable(leaseOutDetailsService.getMaMachineByCode(maCode)); } /** - * 根据QrCode编码查询设备信息 + * 根据QrCode编码查询设备信息(app) * * @param qrCode 二维码编码 * @return 设备信息 */ - @Log(title = "根据QRcode编码获取设备信息", businessType = BusinessType.QUERY) + @Log(title = "根据QRcode编码获取设备信息(app)", businessType = BusinessType.QUERY) @GetMapping("/getMaMachineByQrCode") public TableDataInfo getMaMachineByQrCode(@RequestParam(value = "qrCode") String qrCode) { return getDataTable(leaseOutDetailsService.getMaMachineByQrCode(qrCode)); } /** - * 根据RFID编码查询设备信息 + * 根据RFID编码查询设备信息(app) * * @param rfidCode RFID编码 * @return 设备信息 */ - @Log(title = "根据rfidCode编码获取设备信息", businessType = BusinessType.QUERY) + @Log(title = "根据rfidCode编码获取设备信息(app)", businessType = BusinessType.QUERY) @GetMapping("/getMaMachineByRfidCode") public TableDataInfo getMaMachineByRfidCode(@RequestParam(value = "rfidCode") String rfidCode) { return getDataTable(leaseOutDetailsService.getMaMachineByRfidCode(rfidCode)); } + /** + * 编码出库列表(web) + * + * @param + * @return 设备信息 + */ + @Log(title = "根据TypeId获取编码出库列表(web)", businessType = BusinessType.QUERY) + @GetMapping("/getDetailsByTypeId") + public AjaxResult getDetailsByApplyId(TmTask typeId) { + startPage(); + List detailsByApplyId = leaseOutDetailsService.getDetailsByApplyId(typeId); + return AjaxResult.success(getDataTable(detailsByApplyId)); + } /** * 领料出库,对库存处理 diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/LeaseApplyDetails.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/LeaseApplyDetails.java index 0e92a6bf..281ba810 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/LeaseApplyDetails.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/LeaseApplyDetails.java @@ -165,4 +165,8 @@ public class LeaseApplyDetails implements Serializable { private String endTime; @ApiModelProperty(value="关键字") private String keyWord; + @ApiModelProperty(value="设备状态") + private String maStatus; + @ApiModelProperty(value="预领数量-已领数量的差值") + private Double nums; } \ No newline at end of file diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/TmTask.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/TmTask.java index cf0b4d9b..4a91114c 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/TmTask.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/domain/TmTask.java @@ -245,6 +245,9 @@ public class TmTask implements Serializable { private String typeModelName; private String manageType; + private String maCode; + private String maId; + private String maStatus; private String typeId; @ApiModelProperty(value="预计领料时间(重庆)") @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/LeaseApplyDetailsMapper.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/LeaseApplyDetailsMapper.java index 01a398cf..985d790e 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/LeaseApplyDetailsMapper.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/LeaseApplyDetailsMapper.java @@ -49,4 +49,5 @@ public interface LeaseApplyDetailsMapper { List getByParentId(Integer parentId); + List getDetailsByApplyId(TmTask typeId); } \ No newline at end of file diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/LeaseOutDetailsMapper.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/LeaseOutDetailsMapper.java index 7a100629..e46b7066 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/LeaseOutDetailsMapper.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/LeaseOutDetailsMapper.java @@ -89,4 +89,6 @@ public interface LeaseOutDetailsMapper { int updSltInfo(SltAgreementInfo sltAgreementInfo); MaType selectByTypeId(@Param("record") LeaseOutDetails record); + + LeaseApplyDetails getOutboundNum(LeaseOutDetails record); } diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/LeaseOutDetailsService.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/LeaseOutDetailsService.java index e40b4ab0..85450ac3 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/LeaseOutDetailsService.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/LeaseOutDetailsService.java @@ -1,6 +1,7 @@ package com.bonus.sgzb.app.service; import com.bonus.sgzb.app.domain.LeaseApplyDetails; +import com.bonus.sgzb.app.domain.TmTask; import com.bonus.sgzb.base.api.domain.LeaseOutDetails; import com.bonus.sgzb.base.api.domain.MaMachine; import com.bonus.sgzb.common.core.web.domain.AjaxResult; @@ -74,4 +75,6 @@ public interface LeaseOutDetailsService { List proUseRecord(LeaseApplyDetails bean); AjaxResult submitOutRfid(List recordList); + + List getDetailsByApplyId(TmTask id); } diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/LeaseOutDetailsServiceImpl.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/LeaseOutDetailsServiceImpl.java index 8925846a..ab358dd0 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/LeaseOutDetailsServiceImpl.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/LeaseOutDetailsServiceImpl.java @@ -2,6 +2,7 @@ package com.bonus.sgzb.app.service.impl; import cn.hutool.core.collection.CollUtil; import com.bonus.sgzb.app.domain.LeaseApplyDetails; +import com.bonus.sgzb.app.domain.TmTask; import com.bonus.sgzb.app.mapper.LeaseApplyDetailsMapper; import com.bonus.sgzb.app.mapper.LeaseOutDetailsMapper; import com.bonus.sgzb.app.service.LeaseOutDetailsService; @@ -12,6 +13,7 @@ import com.bonus.sgzb.base.vo.MaLabelBindVO; import com.bonus.sgzb.common.core.utils.StringUtils; import com.bonus.sgzb.common.core.web.domain.AjaxResult; import com.bonus.sgzb.common.security.utils.SecurityUtils; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -30,6 +32,7 @@ import java.util.Objects; */ @Service(value = "LeaseOutDetailsService") +@Slf4j public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService { @Resource @@ -125,6 +128,11 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService { return AjaxResult.success(); } + @Override + public List getDetailsByApplyId(TmTask typeId) { + return leaseApplyDetailsMapper.getDetailsByApplyId(typeId); + } + /** * 领料出库处理 * @@ -134,72 +142,131 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService { @Override @Transactional public AjaxResult submitOut(LeaseOutDetails record) { - String maStatus = "15"; - double outNum = 0.1; - if (StringUtils.isNull(record)) { - return AjaxResult.error("领料出库失败,请检查参数是否填写完整!"); + int res = 0; + try { + // 1、判断是否重复提交 + res = checkRepeatSubmit(record); + if (res > 0) { + //2、判断库存是否足够 + res = checkStorageNum(record); + if (res > 0) { + // 3、插入出库记录,修改库存,修改机具状态 + res = insertRecords(record); + if (res == 0) { + throw new RuntimeException("出库失败,更新设备规格库存数量时出错!"); + } + // 4、修改任务状态(tm_task) + res = updateTaskStatus(record); + if (res == 0) { + throw new RuntimeException("出库失败,修改任务状态失败"); + } + // 5、插入结算记录 + String taskId = leaseOutDetailsMapper.getTaskId(record.getParentId()); + res = insSltInfo(taskId, record); + if (res == 0) { + throw new RuntimeException("出库失败,插入结算记录失败"); + } + } else { + return AjaxResult.error("领料出库失败,机具库存不足"); + } + } else { + return AjaxResult.error("您已提交,请勿重复点击"); + } + } catch (Exception e) { + log.error(e.getMessage()); + return AjaxResult.error("出库失败"); } - if (!(Objects.equals(0, record.getMaId()) || record.getMaId() == null)) { - String status = leaseOutDetailsMapper.getMachineStatus(record); - if (!maStatus.equals(status)) { - return AjaxResult.error("领料出库失败,该设备不是在库状态!"); + return AjaxResult.success("出库成功"); + } + + private int insertRecords(LeaseOutDetails record) { + int res = 0; + // 首先更新领料任务详情表的领料数及状态(lease_apply_details) + res = leaseOutDetailsMapper.updateLeaseApplyDetailsOutNum(record); + if (res > 0) { + // 插入领料出库明细表(lease_out_details) + res = leaseOutDetailsMapper.insertSelective(record); + if (res > 0) { + // 减少 (ma_type 设备规格表)的库存数量 + res = leaseOutDetailsMapper.updateMaTypeStockNum(record); + // 更新 (ma_machine 设备表)的状态 + leaseOutDetailsMapper.updateMaMachineStatus(record); } } + return res; + } + + private int updateTaskStatus(LeaseOutDetails record) { + int res = 0; + // 进行状态判断 + List leaseApplyDetailsList = leaseApplyDetailsMapper.getByParentId(record.getParentId()); + int i = 0; + for (LeaseApplyDetails bean : leaseApplyDetailsList) { + if (Objects.equals(bean.getPreNum(), bean.getAlNum())) { + i++; + } + } + String taskId = leaseOutDetailsMapper.getTaskId(record.getParentId()); + if (i == leaseApplyDetailsList.size()) { + leaseOutDetailsMapper.updateTaskStatus(taskId, 35); + res = 1; + } else { + leaseOutDetailsMapper.updateTaskStatus(taskId, 34); + res = 1; + } + return res; + } + + private int checkStorageNum(LeaseOutDetails record) { + double outNum = 0.1; + if (StringUtils.isNull(record)) { + return 0; + } + if (record.getOutNum() == null || record.getOutNum() < outNum) { - record.setOutNum(1.00); + record.setOutNum(0.00); } //先判断(ma_type 设备规格表)中的库存够不够出库的 MaType maType = leaseOutDetailsMapper.selectByTypeId(record); if (maType != null) { if (maType.getNum() == null || maType.getNum().compareTo(BigDecimal.valueOf(record.getOutNum())) < 0) { - return AjaxResult.error("领料出库失败,机具库存不足"); + return 0; } } - // 首先更新领料任务详情表的领料数及状态 - int updateLeaseApplyDetailsOutNum = leaseOutDetailsMapper.updateLeaseApplyDetailsOutNum(record); - // 插入领料出库明细表 - int insertSelectiveNum = leaseOutDetailsMapper.insertSelective(record); - // 减少 (ma_type 设备规格表)的库存数量 - int updateMaTypeStockNum = leaseOutDetailsMapper.updateMaTypeStockNum(record); - // 更新 (ma_machine 设备表)的状态 - int updateMaMachineStatus = leaseOutDetailsMapper.updateMaMachineStatus(record); - // 插入(tm_task_agreement 任务协议表)协议信息 - // int insertAgreementInfo = leaseOutDetailsMapper.insertAgreementInfo(record); + return 1; + } - // 进行状态判断 - if (updateLeaseApplyDetailsOutNum > 0) { - if (insertSelectiveNum > 0) { - if (updateMaTypeStockNum > 0) { - List leaseApplyDetailsList = leaseApplyDetailsMapper.getByParentId(record.getParentId()); - int i = 0; - for (LeaseApplyDetails bean : leaseApplyDetailsList) { - if (Objects.equals(bean.getPreNum(), bean.getAlNum())) { - i++; - } - } - String taskId = leaseOutDetailsMapper.getTaskId(record.getParentId()); - if (i == leaseApplyDetailsList.size()) { - leaseOutDetailsMapper.updateTaskStatus(taskId, 35); - } else { - leaseOutDetailsMapper.updateTaskStatus(taskId, 34); - } - int j = insSltInfo(taskId, record); - return j > 0 ? AjaxResult.success("领料出库成功!") : AjaxResult.error("领料出库失败,更新设备规格库存数量时出错!"); - } - return AjaxResult.error("出库失败,更新设备规格库存数量时出错!"); + private int checkRepeatSubmit(LeaseOutDetails record) { + String maStatus = "15"; + int res = 0; + if (record.getManageType() == 1) { + // 如果是数量出库校验待出库数量 + LeaseApplyDetails details = leaseOutDetailsMapper.getOutboundNum(record); + if (details == null) { + return res; + } else { + res = 1; + } + } else { + // 如果是编码出库判断是否在库 + if (!(Objects.equals(0, record.getMaId()) || record.getMaId() == null)) { + String status = leaseOutDetailsMapper.getMachineStatus(record); + if (!maStatus.equals(status)) { + return res; + } } - return AjaxResult.error("出库失败,插入领料出库明细错误!"); } - return AjaxResult.error("出库操作失败,更新领料数量及状态时出错!"); + return res; } public int insSltInfo(String taskId, LeaseOutDetails record) { + int res = 0; SltAgreementInfo sltAgreementInfo = leaseOutDetailsMapper.getSltAgreementInfo(record); if (sltAgreementInfo != null) { double num = Double.parseDouble(sltAgreementInfo.getNum()); double outNum = record.getOutNum(); sltAgreementInfo.setNum(String.valueOf(num + outNum)); - return leaseOutDetailsMapper.updSltInfo(sltAgreementInfo); + res = leaseOutDetailsMapper.updSltInfo(sltAgreementInfo); } else { String agreementId = leaseOutDetailsMapper.getAgreementId(taskId); String protocol = leaseOutDetailsMapper.getProtocol(agreementId); @@ -215,8 +282,9 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService { ma.setFinalPrice(ma.getLeasePrice()); } } - return leaseOutDetailsMapper.insSltInfo(record, agreementId, ma); + res = leaseOutDetailsMapper.insSltInfo(record, agreementId, ma); } + return res; } /** diff --git a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/LeaseApplyDetailsMapper.xml b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/LeaseApplyDetailsMapper.xml index 684ee4e2..acd585f1 100644 --- a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/LeaseApplyDetailsMapper.xml +++ b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/LeaseApplyDetailsMapper.xml @@ -40,6 +40,26 @@ select lad.id from lease_apply_details lad left join lease_apply_info lai on lad.parennt_id = lai.id where lai.task_id = #{taskId} + delete from lease_apply_details diff --git a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/LeaseOutDetailsMapper.xml b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/LeaseOutDetailsMapper.xml index 2a657765..5a9b8d45 100644 --- a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/LeaseOutDetailsMapper.xml +++ b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/LeaseOutDetailsMapper.xml @@ -384,4 +384,10 @@ GROUP BY tt.task_id + \ No newline at end of file