refactor(material): 优化租赁模块代码结构和逻辑
- 新增 GlobalConstants 类,定义常用常量 - 优化 LeaseApplyInfoServiceImpl 和 LeaseOutDetailsServiceImpl 中的代码逻辑
This commit is contained in:
parent
37023bbae4
commit
7338b210e9
|
|
@ -225,6 +225,15 @@ public class GlobalConstants {
|
|||
*/
|
||||
public static final char CHAR_9 = '9';
|
||||
|
||||
/**
|
||||
* 整数 0
|
||||
*/
|
||||
public static final int INT_0 = 0;
|
||||
|
||||
/**
|
||||
* 整数 1
|
||||
*/
|
||||
public static final int INT_1 = 1;
|
||||
|
||||
/**
|
||||
* 整数 2
|
||||
|
|
|
|||
|
|
@ -66,6 +66,9 @@ public class LeaseOutDetails extends BaseEntity {
|
|||
@ApiModelProperty(value = "预领料数")
|
||||
private BigDecimal outNum;
|
||||
|
||||
@ApiModelProperty(value = "可退还数量")
|
||||
private BigDecimal returnNum;
|
||||
|
||||
/** 数据所属组织 */
|
||||
@Excel(name = "数据所属组织")
|
||||
@ApiModelProperty(value = "数据所属组织")
|
||||
|
|
@ -160,4 +163,7 @@ public class LeaseOutDetails extends BaseEntity {
|
|||
@ApiModelProperty(value = "状态")
|
||||
private String status;
|
||||
|
||||
@ApiModelProperty(value = "来源")
|
||||
private Integer source;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import java.net.URLEncoder;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.bonus.common.biz.constant.GlobalConstants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
|
|
@ -987,7 +989,7 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
|||
* @param leaseApplyInfo 领料任务info
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult publish(LeaseApplyInfo leaseApplyInfo) {
|
||||
if (leaseApplyInfo.getId() == null) {
|
||||
return AjaxResult.error("ID为空,请完善后重新发布!");
|
||||
|
|
@ -999,7 +1001,7 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
|||
leaseApplyInfo.setReleaseTime(DateUtils.getTime());
|
||||
leaseApplyInfo.setPublisher(SecurityUtils.getLoginUser().getUserid());
|
||||
int result = leaseApplyInfoMapper.updateLeaseApplyInfo(leaseApplyInfo);
|
||||
if (result > 0) {
|
||||
if (result > GlobalConstants.INT_0) {
|
||||
// 同步修改tm_task任务状态, 如果不需要审核,改成 LEASE_TASK_IN_PROGRESS, 如果需要审核,改成 LEASE_TASK_TO_AUDIT
|
||||
TmTask tmTask = new TmTask();
|
||||
tmTask.setTaskType(TmTaskTypeEnum.TM_TASK_LEASE.getTaskTypeId());
|
||||
|
|
@ -1030,7 +1032,7 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
|||
}
|
||||
try {
|
||||
int result = leaseApplyInfoMapper.updateLeaseApplyInfo(leaseApplyInfo);
|
||||
if (result > 0) {
|
||||
if (result > GlobalConstants.INT_0) {
|
||||
// 同步修改tm_task任务状态, 如果不需要审核,改成 LEASE_TASK_IN_PROGRESS, 如果需要审核,改成 LEASE_TASK_TO_AUDIT
|
||||
TmTask tmTask = new TmTask();
|
||||
tmTask.setTaskType(TmTaskTypeEnum.TM_TASK_LEASE.getTaskTypeId());
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import java.time.LocalDate;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.bonus.common.biz.constant.GlobalConstants;
|
||||
import com.bonus.common.biz.constant.MaterialConstants;
|
||||
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
|
||||
import com.bonus.common.biz.enums.*;
|
||||
|
|
@ -57,6 +59,13 @@ import javax.annotation.Resource;
|
|||
@Service
|
||||
@Slf4j
|
||||
public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
||||
|
||||
// 来源1: 单位直接领用
|
||||
private static final Integer DIRECT_RESOURCE = 1;
|
||||
|
||||
// 来源2: 班组领用同步过来的数据
|
||||
private static final Integer SYNC_RESOURCE = 2;
|
||||
|
||||
@Autowired
|
||||
LeaseApplyInfoMapper leaseApplyInfoMapper;
|
||||
|
||||
|
|
@ -178,7 +187,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult leaseOut(LeaseOutDetails record) {
|
||||
int res = 0;
|
||||
int res;
|
||||
try {
|
||||
// 1、判断库存是否足够
|
||||
boolean isEnough = checkStorageIsEnough(record);
|
||||
|
|
@ -191,52 +200,62 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
// 检查库存数量是否足够
|
||||
res = checkStorageNum(record);
|
||||
|
||||
if (res > 0) {
|
||||
if (res > GlobalConstants.INT_0) {
|
||||
// 3、插入出库记录,修改库存,修改机具状态
|
||||
res = insertRecords(record);
|
||||
if (res == 0) {
|
||||
if (res == GlobalConstants.INT_0) {
|
||||
throw new RuntimeException("出库失败,更新设备规格库存数量时出错!");
|
||||
}
|
||||
// 4、修改任务状态(tm_task)
|
||||
res = updateTaskStatus(record);
|
||||
if (res == 0) {
|
||||
if (res == GlobalConstants.INT_0) {
|
||||
throw new RuntimeException("出库失败,修改任务状态失败");
|
||||
}
|
||||
// 5、插入结算记录
|
||||
String taskId = leaseApplyInfoMapper.getTaskId(record.getParentId());
|
||||
record.setTaskId(taskId);
|
||||
|
||||
// 判断如果是班组领料,则插入原本项目部的协议结算记录
|
||||
if (record.getLeaseUnitIsTeam() != null && record.getLeaseUnitIsTeam()) {
|
||||
// 设置数据来源是2(班组同步)
|
||||
record.setSource(SYNC_RESOURCE);
|
||||
// 暂存现在出库的班组单位ID
|
||||
Integer thisOutId = record.getLeaseUnitId();
|
||||
// 查询班组挂靠的项目部协议ID
|
||||
Long projectUnitAgreementId = leaseApplyInfoMapper.selectProjectUnitAgreementIdByTeamAndProject(record.getLeaseUnitId(), record.getLeaseProjectId());
|
||||
if (projectUnitAgreementId != null && projectUnitAgreementId > 0L) {
|
||||
if (projectUnitAgreementId != null && projectUnitAgreementId > GlobalConstants.INT_0) {
|
||||
record.setProjectUnitAgreementId(projectUnitAgreementId);
|
||||
} else {
|
||||
return AjaxResult.error("出库失败,没有找到班组所属项目部协议信息");
|
||||
}
|
||||
// 设置默认可退还数量等同于领用数量,因为班组的协议可以直接去分公司退还, 并设置source来源为2(班组领用)
|
||||
record.setReturnNum(record.getOutNum());
|
||||
// 查询申请领料的项目部单位ID
|
||||
Long originLeaseUnitId = leaseApplyInfoMapper.selectLeaseApplyInfoUnitIdByLeaseId(record.getParentId());
|
||||
record.setLeaseUnitId(Math.toIntExact(originLeaseUnitId));
|
||||
// 插入项目部领料的结算记录
|
||||
int inserts = insSltInfo(taskId, record);
|
||||
System.out.println("插入原本项目部领料结算记录" + (inserts > 0 ? "成功" : "失败"));
|
||||
System.out.println("插入原本项目部领料结算记录" + (inserts > GlobalConstants.INT_0 ? "成功" : "失败"));
|
||||
|
||||
// 恢复出库班组单位ID
|
||||
record.setLeaseUnitId(thisOutId);
|
||||
record.setLeaseUnitIsTeam(false);
|
||||
// 设置可退还数量是0,因为默认全部发给班组了,不允许项目部协议直接退,要等班组退还到项目部后才能恢复
|
||||
record.setReturnNum(BigDecimal.ZERO);
|
||||
}
|
||||
// 设置数据来源是1(直领)
|
||||
record.setSource(DIRECT_RESOURCE);
|
||||
res = insSltInfo(taskId, record);
|
||||
if (res == 0) {
|
||||
if (res == GlobalConstants.INT_0) {
|
||||
throw new RuntimeException("出库失败,插入结算记录失败");
|
||||
}
|
||||
// 6、如果标准箱入库,需要将设备从标准箱移出
|
||||
if (record.getMaId() != null) {
|
||||
if (!Objects.isNull(record.getMaId())) {
|
||||
// 先查询设备是否在标准箱中
|
||||
List<BmQrBoxInfo> list = bmQrBoxMapper.selectByMaId(record.getMaId());
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
res = updateBoxBind(record);
|
||||
if (res == 0) {
|
||||
if (res == GlobalConstants.INT_0) {
|
||||
throw new RuntimeException("出库失败,移出设备失败");
|
||||
}
|
||||
}
|
||||
|
|
@ -275,7 +294,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
// 新增班组
|
||||
tbTeam.setCreateUser(SecurityUtils.getLoginUser().getUserid().toString());
|
||||
int result = bmTeamMapper.insert(tbTeam);
|
||||
if (result <= 0) {
|
||||
if (result <= GlobalConstants.INT_0) {
|
||||
return AjaxResult.error(HttpCodeEnum.UPDATE_TO_DATABASE.getCode(), HttpCodeEnum.UPDATE_TO_DATABASE.getMsg());
|
||||
}
|
||||
bmAgreementInfo.setUnitId(tbTeam.getId());
|
||||
|
|
@ -290,7 +309,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
record.setAgreementId(info.getAgreementId());
|
||||
} else {
|
||||
int count = bmAgreementInfoMapper.insertBmAgreementInfoClz(bmAgreementInfo);
|
||||
if (count > 0) {
|
||||
if (count > GlobalConstants.INT_0) {
|
||||
record.setAgreementId(bmAgreementInfo.getAgreementId());
|
||||
} else {
|
||||
return AjaxResult.error("新增bm_agreement_info表失败");
|
||||
|
|
@ -304,11 +323,11 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
MaterialLeaseApplyInfo materialLeaseApplyInfo = new MaterialLeaseApplyInfo();
|
||||
materialLeaseApplyInfo.setCode(taskCode);
|
||||
materialLeaseApplyInfo.setTaskId(tmTask.getTaskId());
|
||||
materialLeaseApplyInfo.setLeaseStyle("2");
|
||||
materialLeaseApplyInfo.setLeaseStyle(SYNC_RESOURCE.toString());
|
||||
materialLeaseApplyInfo.setTeamId(bmAgreementInfo.getUnitId().toString());
|
||||
materialLeaseApplyInfo.setProjectId(record.getLeaseProjectId().toString());
|
||||
int count = materialLeaseInfoMapper.insertLeaseApplyInfo(materialLeaseApplyInfo);
|
||||
if (count > 0) {
|
||||
if (count > GlobalConstants.INT_0) {
|
||||
return insertPurchaseCheckDetails(record, createBy, tmTask.getTaskId(), materialLeaseApplyInfo.getId());
|
||||
} else {
|
||||
return AjaxResult.error("新增任务失败,lease_apply_info表插入0条");
|
||||
|
|
@ -322,7 +341,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
record.setParentId(info.getId());
|
||||
record.setCreateTime(DateUtils.getNowDate());
|
||||
record.setCreateBy(createBy);
|
||||
record.setIsFinished(1);
|
||||
record.setIsFinished(GlobalConstants.INT_1);
|
||||
MaterialLeaseApplyDetails details = materialLeaseInfoMapper.selectDetailsById(info);
|
||||
if (details != null) {
|
||||
// 走编辑
|
||||
|
|
@ -330,7 +349,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
details.setParentId(info.getId());
|
||||
details.setTypeId(record.getTypeId());
|
||||
int count = materialLeaseInfoMapper.updateLeaseApplyDetails(details);
|
||||
if (count < 0) {
|
||||
if (count < GlobalConstants.INT_1) {
|
||||
throw new Exception("更新clz_lease_apply_details表数据失败");
|
||||
}
|
||||
} else {
|
||||
|
|
@ -338,7 +357,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
record.setPreNum(record.getOutNum());
|
||||
record.setAlNum(record.getOutNum());
|
||||
res = materialLeaseInfoMapper.insertLeaseApplyDetails(record);
|
||||
if (res <= 0) {
|
||||
if (res <= GlobalConstants.INT_0) {
|
||||
throw new Exception("新增clz_lease_apply_details表数据失败");
|
||||
}
|
||||
}
|
||||
|
|
@ -346,7 +365,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
if (record.getMaId() != null) {
|
||||
// 编码直接走新增
|
||||
res = materialLeaseInfoMapper.insertLeaseOutDetails(record);
|
||||
if (res <= 0) {
|
||||
if (res <= GlobalConstants.INT_0) {
|
||||
throw new Exception("新增clz_lease_out_details表数据失败");
|
||||
}
|
||||
res = insSltInfoClz(task.getTaskId(), record);
|
||||
|
|
@ -357,12 +376,12 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
if (leaseOutDetails != null) {
|
||||
leaseOutDetails.setOutNum(record.getOutNum());
|
||||
res = materialLeaseInfoMapper.updateLeaseOutDetails(leaseOutDetails);
|
||||
if (res <= 0) {
|
||||
if (res <= GlobalConstants.INT_0) {
|
||||
throw new Exception("更新clz_lease_out_details表数据失败");
|
||||
}
|
||||
} else {
|
||||
res = materialLeaseInfoMapper.insertLeaseOutDetails(record);
|
||||
if (res <= 0) {
|
||||
if (res <= GlobalConstants.INT_0) {
|
||||
throw new Exception("新增clz_lease_out_details表数据失败");
|
||||
}
|
||||
}
|
||||
|
|
@ -398,17 +417,17 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
record.setParentId(id);
|
||||
record.setIsFinished(1);
|
||||
int res = materialLeaseInfoMapper.insertLeaseOutDetails(record);
|
||||
if (res == 0) {
|
||||
if (res == GlobalConstants.INT_0) {
|
||||
throw new RuntimeException("出库失败,插入结算记录失败");
|
||||
}
|
||||
record.setPreNum(record.getOutNum());
|
||||
record.setAlNum(record.getOutNum());
|
||||
res = materialLeaseInfoMapper.insertLeaseApplyDetails(record);
|
||||
if (res == 0) {
|
||||
if (res == GlobalConstants.INT_0) {
|
||||
throw new RuntimeException("出库失败,插入结算记录失败");
|
||||
}
|
||||
res = insSltInfoClz(taskId, record);
|
||||
if (res == 0) {
|
||||
if (res == GlobalConstants.INT_0) {
|
||||
throw new RuntimeException("出库失败,插入结算记录失败");
|
||||
}
|
||||
return AjaxResult.success("出库成功");
|
||||
|
|
@ -421,7 +440,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
* @return
|
||||
*/
|
||||
private int insSltInfoClz(Long taskId, LeaseOutDetails record) {
|
||||
int res = 0;
|
||||
int res = GlobalConstants.INT_0;
|
||||
MaterialSltAgreementInfo sltAgreementInfo = materialLeaseInfoMapper.getSltAgreementInfo(record);
|
||||
if (sltAgreementInfo != null) {
|
||||
BigDecimal num = sltAgreementInfo.getNum();
|
||||
|
|
@ -474,7 +493,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult leaseOutBack(LeaseOutDetails leaseOutDetails) {
|
||||
int res = 0;
|
||||
int res;
|
||||
try {
|
||||
// 1 根据任务id查询此任务是否已经完结
|
||||
if (StringUtils.isNotBlank(leaseOutDetails.getPublishTask())) {
|
||||
|
|
@ -484,7 +503,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
List<LeaseApplyInfo> leaseApplyOutList = leaseApplyInfoMapper.selectPublishList(leaseApplyInfo);
|
||||
if (!CollectionUtils.isEmpty(leaseApplyOutList)) {
|
||||
for (LeaseApplyInfo applyInfo : leaseApplyOutList) {
|
||||
if (applyInfo.getPreCountNum().compareTo(applyInfo.getAlNum()) == 0) {
|
||||
if (applyInfo.getPreCountNum().compareTo(applyInfo.getAlNum()) == GlobalConstants.INT_0) {
|
||||
return AjaxResult.error("该任务已完成,不能进行退库操作");
|
||||
}
|
||||
}
|
||||
|
|
@ -496,20 +515,20 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
}
|
||||
}
|
||||
// 2、插入出库记录,修改库存,修改机具状态
|
||||
res = updateRecords(leaseOutDetails);
|
||||
if (res == 0) {
|
||||
throw new RuntimeException("出库退回失败,更新设备规格库存数量时出错!");
|
||||
}
|
||||
// 3、修改任务状态(tm_task)
|
||||
if (StringUtils.isNotBlank(leaseOutDetails.getTaskId())) {
|
||||
res = editTaskStatus(leaseOutDetails);
|
||||
if (res == 0) {
|
||||
throw new RuntimeException("出库退回失败,修改任务状态失败");
|
||||
res = updateRecords(leaseOutDetails);
|
||||
if (res == GlobalConstants.INT_0) {
|
||||
throw new RuntimeException("出库退回失败,更新设备规格库存数量时出错!");
|
||||
}
|
||||
// 3、修改任务状态(tm_task)
|
||||
if (StringUtils.isNotBlank(leaseOutDetails.getTaskId())) {
|
||||
res = editTaskStatus(leaseOutDetails);
|
||||
if (res == GlobalConstants.INT_0) {
|
||||
throw new RuntimeException("出库退回失败,修改任务状态失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
// 4、删除结算记录
|
||||
res = deleteSltInfo(leaseOutDetails);
|
||||
if (res == 0) {
|
||||
if (res == GlobalConstants.INT_0) {
|
||||
throw new RuntimeException("出库失败,插入结算记录失败");
|
||||
}
|
||||
} catch (RuntimeException re) {
|
||||
|
|
@ -525,14 +544,14 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
*/
|
||||
@Override
|
||||
public AjaxResult leaseOutByInfo(LeaseOutDetails record) {
|
||||
int res = 0;
|
||||
int res = GlobalConstants.INT_0;
|
||||
try {
|
||||
if (!CollectionUtils.isEmpty(record.getMaCodeList())) {
|
||||
record.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString());
|
||||
record.setCreateTime(DateUtils.getNowDate());
|
||||
record.setOutNum(record.getInputNum());
|
||||
res = leaseOutDetailsMapper.insertLeaseOutDetails(record);
|
||||
if (res == 0) {
|
||||
if (res == GlobalConstants.INT_0) {
|
||||
return AjaxResult.error("出库失败");
|
||||
}
|
||||
for (LeaseOutDetails leaseOutDetails : record.getMaCodeList()) {
|
||||
|
|
@ -543,12 +562,12 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
leaseOutDetails.setLeaseUnit(record.getLeaseUnit());
|
||||
leaseOutDetails.setLeaseProject(record.getLeaseProject());
|
||||
res = insertRecordsByInfo(leaseOutDetails);
|
||||
if (res == 0) {
|
||||
if (res == GlobalConstants.INT_0) {
|
||||
throw new RuntimeException("出库失败,更新设备规格库存数量时出错!");
|
||||
}
|
||||
// 4、修改任务状态(tm_task)
|
||||
res = updateTaskStatus(leaseOutDetails);
|
||||
if (res == 0) {
|
||||
if (res == GlobalConstants.INT_0) {
|
||||
throw new RuntimeException("出库失败,修改任务状态失败");
|
||||
}
|
||||
// 6、如果标准箱入库,需要将设备从标准箱移出
|
||||
|
|
@ -557,7 +576,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
List<BmQrBoxInfo> list = bmQrBoxMapper.selectByMaId(leaseOutDetails.getMaId());
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
res = updateBoxBind(leaseOutDetails);
|
||||
if (res == 0) {
|
||||
if (res == GlobalConstants.INT_0) {
|
||||
throw new RuntimeException("出库失败,移出设备失败");
|
||||
}
|
||||
}
|
||||
|
|
@ -579,21 +598,19 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
* @return
|
||||
*/
|
||||
private int insertRecordsByInfo(LeaseOutDetails record) {
|
||||
int res = 0;
|
||||
int res = GlobalConstants.INT_0;
|
||||
// 首先更新领料任务详情表的领料数及状态(lease_apply_details)
|
||||
res = leaseApplyDetailsMapper.updateLeaseApplyDetailsOutNum(record);
|
||||
LeaseApplyDetails leaseApplyDetails = leaseApplyDetailsMapper.getLeaseApplyDetails(record);
|
||||
if (leaseApplyDetails.getPreNum().equals(leaseApplyDetails.getAlNum()) || leaseApplyDetails.getAuditNum().equals(leaseApplyDetails.getAlNum())) {
|
||||
leaseApplyDetailsMapper.updateLeaseApplyDetailsByLeaseOutRecord(record);
|
||||
}
|
||||
if (res > 0) {
|
||||
if (res > GlobalConstants.INT_0) {
|
||||
// 插入领料出库明细表(lease_out_details)
|
||||
record.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString());
|
||||
if (res > 0) {
|
||||
res += leaseOutDetailsMapper.insertLeaseOutNum(record);
|
||||
record.setIsBack(0);
|
||||
res += leaseOutDetailsMapper.updateMachine(record);
|
||||
}
|
||||
res += leaseOutDetailsMapper.insertLeaseOutNum(record);
|
||||
record.setIsBack(GlobalConstants.INT_0);
|
||||
res += leaseOutDetailsMapper.updateMachine(record);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
@ -622,14 +639,14 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
* @return
|
||||
*/
|
||||
private int updateRecords(LeaseOutDetails leaseOutDetails) {
|
||||
int res = 0;
|
||||
int res = GlobalConstants.INT_0;
|
||||
// 首先更新领料任务详情表的领料数及状态(lease_apply_details)
|
||||
leaseOutDetails.setUpdateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
||||
res = leaseApplyDetailsMapper.updateBackDetailsOutNum(leaseOutDetails);
|
||||
if (res > 0) {
|
||||
if (res > GlobalConstants.INT_0) {
|
||||
// 删除领料出库明细表(lease_out_details)
|
||||
res = leaseOutDetailsMapper.deleteLeaseOutDetails(leaseOutDetails);
|
||||
if (res > 0) {
|
||||
if (res > GlobalConstants.INT_0) {
|
||||
// 普通机具减少 (ma_type 设备规格表)的库存数量
|
||||
res = typeMapper.addMaTypeStockNum(leaseOutDetails);
|
||||
// 更新 (ma_machine 设备表)的状态
|
||||
|
|
@ -680,25 +697,23 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
return false;
|
||||
}
|
||||
} else if (record.getManageType().equals(MaTypeManageTypeEnum.CODE_DEVICE.getTypeId())) {
|
||||
if (!(Objects.equals(0, record.getMaId()) || record.getMaId() == null)) {
|
||||
if (!(Objects.equals(0L, record.getMaId()) || record.getMaId() == null)) {
|
||||
String status = machineMapper.getMachineStatus(record);
|
||||
if (!String.valueOf(MaMachineStatusEnum.IN_STORE.getStatus()).equals(status)) {
|
||||
return false;
|
||||
}
|
||||
return String.valueOf(MaMachineStatusEnum.IN_STORE.getStatus()).equals(status);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private int updateTaskStatus(LeaseOutDetails record) {
|
||||
int res = 0;
|
||||
int res;
|
||||
// 领用任务单独判断
|
||||
if (StringUtils.isNotBlank(record.getPublishTask())) {
|
||||
return 1;
|
||||
return GlobalConstants.INT_1;
|
||||
}
|
||||
// 进行状态判断
|
||||
List<LeaseApplyDetails> leaseApplyDetailsList = leaseApplyDetailsMapper.getByParentId(record.getParentId());
|
||||
int i = 0;
|
||||
int i = GlobalConstants.INT_0;
|
||||
for (LeaseApplyDetails bean : leaseApplyDetailsList) {
|
||||
if (Objects.equals(bean.getPreNum(), bean.getAlNum())) {
|
||||
i++;
|
||||
|
|
@ -707,18 +722,18 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
String taskId = leaseApplyInfoMapper.getTaskId(record.getParentId());
|
||||
if (i == leaseApplyDetailsList.size()) {
|
||||
tmTaskMapper.updateTaskStatus(taskId, LeaseTaskStatusEnum.LEASE_TASK_FINISHED.getStatus());
|
||||
res = 1;
|
||||
res = GlobalConstants.INT_1;
|
||||
} else {
|
||||
tmTaskMapper.updateTaskStatus(taskId, LeaseTaskStatusEnum.LEASE_TASK_IN_PROGRESS.getStatus());
|
||||
res = 1;
|
||||
res = GlobalConstants.INT_1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private int checkStorageNum(LeaseOutDetails record) {
|
||||
BigDecimal outNum = BigDecimal.valueOf(0);
|
||||
BigDecimal outNum = BigDecimal.valueOf(GlobalConstants.INT_0);
|
||||
if (StringUtils.isNull(record)) {
|
||||
return 0;
|
||||
return GlobalConstants.INT_0;
|
||||
}
|
||||
|
||||
if (record.getOutNum() == null) {
|
||||
|
|
@ -729,12 +744,12 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
if (maType != null) {
|
||||
if ("0".equals(maType.getManageType())) {
|
||||
int count = typeMapper.getCountOfCodeMachine(record);
|
||||
if (BigDecimal.valueOf(count).compareTo(record.getOutNum()) < 0) {
|
||||
return 0;
|
||||
if (BigDecimal.valueOf(count).compareTo(record.getOutNum()) < GlobalConstants.INT_0) {
|
||||
return GlobalConstants.INT_0;
|
||||
}
|
||||
} else if ("1".equals(maType.getManageType())) {
|
||||
if (maType.getStorageNum() == null || maType.getStorageNum().compareTo(record.getOutNum()) < 0) {
|
||||
return 0;
|
||||
if (maType.getStorageNum() == null || maType.getStorageNum().compareTo(record.getOutNum()) < GlobalConstants.INT_0) {
|
||||
return GlobalConstants.INT_0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -742,7 +757,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
}
|
||||
|
||||
private int insertRecords(LeaseOutDetails record) {
|
||||
int res = 0;
|
||||
int res = GlobalConstants.INT_0;
|
||||
LeaseApplyDetails leaseApplyDetails = new LeaseApplyDetails();
|
||||
// 首先更新领料任务详情表的领料数及状态(lease_apply_details)
|
||||
if (StringUtils.isNotBlank(record.getPublishTask())) {
|
||||
|
|
@ -757,11 +772,11 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
if (leaseApplyDetails.getPreNum().equals(leaseApplyDetails.getAlNum()) || leaseApplyDetails.getAuditNum().equals(leaseApplyDetails.getAlNum())) {
|
||||
leaseApplyDetailsMapper.updateLeaseApplyDetailsByLeaseOutRecord(record);
|
||||
}
|
||||
if (res > 0) {
|
||||
if (res > GlobalConstants.INT_0) {
|
||||
// 插入领料出库明细表(lease_out_details)
|
||||
record.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString());
|
||||
res = leaseOutDetailsMapper.insertLeaseOutDetails(record);
|
||||
if (res > 0) {
|
||||
if (res > GlobalConstants.INT_0) {
|
||||
// 普通机具减少 (ma_type 设备规格表)的库存数量
|
||||
res = typeMapper.updateMaTypeStockNum(record);
|
||||
if (record.getMaId() != null) {
|
||||
|
|
@ -786,7 +801,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
* @param record 出库记录
|
||||
*/
|
||||
public int insSltInfo(String taskId, LeaseOutDetails record) {
|
||||
int res = 0;
|
||||
int res = GlobalConstants.INT_0;
|
||||
// 根据发布批次查询结算协议信息
|
||||
SltAgreementInfo sltAgreementInfo;
|
||||
// 判断是否是班组领用
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@ public class PurchaseCheckInfoServiceImpl implements IPurchaseCheckInfoService {
|
|||
if (isAllowPartTransfer) {
|
||||
maTypeNames = purchaseCheckDetailsMapper.selectMaTypeNameByTaskIdsBatch(taskIds, purchaseQueryDto.getStatusList());
|
||||
} else {
|
||||
maTypeNames = purchaseCheckDetailsMapper.selectMaTypeNameByTaskIdsBatch(taskIds, new ArrayList<>());
|
||||
maTypeNames = purchaseCheckDetailsMapper.selectMaTypeNameByTaskIdsBatch(taskIds, Collections.emptyList());
|
||||
}
|
||||
Map<Long, String> maTypeNameMap = maTypeNames.stream()
|
||||
.filter(info -> info.getTaskId() != null)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import java.util.*;
|
|||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.bonus.common.biz.constant.GlobalConstants;
|
||||
import com.bonus.common.biz.domain.ProjectTreeBuild;
|
||||
import com.bonus.common.biz.domain.ProjectTreeNode;
|
||||
import com.bonus.common.biz.enums.TmTaskTypeEnum;
|
||||
|
|
@ -566,9 +567,9 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
|||
// 更新协议状态
|
||||
int beforeSettlementCount = sltAgreementInfoMapper.getBeforeSettlementCount(new SltInfoVo().setAgreementId(sltAgreementApply.getAgreementId()));
|
||||
// 根据待审核+已审核的数量来决定更新到哪种状态
|
||||
sltAgreementApply.setIsSlt(beforeSettlementCount > 0 ? 2 : 0);
|
||||
sltAgreementApply.setIsSlt(beforeSettlementCount > GlobalConstants.INT_0 ? GlobalConstants.INT_2 : GlobalConstants.INT_0);
|
||||
int countTwo = sltAgreementInfoMapper.updateBmAgreementReject(sltAgreementApply);
|
||||
if(countTwo != 1) {
|
||||
if(countTwo != GlobalConstants.INT_1) {
|
||||
return AjaxResult.error("bm_agreement_info修改失败");
|
||||
}
|
||||
return AjaxResult.success();
|
||||
|
|
@ -576,7 +577,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
|||
} else {
|
||||
//通过
|
||||
int count = sltAgreementInfoMapper.costExame(sltAgreementApply);
|
||||
if (count == 0) {
|
||||
if (count == GlobalConstants.INT_0) {
|
||||
return AjaxResult.error("结算审批失败");
|
||||
} else {
|
||||
return AjaxResult.success();
|
||||
|
|
@ -592,11 +593,11 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
|||
SltInfoVo sltInfoVo = new SltInfoVo();
|
||||
sltInfoVo.setUnitName(info.getUnitName());
|
||||
sltInfoVo.setProjectName(info.getProjectName());
|
||||
BigDecimal leaseCost = BigDecimal.valueOf(0.00);
|
||||
BigDecimal repairCost = BigDecimal.valueOf(0.00);
|
||||
BigDecimal scrapCost = BigDecimal.valueOf(0.00);
|
||||
BigDecimal loseCost = BigDecimal.valueOf(0.00);
|
||||
BigDecimal reductionCost = BigDecimal.valueOf(0.00);
|
||||
BigDecimal leaseCost = BigDecimal.ZERO;
|
||||
BigDecimal repairCost = BigDecimal.ZERO;
|
||||
BigDecimal scrapCost = BigDecimal.ZERO;
|
||||
BigDecimal loseCost = BigDecimal.ZERO;
|
||||
BigDecimal reductionCost = BigDecimal.ZERO;
|
||||
//租赁费用列表
|
||||
List<SltAgreementInfo> leaseList = getLeaseList(info);
|
||||
//维修费用列表
|
||||
|
|
@ -646,7 +647,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
|||
sltInfoVo.setReductionCost(reductionCost);
|
||||
List<SltAgreementRelation> relations = getRelations(leaseList, repairList, scrapList, loseList, info);
|
||||
//加上减免
|
||||
if (relations.size()>0){
|
||||
if (!relations.isEmpty()){
|
||||
relations.get(0).setSubCost(reductionCost);
|
||||
}
|
||||
sltInfoVo.setRelations(relations);
|
||||
|
|
@ -663,24 +664,23 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
|||
List<ProjectTreeNode> groupList = new ArrayList<>();
|
||||
List<ProjectTreeNode> list = new ArrayList<>();
|
||||
try {
|
||||
if(bmProject.getUnitIds()!=null){
|
||||
Map<Integer,Integer> map= new HashMap<>();
|
||||
if (bmProject.getUnitIds() != null) {
|
||||
Map<Integer,Integer> map = new HashMap<>();
|
||||
for (int i = 0; i < bmProject.getUnitIds().length; i++) {
|
||||
int id = bmProject.getUnitIds()[i];
|
||||
int[] projectIds= sltAgreementInfoMapper.getProjectListByUnitIds(bmProject.getUnitIds()[i]);
|
||||
Map<Integer,Integer> mapTemp=new HashMap<>();
|
||||
for (int j = 0; j < projectIds.length; j++) {
|
||||
mapTemp.put(projectIds[j],1);
|
||||
for (int projectId : projectIds) {
|
||||
mapTemp.put(projectId, 1);
|
||||
}
|
||||
mapTemp.forEach((k,v)->{
|
||||
if(map.containsKey(k)){
|
||||
map.put(Integer.valueOf(k),map.get(k)+v);
|
||||
}else{
|
||||
map.put(Integer.valueOf(k),v);
|
||||
mapTemp.forEach((k,v)-> {
|
||||
if (map.containsKey(k)) {
|
||||
map.put(k, map.get(k) + v);
|
||||
} else {
|
||||
map.put(k, v);
|
||||
}
|
||||
});
|
||||
}
|
||||
if(map.size()>0){
|
||||
if(!map.isEmpty()){
|
||||
List<Integer> keys = new ArrayList<>();
|
||||
for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
|
||||
if (entry.getValue() == bmProject.getUnitIds().length) {
|
||||
|
|
@ -696,11 +696,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
// list = sltAgreementInfoMapper.getProjectListByUnitIds(bmProject);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
// 创建树形结构(数据集合作为参数)
|
||||
ProjectTreeBuild treeBuild = new ProjectTreeBuild(list);
|
||||
|
|
@ -716,7 +712,7 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
|
|||
|
||||
@Override
|
||||
public AjaxResult getAgreementInfoById(SelectDto dto) {
|
||||
List<AgreementVo> vo = new ArrayList<>();
|
||||
List<AgreementVo> vo;
|
||||
try {
|
||||
List<AgreementVo> list = sltAgreementInfoMapper.getAgreementInfoById(dto.getUnitIds(), Integer.parseInt(dto.getProjectId()));
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.material.settlement.service.impl;
|
||||
|
||||
import com.bonus.common.biz.constant.GlobalConstants;
|
||||
import com.bonus.common.biz.enums.TmTaskTypeEnum;
|
||||
import com.bonus.common.biz.enums.WorkFlowStatusEnum;
|
||||
import com.bonus.common.core.utils.DateUtils;
|
||||
|
|
@ -89,7 +90,8 @@ public class SltAgreementReduceServiceImpl implements ISltAgreementReduceService
|
|||
throw new RuntimeException("新增失败");
|
||||
}
|
||||
AtomicBoolean addFileInfoResult = new AtomicBoolean(false);
|
||||
if (sltAgreement.getBmFileInfos() != null) {
|
||||
if (sltAgreement.getBmFileInfos() != null && !sltAgreement.getBmFileInfos().isEmpty()) {
|
||||
sltAgreement.getBmFileInfos().removeIf(Objects::isNull);
|
||||
sltAgreement.getBmFileInfos().forEach(bmFileInfo -> {
|
||||
bmFileInfo.setModelId(taskId);
|
||||
bmFileInfo.setCreateTime(DateUtils.getNowDate());
|
||||
|
|
@ -97,7 +99,7 @@ public class SltAgreementReduceServiceImpl implements ISltAgreementReduceService
|
|||
});
|
||||
|
||||
}
|
||||
if (rs > 0) {
|
||||
if (rs > GlobalConstants.INT_0) {
|
||||
// 批量插入明细
|
||||
List<SltAgreementReduce> detailList = list.stream()
|
||||
.peek(detail -> detail.setId(taskId))
|
||||
|
|
|
|||
|
|
@ -261,8 +261,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</update>
|
||||
|
||||
<insert id="insSltInfo">
|
||||
insert into slt_agreement_info (agreement_id,type_id,ma_id,num,start_time,status,lease_id,lease_price,buy_price,is_slt,company_id,lease_type,create_time,publish_task)
|
||||
values (#{agreementId},#{record.typeId},#{record.maId},#{record.outNum},now(),0,#{record.parentId},#{ma.finalPrice},#{ma.buyPrice},'0',#{record.companyId},#{record.leaseType},now(),#{record.publishTask});
|
||||
insert into slt_agreement_info (agreement_id,type_id,ma_id,num,return_num,start_time,status,lease_id,lease_price,buy_price,is_slt,company_id,lease_type,create_time,publish_task,source)
|
||||
values (#{agreementId},#{record.typeId},#{record.maId},#{record.outNum},#{record.returnNum},now(),0,#{record.parentId},#{ma.finalPrice},#{ma.buyPrice},'0',#{record.companyId},#{record.leaseType},now(),#{record.publishTask},#{record.source});
|
||||
</insert>
|
||||
|
||||
<select id="getLeaseList" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
|
||||
|
|
|
|||
Loading…
Reference in New Issue