工地直转优化
This commit is contained in:
parent
ac0646df6b
commit
273e0af612
|
|
@ -577,4 +577,11 @@ public interface BackApplyInfoMapper {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
SltAgreementInfo getClzUseInfoList(@Param("info") MaCodeVo maCodeVo, @Param("agreementIds") List<BmAgreementInfo> listAgreement);
|
SltAgreementInfo getClzUseInfoList(@Param("info") MaCodeVo maCodeVo, @Param("agreementIds") List<BmAgreementInfo> listAgreement);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询项目部在用数据
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<SltAgreementInfo> getXmInfoList(BackApplyInfo bean);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -160,8 +160,8 @@ public class SelectServiceImpl implements SelectService {
|
||||||
return AjaxResult.success(bmProjects);
|
return AjaxResult.success(bmProjects);
|
||||||
}
|
}
|
||||||
|
|
||||||
Long deptId = typeService.getUserDeptId();
|
/*Long deptId = typeService.getUserDeptId();
|
||||||
bmProject.setDeptId(deptId);
|
bmProject.setDeptId(deptId);*/
|
||||||
// // 获取登陆用户的组织ID
|
// // 获取登陆用户的组织ID
|
||||||
// Long thisLoginUserDeptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
|
// Long thisLoginUserDeptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
|
||||||
// if (null == thisLoginUserDeptId || 0 == thisLoginUserDeptId) {
|
// if (null == thisLoginUserDeptId || 0 == thisLoginUserDeptId) {
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import com.bonus.material.basic.domain.BmUnit;
|
||||||
import com.bonus.material.common.annotation.PreventRepeatSubmit;
|
import com.bonus.material.common.annotation.PreventRepeatSubmit;
|
||||||
import com.bonus.material.ma.domain.*;
|
import com.bonus.material.ma.domain.*;
|
||||||
import com.bonus.material.ma.service.DirectRotationService;
|
import com.bonus.material.ma.service.DirectRotationService;
|
||||||
|
import com.bonus.material.ma.service.ITypeService;
|
||||||
import com.bonus.material.settlement.domain.SltAgreementInfo;
|
import com.bonus.material.settlement.domain.SltAgreementInfo;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
|
@ -37,6 +38,9 @@ public class DirectRotationController extends BaseController {
|
||||||
@Resource(name = "directRotationService")
|
@Resource(name = "directRotationService")
|
||||||
private DirectRotationService service;
|
private DirectRotationService service;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ITypeService typeService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据协议Id查询在用数据
|
* 根据协议Id查询在用数据
|
||||||
*/
|
*/
|
||||||
|
|
@ -157,6 +161,8 @@ public class DirectRotationController extends BaseController {
|
||||||
@ApiOperation(value = "直转提交")
|
@ApiOperation(value = "直转提交")
|
||||||
@PostMapping("/submitNew")
|
@PostMapping("/submitNew")
|
||||||
public AjaxResult submitNew(@RequestBody DirectApplyInfoDetails directApplyInfoDetails) {
|
public AjaxResult submitNew(@RequestBody DirectApplyInfoDetails directApplyInfoDetails) {
|
||||||
|
Long deptId = typeService.getUserDeptId();
|
||||||
|
directApplyInfoDetails.getDirectApplyInfo().setCompanyId(deptId);
|
||||||
return service.submitNew(directApplyInfoDetails);
|
return service.submitNew(directApplyInfoDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.bonus.material.ma.domain;
|
package com.bonus.material.ma.domain;
|
||||||
|
|
||||||
import com.bonus.common.core.web.domain.BaseEntity;
|
import com.bonus.common.core.web.domain.BaseEntity;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
|
@ -64,4 +65,17 @@ public class DirectApplyDetails extends BaseEntity {
|
||||||
* 领料协议id
|
* 领料协议id
|
||||||
*/
|
*/
|
||||||
private Long leaseAgreementId;
|
private Long leaseAgreementId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "协议id")
|
||||||
|
private Long agreementId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否存在于xmList
|
||||||
|
*/
|
||||||
|
private Boolean isXmbUse = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否存在于clzInfoList
|
||||||
|
*/
|
||||||
|
private Boolean isClzUse = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -244,4 +244,7 @@ public class DirectApplyInfo extends BaseEntity {
|
||||||
* 审核单位id
|
* 审核单位id
|
||||||
*/
|
*/
|
||||||
private String auditUnitId;
|
private String auditUnitId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "数据所属组织")
|
||||||
|
private Long companyId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -133,4 +133,8 @@ public interface DirectRotationMapper {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<DirectApplyInfo> getCodeList(DirectApplyInfo directApplyInfo);
|
List<DirectApplyInfo> getCodeList(DirectApplyInfo directApplyInfo);
|
||||||
|
|
||||||
|
List<SltAgreementInfo> getXmList(DirectApplyDetails applyDetail);
|
||||||
|
|
||||||
|
List<SltAgreementInfo> getClzList(DirectApplyDetails applyDetail);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.bonus.material.ma.service.impl;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||||
import com.alibaba.nacos.common.utils.StringUtils;
|
import com.alibaba.nacos.common.utils.StringUtils;
|
||||||
|
import com.bonus.common.biz.constant.GlobalConstants;
|
||||||
import com.bonus.common.biz.constant.MaterialConstants;
|
import com.bonus.common.biz.constant.MaterialConstants;
|
||||||
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
|
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
|
||||||
import com.bonus.common.biz.domain.lease.LeaseOutDetails;
|
import com.bonus.common.biz.domain.lease.LeaseOutDetails;
|
||||||
|
|
@ -16,8 +17,18 @@ import com.bonus.common.security.utils.SecurityUtils;
|
||||||
import com.bonus.material.back.domain.BackApplyDetails;
|
import com.bonus.material.back.domain.BackApplyDetails;
|
||||||
import com.bonus.material.back.domain.BackApplyInfo;
|
import com.bonus.material.back.domain.BackApplyInfo;
|
||||||
import com.bonus.material.back.mapper.BackApplyInfoMapper;
|
import com.bonus.material.back.mapper.BackApplyInfoMapper;
|
||||||
|
import com.bonus.material.basic.domain.BmAgreementInfo;
|
||||||
import com.bonus.material.basic.domain.BmUnit;
|
import com.bonus.material.basic.domain.BmUnit;
|
||||||
|
import com.bonus.material.basic.mapper.BmAgreementInfoMapper;
|
||||||
|
import com.bonus.material.clz.domain.back.MaterialBackApplyDetails;
|
||||||
|
import com.bonus.material.clz.domain.back.MaterialBackApplyInfo;
|
||||||
import com.bonus.material.clz.domain.direct.ClzDirectApplyInfo;
|
import com.bonus.material.clz.domain.direct.ClzDirectApplyInfo;
|
||||||
|
import com.bonus.material.clz.domain.lease.MaterialLeaseApplyInfo;
|
||||||
|
import com.bonus.material.clz.mapper.MaterialBackInfoMapper;
|
||||||
|
import com.bonus.material.clz.mapper.MaterialLeaseInfoMapper;
|
||||||
|
import com.bonus.material.common.domain.dto.SelectDto;
|
||||||
|
import com.bonus.material.common.domain.vo.AgreementVo;
|
||||||
|
import com.bonus.material.common.mapper.SelectMapper;
|
||||||
import com.bonus.material.event.InsertWorkflowEvent;
|
import com.bonus.material.event.InsertWorkflowEvent;
|
||||||
import com.bonus.material.lease.domain.LeaseApplyDetails;
|
import com.bonus.material.lease.domain.LeaseApplyDetails;
|
||||||
import com.bonus.material.lease.mapper.LeaseApplyDetailsMapper;
|
import com.bonus.material.lease.mapper.LeaseApplyDetailsMapper;
|
||||||
|
|
@ -119,6 +130,18 @@ public class DirectRotationImpl implements DirectRotationService {
|
||||||
@Resource
|
@Resource
|
||||||
private ApplicationEventPublisher applicationEventPublisher;
|
private ApplicationEventPublisher applicationEventPublisher;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SelectMapper selectMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BmAgreementInfoMapper bmAgreementInfoMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MaterialBackInfoMapper materialBackInfoMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MaterialLeaseInfoMapper materialLeaseInfoMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SltAgreementInfo> getUseringData(SltAgreementInfo sltAgreementInfo) {
|
public List<SltAgreementInfo> getUseringData(SltAgreementInfo sltAgreementInfo) {
|
||||||
return mapper.getUseringData(sltAgreementInfo);
|
return mapper.getUseringData(sltAgreementInfo);
|
||||||
|
|
@ -345,6 +368,31 @@ public class DirectRotationImpl implements DirectRotationService {
|
||||||
if (directApplyInfos.getBackAgreementId()==directApplyInfos.getLeaseAgreementId()){
|
if (directApplyInfos.getBackAgreementId()==directApplyInfos.getLeaseAgreementId()){
|
||||||
return AjaxResult.error("直转失败,不能转入同单位同工程");
|
return AjaxResult.error("直转失败,不能转入同单位同工程");
|
||||||
}
|
}
|
||||||
|
// 判断领退料单位是否为班组类型(typeId为1731)
|
||||||
|
// 查询退料单位类型
|
||||||
|
Long backUnitTypeId = leaseApplyInfoMapper.selectUnitTypeByUnitId(Long.valueOf(directApplyInfos.getBackUnitId()));
|
||||||
|
if (backUnitTypeId != null && backUnitTypeId == 1731L) {
|
||||||
|
// 查询该班在机具签署✍️的协议ID,查询班组挂靠的项目部协议信息
|
||||||
|
LeaseOutDetails backOutDetail = leaseApplyInfoMapper.selectProjectUnitAgreementIdByTeamAndProject(
|
||||||
|
Math.toIntExact(Long.parseLong(directApplyInfos.getBackUnitId())),
|
||||||
|
Math.toIntExact(Long.parseLong(directApplyInfos.getBackProId()))
|
||||||
|
);
|
||||||
|
if (backOutDetail == null) {
|
||||||
|
return AjaxResult.error("退料单位项目部协议信息查询为空");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 查询领料单位类型
|
||||||
|
Long leaseUnitTypeId = leaseApplyInfoMapper.selectUnitTypeByUnitId(Long.valueOf(directApplyInfos.getLeaseUnitId()));
|
||||||
|
if (leaseUnitTypeId != null && leaseUnitTypeId == 1731L) {
|
||||||
|
// 查询该班在机具签署✍️的协议ID,查询班组挂靠的项目部协议信息
|
||||||
|
LeaseOutDetails leaseOutDetail = leaseApplyInfoMapper.selectProjectUnitAgreementIdByTeamAndProject(
|
||||||
|
Math.toIntExact(Long.parseLong(directApplyInfos.getLeaseUnitId())),
|
||||||
|
Math.toIntExact(Long.parseLong(directApplyInfos.getLeaseProId()))
|
||||||
|
);
|
||||||
|
if (leaseOutDetail == null) {
|
||||||
|
return AjaxResult.error("领料单位项目部协议信息查询为空");
|
||||||
|
}
|
||||||
|
}
|
||||||
String code = workSiteDirectManageService.genderLeaseCode();
|
String code = workSiteDirectManageService.genderLeaseCode();
|
||||||
directApplyInfos.setCode(code);
|
directApplyInfos.setCode(code);
|
||||||
directApplyInfos.setCreateTime(new Date());
|
directApplyInfos.setCreateTime(new Date());
|
||||||
|
|
@ -372,10 +420,9 @@ public class DirectRotationImpl implements DirectRotationService {
|
||||||
int i = workSiteDirectManageService.saveDirectApplyDetails(directApplyDetail);
|
int i = workSiteDirectManageService.saveDirectApplyDetails(directApplyDetail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//以下走退料、领料方法
|
//以下走退料、领料方法
|
||||||
SltAgreementInfo sltAgreementInfo = new SltAgreementInfo();
|
SltAgreementInfo sltAgreementInfo = new SltAgreementInfo();
|
||||||
sltAgreementInfo.setId(Long.valueOf(id));
|
sltAgreementInfo.setId((long) id);
|
||||||
DirectApplyInfo info = mapper.getInfoById(sltAgreementInfo);
|
DirectApplyInfo info = mapper.getInfoById(sltAgreementInfo);
|
||||||
BackApplyInfo backApplyInfo = new BackApplyInfo();
|
BackApplyInfo backApplyInfo = new BackApplyInfo();
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
|
|
@ -389,29 +436,171 @@ public class DirectRotationImpl implements DirectRotationService {
|
||||||
String codes = genderZzBackTaskCode(thisMonthMaxOrder);
|
String codes = genderZzBackTaskCode(thisMonthMaxOrder);
|
||||||
TmTask task = new TmTask(null, TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId(),
|
TmTask task = new TmTask(null, TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId(),
|
||||||
BackTaskStatusEnum.BACK_TASK_IN_FINISHED.getStatus(),
|
BackTaskStatusEnum.BACK_TASK_IN_FINISHED.getStatus(),
|
||||||
null,thisMonthMaxOrder + 1, codes);
|
directApplyInfos.getCompanyId(),thisMonthMaxOrder + 1, codes);
|
||||||
task.setCreateTime(DateUtils.getNowDate());
|
task.setCreateTime(DateUtils.getNowDate());
|
||||||
task.setCreateBy(SecurityUtils.getUsername());
|
task.setCreateBy(SecurityUtils.getUsername());
|
||||||
backApplyInfo.setCode(codes);
|
backApplyInfo.setCode(codes);
|
||||||
backApplyInfo.setCreateBy(SecurityUtils.getUsername());
|
backApplyInfo.setCreateBy(SecurityUtils.getUsername());
|
||||||
backApplyInfo.setCreateTime(DateUtils.getNowDate());
|
backApplyInfo.setCreateTime(DateUtils.getNowDate());
|
||||||
backApplyInfo.setDirectId(Long.valueOf(id));
|
backApplyInfo.setDirectId((long) id);
|
||||||
// 保存退料信息到 tm_task 表中
|
// 保存退料信息到 tm_task 表中
|
||||||
int result = 0;
|
int result = 0;
|
||||||
result = taskMapper.insertTmTask(task);
|
result = taskMapper.insertTmTask(task);
|
||||||
// 新增退料表back_apply_info信息
|
// 新增退料表back_apply_info信息
|
||||||
result = getBackInfoResult(info, backApplyInfo, task, result);
|
result = getBackInfoResult(info, backApplyInfo, task, result, directApplyInfos.getCompanyId());
|
||||||
if (result > 0) {
|
if (result > 0) {
|
||||||
// 保存退料详情数据 back_apply_details
|
// 保存退料详情数据 back_apply_details
|
||||||
result = getBackDetailsResult(backApplyInfo, list, result);
|
result = getBackDetailsResult(backApplyInfo, list, result, directApplyInfos.getCompanyId());
|
||||||
// 保存退料详情数据 back_check_details
|
// 保存退料详情数据 back_check_details
|
||||||
extractedCheckDetails(backApplyInfo, detailById, result);
|
extractedCheckDetails(backApplyInfo, detailById, result, directApplyInfos.getCompanyId(), null, 1);
|
||||||
|
// 如果退料单位类型为班组,则需要进行项目部以及材料站数据
|
||||||
|
if (backUnitTypeId != null && backUnitTypeId == 1731L) {
|
||||||
|
// 查询该班在机具签署✍️的协议ID,查询班组挂靠的项目部协议信息
|
||||||
|
LeaseOutDetails leaseOutDetail = leaseApplyInfoMapper.selectProjectUnitAgreementIdByTeamAndProject(
|
||||||
|
Math.toIntExact(Long.parseLong(directApplyInfos.getBackUnitId())),
|
||||||
|
Math.toIntExact(Long.parseLong(directApplyInfos.getBackProId()))
|
||||||
|
);
|
||||||
|
SelectDto dto = new SelectDto();
|
||||||
|
dto.setProjectId(directApplyInfos.getBackProId()).setUnitId(Math.toIntExact(Long.parseLong(directApplyInfos.getBackUnitId())));
|
||||||
|
List<AgreementVo> clzList = selectMapper.getAgreementInfoByIdBack(dto);
|
||||||
|
for (DirectApplyDetails applyDetail : detailById) {
|
||||||
|
// 根据项目部及材料站协议查询退料设备是否存在于其中,若不存在,则不用进行退料
|
||||||
|
applyDetail.setAgreementId(leaseOutDetail.getProjectUnitAgreementId());
|
||||||
|
List<SltAgreementInfo> xmList = mapper.getXmList(applyDetail);
|
||||||
|
if (!CollectionUtils.isEmpty(xmList)) {
|
||||||
|
applyDetail.setIsXmbUse(true);
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isNotEmpty(list)) {
|
||||||
|
applyDetail.setAgreementId(Long.valueOf(clzList.get(0).getAgreementId()));
|
||||||
|
List<SltAgreementInfo> clzInfoList = mapper.getClzList(applyDetail);
|
||||||
|
if (!CollectionUtils.isEmpty(clzInfoList)) {
|
||||||
|
applyDetail.setIsClzUse(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 项目部使用
|
||||||
|
boolean isXmbUse = false;
|
||||||
|
// 材料站使用
|
||||||
|
boolean isClzUse = false;
|
||||||
|
// 示例:统计全局是否有至少一条数据满足xmList
|
||||||
|
isXmbUse = detailById.stream()
|
||||||
|
.anyMatch(DirectApplyDetails::getIsXmbUse);
|
||||||
|
|
||||||
|
// 示例:统计全局是否有至少一条数据满足clzInfoList
|
||||||
|
isClzUse = detailById.stream()
|
||||||
|
.anyMatch(DirectApplyDetails::getIsClzUse);
|
||||||
|
|
||||||
|
// 材料站对分公司建立退料任务
|
||||||
|
if (isXmbUse) {
|
||||||
|
BackApplyInfo backApplyInfo4 = new BackApplyInfo();
|
||||||
|
if (info != null) {
|
||||||
|
backApplyInfo.setAgreementId(Long.valueOf(info.getBackAgreementId()));
|
||||||
|
backApplyInfo.setBackPerson(info.getBackMan());
|
||||||
|
backApplyInfo.setPhone(info.getBackPhone());
|
||||||
|
}
|
||||||
|
int maxOrder = taskMapper.getMonthMaxOrderByDateTwo(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId());
|
||||||
|
String ZzCode = genderZzBackTaskCode(maxOrder);
|
||||||
|
TmTask newTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId(),
|
||||||
|
BackTaskStatusEnum.BACK_TASK_IN_FINISHED.getStatus(),
|
||||||
|
directApplyInfos.getCompanyId(),maxOrder + 1, ZzCode);
|
||||||
|
newTask.setCreateTime(DateUtils.getNowDate());
|
||||||
|
newTask.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
backApplyInfo4.setCode(ZzCode);
|
||||||
|
backApplyInfo4.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
backApplyInfo4.setCreateTime(DateUtils.getNowDate());
|
||||||
|
backApplyInfo4.setDirectId((long) id);
|
||||||
|
// 保存退料信息到 tm_task 表中
|
||||||
|
result = taskMapper.insertTmTask(task);
|
||||||
|
if (result > 0) {
|
||||||
|
// 根据单位和工程id查询项目部关联协议id
|
||||||
|
BackApplyInfo backApplyInfo3 = backApplyInfoMapper.selectInfo(backApplyInfo);
|
||||||
|
if (backApplyInfo3 != null) {
|
||||||
|
// 给项目部处理的时候要使用挂靠的项目部协议ID
|
||||||
|
TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(newTask.getTaskId(), leaseOutDetail.getProjectUnitAgreementId());
|
||||||
|
tmTaskAgreement.setCreateTime(DateUtils.getNowDate());
|
||||||
|
tmTaskAgreement.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
||||||
|
tmTaskAgreement.setCompanyId(directApplyInfos.getCompanyId());
|
||||||
|
taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement);
|
||||||
|
}
|
||||||
|
backApplyInfo4.setTaskId(newTask.getTaskId());
|
||||||
|
BackApplyInfo backApplyInfo2 = backApplyInfoMapper.selectBackApplyInfoById(backApplyInfo.getId());
|
||||||
|
if (backApplyInfo2 != null) {
|
||||||
|
backApplyInfo4.setBackPerson(StringUtils.isNotBlank(backApplyInfo2.getBackPerson()) ? backApplyInfo2.getBackPerson() : "");
|
||||||
|
backApplyInfo4.setPhone(StringUtils.isNotBlank(backApplyInfo2.getPhone()) ? backApplyInfo2.getPhone() : "");
|
||||||
|
backApplyInfo4.setBackStyle("2");
|
||||||
|
backApplyInfo4.setCompanyId(directApplyInfos.getCompanyId());
|
||||||
|
}
|
||||||
|
result += backApplyInfoMapper.insertBackApplyInfo(backApplyInfo4);
|
||||||
|
}
|
||||||
|
// 保存退料详情数据 back_apply_details
|
||||||
|
result = getBackDetailsResult(backApplyInfo4, list, result, directApplyInfos.getCompanyId());
|
||||||
|
// 保存退料详情数据 back_check_details
|
||||||
|
extractedCheckDetails(backApplyInfo4, detailById, result, directApplyInfos.getCompanyId(), leaseOutDetail.getProjectUnitAgreementId(), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
BmAgreementInfo bmAgreementInfo = new BmAgreementInfo();
|
||||||
|
bmAgreementInfo.setUnitId(Long.valueOf(directApplyInfos.getBackUnitId()));
|
||||||
|
bmAgreementInfo.setProjectId(Long.valueOf(directApplyInfos.getBackProId()));
|
||||||
|
BmAgreementInfo agreementInfo = bmAgreementInfoMapper.queryByTeamIdAndProjectIdCl(bmAgreementInfo);
|
||||||
|
// 材料站建立退料任务
|
||||||
|
if (isClzUse) {
|
||||||
|
MaterialBackApplyInfo materialBackApplyInfo = new MaterialBackApplyInfo();
|
||||||
|
int clzMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_MATERIAL_BACK.getTaskTypeId());
|
||||||
|
String clzCode = genderClzTaskCode(clzMonthMaxOrder);
|
||||||
|
TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_MATERIAL_BACK.getTaskTypeId(),
|
||||||
|
BackTaskStatusEnum.BACK_TASK_IN_FINISHED.getStatus(), backApplyInfo.getCompanyId(), clzMonthMaxOrder + 1, clzCode);
|
||||||
|
tmTask.setCreateTime(DateUtils.getNowDate());
|
||||||
|
String createBy = SecurityUtils.getLoginUser().getSysUser().getNickName();
|
||||||
|
tmTask.setCreateBy(createBy);
|
||||||
|
materialBackApplyInfo.setCode(clzCode);
|
||||||
|
materialBackApplyInfo.setCreateBy(createBy);
|
||||||
|
materialBackApplyInfo.setCreateTime(DateUtils.getNowDate());
|
||||||
|
// 保存退料信息到 tm_task 表中
|
||||||
|
result += taskMapper.insertTmTask(tmTask);
|
||||||
|
if (result > 0) {
|
||||||
|
TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(tmTask.getTaskId(), agreementInfo.getAgreementId());
|
||||||
|
tmTaskAgreement.setCreateTime(DateUtils.getNowDate());
|
||||||
|
tmTaskAgreement.setCreateBy(createBy);
|
||||||
|
tmTaskAgreement.setCompanyId(backApplyInfo.getCompanyId());
|
||||||
|
taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement);
|
||||||
|
materialBackApplyInfo.setTaskId(tmTask.getTaskId());
|
||||||
|
materialBackApplyInfo.setBackStyle("2");
|
||||||
|
materialBackApplyInfo.setStatus("2");
|
||||||
|
BackApplyInfo backApplyInfo1 = backApplyInfoMapper.selectBackApplyInfoById(backApplyInfo.getId());
|
||||||
|
if (backApplyInfo1 != null) {
|
||||||
|
materialBackApplyInfo.setBackPerson(StringUtils.isNotBlank(backApplyInfo1.getBackPerson()) ? backApplyInfo1.getBackPerson() : "");
|
||||||
|
materialBackApplyInfo.setPhone(StringUtils.isNotBlank(backApplyInfo1.getPhone()) ? backApplyInfo1.getPhone() : "");
|
||||||
|
}
|
||||||
|
result += materialBackInfoMapper.insertBackApplyInfo(materialBackApplyInfo);
|
||||||
|
if (CollectionUtils.isNotEmpty(list)) {
|
||||||
|
for (DirectApplyDetails applyInfo : list) {
|
||||||
|
MaterialBackApplyDetails details = new MaterialBackApplyDetails();
|
||||||
|
details.setCode(clzCode);
|
||||||
|
details.setParentId(materialBackApplyInfo.getId());
|
||||||
|
details.setPreNum(applyInfo.getDirectNum());
|
||||||
|
details.setAuditNum(applyInfo.getDirectNum());
|
||||||
|
details.setStatus(String.valueOf(BackTaskStatusEnum.BACK_TASK_NO_FINISHED.getStatus()));
|
||||||
|
details.setCreateBy(createBy);
|
||||||
|
details.setCreateTime(DateUtils.getNowDate());
|
||||||
|
details.setTypeId(Long.valueOf(applyInfo.getTypeId()));
|
||||||
|
// 保存退料详情
|
||||||
|
if (applyInfo.getIsClzUse()) {
|
||||||
|
result += materialBackInfoMapper.insertBackApplyDetails(details);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 保存退料详情数据 back_check_details
|
||||||
|
extractedClzCheckDetails(materialBackApplyInfo, detailById, result, directApplyInfos.getCompanyId(), agreementInfo.getAgreementId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 审核通过,处理转入单位领料逻辑
|
// 审核通过,处理转入单位领料逻辑
|
||||||
int maxOrderByDate = tmTaskMapper.getMonthMaxOrderByDateTwo(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_LEASE.getTaskTypeId());
|
int maxOrderByDate = tmTaskMapper.getMonthMaxOrderByDateTwo(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_LEASE.getTaskTypeId());
|
||||||
String taskCode = genderZzLeaseTaskCode(maxOrderByDate);
|
String taskCode = genderZzLeaseTaskCode(maxOrderByDate);
|
||||||
TmTask tmTask1 = new TmTask(null, TmTaskTypeEnum.TM_TASK_LEASE.getTaskTypeId(),
|
TmTask tmTask1 = new TmTask(null, TmTaskTypeEnum.TM_TASK_LEASE.getTaskTypeId(),
|
||||||
LeaseTaskStatusEnum.LEASE_TASK_FINISHED.getStatus(),null
|
LeaseTaskStatusEnum.LEASE_TASK_FINISHED.getStatus(),directApplyInfos.getCompanyId()
|
||||||
,maxOrderByDate + 1, taskCode);
|
,maxOrderByDate + 1, taskCode);
|
||||||
tmTask1.setCreateTime(DateUtils.getNowDate());
|
tmTask1.setCreateTime(DateUtils.getNowDate());
|
||||||
tmTask1.setCreateBy(SecurityUtils.getUsername());
|
tmTask1.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
|
@ -419,6 +608,7 @@ public class DirectRotationImpl implements DirectRotationService {
|
||||||
TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(tmTask1.getTaskId(), Long.valueOf(info.getLeaseAgreementId()));
|
TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(tmTask1.getTaskId(), Long.valueOf(info.getLeaseAgreementId()));
|
||||||
tmTaskAgreement.setCreateTime(DateUtils.getNowDate());
|
tmTaskAgreement.setCreateTime(DateUtils.getNowDate());
|
||||||
tmTaskAgreement.setCreateBy(SecurityUtils.getUsername());
|
tmTaskAgreement.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
tmTaskAgreement.setCompanyId(directApplyInfos.getCompanyId());
|
||||||
taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement);
|
taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement);
|
||||||
/** 设置审批人为默认的董班长 --防止代码冲突 **/
|
/** 设置审批人为默认的董班长 --防止代码冲突 **/
|
||||||
Long peopleId = leaseApplyInfoMapper.getDirectAuditBy();
|
Long peopleId = leaseApplyInfoMapper.getDirectAuditBy();
|
||||||
|
|
@ -430,19 +620,89 @@ public class DirectRotationImpl implements DirectRotationService {
|
||||||
applyInfo.setPhone(info.getLeasePhone());
|
applyInfo.setPhone(info.getLeasePhone());
|
||||||
applyInfo.setCreateBy(SecurityUtils.getUsername());
|
applyInfo.setCreateBy(SecurityUtils.getUsername());
|
||||||
applyInfo.setCreateTime(DateUtils.getNowDate());
|
applyInfo.setCreateTime(DateUtils.getNowDate());
|
||||||
applyInfo.setDeptId(Long.valueOf(id));
|
applyInfo.setDeptId((long) id);
|
||||||
applyInfo.setDirectId((long) id);
|
applyInfo.setDirectId((long) id);
|
||||||
|
applyInfo.setCompanyId(directApplyInfos.getCompanyId());
|
||||||
/** 设置审批人为默认的董班长 --防止代码冲突 **/
|
/** 设置审批人为默认的董班长 --防止代码冲突 **/
|
||||||
int count = leaseApplyInfoMapper.insertLeaseApplyInfo(applyInfo);
|
int count = leaseApplyInfoMapper.insertLeaseApplyInfo(applyInfo);
|
||||||
|
boolean isBz = false;
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
// 新增lease_apply_details表数据
|
// 新增lease_apply_details表数据
|
||||||
count = getLeaseApplyCount(list, applyInfo, count);
|
count = getLeaseApplyCount(list, applyInfo, count, directApplyInfos.getCompanyId());
|
||||||
// 插入 lease_out_details表数据
|
// 插入 lease_out_details表数据
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
extracted(sltAgreementInfo, info, detailById, applyInfo);
|
Long projectUnitAgreementId = null;
|
||||||
|
if (leaseUnitTypeId != null && leaseUnitTypeId == 1731L) {
|
||||||
|
isBz = true;
|
||||||
|
// 查询领料班组挂靠的项目部协议ID
|
||||||
|
projectUnitAgreementId = leaseApplyInfoMapper.selectProjectUnitAgreementIdByTeamAndProject(
|
||||||
|
Math.toIntExact(Long.parseLong(directApplyInfos.getLeaseUnitId())),
|
||||||
|
Math.toIntExact(Long.parseLong(directApplyInfos.getLeaseProId()))
|
||||||
|
).getProjectUnitAgreementId();
|
||||||
|
}
|
||||||
|
extracted(info, detailById, applyInfo, directApplyInfos.getCompanyId(), isBz, projectUnitAgreementId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isBz) {
|
||||||
|
// 同步一份数据至材料站
|
||||||
|
int clzMonthMaxOrder = tmTaskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_MATERIAL_LEASE.getTaskTypeId());
|
||||||
|
String clzCode = genderClzLeaseTaskCode(clzMonthMaxOrder);
|
||||||
|
TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_MATERIAL_LEASE.getTaskTypeId(),
|
||||||
|
LeaseTaskStatusEnum.LEASE_TASK_FINISHED.getStatus(),
|
||||||
|
directApplyInfos.getCompanyId(), clzMonthMaxOrder + GlobalConstants.INT_1, clzCode);
|
||||||
|
tmTask.setCreateTime(DateUtils.getNowDate());
|
||||||
|
tmTask.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
||||||
|
tmTaskMapper.insertTmTask(tmTask);
|
||||||
|
BmAgreementInfo bmAgreementInfo = new BmAgreementInfo();
|
||||||
|
bmAgreementInfo.setUnitId(Long.valueOf(directApplyInfos.getLeaseUnitId()));
|
||||||
|
bmAgreementInfo.setProjectId(Long.valueOf(directApplyInfos.getLeaseProId()));
|
||||||
|
// 先根据班组和工程id查询,若存在则直接返回,不存在则新增
|
||||||
|
Long agreementId = null;
|
||||||
|
BmAgreementInfo bmAgreementInfo1 = bmAgreementInfoMapper.queryByTeamIdAndProjectIdCl(bmAgreementInfo);
|
||||||
|
if (bmAgreementInfo1 != null) {
|
||||||
|
agreementId = bmAgreementInfo1.getAgreementId();
|
||||||
|
} else {
|
||||||
|
count = bmAgreementInfoMapper.insertBmAgreementInfoClz(bmAgreementInfo);
|
||||||
|
if (count > GlobalConstants.INT_0) {
|
||||||
|
agreementId = bmAgreementInfo.getAgreementId();
|
||||||
|
} else {
|
||||||
|
return AjaxResult.error("新增bm_agreement_info表失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TmTaskAgreement agreement = new TmTaskAgreement(tmTask.getTaskId(), agreementId);
|
||||||
|
agreement.setCreateTime(DateUtils.getNowDate());
|
||||||
|
agreement.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
||||||
|
agreement.setCompanyId(directApplyInfos.getCompanyId());
|
||||||
|
taskAgreementMapper.insertTmTaskAgreement(agreement);
|
||||||
|
// 领料任务类型为2 数据同步
|
||||||
|
MaterialLeaseApplyInfo materialLeaseApplyInfo = new MaterialLeaseApplyInfo();
|
||||||
|
materialLeaseApplyInfo.setCode(clzCode);
|
||||||
|
materialLeaseApplyInfo.setTaskId(tmTask.getTaskId());
|
||||||
|
materialLeaseApplyInfo.setLeaseStyle("2");
|
||||||
|
materialLeaseApplyInfo.setTeamId(directApplyInfos.getLeaseUnitId());
|
||||||
|
materialLeaseApplyInfo.setProId(Long.valueOf(directApplyInfos.getLeaseProId()));
|
||||||
|
materialLeaseApplyInfo.setCreateTime(DateUtils.getNowDate());
|
||||||
|
materialLeaseApplyInfo.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
||||||
|
materialLeaseApplyInfo.setDirectId((long) id);
|
||||||
|
materialLeaseApplyInfo.setCompanyId(directApplyInfos.getCompanyId());
|
||||||
|
// 根据领料id查询领料人和领料电话
|
||||||
|
LeaseApplyInfo leaseApplyInfo = new LeaseApplyInfo();
|
||||||
|
leaseApplyInfo = materialLeaseInfoMapper.selectLeaseInfo(applyInfo.getId());
|
||||||
|
if (leaseApplyInfo != null) {
|
||||||
|
materialLeaseApplyInfo.setLeasePerson(StringUtils.isNotBlank(leaseApplyInfo.getLeasePerson()) ? leaseApplyInfo.getLeasePerson() : "");
|
||||||
|
materialLeaseApplyInfo.setPhone(StringUtils.isNotBlank(leaseApplyInfo.getPhone()) ? leaseApplyInfo.getPhone() : "");
|
||||||
|
}
|
||||||
|
count = materialLeaseInfoMapper.insertLeaseApplyInfo(materialLeaseApplyInfo);
|
||||||
|
LeaseOutDetails record = new LeaseOutDetails();
|
||||||
|
if (count > GlobalConstants.INT_0) {
|
||||||
|
// 新增clz_lease_apply_details表数据
|
||||||
|
insertPurchaseCheckDetails(list, materialLeaseApplyInfo, record, directApplyInfos.getCompanyId());
|
||||||
|
// 插入 clz_lease_out_details表数据
|
||||||
|
insertPurchaseCheckOutDetails(detailById, materialLeaseApplyInfo, record, directApplyInfos.getCompanyId(), agreementId);
|
||||||
|
} else {
|
||||||
|
return AjaxResult.error("新增任务失败,lease_apply_info表插入0条");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return AjaxResult.success("直转成功");
|
return AjaxResult.success("直转成功");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -456,6 +716,135 @@ public class DirectRotationImpl implements DirectRotationService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取材料站领料任务编号
|
||||||
|
* @param clzMonthMaxOrder
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String genderClzLeaseTaskCode(int clzMonthMaxOrder) {
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
Date nowDate = DateUtils.getNowDate();
|
||||||
|
String format = dateFormat.format(nowDate);
|
||||||
|
String result = format.replace("-", "");
|
||||||
|
return MaterialConstants.MATERIAL_LEASE_TASK_TYPE_LABEL + result + String.format("-%03d", clzMonthMaxOrder + GlobalConstants.INT_1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 插入 clz_lease_out_details表数据
|
||||||
|
* @param detailById
|
||||||
|
* @param materialLeaseApplyInfo
|
||||||
|
* @param record
|
||||||
|
* @param companyId
|
||||||
|
*/
|
||||||
|
private void insertPurchaseCheckOutDetails(List<DirectApplyDetails> detailById, MaterialLeaseApplyInfo materialLeaseApplyInfo, LeaseOutDetails record,
|
||||||
|
Long companyId, Long agreementId) {
|
||||||
|
for (DirectApplyDetails directApplyDetails : detailById) {
|
||||||
|
record.setCreateTime(DateUtils.getNowDate());
|
||||||
|
record.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
||||||
|
record.setIsFinished(GlobalConstants.INT_1);
|
||||||
|
record.setPreNum(directApplyDetails.getDirectNum());
|
||||||
|
record.setAlNum(directApplyDetails.getDirectNum());
|
||||||
|
record.setParentId(materialLeaseApplyInfo.getId());
|
||||||
|
record.setTypeId(Long.valueOf(directApplyDetails.getTypeId()));
|
||||||
|
record.setCompanyId(companyId);
|
||||||
|
record.setMaId(directApplyDetails.getMaId() == null ? null : Long.valueOf(directApplyDetails.getMaId()));
|
||||||
|
int res = materialLeaseInfoMapper.insertLeaseOutDetails(record);
|
||||||
|
if (res == GlobalConstants.INT_0) {
|
||||||
|
throw new RuntimeException("出库失败,插入结算记录失败");
|
||||||
|
}
|
||||||
|
Type maType = typeMapper.getMaType(record.getTypeId());
|
||||||
|
maType.setFinalPrice(maType.getLeasePrice());
|
||||||
|
record.setLeaseStyle("2");
|
||||||
|
record.setSource(2);
|
||||||
|
record.setOutNum(directApplyDetails.getDirectNum());
|
||||||
|
res = materialLeaseInfoMapper.insSltInfo(record, agreementId.toString(), maType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加clz_lease_apply_details表数据
|
||||||
|
* @param list
|
||||||
|
* @param materialLeaseApplyInfo
|
||||||
|
* @param record
|
||||||
|
*/
|
||||||
|
private void insertPurchaseCheckDetails(List<DirectApplyDetails> list, MaterialLeaseApplyInfo materialLeaseApplyInfo,
|
||||||
|
LeaseOutDetails record, Long companyId) {
|
||||||
|
for (DirectApplyDetails directApplyDetails : list) {
|
||||||
|
record.setPreNum(directApplyDetails.getDirectNum());
|
||||||
|
record.setAlNum(directApplyDetails.getDirectNum());
|
||||||
|
record.setParentId(materialLeaseApplyInfo.getId());
|
||||||
|
record.setTypeId(Long.valueOf(directApplyDetails.getTypeId()));
|
||||||
|
record.setCompanyId(companyId);
|
||||||
|
record.setCreateTime(DateUtils.getNowDate());
|
||||||
|
record.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
||||||
|
materialLeaseInfoMapper.insertLeaseApplyDetails(record);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工地直转材料站逻辑处理
|
||||||
|
* @param record
|
||||||
|
* @param detailById
|
||||||
|
* @param result
|
||||||
|
* @param companyId
|
||||||
|
* @param agreementId
|
||||||
|
*/
|
||||||
|
private void extractedClzCheckDetails(MaterialBackApplyInfo record, List<DirectApplyDetails> detailById, int result, Long companyId, Long agreementId) {
|
||||||
|
if (CollectionUtil.isNotEmpty(detailById)) {
|
||||||
|
for (DirectApplyDetails directApplyDetails : detailById) {
|
||||||
|
MaterialBackApplyDetails details = new MaterialBackApplyDetails();
|
||||||
|
details.setParentId(record.getId());
|
||||||
|
details.setTypeId(Long.valueOf(directApplyDetails.getTypeId()));
|
||||||
|
details.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
||||||
|
details.setCreateTime(DateUtils.getNowDate());
|
||||||
|
details.setPreNum(directApplyDetails.getDirectNum());
|
||||||
|
details.setStatus("0");
|
||||||
|
details.setMaId(directApplyDetails.getMaId() != null ? Long.valueOf(directApplyDetails.getMaId()) : null);
|
||||||
|
details.setIsFinished(1);
|
||||||
|
details.setCompanyId(companyId);
|
||||||
|
result += materialBackInfoMapper.insertCheckDetails(details);
|
||||||
|
// 更新结算表信息
|
||||||
|
MaterialBackApplyInfo bean = new MaterialBackApplyInfo();
|
||||||
|
bean.setAgreementId(agreementId);
|
||||||
|
bean.setTypeId(directApplyDetails.getTypeId().toString());
|
||||||
|
bean.setMaId(directApplyDetails.getMaId() != null ? Long.valueOf(directApplyDetails.getMaId()) : null);
|
||||||
|
List<SltAgreementInfo> infoList = materialBackInfoMapper.getClzInfo(bean);
|
||||||
|
BigDecimal backNum = directApplyDetails.getDirectNum();
|
||||||
|
if (CollectionUtils.isNotEmpty(infoList)) {
|
||||||
|
for (SltAgreementInfo info : infoList) {
|
||||||
|
BigDecimal num = info.getBackNum();
|
||||||
|
if (backNum.compareTo(num) == 0) {
|
||||||
|
materialBackInfoMapper.updateStlInfo(info, record);
|
||||||
|
break;
|
||||||
|
} else if (backNum.compareTo(num) > 0) {
|
||||||
|
backNum = backNum.subtract(num);
|
||||||
|
materialBackInfoMapper.updateStlInfo(info, record);
|
||||||
|
} else {
|
||||||
|
BigDecimal many = num.subtract(backNum);
|
||||||
|
materialBackInfoMapper.updateStlInfoTwo(info, record, backNum);
|
||||||
|
info.setSource("2");
|
||||||
|
materialBackInfoMapper.insStlInfoTwo(info, many);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成材料站退料任务单号
|
||||||
|
* @param thisMonthMaxOrder
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String genderClzTaskCode(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_MATERIAL_TASK_TYPE_LABEL + result + String.format("-%03d", thisMonthMaxOrder + 1);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SltAgreementInfo> getUseringDataByClz(Integer projectId) {
|
public List<SltAgreementInfo> getUseringDataByClz(Integer projectId) {
|
||||||
return mapper.getUseringDataByClz(projectId);
|
return mapper.getUseringDataByClz(projectId);
|
||||||
|
|
@ -667,16 +1056,18 @@ public class DirectRotationImpl implements DirectRotationService {
|
||||||
* @param result
|
* @param result
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private int getBackInfoResult(DirectApplyInfo info, BackApplyInfo backApplyInfo, TmTask task, int result) {
|
private int getBackInfoResult(DirectApplyInfo info, BackApplyInfo backApplyInfo, TmTask task, int result, Long companyId) {
|
||||||
if (result > 0) {
|
if (result > 0) {
|
||||||
TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(task.getTaskId(), Long.valueOf(info.getBackAgreementId()));
|
TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(task.getTaskId(), Long.valueOf(info.getBackAgreementId()));
|
||||||
tmTaskAgreement.setCreateTime(DateUtils.getNowDate());
|
tmTaskAgreement.setCreateTime(DateUtils.getNowDate());
|
||||||
tmTaskAgreement.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
tmTaskAgreement.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
||||||
|
tmTaskAgreement.setCompanyId(companyId);
|
||||||
taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement);
|
taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement);
|
||||||
backApplyInfo.setTaskId(task.getTaskId());
|
backApplyInfo.setTaskId(task.getTaskId());
|
||||||
/** 设置审批人为默认的李勇 --防止代码冲突 **/
|
/** 设置审批人为默认的李勇 --防止代码冲突 **/
|
||||||
Long peopleId = backApplyInfoMapper.getDirectAuditBy();
|
Long peopleId = backApplyInfoMapper.getDirectAuditBy();
|
||||||
backApplyInfo.setDirectAuditBy(peopleId);
|
backApplyInfo.setDirectAuditBy(peopleId);
|
||||||
|
backApplyInfo.setCompanyId(companyId);
|
||||||
/** 设置审批人为默认的李勇 --防止代码冲突 **/
|
/** 设置审批人为默认的李勇 --防止代码冲突 **/
|
||||||
result += backApplyInfoMapper.insertBackApplyInfo(backApplyInfo);
|
result += backApplyInfoMapper.insertBackApplyInfo(backApplyInfo);
|
||||||
}
|
}
|
||||||
|
|
@ -690,7 +1081,7 @@ public class DirectRotationImpl implements DirectRotationService {
|
||||||
* @param result
|
* @param result
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private int getBackDetailsResult(BackApplyInfo backApplyInfo, List<DirectApplyDetails> list, int result) {
|
private int getBackDetailsResult(BackApplyInfo backApplyInfo, List<DirectApplyDetails> list, int result, Long companyId) {
|
||||||
if (CollectionUtil.isNotEmpty(list)) {
|
if (CollectionUtil.isNotEmpty(list)) {
|
||||||
for (DirectApplyDetails directApplyDetails : list) {
|
for (DirectApplyDetails directApplyDetails : list) {
|
||||||
BackApplyDetails details = new BackApplyDetails();
|
BackApplyDetails details = new BackApplyDetails();
|
||||||
|
|
@ -704,6 +1095,7 @@ public class DirectRotationImpl implements DirectRotationService {
|
||||||
details.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
details.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
||||||
details.setCreateTime(DateUtils.getNowDate());
|
details.setCreateTime(DateUtils.getNowDate());
|
||||||
details.setTypeId(Long.valueOf(directApplyDetails.getTypeId()));
|
details.setTypeId(Long.valueOf(directApplyDetails.getTypeId()));
|
||||||
|
details.setCompanyId(companyId);
|
||||||
// 保存退料详情
|
// 保存退料详情
|
||||||
result += backApplyInfoMapper.insertBackApplyDetails(details);
|
result += backApplyInfoMapper.insertBackApplyDetails(details);
|
||||||
}
|
}
|
||||||
|
|
@ -717,7 +1109,8 @@ public class DirectRotationImpl implements DirectRotationService {
|
||||||
* @param detailById
|
* @param detailById
|
||||||
* @param result
|
* @param result
|
||||||
*/
|
*/
|
||||||
private void extractedCheckDetails(BackApplyInfo backApplyInfo, List<DirectApplyDetails> detailById, int result) {
|
private void extractedCheckDetails(BackApplyInfo backApplyInfo, List<DirectApplyDetails> detailById, int result, Long companyId,
|
||||||
|
Long projectUnitAgreementId, Integer flag) {
|
||||||
if (CollectionUtil.isNotEmpty(detailById)) {
|
if (CollectionUtil.isNotEmpty(detailById)) {
|
||||||
for (DirectApplyDetails directApplyDetails : detailById) {
|
for (DirectApplyDetails directApplyDetails : detailById) {
|
||||||
BackApplyDetails details = new BackApplyDetails();
|
BackApplyDetails details = new BackApplyDetails();
|
||||||
|
|
@ -731,15 +1124,24 @@ public class DirectRotationImpl implements DirectRotationService {
|
||||||
details.setBackStatus("0");
|
details.setBackStatus("0");
|
||||||
details.setStatus("2");
|
details.setStatus("2");
|
||||||
details.setIsFinished(1);
|
details.setIsFinished(1);
|
||||||
|
details.setCompanyId(companyId);
|
||||||
// 插入 CheckDetails
|
// 插入 CheckDetails
|
||||||
result += backApplyInfoMapper.insertCheckDetails(details);
|
result += backApplyInfoMapper.insertCheckDetails(details);
|
||||||
// 更新结算表信息
|
// 更新结算表信息
|
||||||
BackApplyInfo bean = new BackApplyInfo();
|
BackApplyInfo bean = new BackApplyInfo();
|
||||||
bean.setAgreementId(directApplyDetails.getBackAgreementId());
|
bean.setAgreementId(projectUnitAgreementId != null ? projectUnitAgreementId : directApplyDetails.getBackAgreementId());
|
||||||
bean.setTypeId(directApplyDetails.getTypeId().toString());
|
bean.setTypeId(directApplyDetails.getTypeId().toString());
|
||||||
bean.setMaId(directApplyDetails.getMaId() == null ?
|
bean.setMaId(directApplyDetails.getMaId() == null ?
|
||||||
null : Long.valueOf(directApplyDetails.getMaId()));
|
null : Long.valueOf(directApplyDetails.getMaId()));
|
||||||
List<SltAgreementInfo> infoList = backApplyInfoMapper.getStlInfo(bean);
|
List<SltAgreementInfo> infoList = new ArrayList<>();
|
||||||
|
if (flag == 1) {
|
||||||
|
// 查询直领数据
|
||||||
|
infoList = backApplyInfoMapper.getStlInfo(bean);
|
||||||
|
} else if (flag == 2) {
|
||||||
|
// 获取项目部数据
|
||||||
|
infoList = backApplyInfoMapper.getXmInfoList(bean);
|
||||||
|
}
|
||||||
|
|
||||||
BigDecimal backNum = directApplyDetails.getDirectNum();
|
BigDecimal backNum = directApplyDetails.getDirectNum();
|
||||||
if (CollectionUtils.isNotEmpty(infoList)) {
|
if (CollectionUtils.isNotEmpty(infoList)) {
|
||||||
for (SltAgreementInfo agreementInfo : infoList) {
|
for (SltAgreementInfo agreementInfo : infoList) {
|
||||||
|
|
@ -790,7 +1192,7 @@ public class DirectRotationImpl implements DirectRotationService {
|
||||||
* @param count
|
* @param count
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private int getLeaseApplyCount(List<DirectApplyDetails> list, LeaseApplyInfo applyInfo, int count) {
|
private int getLeaseApplyCount(List<DirectApplyDetails> list, LeaseApplyInfo applyInfo, int count, Long companyId) {
|
||||||
if (CollectionUtil.isNotEmpty(list)) {
|
if (CollectionUtil.isNotEmpty(list)) {
|
||||||
List<LeaseApplyDetails> leaseApplyDetails = new ArrayList<>();
|
List<LeaseApplyDetails> leaseApplyDetails = new ArrayList<>();
|
||||||
for (DirectApplyDetails directApplyDetails : list) {
|
for (DirectApplyDetails directApplyDetails : list) {
|
||||||
|
|
@ -802,6 +1204,7 @@ public class DirectRotationImpl implements DirectRotationService {
|
||||||
details.setPreNum(directApplyDetails.getDirectNum());
|
details.setPreNum(directApplyDetails.getDirectNum());
|
||||||
details.setAlNum(directApplyDetails.getDirectNum());
|
details.setAlNum(directApplyDetails.getDirectNum());
|
||||||
details.setStatus("2");
|
details.setStatus("2");
|
||||||
|
details.setCompanyId(companyId);
|
||||||
leaseApplyDetails.add(details);
|
leaseApplyDetails.add(details);
|
||||||
}
|
}
|
||||||
// 批量插入详情数据
|
// 批量插入详情数据
|
||||||
|
|
@ -814,12 +1217,12 @@ public class DirectRotationImpl implements DirectRotationService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 插入(领料出库详情表) lease_out_details表数据
|
* 插入(领料出库详情表) lease_out_details表数据
|
||||||
* @param sltAgreementInfo
|
|
||||||
* @param info
|
* @param info
|
||||||
* @param detailById
|
* @param detailById
|
||||||
* @param applyInfo
|
* @param applyInfo
|
||||||
*/
|
*/
|
||||||
private void extracted(SltAgreementInfo sltAgreementInfo, DirectApplyInfo info, List<DirectApplyDetails> detailById, LeaseApplyInfo applyInfo) {
|
private void extracted(DirectApplyInfo info, List<DirectApplyDetails> detailById, LeaseApplyInfo applyInfo,
|
||||||
|
Long companyId, boolean isBz, Long projectUnitAgreementId) {
|
||||||
int count;
|
int count;
|
||||||
if (CollectionUtils.isNotEmpty(detailById)) {
|
if (CollectionUtils.isNotEmpty(detailById)) {
|
||||||
for (DirectApplyDetails directApplyDetails : detailById) {
|
for (DirectApplyDetails directApplyDetails : detailById) {
|
||||||
|
|
@ -833,26 +1236,23 @@ public class DirectRotationImpl implements DirectRotationService {
|
||||||
1 : 0);
|
1 : 0);
|
||||||
record.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
record.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
||||||
record.setCreateTime(DateUtils.getNowDate());
|
record.setCreateTime(DateUtils.getNowDate());
|
||||||
record.setSource(1);
|
record.setSource(isBz ? 2 : 1);
|
||||||
|
record.setCompanyId(companyId);
|
||||||
count = leaseOutDetailsMapper.insertLeaseOutDetails(record);
|
count = leaseOutDetailsMapper.insertLeaseOutDetails(record);
|
||||||
// 插入结算表
|
// 插入结算表
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
SltAgreementInfo dto = sltAgreementInfoMapper.getSltAgreementInfo(record);
|
Type maType = typeMapper.getMaType(record.getTypeId());
|
||||||
if (dto != null) {
|
maType.setFinalPrice(maType.getLeasePrice());
|
||||||
BigDecimal num = dto.getNum();
|
count = sltAgreementInfoMapper.insSltInfo(record, String.valueOf(info.getLeaseAgreementId()), maType);
|
||||||
BigDecimal outNum = record.getOutNum();
|
// 班组领料,同步一份数据至项目部
|
||||||
dto.setNum(num.add(outNum));
|
if (isBz) {
|
||||||
count = sltAgreementInfoMapper.updSltInfo(dto);
|
record.setSource(1);
|
||||||
record.setAgreementId(sltAgreementInfo.getAgreementId());
|
count = sltAgreementInfoMapper.insSltInfo(record, String.valueOf(projectUnitAgreementId), maType);
|
||||||
}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("领料结算表插入失败");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (count <= 0) {
|
||||||
|
throw new RuntimeException("领料结算表插入失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1930,4 +1930,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
order by start_time asc
|
order by start_time asc
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getXmInfoList" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
|
||||||
|
SELECT
|
||||||
|
id AS id,
|
||||||
|
agreement_id AS agreementId,
|
||||||
|
type_id AS typeId,
|
||||||
|
ma_id AS maId,
|
||||||
|
num AS backNum,
|
||||||
|
start_time AS startTime,
|
||||||
|
end_time AS endTime,
|
||||||
|
status AS status,
|
||||||
|
lease_id AS leaseId,
|
||||||
|
lease_type AS leaseType,
|
||||||
|
back_id AS backId,
|
||||||
|
lease_price AS leasePrice,
|
||||||
|
buy_price AS buyPrice,
|
||||||
|
company_id AS companyId
|
||||||
|
FROM
|
||||||
|
slt_agreement_info
|
||||||
|
WHERE
|
||||||
|
status = 0
|
||||||
|
AND source = '1'
|
||||||
|
AND type_id = #{typeId}
|
||||||
|
AND agreement_id = #{agreementId}
|
||||||
|
<if test="maId != null">
|
||||||
|
AND ma_id = #{maId}
|
||||||
|
</if>
|
||||||
|
order by start_time asc
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -462,4 +462,62 @@
|
||||||
ORDER BY
|
ORDER BY
|
||||||
lai.create_time DESC
|
lai.create_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getXmList" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
|
||||||
|
SELECT
|
||||||
|
id AS id,
|
||||||
|
agreement_id AS agreementId,
|
||||||
|
type_id AS typeId,
|
||||||
|
ma_id AS maId,
|
||||||
|
num AS backNum,
|
||||||
|
start_time AS startTime,
|
||||||
|
end_time AS endTime,
|
||||||
|
status AS status,
|
||||||
|
lease_id AS leaseId,
|
||||||
|
lease_type AS leaseType,
|
||||||
|
back_id AS backId,
|
||||||
|
lease_price AS leasePrice,
|
||||||
|
buy_price AS buyPrice,
|
||||||
|
company_id AS companyId
|
||||||
|
FROM
|
||||||
|
slt_agreement_info
|
||||||
|
WHERE
|
||||||
|
status = 0
|
||||||
|
AND source = '1'
|
||||||
|
AND type_id = #{typeId}
|
||||||
|
AND agreement_id = #{agreementId}
|
||||||
|
<if test="maId != null">
|
||||||
|
AND ma_id = #{maId}
|
||||||
|
</if>
|
||||||
|
order by start_time asc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getClzList" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
|
||||||
|
SELECT
|
||||||
|
id AS id,
|
||||||
|
agreement_id AS agreementId,
|
||||||
|
type_id AS typeId,
|
||||||
|
ma_id AS maId,
|
||||||
|
num AS backNum,
|
||||||
|
start_time AS startTime,
|
||||||
|
end_time AS endTime,
|
||||||
|
status AS status,
|
||||||
|
lease_id AS leaseId,
|
||||||
|
lease_type AS leaseType,
|
||||||
|
back_id AS backId,
|
||||||
|
lease_price AS leasePrice,
|
||||||
|
buy_price AS buyPrice,
|
||||||
|
company_id AS companyId
|
||||||
|
FROM
|
||||||
|
clz_slt_agreement_info
|
||||||
|
WHERE
|
||||||
|
status = 0
|
||||||
|
AND source = '2'
|
||||||
|
AND type_id = #{typeId}
|
||||||
|
AND agreement_id = #{agreementId}
|
||||||
|
<if test="maId != null">
|
||||||
|
AND ma_id = #{maId}
|
||||||
|
</if>
|
||||||
|
order by start_time asc
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue