领料出库代码提交

This commit is contained in:
liang.chao 2024-03-28 18:11:48 +08:00
parent 0f4ae97bad
commit 759a4e22ff
10 changed files with 238 additions and 72 deletions

View File

@ -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;
}

View File

@ -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<TmTask> detailsByApplyId = leaseOutDetailsService.getDetailsByApplyId(typeId);
return AjaxResult.success(getDataTable(detailsByApplyId));
}
/**
* 领料出库对库存处理

View File

@ -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;
}

View File

@ -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")

View File

@ -49,4 +49,5 @@ public interface LeaseApplyDetailsMapper {
List<LeaseApplyDetails> getByParentId(Integer parentId);
List<TmTask> getDetailsByApplyId(TmTask typeId);
}

View File

@ -89,4 +89,6 @@ public interface LeaseOutDetailsMapper {
int updSltInfo(SltAgreementInfo sltAgreementInfo);
MaType selectByTypeId(@Param("record") LeaseOutDetails record);
LeaseApplyDetails getOutboundNum(LeaseOutDetails record);
}

View File

@ -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<LeaseApplyDetails> proUseRecord(LeaseApplyDetails bean);
AjaxResult submitOutRfid(List<LeaseOutDetails> recordList);
List<TmTask> getDetailsByApplyId(TmTask id);
}

View File

@ -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<TmTask> 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<LeaseApplyDetails> 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<LeaseApplyDetails> 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;
}
/**

View File

@ -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}
</select>
<select id="getDetailsByApplyId" resultType="com.bonus.sgzb.app.domain.TmTask">
SELECT
mt2.type_name AS typeName,
mt.type_name AS typeModelName,
mt.type_id AS typeId,
mm.ma_code AS maCode,
mm.ma_id AS maId,
sd.NAME AS maStatus
FROM
ma_type mt
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
LEFT JOIN ma_machine mm ON mt.type_id = mm.type_id
LEFT JOIN sys_dic sd ON sd.id = mm.ma_status
WHERE
mm.ma_status = 15
AND mt.type_id = #{typeId}
<if test="maCode != null and maCode !=''">
AND mm.ma_code like concat('%', #{maCode}, '%')
</if>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from lease_apply_details

View File

@ -384,4 +384,10 @@
GROUP BY
tt.task_id
</select>
<select id="getOutboundNum" resultType="com.bonus.sgzb.app.domain.LeaseApplyDetails">
SELECT pre_num AS preNum,
pre_num - IFNULL(al_num, 0) AS nums
FROM lease_apply_details
WHERE id = #{id} AND (pre_num - IFNULL(al_num, 0)) > 0
</select>
</mapper>