直转领退料
This commit is contained in:
parent
80eedb2bd6
commit
4ae4266381
|
|
@ -104,7 +104,18 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
List<BmFileInfo> bmFileInfos = fetchBmFileInfos(id, backApplyDetailsList);
|
List<BmFileInfo> bmFileInfos = fetchBmFileInfos(id, backApplyDetailsList);
|
||||||
// 查询编码设备信息
|
// 查询编码设备信息
|
||||||
List<MaCodeVo> maCodeList = fetchMaCodeList(id);
|
List<MaCodeVo> maCodeList = fetchMaCodeList(id);
|
||||||
|
// 根据协议id查询设备在用数
|
||||||
|
// 先查第四层类型
|
||||||
|
List<TypeTreeNode> listL4 = mapper.getUseTypeTreeL4(backApplyInfo);
|
||||||
for (BackApplyDetails details : backApplyDetailsList) {
|
for (BackApplyDetails details : backApplyDetailsList) {
|
||||||
|
if (CollectionUtils.isNotEmpty(listL4)) {
|
||||||
|
for (TypeTreeNode node : listL4) {
|
||||||
|
if (node.getTypeId() == details.getTypeId()) {
|
||||||
|
details.setNum(node.getNum());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// 为每个退料详情设置附件信息
|
// 为每个退料详情设置附件信息
|
||||||
setBmFileInfosForDetails(details, bmFileInfos);
|
setBmFileInfosForDetails(details, bmFileInfos);
|
||||||
// 如果是编码设备,查询并设置相关的编码信息和附件
|
// 如果是编码设备,查询并设置相关的编码信息和附件
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public AjaxResult leaseOut(LeaseOutDetails record) {
|
public AjaxResult leaseOut(LeaseOutDetails record) {
|
||||||
int res = 0;
|
int res = 0;
|
||||||
/*try {*/
|
try {
|
||||||
// 1、判断库存是否足够
|
// 1、判断库存是否足够
|
||||||
boolean isEnough = checkStorageIsEnough(record);
|
boolean isEnough = checkStorageIsEnough(record);
|
||||||
record.setPreStoreNum(getStorageNum(record));
|
record.setPreStoreNum(getStorageNum(record));
|
||||||
|
|
@ -210,10 +210,10 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
||||||
} else {
|
} else {
|
||||||
return AjaxResult.error("已领数量大于预领数量或该机具未在库");
|
return AjaxResult.error("已领数量大于预领数量或该机具未在库");
|
||||||
}
|
}
|
||||||
/*} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage());
|
log.error(e.getMessage());
|
||||||
return AjaxResult.error("出库失败");
|
return AjaxResult.error("出库失败");
|
||||||
}*/
|
}
|
||||||
return AjaxResult.success("出库成功");
|
return AjaxResult.success("出库成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,4 +50,16 @@ public class DirectApplyDetails extends BaseEntity {
|
||||||
private String leasePerson;
|
private String leasePerson;
|
||||||
|
|
||||||
private String startTime;
|
private String startTime;
|
||||||
|
|
||||||
|
private String manageType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退料协议id
|
||||||
|
*/
|
||||||
|
private Long backAgreementId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 领料协议id
|
||||||
|
*/
|
||||||
|
private Long leaseAgreementId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,4 +71,10 @@ public interface DirectRotationMapper {
|
||||||
*/
|
*/
|
||||||
List<SltAgreementInfo> getTypeNameList(SltAgreementInfo bean);
|
List<SltAgreementInfo> getTypeNameList(SltAgreementInfo bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 直转详情信息
|
||||||
|
* @param sltAgreementInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<DirectApplyDetails> selectDetails(SltAgreementInfo sltAgreementInfo);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,49 @@
|
||||||
package com.bonus.material.work.service.impl;
|
package com.bonus.material.work.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||||
|
import com.bonus.common.biz.constant.MaterialConstants;
|
||||||
|
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
|
||||||
|
import com.bonus.common.biz.domain.lease.LeaseOutDetails;
|
||||||
|
import com.bonus.common.biz.enums.BackTaskStatusEnum;
|
||||||
import com.bonus.common.biz.enums.LeaseTaskStatusEnum;
|
import com.bonus.common.biz.enums.LeaseTaskStatusEnum;
|
||||||
|
import com.bonus.common.biz.enums.TmTaskTypeEnum;
|
||||||
import com.bonus.common.core.exception.ServiceException;
|
import com.bonus.common.core.exception.ServiceException;
|
||||||
import com.bonus.common.core.utils.DateUtils;
|
import com.bonus.common.core.utils.DateUtils;
|
||||||
import com.bonus.common.security.utils.SecurityUtils;
|
import com.bonus.common.security.utils.SecurityUtils;
|
||||||
|
import com.bonus.material.back.domain.BackApplyDetails;
|
||||||
|
import com.bonus.material.back.domain.BackApplyInfo;
|
||||||
|
import com.bonus.material.back.mapper.BackApplyInfoMapper;
|
||||||
|
import com.bonus.material.lease.domain.LeaseApplyDetails;
|
||||||
|
import com.bonus.material.lease.mapper.LeaseApplyDetailsMapper;
|
||||||
|
import com.bonus.material.lease.mapper.LeaseApplyInfoMapper;
|
||||||
|
import com.bonus.material.lease.mapper.LeaseOutDetailsMapper;
|
||||||
|
import com.bonus.material.ma.domain.DirectApplyDetails;
|
||||||
import com.bonus.material.ma.domain.DirectApplyInfo;
|
import com.bonus.material.ma.domain.DirectApplyInfo;
|
||||||
|
import com.bonus.material.ma.domain.Type;
|
||||||
|
import com.bonus.material.ma.mapper.DirectRotationMapper;
|
||||||
|
import com.bonus.material.ma.mapper.TypeMapper;
|
||||||
|
import com.bonus.material.settlement.domain.SltAgreementInfo;
|
||||||
|
import com.bonus.material.settlement.mapper.SltAgreementInfoMapper;
|
||||||
import com.bonus.material.settlement.service.ISltAgreementReduceService;
|
import com.bonus.material.settlement.service.ISltAgreementReduceService;
|
||||||
import com.bonus.material.task.domain.TmTask;
|
import com.bonus.material.task.domain.TmTask;
|
||||||
|
import com.bonus.material.task.domain.TmTaskAgreement;
|
||||||
|
import com.bonus.material.task.mapper.TmTaskAgreementMapper;
|
||||||
import com.bonus.material.task.mapper.TmTaskMapper;
|
import com.bonus.material.task.mapper.TmTaskMapper;
|
||||||
import com.bonus.material.work.domain.SysWorkflowNode;
|
import com.bonus.material.work.domain.SysWorkflowNode;
|
||||||
import com.bonus.material.work.domain.SysWorkflowRecord;
|
import com.bonus.material.work.domain.SysWorkflowRecord;
|
||||||
import com.bonus.material.work.domain.SysWorkflowRecordHistory;
|
import com.bonus.material.work.domain.SysWorkflowRecordHistory;
|
||||||
import com.bonus.material.work.domain.SysWorkflowType;
|
|
||||||
import com.bonus.material.work.domain.dto.SysWorkflowAuditDto;
|
import com.bonus.material.work.domain.dto.SysWorkflowAuditDto;
|
||||||
import com.bonus.material.work.mapper.*;
|
import com.bonus.material.work.mapper.*;
|
||||||
import com.bonus.material.work.service.SysWorkflowRecordHistoryService;
|
import com.bonus.material.work.service.SysWorkflowRecordHistoryService;
|
||||||
import com.bonus.material.work.service.SysWorkflowRecordService;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Arrays;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
|
@ -50,6 +71,32 @@ public class SysWorkflowRecordHistoryServiceImpl implements SysWorkflowRecordHis
|
||||||
@Resource
|
@Resource
|
||||||
private DirectAuditMapper directAuditMapper;
|
private DirectAuditMapper directAuditMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DirectRotationMapper mapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private LeaseApplyInfoMapper leaseApplyInfoMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TmTaskMapper taskMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TmTaskAgreementMapper taskAgreementMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BackApplyInfoMapper backApplyInfoMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private LeaseApplyDetailsMapper leaseApplyDetailsMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private LeaseOutDetailsMapper leaseOutDetailsMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SltAgreementInfoMapper sltAgreementInfoMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TypeMapper typeMapper;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -57,7 +104,7 @@ public class SysWorkflowRecordHistoryServiceImpl implements SysWorkflowRecordHis
|
||||||
* 审批
|
* 审批
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public int updateSysWorkflowRecordHistory(SysWorkflowRecordHistory sysWorkflowRecordHistory) {
|
public int updateSysWorkflowRecordHistory(SysWorkflowRecordHistory sysWorkflowRecordHistory) {
|
||||||
//保存审核人信息
|
//保存审核人信息
|
||||||
Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
|
@ -137,9 +184,75 @@ public class SysWorkflowRecordHistoryServiceImpl implements SysWorkflowRecordHis
|
||||||
// 工地直转16
|
// 工地直转16
|
||||||
case 16:
|
case 16:
|
||||||
DirectApplyInfo directApplyInfo = new DirectApplyInfo();
|
DirectApplyInfo directApplyInfo = new DirectApplyInfo();
|
||||||
directApplyInfo.setId(sysWorkflowRecordHistory.getId());
|
directApplyInfo.setId(sysWorkflowRecordHistory.getTaskId());
|
||||||
directApplyInfo.setStatus("1");
|
directApplyInfo.setStatus("1");
|
||||||
directAuditMapper.updateDirectAudit(directApplyInfo);
|
directAuditMapper.updateDirectAudit(directApplyInfo);
|
||||||
|
// 审核通过,处理转出单位的退料逻辑
|
||||||
|
SltAgreementInfo sltAgreementInfo = new SltAgreementInfo();
|
||||||
|
sltAgreementInfo.setId(Long.valueOf(sysWorkflowRecordHistory.getTaskId()));
|
||||||
|
DirectApplyInfo info = mapper.getInfoById(sltAgreementInfo);
|
||||||
|
BackApplyInfo backApplyInfo = new BackApplyInfo();
|
||||||
|
if (info != null) {
|
||||||
|
backApplyInfo.setAgreementId(Long.valueOf(info.getBackAgreementId()));
|
||||||
|
backApplyInfo.setBackPerson(info.getBackMan());
|
||||||
|
backApplyInfo.setPhone(info.getBackPhone());
|
||||||
|
}
|
||||||
|
List<DirectApplyDetails> detailById = mapper.getDetailById(sltAgreementInfo);
|
||||||
|
List<DirectApplyDetails> list = mapper.selectDetails(sltAgreementInfo);
|
||||||
|
int thisMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId());
|
||||||
|
String code = genderTaskCode(thisMonthMaxOrder);
|
||||||
|
TmTask task = new TmTask(null, TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId(),
|
||||||
|
BackTaskStatusEnum.BACK_TASK_IN_FINISHED.getStatus(),
|
||||||
|
null,thisMonthMaxOrder + 1, code);
|
||||||
|
task.setCreateTime(DateUtils.getNowDate());
|
||||||
|
task.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
backApplyInfo.setCode(code);
|
||||||
|
backApplyInfo.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
backApplyInfo.setCreateTime(DateUtils.getNowDate());
|
||||||
|
// 保存退料信息到 tm_task 表中
|
||||||
|
int result = 0;
|
||||||
|
result = taskMapper.insertTmTask(task);
|
||||||
|
// 新增退料表back_apply_info信息
|
||||||
|
result = getBackInfoResult(info, backApplyInfo, task, result);
|
||||||
|
if (result > 0) {
|
||||||
|
// 保存退料详情数据 back_apply_details
|
||||||
|
result = getBackDetailsResult(backApplyInfo, list, result);
|
||||||
|
// 保存退料详情数据 back_check_details
|
||||||
|
extractedCheckDetails(backApplyInfo, detailById, result);
|
||||||
|
}
|
||||||
|
// 审核通过,处理转入单位领料逻辑
|
||||||
|
int maxOrderByDate = tmTaskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_LEASE.getTaskTypeId());
|
||||||
|
String taskCode = genderLeaseTaskCode(maxOrderByDate);
|
||||||
|
TmTask tmTask1 = new TmTask(null, TmTaskTypeEnum.TM_TASK_LEASE.getTaskTypeId(),
|
||||||
|
LeaseTaskStatusEnum.LEASE_TASK_FINISHED.getStatus(),null
|
||||||
|
,maxOrderByDate + 1, taskCode);
|
||||||
|
tmTask1.setCreateTime(DateUtils.getNowDate());
|
||||||
|
tmTask1.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
tmTaskMapper.insertTmTask(tmTask1);
|
||||||
|
TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(tmTask1.getTaskId(), Long.valueOf(info.getLeaseAgreementId()));
|
||||||
|
tmTaskAgreement.setCreateTime(DateUtils.getNowDate());
|
||||||
|
tmTaskAgreement.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement);
|
||||||
|
/** 设置审批人为默认的董班长 --防止代码冲突 **/
|
||||||
|
Long peopleId = leaseApplyInfoMapper.getDirectAuditBy();
|
||||||
|
LeaseApplyInfo applyInfo = new LeaseApplyInfo();
|
||||||
|
applyInfo.setDirectAuditBy(peopleId);
|
||||||
|
applyInfo.setCode(taskCode);
|
||||||
|
applyInfo.setTaskId(tmTask1.getTaskId());
|
||||||
|
applyInfo.setLeasePerson(info.getLeaseMan());
|
||||||
|
applyInfo.setPhone(info.getLeasePhone());
|
||||||
|
applyInfo.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
applyInfo.setCreateTime(DateUtils.getNowDate());
|
||||||
|
/** 设置审批人为默认的董班长 --防止代码冲突 **/
|
||||||
|
int count = leaseApplyInfoMapper.insertLeaseApplyInfo(applyInfo);
|
||||||
|
if (count > 0) {
|
||||||
|
// 新增lease_apply_details表数据
|
||||||
|
count = getLeaseApplyCount(list, applyInfo, count);
|
||||||
|
// 插入 lease_out_details表数据
|
||||||
|
if (count > 0) {
|
||||||
|
extracted(sltAgreementInfo, info, detailById, applyInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -180,4 +293,206 @@ public class SysWorkflowRecordHistoryServiceImpl implements SysWorkflowRecordHis
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插入 lease_out_details表数据
|
||||||
|
* @param sltAgreementInfo
|
||||||
|
* @param info
|
||||||
|
* @param detailById
|
||||||
|
* @param applyInfo
|
||||||
|
*/
|
||||||
|
private void extracted(SltAgreementInfo sltAgreementInfo, DirectApplyInfo info, List<DirectApplyDetails> detailById, LeaseApplyInfo applyInfo) {
|
||||||
|
int count;
|
||||||
|
if (CollectionUtils.isNotEmpty(detailById)) {
|
||||||
|
for (DirectApplyDetails directApplyDetails : detailById) {
|
||||||
|
LeaseOutDetails record = new LeaseOutDetails();
|
||||||
|
record.setParentId(applyInfo.getId());
|
||||||
|
record.setTypeId(Long.valueOf(directApplyDetails.getTypeId()));
|
||||||
|
record.setMaId(directApplyDetails.getMaId() == null ?
|
||||||
|
null : Long.valueOf(directApplyDetails.getMaId()));
|
||||||
|
record.setOutNum(BigDecimal.valueOf(directApplyDetails.getDirectNum()));
|
||||||
|
record.setOutType("1".equals(directApplyDetails.getManageType()) ?
|
||||||
|
1 : 0);
|
||||||
|
record.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
record.setCreateTime(DateUtils.getNowDate());
|
||||||
|
count = leaseOutDetailsMapper.insertLeaseOutDetails(record);
|
||||||
|
// 插入结算表
|
||||||
|
if (count > 0) {
|
||||||
|
SltAgreementInfo dto = sltAgreementInfoMapper.getSltAgreementInfo(record);
|
||||||
|
if (dto != null) {
|
||||||
|
BigDecimal num = dto.getNum();
|
||||||
|
BigDecimal outNum = record.getOutNum();
|
||||||
|
dto.setNum(num.add(outNum));
|
||||||
|
count = sltAgreementInfoMapper.updSltInfo(dto);
|
||||||
|
record.setAgreementId(sltAgreementInfo.getAgreementId());
|
||||||
|
}else {
|
||||||
|
Type maType = typeMapper.getMaType(record.getTypeId());
|
||||||
|
maType.setFinalPrice(maType.getLeasePrice());
|
||||||
|
count = sltAgreementInfoMapper.insSltInfo(record, String.valueOf(info.getLeaseAgreementId()), maType);
|
||||||
|
}
|
||||||
|
if (count <= 0) {
|
||||||
|
throw new RuntimeException("领料结算表插入失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增lease_apply_details表数据
|
||||||
|
* @param list
|
||||||
|
* @param applyInfo
|
||||||
|
* @param count
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private int getLeaseApplyCount(List<DirectApplyDetails> list, LeaseApplyInfo applyInfo, int count) {
|
||||||
|
if (CollectionUtil.isNotEmpty(list)) {
|
||||||
|
List<LeaseApplyDetails> leaseApplyDetails = new ArrayList<>();
|
||||||
|
for (DirectApplyDetails directApplyDetails : list) {
|
||||||
|
LeaseApplyDetails details = new LeaseApplyDetails();
|
||||||
|
details.setParentId(applyInfo.getId());
|
||||||
|
details.setCreateTime(DateUtils.getNowDate());
|
||||||
|
details.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
details.setTypeId(Long.valueOf(directApplyDetails.getTypeId()));
|
||||||
|
details.setPreNum(BigDecimal.valueOf(directApplyDetails.getDirectNum()));
|
||||||
|
details.setAlNum(BigDecimal.valueOf(directApplyDetails.getDirectNum()));
|
||||||
|
details.setStatus("2");
|
||||||
|
leaseApplyDetails.add(details);
|
||||||
|
}
|
||||||
|
// 批量插入详情数据
|
||||||
|
if (CollectionUtil.isNotEmpty(leaseApplyDetails)) {
|
||||||
|
count = leaseApplyDetailsMapper.insertLeaseApplyDetailsList(leaseApplyDetails);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成领料任务单号
|
||||||
|
* @param thisMonthMaxOrder
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static String genderLeaseTaskCode(Integer thisMonthMaxOrder) {
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
Date nowDate = DateUtils.getNowDate();
|
||||||
|
String format = dateFormat.format(nowDate);
|
||||||
|
String result = format.replace("-", "");
|
||||||
|
return MaterialConstants.LEASE_TASK_TYPE_LABEL + result + String.format("-%03d", thisMonthMaxOrder + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存退料详情数据 back_check_details
|
||||||
|
* @param backApplyInfo
|
||||||
|
* @param detailById
|
||||||
|
* @param result
|
||||||
|
*/
|
||||||
|
private void extractedCheckDetails(BackApplyInfo backApplyInfo, List<DirectApplyDetails> detailById, int result) {
|
||||||
|
if (CollectionUtil.isNotEmpty(detailById)) {
|
||||||
|
for (DirectApplyDetails directApplyDetails : detailById) {
|
||||||
|
BackApplyDetails details = new BackApplyDetails();
|
||||||
|
details.setParentId(backApplyInfo.getId());
|
||||||
|
details.setTypeId(Long.valueOf(directApplyDetails.getTypeId()));
|
||||||
|
details.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
details.setCreateTime(DateUtils.getNowDate());
|
||||||
|
details.setPreNum(BigDecimal.valueOf(directApplyDetails.getDirectNum()));
|
||||||
|
details.setMaId(directApplyDetails.getMaId() == null ?
|
||||||
|
null : Long.valueOf(directApplyDetails.getMaId()));
|
||||||
|
details.setBackStatus("0");
|
||||||
|
details.setStatus("2");
|
||||||
|
details.setIsFinished(1);
|
||||||
|
// 插入 CheckDetails
|
||||||
|
result += backApplyInfoMapper.insertCheckDetails(details);
|
||||||
|
// 更新结算表信息
|
||||||
|
BackApplyInfo bean = new BackApplyInfo();
|
||||||
|
bean.setAgreementId(directApplyDetails.getBackAgreementId());
|
||||||
|
bean.setTypeId(directApplyDetails.getTypeId().toString());
|
||||||
|
bean.setMaId(directApplyDetails.getMaId() == null ?
|
||||||
|
null : Long.valueOf(directApplyDetails.getMaId()));
|
||||||
|
List<SltAgreementInfo> infoList = backApplyInfoMapper.getStlInfo(bean);
|
||||||
|
Integer backNum = directApplyDetails.getDirectNum();
|
||||||
|
if (CollectionUtils.isNotEmpty(infoList)) {
|
||||||
|
for (SltAgreementInfo agreementInfo : infoList) {
|
||||||
|
Integer num = agreementInfo.getBackNum();
|
||||||
|
if (backNum.equals(num)) {
|
||||||
|
backApplyInfoMapper.updateStlInfo(agreementInfo, backApplyInfo);
|
||||||
|
break;
|
||||||
|
} else if (backNum > num) {
|
||||||
|
backNum = backNum - num;
|
||||||
|
backApplyInfoMapper.updateStlInfo(agreementInfo, backApplyInfo);
|
||||||
|
} else {
|
||||||
|
Integer many = num - backNum;
|
||||||
|
backApplyInfoMapper.updateStlInfoTwo(agreementInfo, backApplyInfo, backNum);
|
||||||
|
backApplyInfoMapper.insStlInfoTwo(agreementInfo, many);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增退料详情back_apply_details表信息
|
||||||
|
* @param backApplyInfo
|
||||||
|
* @param list
|
||||||
|
* @param result
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private int getBackDetailsResult(BackApplyInfo backApplyInfo, List<DirectApplyDetails> list, int result) {
|
||||||
|
if (CollectionUtil.isNotEmpty(list)) {
|
||||||
|
for (DirectApplyDetails directApplyDetails : list) {
|
||||||
|
BackApplyDetails details = new BackApplyDetails();
|
||||||
|
details.setCode(backApplyInfo.getCode());
|
||||||
|
details.setParentId(backApplyInfo.getId());
|
||||||
|
details.setPreNum(BigDecimal.valueOf(directApplyDetails.getDirectNum()));
|
||||||
|
details.setAuditNum(BigDecimal.valueOf(directApplyDetails.getDirectNum()));
|
||||||
|
details.setNum(directApplyDetails.getUseNum() == null ?
|
||||||
|
BigDecimal.ZERO : BigDecimal.valueOf(directApplyDetails.getUseNum()));
|
||||||
|
details.setStatus(String.valueOf(BackTaskStatusEnum.BACK_TASK_IN_FINISHED.getStatus()));
|
||||||
|
details.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
details.setCreateTime(DateUtils.getNowDate());
|
||||||
|
details.setTypeId(Long.valueOf(directApplyDetails.getTypeId()));
|
||||||
|
// 保存退料详情
|
||||||
|
result += backApplyInfoMapper.insertBackApplyDetails(details);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增退料信息
|
||||||
|
* @param info
|
||||||
|
* @param backApplyInfo
|
||||||
|
* @param task
|
||||||
|
* @param result
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private int getBackInfoResult(DirectApplyInfo info, BackApplyInfo backApplyInfo, TmTask task, int result) {
|
||||||
|
if (result > 0) {
|
||||||
|
TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(task.getTaskId(), Long.valueOf(info.getBackAgreementId()));
|
||||||
|
tmTaskAgreement.setCreateTime(DateUtils.getNowDate());
|
||||||
|
tmTaskAgreement.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement);
|
||||||
|
backApplyInfo.setTaskId(task.getTaskId());
|
||||||
|
/** 设置审批人为默认的李勇 --防止代码冲突 **/
|
||||||
|
Long peopleId = backApplyInfoMapper.getDirectAuditBy();
|
||||||
|
backApplyInfo.setDirectAuditBy(peopleId);
|
||||||
|
/** 设置审批人为默认的李勇 --防止代码冲突 **/
|
||||||
|
result += backApplyInfoMapper.insertBackApplyInfo(backApplyInfo);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成退料单号
|
||||||
|
* @param thisMonthMaxOrder
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String genderTaskCode(int thisMonthMaxOrder) {
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
Date nowDate = DateUtils.getNowDate();
|
||||||
|
String format = dateFormat.format(nowDate);
|
||||||
|
String result = format.replace("-", "");
|
||||||
|
return MaterialConstants.BACK_TASK_TYPE_LABEL + result + String.format("-%03d", thisMonthMaxOrder + 1);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,10 @@
|
||||||
mm.ma_code AS maCode,
|
mm.ma_code AS maCode,
|
||||||
mm.ma_id AS maId,
|
mm.ma_id AS maId,
|
||||||
lai.lease_person as leasePerson,
|
lai.lease_person as leasePerson,
|
||||||
DATE(sai.start_time) as startTime
|
DATE(sai.start_time) as startTime,
|
||||||
|
mt.manage_type as manageType,
|
||||||
|
dai.back_agreement_id as backAgreementId,
|
||||||
|
dai.lease_agreement_id as leaseAgreementId
|
||||||
FROM
|
FROM
|
||||||
direct_apply_info dai
|
direct_apply_info dai
|
||||||
LEFT JOIN direct_apply_details dad ON dai.id = dad.direct_id
|
LEFT JOIN direct_apply_details dad ON dai.id = dad.direct_id
|
||||||
|
|
@ -258,4 +261,22 @@
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectDetails" resultType="com.bonus.material.ma.domain.DirectApplyDetails">
|
||||||
|
SELECT
|
||||||
|
dad.type_id AS typeId,
|
||||||
|
mt2.type_name AS typeName,
|
||||||
|
mt.type_name AS typeModelName,
|
||||||
|
mt.unit_name AS unitName,
|
||||||
|
mt.manage_type AS manageType,
|
||||||
|
SUM( dad.direct_num ) AS directNum
|
||||||
|
FROM
|
||||||
|
direct_apply_info dai
|
||||||
|
LEFT JOIN direct_apply_details dad ON dai.id = dad.direct_id
|
||||||
|
LEFT JOIN ma_type mt ON mt.type_id = dad.type_id
|
||||||
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||||
|
WHERE
|
||||||
|
dai.id = #{id}
|
||||||
|
GROUP BY
|
||||||
|
dad.type_id
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
|
||||||
<select id="getSltAgreementInfo" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
|
<select id="getSltAgreementInfo" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
|
||||||
SELECT
|
SELECT
|
||||||
id,
|
id AS id,
|
||||||
agreement_id AS agreementId,
|
agreement_id AS agreementId,
|
||||||
type_id AS typeId,
|
type_id AS typeId,
|
||||||
ma_id AS maId,
|
ma_id AS maId,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue