This commit is contained in:
parent
e48cfda3f0
commit
60e13662a7
|
|
@ -16,6 +16,13 @@ import java.util.List;
|
|||
*/
|
||||
@Data
|
||||
public class BackApplyInfo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 是否完成退料(0 否,1 是)
|
||||
*/
|
||||
@ApiModelProperty(value = "是否完成退料(0 否,1 是)")
|
||||
private Integer isFinishBack;
|
||||
|
||||
/**
|
||||
* 退料id
|
||||
*/
|
||||
|
|
@ -113,7 +120,7 @@ public class BackApplyInfo extends BaseEntity {
|
|||
/**
|
||||
* 类型名称
|
||||
*/
|
||||
@Excel(name = "退料机具",sort = 4)
|
||||
@Excel(name = "退料类型名称",sort = 4)
|
||||
@ApiModelProperty(value = "类型名称")
|
||||
private String typeName;
|
||||
/**
|
||||
|
|
@ -125,7 +132,6 @@ public class BackApplyInfo extends BaseEntity {
|
|||
/**
|
||||
* 规格编号
|
||||
*/
|
||||
@Excel(name = "规格型号")
|
||||
@ApiModelProperty(value = "规格编号")
|
||||
private String typeCode;
|
||||
|
||||
|
|
@ -183,7 +189,7 @@ public class BackApplyInfo extends BaseEntity {
|
|||
private BackApplyInfo info;
|
||||
|
||||
|
||||
private Integer parentId;
|
||||
private Long parentId;
|
||||
private String sdStatus;
|
||||
private String sdId;
|
||||
/**
|
||||
|
|
@ -219,7 +225,6 @@ public class BackApplyInfo extends BaseEntity {
|
|||
|
||||
|
||||
|
||||
@Excel(name = "退料状态" , readConverterExp = "37=待退料审核,38=退料已审核,39=退料核查中,40=退料完成,101 = 退料审核驳回")
|
||||
@ApiModelProperty(value = "任务状态")
|
||||
private String taskStatus;
|
||||
|
||||
|
|
@ -270,13 +275,6 @@ public class BackApplyInfo extends BaseEntity {
|
|||
@ApiModelProperty(value = "工程id")
|
||||
private Integer lotId;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ApiModelProperty(value = "单位id")
|
||||
private Integer unitId;
|
||||
@ApiModelProperty(value = "计量单位")
|
||||
|
|
@ -392,4 +390,29 @@ public class BackApplyInfo extends BaseEntity {
|
|||
|
||||
/** 库管员 */
|
||||
private long userId;
|
||||
|
||||
/**
|
||||
* 退料合格编码集合
|
||||
*/
|
||||
private List<MaCodeDto> passMaCodeDtoList;
|
||||
|
||||
/**
|
||||
* 退料维修编码集合
|
||||
*/
|
||||
private List<MaCodeDto> repairMaCodeDtoList;
|
||||
|
||||
/**
|
||||
* 退料编码集合
|
||||
*/
|
||||
private List<MaCodeDto> numList;
|
||||
|
||||
@ApiModelProperty(value = "数据字典")
|
||||
private Long dicId;
|
||||
|
||||
private String maStatus;
|
||||
|
||||
@ApiModelProperty(value = "物资类型")
|
||||
private String materialType;
|
||||
|
||||
private String materialName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
package com.bonus.sgzb.base.api.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 退料机具设备信息
|
||||
* @Author ma_sh
|
||||
* @create 2025/3/21 11:09
|
||||
*/
|
||||
@Data
|
||||
public class MaCodeDto {
|
||||
|
||||
private Integer maId;
|
||||
|
||||
private String maCode;
|
||||
|
||||
private String maStatus;
|
||||
|
||||
private String maStatusName;
|
||||
|
||||
private String typeId;
|
||||
|
||||
private String taskId;
|
||||
|
||||
@ApiModelProperty(value = "物资类型")
|
||||
private String materialType;
|
||||
|
||||
private String materialName;
|
||||
|
||||
private String typeName;
|
||||
|
||||
private String typeModelName;
|
||||
|
||||
private Integer totalNum;
|
||||
}
|
||||
|
|
@ -226,7 +226,8 @@ public class AppBackApplyController extends BaseController {
|
|||
if (CollUtil.isEmpty(record.getBackApplyDetails())) {
|
||||
return AjaxResult.error("退料设备明细为空,请重新选择后上传!");
|
||||
}
|
||||
backApplyService.updateBackInfo(record.getParentId(),record.getCompanyId());
|
||||
int intValue = record.getParentId().intValue();
|
||||
backApplyService.updateBackInfo(intValue, record.getCompanyId());
|
||||
for (BackApplyInfo backApplyInfo : record.getBackApplyDetails()) {
|
||||
backApplyInfo.setParentId(record.getParentId());
|
||||
backApplyInfo.setAuditNum(backApplyInfo.getPreNum());
|
||||
|
|
|
|||
|
|
@ -220,4 +220,13 @@ public interface BackReceiveMapper {
|
|||
Integer deleteFile(BackApplyInfo record);
|
||||
|
||||
FileInfo getfileByUid(String uid);
|
||||
|
||||
/**
|
||||
* 查询文件信息
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
List<FileInfo> selectFileInfoList(BackApplyInfo dto);
|
||||
|
||||
int deleteBackFile(BackApplyInfo backApplyInfo);
|
||||
}
|
||||
|
|
@ -134,7 +134,8 @@ public class BackReceiveServiceImpl implements BackReceiveService {
|
|||
if (arr.length > 0) {
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
//判断是否超出审核数量
|
||||
int re = backReceiveMapper.selectNumByTypeId(arr[i].getParentId(), arr[i].getTypeId());
|
||||
int intValue = arr[i].getParentId().intValue();
|
||||
int re = backReceiveMapper.selectNumByTypeId(intValue, arr[i].getTypeId());
|
||||
if (re <= 0) {
|
||||
res = -2;
|
||||
break;
|
||||
|
|
@ -223,7 +224,7 @@ public class BackReceiveServiceImpl implements BackReceiveService {
|
|||
maintenanceNum += bi.getBackNum();
|
||||
}
|
||||
}
|
||||
List<BackApplyInfo> bfList = backReceiveMapper.getBfList(record);
|
||||
List<BackApplyInfo> bfList = backReceiveMapper.getWxList(record);
|
||||
if (bfList != null && bfList.size() > 0) {
|
||||
for (BackApplyInfo bi : bfList) {
|
||||
scrapNum += bi.getBackNum();
|
||||
|
|
@ -547,15 +548,73 @@ public class BackReceiveServiceImpl implements BackReceiveService {
|
|||
}
|
||||
List<BackApplyInfo> backApplyInfoList = receiveView(record);
|
||||
if (!CollectionUtils.isEmpty(backApplyInfoList) && !CollectionUtils.isEmpty(useTypeTree)) {
|
||||
// 将最大退料数量为0或者最大退料数量小于实际退料数量则移除
|
||||
backApplyInfoList.removeIf(info -> info.getMaxBackNum() == 0);
|
||||
for (TypeTreeNode typeTreeNode : useTypeTree) {
|
||||
for (BackApplyInfo applyInfo : backApplyInfoList) {
|
||||
if (String.valueOf(typeTreeNode.getTypeId()).equals(applyInfo.getModelId())) {
|
||||
BackApplyInfo dto = new BackApplyInfo();
|
||||
dto.setTypeId(String.valueOf(typeTreeNode.getTypeId()));
|
||||
dto.setParentId(backApplyInfos.get(0).getId());
|
||||
applyInfo.setUnitNames(typeTreeNode.getUnitNames());
|
||||
applyInfo.setTypeId(String.valueOf(typeTreeNode.getTypeId()));
|
||||
applyInfo.setUseNum(typeTreeNode.getNum());
|
||||
applyInfo.setNum(applyInfo.getPreNum());
|
||||
applyInfo.setBackNum(applyInfo.getPreNum());
|
||||
// 查询设备合格及维修数量及详情
|
||||
List<MaCodeDto> numList = new ArrayList<>();
|
||||
List<BackApplyInfo> hgList = backReceiveMapper.getHgList(dto);
|
||||
if (!CollectionUtils.isEmpty(hgList)) {
|
||||
if (StringUtils.isNotBlank(hgList.get(0).getMaCode())) {
|
||||
List<MaCodeDto> list = new ArrayList<>();
|
||||
|
||||
applyInfo.setPassNum(hgList.size());
|
||||
for (BackApplyInfo info : hgList) {
|
||||
MaCodeDto maCodeDto = new MaCodeDto();
|
||||
maCodeDto.setMaId(info.getMaId());
|
||||
maCodeDto.setMaCode(info.getMaCode());
|
||||
maCodeDto.setMaStatus(info.getMaStatus());
|
||||
maCodeDto.setTypeId(info.getTypeId());
|
||||
maCodeDto.setMaterialType(info.getMaterialType());
|
||||
maCodeDto.setMaterialName(info.getMaterialName());
|
||||
maCodeDto.setTypeName(info.getTypeName());
|
||||
list.add(maCodeDto);
|
||||
}
|
||||
applyInfo.setPassMaCodeDtoList(list);
|
||||
numList.addAll(list);
|
||||
} else {
|
||||
applyInfo.setPassNum(hgList.get(0).getBackNum());
|
||||
}
|
||||
}
|
||||
// 查询维修数量及详情
|
||||
List<BackApplyInfo> wxList = backReceiveMapper.getWxList(dto);
|
||||
if (!CollectionUtils.isEmpty(wxList)) {
|
||||
if (StringUtils.isNotBlank(wxList.get(0).getMaCode())) {
|
||||
List<MaCodeDto> list = new ArrayList<>();
|
||||
applyInfo.setMaintenanceNum(wxList.size());
|
||||
for (BackApplyInfo info : wxList) {
|
||||
MaCodeDto maCodeDto = new MaCodeDto();
|
||||
maCodeDto.setMaId(info.getMaId());
|
||||
maCodeDto.setMaCode(info.getMaCode());
|
||||
maCodeDto.setMaStatus(info.getMaStatus());
|
||||
maCodeDto.setTypeId(info.getTypeId());
|
||||
maCodeDto.setMaterialType(info.getMaterialType());
|
||||
maCodeDto.setMaterialName(info.getMaterialName());
|
||||
maCodeDto.setTypeName(info.getTypeName());
|
||||
list.add(maCodeDto);
|
||||
}
|
||||
applyInfo.setRepairMaCodeDtoList(list);
|
||||
numList.addAll(list);
|
||||
} else {
|
||||
applyInfo.setMaintenanceNum(wxList.get(0).getBackNum());
|
||||
}
|
||||
}
|
||||
// 查询是否存在附件
|
||||
dto.setDicId(36L);
|
||||
List<FileInfo> fileInfoList = backReceiveMapper.selectFileInfoList(dto);
|
||||
if (!CollectionUtils.isEmpty(fileInfoList)) {
|
||||
applyInfo.setFileList(fileInfoList);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(numList)) {
|
||||
applyInfo.setNumList(numList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import com.bonus.sgzb.base.api.domain.BackApplyInfo;
|
|||
import com.bonus.sgzb.material.service.BackApplyService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
|
@ -159,16 +160,22 @@ public class BackApplyController extends BaseController {
|
|||
return backApplyService.del(bean);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据单位和工程id查询领料机具
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "根据单位和工程id查询领料机具")
|
||||
@GetMapping("/getMachineById")
|
||||
public AjaxResult getMachineById(BackApplyInfo dto){
|
||||
return backApplyService.getMachineById(dto);
|
||||
}
|
||||
|
||||
@Log(title = "退料申请提交", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/submitBackApply")
|
||||
public AjaxResult submitBackApply(@RequestBody BackApplyInfo bean) {
|
||||
boolean addLeaseTaskResult = false;
|
||||
Long backApplyInfoId = 0L;
|
||||
if (StringUtils.isNull(bean)) {
|
||||
return AjaxResult.error("参数错误");
|
||||
}
|
||||
try {
|
||||
return backApplyService.submitBackApply(bean);
|
||||
/*try {
|
||||
//查看本次退料申请是否合法
|
||||
if (!backApplyService.isBackApplyNumberCorrect(bean)) {
|
||||
return AjaxResult.error("已申请退料数量加上本次退料申请数量,超过领料出库数量,请重试!");
|
||||
|
|
@ -187,13 +194,6 @@ public class BackApplyController extends BaseController {
|
|||
//任务协议表(tm_task_agreement)
|
||||
Boolean addTaskAgreementRes = backApplyService.insertTaskAgreement(bean) > 0;
|
||||
if (addTaskAgreementRes && bean.getBackApplyInfo() != null) {
|
||||
if (CollUtil.isEmpty(bean.getBackApplyDetails())) {
|
||||
return AjaxResult.error("退料设备明细为空,请重新选择后上传!");
|
||||
}
|
||||
if (StringUtils.isNull(bean.getBackApplyInfo())) {
|
||||
return AjaxResult.error("退料任务信息为空,请重新选择后上传!");
|
||||
}
|
||||
|
||||
Integer taskId = bean.getTaskId();
|
||||
// 根据设备所属分公司拆分集合
|
||||
List<List<BackApplyInfo>> backApplyInfoList = CollUtil.groupByField(bean.getBackApplyDetails(), "companyId");
|
||||
|
|
@ -204,11 +204,11 @@ public class BackApplyController extends BaseController {
|
|||
BackApplyInfo backApplyInfo1 = leaseApplyDetailsList.get(0);
|
||||
// 对领料任务表的对象做数据处理
|
||||
BackApplyInfo backApplyInfo = bean.getBackApplyInfo();
|
||||
/* 创建领料单号*/
|
||||
*//* 创建领料单号*//*
|
||||
backApplyInfo.setCode(code);
|
||||
/*设置任务ID*/
|
||||
*//*设置任务ID*//*
|
||||
backApplyInfo.setTaskId(taskId);
|
||||
/*设置设备所属分公司,用于交给哪家审核*/
|
||||
*//*设置设备所属分公司,用于交给哪家审核*//*
|
||||
backApplyInfo.setCompanyId(backApplyInfo1.getCompanyId());
|
||||
// 创建领料任务,返回领料任务编号
|
||||
addLeaseTaskResult = backApplyService.insertBackApply(backApplyInfo) > 0;
|
||||
|
|
@ -219,7 +219,7 @@ public class BackApplyController extends BaseController {
|
|||
if (addLeaseTaskResult) {
|
||||
if (StringUtils.isNotNull(backApplyInfoId)) {
|
||||
for (BackApplyInfo leaseApplyDetails : leaseApplyDetailsList) {
|
||||
/* 设置领料任务ID*/
|
||||
*//* 设置领料任务ID*//*
|
||||
leaseApplyDetails.setId(backApplyInfoId);
|
||||
// 插入领料任务明细
|
||||
leaseApplyDetails.setAuditNum(leaseApplyDetails.getNum());
|
||||
|
|
@ -248,7 +248,7 @@ public class BackApplyController extends BaseController {
|
|||
} catch (Exception e) {
|
||||
return AjaxResult.error("创建任务失败," + e.getCause().toString() + "," + e.getMessage());
|
||||
}
|
||||
return AjaxResult.success("退料任务创建成功");
|
||||
return AjaxResult.success("退料任务创建成功");*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -34,4 +34,6 @@ public class SelectVo {
|
|||
private String isStorage;
|
||||
|
||||
private String parentId;
|
||||
|
||||
private String manageType;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.sgzb.material.mapper;
|
||||
|
||||
import com.bonus.sgzb.base.api.domain.MaCodeDto;
|
||||
import com.bonus.sgzb.material.domain.BackApplyDto;
|
||||
import com.bonus.sgzb.base.api.domain.BackApplyInfo;
|
||||
import com.bonus.sgzb.material.domain.TypeTreeNode;
|
||||
|
|
@ -198,4 +199,20 @@ public interface BackApplyMapper {
|
|||
List<BackApplyInfo> getBackCheckView(BackApplyInfo bean);
|
||||
|
||||
Integer getPreAuditNum(BackApplyInfo record);
|
||||
|
||||
List<MaCodeDto> getMachineById(BackApplyInfo dto);
|
||||
|
||||
/**
|
||||
* 删除退料申请明细
|
||||
* @param backApplyInfo
|
||||
* @return
|
||||
*/
|
||||
int deleteBackApplyDetails(BackApplyInfo backApplyInfo);
|
||||
|
||||
/**
|
||||
* 删除退料审核明细
|
||||
* @param backApplyInfo
|
||||
* @return
|
||||
*/
|
||||
int delBackCheckDetailsById(BackApplyInfo backApplyInfo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,4 +131,18 @@ public interface BackApplyService {
|
|||
* @return
|
||||
*/
|
||||
AjaxResult updateBackApply(BackApplyInfo bean);
|
||||
|
||||
/**
|
||||
* 退料任务创建提交
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
AjaxResult submitBackApply(BackApplyInfo bean);
|
||||
|
||||
/**
|
||||
* 根据单位和工程id查询领料机具
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
AjaxResult getMachineById(BackApplyInfo dto);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,15 @@
|
|||
package com.bonus.sgzb.material.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.bonus.sgzb.app.mapper.BackReceiveMapper;
|
||||
import com.bonus.sgzb.app.mapper.LeaseApplyDetailsMapper;
|
||||
import com.bonus.sgzb.base.api.domain.BackApplyInfo;
|
||||
import com.bonus.sgzb.base.api.domain.MachinePart;
|
||||
import com.bonus.sgzb.base.api.domain.*;
|
||||
import com.bonus.sgzb.base.api.domain.FileInfo;
|
||||
import com.bonus.sgzb.common.core.constant.TaskTypeConstants;
|
||||
import com.bonus.sgzb.common.core.enums.TaskStatusEnum;
|
||||
import com.bonus.sgzb.common.core.enums.TaskTypeEnum;
|
||||
import com.bonus.sgzb.common.core.utils.DateUtils;
|
||||
import com.bonus.sgzb.common.core.utils.HttpCodeEnum;
|
||||
import com.bonus.sgzb.common.core.utils.StringHelper;
|
||||
import com.bonus.sgzb.common.core.utils.StringUtils;
|
||||
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
|
||||
|
|
@ -19,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collector;
|
||||
|
|
@ -41,6 +47,9 @@ public class BackApplyServiceImpl implements BackApplyService {
|
|||
@Autowired
|
||||
private TaskMapper tmTaskMapper;
|
||||
|
||||
@Resource
|
||||
private BackReceiveMapper backReceiveMapper;
|
||||
|
||||
@Override
|
||||
public List<BackApplyInfo> getBackApplyList(BackApplyInfo bean) {
|
||||
Set<String> roles = SecurityUtils.getLoginUser().getRoles();
|
||||
|
|
@ -554,64 +563,128 @@ public class BackApplyServiceImpl implements BackApplyService {
|
|||
if (bean == null || bean.getBackApplyInfo() == null || CollectionUtils.isEmpty(bean.getBackApplyDetails())) {
|
||||
return AjaxResult.error("退料申请数据不能为空");
|
||||
}
|
||||
for (BackApplyInfo backApplyDetail : bean.getBackApplyDetails()) {
|
||||
if (backApplyDetail.getBackNum() != null && backApplyDetail.getUseNum() != null && backApplyDetail.getBackNum() > Integer.parseInt(backApplyDetail.getUseNum())){
|
||||
return AjaxResult.error("退料数不能超过在用数");
|
||||
}
|
||||
}
|
||||
BackApplyInfo backApplyInfo = bean.getBackApplyInfo();
|
||||
List<BackApplyInfo> backApplyDetails = bean.getBackApplyDetails();
|
||||
for (BackApplyInfo backApplyDetail : backApplyDetails) {
|
||||
backApplyDetail.setId(backApplyInfo.getId());
|
||||
// 先去back_check_details查询该条数据退料情况
|
||||
BackApplyInfo info = backApplyMapper.selectCheckDetailsById(backApplyDetail);
|
||||
if (info != null && info.getNum() > backApplyDetail.getNum()) {
|
||||
return AjaxResult.error(backApplyDetail.getTypeName() + "的退料数量不能小于已退料数量,情修改后重新提交");
|
||||
}
|
||||
}
|
||||
try {
|
||||
int result = 0;
|
||||
List<BackApplyInfo> infoList = new ArrayList<>();
|
||||
List<BackApplyInfo> checkList = new ArrayList<>();
|
||||
if (backApplyInfo.getId() != null) {
|
||||
infoList = backApplyMapper.selectBackDetailsById(backApplyInfo);
|
||||
checkList = backApplyMapper.selectDetailsById(bean);
|
||||
if (CollectionUtils.isNotEmpty(checkList)) {
|
||||
// 将checkList中所有的typeId提取到一个Set中
|
||||
Set<String> infoTypeIds = checkList.stream()
|
||||
.map(BackApplyInfo::getTypeId)
|
||||
.collect(Collectors.toSet());
|
||||
// 从infoList中移除那些typeId在infoTypeIds中的元素
|
||||
infoList.removeIf(o -> infoTypeIds.contains(o.getTypeId()));
|
||||
// 首先根据id进行数据删除,重新走新增逻辑
|
||||
// 先删除back_apply_details表数据
|
||||
int res = backApplyMapper.deleteBackApplyDetails(backApplyInfo);
|
||||
if (res <= 0) {
|
||||
return AjaxResult.error("退料申请表back_apply_details数据删除失败");
|
||||
}
|
||||
// 删除back_check_details表数据
|
||||
int res1 = backApplyMapper.delBackCheckDetailsById(backApplyInfo);
|
||||
if (res1 <= 0) {
|
||||
return AjaxResult.error("退料申请表back_check_details数据删除失败");
|
||||
}
|
||||
// 删除文件表数据,先查询是否存在相关数据
|
||||
backApplyInfo.setDicId(36L);
|
||||
backApplyInfo.setParentId(backApplyInfo.getId());
|
||||
List<FileInfo> fileInfoList = backReceiveMapper.selectFileInfoList(backApplyInfo);
|
||||
if (!CollectionUtils.isEmpty(fileInfoList)) {
|
||||
// 存在文件数据,删除
|
||||
int i = backReceiveMapper.deleteBackFile(backApplyInfo);
|
||||
if (i == 0) {
|
||||
return AjaxResult.error("退料申请表文件表数据删除失败");
|
||||
}
|
||||
}
|
||||
if (backApplyInfo.getId() != null) {
|
||||
backApplyInfo.setUpdateBy(SecurityUtils.getUsername());
|
||||
result = backApplyMapper.updateBackApply(backApplyInfo);
|
||||
if (result == 0) {
|
||||
return AjaxResult.error("退料申请修改失败");
|
||||
}
|
||||
}
|
||||
List<String> typeIdList = backApplyDetails.stream().map(BackApplyInfo::getTypeId).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(infoList)) {
|
||||
for (BackApplyInfo backApplyDetail : infoList) {
|
||||
if (!typeIdList.contains(backApplyDetail.getTypeId())) {
|
||||
// 进行删除操作
|
||||
result = backApplyMapper.delBackDetailsById(backApplyDetail);
|
||||
if (result == 0) {
|
||||
return AjaxResult.error("退料申请删除失败");
|
||||
if (bean.getIsFinishBack() != null && bean.getIsFinishBack() == 1) {
|
||||
// 退料完成
|
||||
bean.setTaskStatus("40");
|
||||
res = updateTaskStatus(backApplyInfo.getTaskId(), 40);
|
||||
if (res == 0) {
|
||||
throw new RuntimeException("tm_task修改状态");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (BackApplyInfo backApplyDetail : backApplyDetails) {
|
||||
backApplyDetail.setId(backApplyInfo.getId());
|
||||
// 先根据id和typeId查询,数据是否存在,存在则更新,不存在则新增
|
||||
List<BackApplyInfo> list = backApplyMapper.selectBackDetailsById(backApplyDetail);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
backApplyDetail.setUpdateBy(SecurityUtils.getUsername());
|
||||
backApplyDetail.setAuditNum(backApplyDetail.getNum());
|
||||
result = backApplyMapper.update(backApplyDetail);
|
||||
} else {
|
||||
backApplyDetail.setCreateBy(SecurityUtils.getUsername());
|
||||
backApplyDetail.setAuditNum(backApplyDetail.getNum());
|
||||
result = backApplyMapper.upload(backApplyDetail);
|
||||
// 退料进行中
|
||||
bean.setTaskStatus("39");
|
||||
}
|
||||
// 领料任务编号
|
||||
Long backApplyInfoId = backApplyInfo.getId();
|
||||
Integer taskId = backApplyInfo.getTaskId();
|
||||
if (StringUtils.isNotNull(backApplyInfoId)) {
|
||||
List<BackApplyInfo> leaseApplyDetailsList = bean.getBackApplyDetails();
|
||||
for (BackApplyInfo leaseApplyDetails : leaseApplyDetailsList) {
|
||||
// 首先判断附件是否存在
|
||||
if (CollectionUtils.isNotEmpty(leaseApplyDetails.getFileList())) {
|
||||
for (FileInfo fileInfo : leaseApplyDetails.getFileList()) {
|
||||
fileInfo.setModelId(backApplyInfoId);
|
||||
fileInfo.setCreateBy(SecurityUtils.getUserId().toString());
|
||||
fileInfo.setCreateTime(new Date());
|
||||
fileInfo.setTypeId(Integer.parseInt(leaseApplyDetails.getTypeId()));
|
||||
fileInfo.setDicId(36L);
|
||||
backReceiveMapper.insertBmFileInfo(fileInfo);
|
||||
}
|
||||
}
|
||||
/* 设置领料任务ID*/
|
||||
leaseApplyDetails.setId(backApplyInfoId);
|
||||
// 插入领料任务明细
|
||||
leaseApplyDetails.setAuditNum(leaseApplyDetails.getBackNum());
|
||||
leaseApplyDetails.setNum(leaseApplyDetails.getBackNum());
|
||||
boolean addLeaseTaskDetailsResult = upload(leaseApplyDetails) > 0;
|
||||
if (!addLeaseTaskDetailsResult) {
|
||||
return AjaxResult.error("退料任务创建成功,但退料任务明细插入失败");
|
||||
}
|
||||
int intValue = backApplyInfoId.intValue();
|
||||
leaseApplyDetails.setParentId((long) intValue);
|
||||
leaseApplyDetails.setCreateBy(SecurityUtils.getUserId().toString());
|
||||
// 根据任务详情往back_check_details插入数据
|
||||
// 退料合格数据处理
|
||||
if ("1".equals(leaseApplyDetails.getManageType()) && leaseApplyDetails.getPassNum() > 0) {
|
||||
AjaxResult error = getHgAjaxResult(bean, taskId, leaseApplyDetails);
|
||||
if (error != null) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
// 维修数据处理
|
||||
if ("1".equals(leaseApplyDetails.getManageType()) && leaseApplyDetails.getMaintenanceNum() > 0) {
|
||||
AjaxResult error = getWxAjaxResult(bean, backApplyInfoId, leaseApplyDetails);
|
||||
if (error != null) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
// 编码设备合格数据处理
|
||||
if ("0".equals(leaseApplyDetails.getManageType()) && !CollectionUtils.isEmpty(leaseApplyDetails.getPassMaCodeDtoList())){
|
||||
AjaxResult error = getMaCodeHgAjaxResult(bean, taskId, leaseApplyDetails);
|
||||
if (error != null) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
// 编码维修数据处理
|
||||
if ("0".equals(leaseApplyDetails.getManageType()) && !CollectionUtils.isEmpty(leaseApplyDetails.getRepairMaCodeDtoList())){
|
||||
AjaxResult error = getMaCodeWxAjaxResult(bean, backApplyInfoId, leaseApplyDetails);
|
||||
if (error != null) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
if ("1".equals(leaseApplyDetails.getManageType()) &&
|
||||
bean.getIsFinishBack() != null && bean.getIsFinishBack() == 1) {
|
||||
//更新结算表 slt_agreement_info
|
||||
leaseApplyDetails.setAgreementId(bean.getAgreementId());
|
||||
int r = updateSlt4Bean(leaseApplyDetails);
|
||||
if (r == 0) {
|
||||
throw new RuntimeException("该机具未被领料使用");
|
||||
}
|
||||
}
|
||||
if (bean.getIsFinishBack() != null && bean.getIsFinishBack() == 1) {
|
||||
int r = backReceiveMapper.finishBackCheckDetails(leaseApplyDetails);
|
||||
if (r == 0) {
|
||||
throw new RuntimeException("更新退料任务明细失败");
|
||||
}
|
||||
backReceiveMapper.updateBackReceiveTime(leaseApplyDetails);
|
||||
}
|
||||
if (result == 0) {
|
||||
return AjaxResult.error("退料申请修改失败");
|
||||
}
|
||||
}
|
||||
return AjaxResult.success("退料申请修改成功");
|
||||
|
|
@ -620,6 +693,446 @@ public class BackApplyServiceImpl implements BackApplyService {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新任务状态
|
||||
* @param taskId
|
||||
* @param i
|
||||
* @return
|
||||
*/
|
||||
private int updateTaskStatus(Integer taskId, int i) {
|
||||
int res;
|
||||
res = backReceiveMapper.updateTaskStatus(taskId, i);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 退料任务创建提交
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult submitBackApply(BackApplyInfo bean) {
|
||||
if (bean == null || bean.getBackApplyInfo() == null || CollectionUtils.isEmpty(bean.getBackApplyDetails())) {
|
||||
return AjaxResult.error("退料申请数据不能为空");
|
||||
}
|
||||
// 判断退料数不能超过在用数
|
||||
for (BackApplyInfo backApplyDetail : bean.getBackApplyDetails()) {
|
||||
if (backApplyDetail.getBackNum() != null && backApplyDetail.getUseNum() != null &&
|
||||
backApplyDetail.getBackNum() > Integer.parseInt(backApplyDetail.getUseNum())){
|
||||
return AjaxResult.error("退料数不能超过在用数");
|
||||
}
|
||||
}
|
||||
boolean addLeaseTaskResult = false;
|
||||
Long backApplyInfoId = 0L;
|
||||
try {
|
||||
//查看本次退料申请是否合法
|
||||
if (!isBackApplyNumberCorrect(bean)) {
|
||||
return AjaxResult.error("已申请退料数量加上本次退料申请数量,超过领料出库数量,请重试!");
|
||||
}
|
||||
//生成退料编码
|
||||
String code = genderBackCode();
|
||||
if (StringUtils.isEmpty(code)) {
|
||||
return AjaxResult.error("后台退料编号生成异常,请重试!");
|
||||
}
|
||||
bean.setCode(code);
|
||||
bean.setTaskType(36);
|
||||
if (bean.getIsFinishBack() != null && bean.getIsFinishBack() == 1) {
|
||||
// 退料完成
|
||||
bean.setTaskStatus("40");
|
||||
} else {
|
||||
// 退料进行中
|
||||
bean.setTaskStatus("39");
|
||||
}
|
||||
// 创建任务
|
||||
boolean addTaskResult = insertSelective(bean) > 0;
|
||||
if (addTaskResult && bean.getTaskId() != null) {
|
||||
//任务协议表(tm_task_agreement)
|
||||
Boolean addTaskAgreementRes = insertTaskAgreement(bean) > 0;
|
||||
if (addTaskAgreementRes && bean.getBackApplyInfo() != null) {
|
||||
Integer taskId = bean.getTaskId();
|
||||
// 根据设备所属分公司拆分集合
|
||||
List<List<BackApplyInfo>> backApplyInfoList = CollUtil.groupByField(bean.getBackApplyDetails(), "companyId");
|
||||
// 判断拆分后的集合内是否有数据
|
||||
if (CollUtil.isNotEmpty(backApplyInfoList)) {
|
||||
// 对拆分后的集合进行each遍历
|
||||
for (List<BackApplyInfo> leaseApplyDetailsList : backApplyInfoList) {
|
||||
BackApplyInfo backApplyInfo1 = leaseApplyDetailsList.get(0);
|
||||
// 对领料任务表的对象做数据处理
|
||||
BackApplyInfo backApplyInfo = bean.getBackApplyInfo();
|
||||
/* 创建领料单号*/
|
||||
backApplyInfo.setCode(code);
|
||||
/*设置任务ID*/
|
||||
backApplyInfo.setTaskId(taskId);
|
||||
/*设置设备所属分公司,用于交给哪家审核*/
|
||||
backApplyInfo.setCompanyId(backApplyInfo1.getCompanyId());
|
||||
// 创建领料任务,返回领料任务编号
|
||||
backApplyInfo.setCreateBy(SecurityUtils.getUsername());
|
||||
addLeaseTaskResult = insertBackApply(backApplyInfo) > 0;
|
||||
// 领料任务编号
|
||||
backApplyInfoId = backApplyInfo.getId();
|
||||
// 领料任务创建完成,进行领料任务明细插入
|
||||
if (addLeaseTaskResult) {
|
||||
if (StringUtils.isNotNull(backApplyInfoId)) {
|
||||
for (BackApplyInfo leaseApplyDetails : leaseApplyDetailsList) {
|
||||
// 首先判断附件是否存在
|
||||
if (CollectionUtils.isNotEmpty(leaseApplyDetails.getFileList())) {
|
||||
for (FileInfo fileInfo : leaseApplyDetails.getFileList()) {
|
||||
fileInfo.setModelId(backApplyInfoId);
|
||||
fileInfo.setCreateBy(SecurityUtils.getUserId().toString());
|
||||
fileInfo.setCreateTime(new Date());
|
||||
fileInfo.setTypeId(Integer.parseInt(leaseApplyDetails.getTypeId()));
|
||||
fileInfo.setDicId(36L);
|
||||
backReceiveMapper.insertBmFileInfo(fileInfo);
|
||||
}
|
||||
}
|
||||
/* 设置领料任务ID*/
|
||||
leaseApplyDetails.setId(backApplyInfoId);
|
||||
// 插入领料任务明细
|
||||
leaseApplyDetails.setAuditNum(leaseApplyDetails.getNum());
|
||||
boolean addLeaseTaskDetailsResult = upload(leaseApplyDetails) > 0;
|
||||
if (!addLeaseTaskDetailsResult) {
|
||||
return AjaxResult.error("退料任务创建成功,但退料任务明细插入失败");
|
||||
}
|
||||
int intValue = backApplyInfoId.intValue();
|
||||
leaseApplyDetails.setParentId((long) intValue);
|
||||
leaseApplyDetails.setCreateBy(SecurityUtils.getUserId().toString());
|
||||
// 根据任务详情往back_check_details插入数据
|
||||
// 退料合格数据处理
|
||||
if ("1".equals(leaseApplyDetails.getManageType()) && leaseApplyDetails.getPassNum() > 0) {
|
||||
AjaxResult error = getHgAjaxResult(bean, taskId, leaseApplyDetails);
|
||||
if (error != null) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
// 维修数据处理
|
||||
if ("1".equals(leaseApplyDetails.getManageType()) && leaseApplyDetails.getMaintenanceNum() > 0) {
|
||||
AjaxResult error = getWxAjaxResult(bean, backApplyInfoId, leaseApplyDetails);
|
||||
if (error != null) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
// 编码设备合格数据处理
|
||||
if ("0".equals(leaseApplyDetails.getManageType()) && !CollectionUtils.isEmpty(leaseApplyDetails.getPassMaCodeDtoList())){
|
||||
AjaxResult error = getMaCodeHgAjaxResult(bean, taskId, leaseApplyDetails);
|
||||
if (error != null) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
// 编码维修数据处理
|
||||
if ("0".equals(leaseApplyDetails.getManageType()) && !CollectionUtils.isEmpty(leaseApplyDetails.getRepairMaCodeDtoList())){
|
||||
AjaxResult error = getMaCodeWxAjaxResult(bean, backApplyInfoId, leaseApplyDetails);
|
||||
if (error != null) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
// 更新结算表
|
||||
if ("1".equals(leaseApplyDetails.getManageType()) &&
|
||||
bean.getIsFinishBack() != null && bean.getIsFinishBack() == 1) {
|
||||
//更新结算表 slt_agreement_info
|
||||
leaseApplyDetails.setAgreementId(bean.getAgreementId());
|
||||
int res = updateSlt4Bean(leaseApplyDetails);
|
||||
if (res == 0) {
|
||||
throw new RuntimeException("该机具未被领料使用");
|
||||
}
|
||||
|
||||
}
|
||||
if (bean.getIsFinishBack() != null && bean.getIsFinishBack() == 1) {
|
||||
int res = backReceiveMapper.finishBackCheckDetails(leaseApplyDetails);
|
||||
if (res == 0) {
|
||||
throw new RuntimeException("更新退料任务明细失败");
|
||||
}
|
||||
backReceiveMapper.updateBackReceiveTime(leaseApplyDetails);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return AjaxResult.error("退料任务编号为空");
|
||||
}
|
||||
} else {
|
||||
return AjaxResult.error("创建退料任务失败,或退料明细为空");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return AjaxResult.error("创建任务失败,缺少数据");
|
||||
}
|
||||
} else {
|
||||
return AjaxResult.error("创建任务失败");
|
||||
}
|
||||
} else {
|
||||
return AjaxResult.error("创建任务失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return AjaxResult.error("创建任务失败," + e.getCause().toString() + "," + e.getMessage());
|
||||
}
|
||||
return AjaxResult.success("退料任务创建成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新结算表
|
||||
* @param leaseApplyDetails
|
||||
* @return
|
||||
*/
|
||||
private int updateSlt4Bean(BackApplyInfo leaseApplyDetails) {
|
||||
List<SltAgreementInfo> infoList = backReceiveMapper.getStlInfo(leaseApplyDetails);
|
||||
if (infoList.size() > 0) {
|
||||
Integer backNum = leaseApplyDetails.getBackNum();
|
||||
for (SltAgreementInfo info : infoList) {
|
||||
Integer num = info.getNum();
|
||||
if (backNum.equals(num)) {
|
||||
backReceiveMapper.updateStlInfo(info, leaseApplyDetails);
|
||||
break;
|
||||
} else if (backNum > num) {
|
||||
backNum = backNum - num;
|
||||
backReceiveMapper.updateStlInfo(info, leaseApplyDetails);
|
||||
} else if (backNum < num) {
|
||||
Integer many = num - backNum;
|
||||
backReceiveMapper.updateStlInfoTwo(info, leaseApplyDetails, backNum);
|
||||
backReceiveMapper.insStlInfoTwo(info, many);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编码维修数据处理
|
||||
* @param bean
|
||||
* @param backApplyInfoId
|
||||
* @param leaseApplyDetails
|
||||
* @return
|
||||
*/
|
||||
private AjaxResult getMaCodeWxAjaxResult(BackApplyInfo bean, Long backApplyInfoId, BackApplyInfo leaseApplyDetails) {
|
||||
int newTaskId = 0;
|
||||
if (bean.getIsFinishBack() != null && bean.getIsFinishBack() == 1) {
|
||||
//插入任务表tm_task
|
||||
newTaskId = insertTt(TaskTypeEnum.MAINTENANCE_TASK.getCode());
|
||||
//插入协议任务表tm_task_agreement
|
||||
insertTta(newTaskId, bean);
|
||||
//插入维修记录表repair_apply_details
|
||||
leaseApplyDetails.setBackId(backApplyInfoId.toString());
|
||||
}
|
||||
for (MaCodeDto maCodeDto : leaseApplyDetails.getRepairMaCodeDtoList()) {
|
||||
leaseApplyDetails.setBackNum(1);
|
||||
leaseApplyDetails.setBackStatus("2");
|
||||
leaseApplyDetails.setMaId(maCodeDto.getMaId());
|
||||
int res = backReceiveMapper.insertCheckDetails(leaseApplyDetails);
|
||||
if (res <= 0) {
|
||||
return AjaxResult.error("退料任务创建成功,但退料任务明细插入失败");
|
||||
}
|
||||
if (bean.getIsFinishBack() != null && bean.getIsFinishBack() == 1) {
|
||||
//退料维修状态变为退料待检修17
|
||||
backReceiveMapper.updateMaStatus(maCodeDto.getMaId(), "17");
|
||||
}
|
||||
if (bean.getIsFinishBack() != null && bean.getIsFinishBack() == 1) {
|
||||
insertRad(newTaskId, leaseApplyDetails);
|
||||
//更新结算表 slt_agreement_info
|
||||
leaseApplyDetails.setAgreementId(bean.getAgreementId());
|
||||
int result = updateSlt4Bean(leaseApplyDetails);
|
||||
if (result == 0) {
|
||||
throw new RuntimeException("该机具未被领料使用");
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编码设备合格数据处理
|
||||
* @param bean
|
||||
* @param taskId
|
||||
* @param leaseApplyDetails
|
||||
* @return
|
||||
*/
|
||||
private AjaxResult getMaCodeHgAjaxResult(BackApplyInfo bean, Integer taskId, BackApplyInfo leaseApplyDetails) {
|
||||
for (MaCodeDto maCodeDto : leaseApplyDetails.getPassMaCodeDtoList()) {
|
||||
leaseApplyDetails.setBackNum(1);
|
||||
leaseApplyDetails.setBackStatus("1");
|
||||
leaseApplyDetails.setMaId(maCodeDto.getMaId());
|
||||
int res = backReceiveMapper.insertCheckDetails(leaseApplyDetails);
|
||||
if (res <= 0) {
|
||||
return AjaxResult.error("退料任务创建成功,但退料任务明细插入失败");
|
||||
}
|
||||
if (bean.getIsFinishBack() != null && bean.getIsFinishBack() == 1) {
|
||||
//退料合格状态变为在库状态15
|
||||
backReceiveMapper.updateMaStatus(maCodeDto.getMaId(), "15");
|
||||
leaseApplyDetails.setTaskId(taskId);
|
||||
backReceiveMapper.insertIad(leaseApplyDetails);
|
||||
//更新结算表 slt_agreement_info
|
||||
leaseApplyDetails.setAgreementId(bean.getAgreementId());
|
||||
int result = updateSlt4Bean(leaseApplyDetails);
|
||||
if (result == 0) {
|
||||
throw new RuntimeException("该机具未被领料使用");
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 针对数量装备,进行合格数据处理
|
||||
* @param bean
|
||||
* @param taskId
|
||||
* @param leaseApplyDetails
|
||||
* @return
|
||||
*/
|
||||
private AjaxResult getHgAjaxResult(BackApplyInfo bean, Integer taskId, BackApplyInfo leaseApplyDetails) {
|
||||
leaseApplyDetails.setBackNum(leaseApplyDetails.getPassNum());
|
||||
leaseApplyDetails.setBackStatus("1");
|
||||
int res = backReceiveMapper.insertCheckDetails(leaseApplyDetails);
|
||||
if (res <= 0) {
|
||||
return AjaxResult.error("退料任务创建成功,但退料任务明细插入失败");
|
||||
}
|
||||
// 如果完成退料,更新库存,并进行库存记录
|
||||
if (bean.getIsFinishBack() != null && bean.getIsFinishBack() == 1) {
|
||||
backReceiveMapper.updateMt(leaseApplyDetails);
|
||||
leaseApplyDetails.setTaskId(taskId);
|
||||
backReceiveMapper.insertIad(leaseApplyDetails);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 针对数量装备,进行维修数据处理
|
||||
* @param bean
|
||||
* @param backApplyInfoId
|
||||
* @param leaseApplyDetails
|
||||
* @return
|
||||
*/
|
||||
private AjaxResult getWxAjaxResult(BackApplyInfo bean, Long backApplyInfoId, BackApplyInfo leaseApplyDetails) {
|
||||
leaseApplyDetails.setBackNum(leaseApplyDetails.getMaintenanceNum());
|
||||
leaseApplyDetails.setBackStatus("2");
|
||||
int res = backReceiveMapper.insertCheckDetails(leaseApplyDetails);
|
||||
if (res <= 0) {
|
||||
return AjaxResult.error("退料任务创建成功,但退料任务明细插入失败");
|
||||
}
|
||||
if (bean.getIsFinishBack() != null && bean.getIsFinishBack() == 1) {
|
||||
//插入任务表tm_task
|
||||
int newTaskId = insertTt(TaskTypeEnum.MAINTENANCE_TASK.getCode());
|
||||
//插入协议任务表tm_task_agreement
|
||||
insertTta(newTaskId, bean);
|
||||
//插入维修记录表repair_apply_details
|
||||
leaseApplyDetails.setBackId(backApplyInfoId.toString());
|
||||
insertRad(newTaskId, leaseApplyDetails);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建维修记录表repair_apply_details
|
||||
* @param newTaskId
|
||||
* @param leaseApplyDetails
|
||||
* @return
|
||||
*/
|
||||
private void insertRad(int newTaskId, BackApplyInfo leaseApplyDetails) {
|
||||
leaseApplyDetails.setTaskId(newTaskId);
|
||||
leaseApplyDetails.setRepairRemark(leaseApplyDetails.getRemark());
|
||||
int result = backReceiveMapper.insertRad(leaseApplyDetails);
|
||||
if (result <= 0) {
|
||||
throw new RuntimeException("创建维修记录表repair_apply_details失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建退料任务明细
|
||||
* @param newTaskId
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
private int insertTta(int newTaskId, BackApplyInfo bean) {
|
||||
int res;
|
||||
String agreementId = String.valueOf(bean.getAgreementId());
|
||||
res = backReceiveMapper.insertTta(newTaskId, agreementId);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建退料任务
|
||||
* @param taskType
|
||||
* @return
|
||||
*/
|
||||
private int insertTt(Integer taskType) {
|
||||
int newTask;
|
||||
//生成单号
|
||||
String code = genCodeRule(taskType);
|
||||
BackApplyInfo applyInfo = new BackApplyInfo();
|
||||
applyInfo.setTaskType(taskType);
|
||||
String taskStatus = "";
|
||||
if (TaskTypeEnum.MAINTENANCE_TASK.getCode().equals(taskType)) {
|
||||
taskStatus = TaskStatusEnum.REPAIRPENDING.getCode();
|
||||
}
|
||||
applyInfo.setTaskStatus(taskStatus);
|
||||
applyInfo.setCode(code);
|
||||
//创建人
|
||||
applyInfo.setCreateBy(SecurityUtils.getUsername());
|
||||
newTask = backReceiveMapper.insertTt(applyInfo);
|
||||
if (newTask > 0 && applyInfo.getTaskId() > 0) {
|
||||
newTask = applyInfo.getTaskId();
|
||||
}
|
||||
return newTask;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成退料任务编号
|
||||
* @param taskType
|
||||
* @return
|
||||
*/
|
||||
private String genCodeRule(Integer taskType) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
|
||||
Date nowDate = DateUtils.getNowDate();
|
||||
String format = dateFormat.format(nowDate);
|
||||
Integer taskNum = backReceiveMapper.selectTaskNumByMonthWx(nowDate, taskType);
|
||||
|
||||
String taskNumStr = "";
|
||||
if (taskNum != null) {
|
||||
// 将字符串转换为整数
|
||||
// int num = Integer.parseInt(taskNum);
|
||||
// 执行加一操作
|
||||
taskNum++;
|
||||
// 将结果转换回字符串格式,并确保结果是四位数,不足四位则在前面补0
|
||||
taskNumStr = String.format("%04d", taskNum);
|
||||
} else {
|
||||
taskNumStr = "0001";
|
||||
}
|
||||
String code = "";
|
||||
if (TaskTypeEnum.MAINTENANCE_TASK.getCode().equals(taskType)) {
|
||||
code = TaskTypeConstants.WX;
|
||||
}
|
||||
|
||||
if (TaskTypeEnum.RETURNED_MATERIALS_TO_BE_SCRAPPED.getCode().equals(taskType)) {
|
||||
code = TaskTypeConstants.YBF;
|
||||
}
|
||||
code = code + format + "-" + taskNumStr;
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据单位和工程id查询领料机具
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult getMachineById(BackApplyInfo dto) {
|
||||
if (dto == null) {
|
||||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "参数不能为空");
|
||||
}
|
||||
if (dto.getUnitId() == null) {
|
||||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "单位ID为空");
|
||||
}
|
||||
if (dto.getProjectId() == null) {
|
||||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "工程ID为空");
|
||||
}
|
||||
if (StringUtils.isBlank(dto.getTypeId())) {
|
||||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "机具类型ID为空");
|
||||
}
|
||||
List<MaCodeDto> list = backApplyMapper.getMachineById(dto);
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
list.get(0).setTotalNum(list.size());
|
||||
}
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
private int auditAllDetails(BackApplyDto dto) {
|
||||
int re = 0;
|
||||
if (CollUtil.isNotEmpty(dto.getBackApplyList())) {
|
||||
|
|
|
|||
|
|
@ -409,7 +409,7 @@ public class WorkSiteDirectManageImpl implements WorkSiteDirectManageService {
|
|||
BackApplyInfo backCheckDetails = new BackApplyInfo();
|
||||
for (BackApplyInfo backApplyInfo2 : backApplyInfoList) {
|
||||
if (backApplyInfo1.getCompanyId().equals(backApplyInfo2.getCompanyId())) {
|
||||
backCheckDetails.setParentId(backApplyInfo2.getId().intValue());
|
||||
backCheckDetails.setParentId(backApplyInfo2.getId());
|
||||
backCheckDetails.setTypeId(backApplyInfo1.getTypeId());
|
||||
backCheckDetails.setMaId(backApplyInfo1.getMaId());
|
||||
backCheckDetails.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString());
|
||||
|
|
|
|||
|
|
@ -657,6 +657,10 @@
|
|||
and ma_id = #{maId}
|
||||
</if>
|
||||
</delete>
|
||||
<delete id="deleteBackFile">
|
||||
delete from sys_file_info
|
||||
where model_id = #{parentId} and dic_id = 36
|
||||
</delete>
|
||||
|
||||
<select id="getbackReceiveList" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
|
||||
SELECT
|
||||
|
|
@ -724,7 +728,7 @@
|
|||
bagi.plan_start_time
|
||||
<if test="typeId != null and typeId != ''">
|
||||
HAVING
|
||||
FIND_IN_SET(#{typeId}, GROUP_CONCAT(DISTINCT bad.type_id))
|
||||
FIND_IN_SET(#{typeId}, GROUP_CONCAT(DISTINCT mt2.type_id))
|
||||
</if>
|
||||
ORDER BY
|
||||
tt.task_status ASC,
|
||||
|
|
@ -886,13 +890,25 @@
|
|||
bcd.parent_id as parentId,
|
||||
bcd.create_by as createBy,
|
||||
bcd.ma_id as maId,
|
||||
bai.company_id as companyId
|
||||
bai.company_id as companyId,
|
||||
mm.ma_code as maCode,
|
||||
mm.ma_status AS maStatus,
|
||||
mt1.type_name AS typeName,
|
||||
mt.type_name AS materialName,
|
||||
mt2.type_name AS materialType
|
||||
FROM
|
||||
back_check_details bcd
|
||||
LEFT JOIN back_apply_info bai on bai.id=bcd.parent_id
|
||||
LEFT JOIN tm_task_agreement tta on tta.task_id=bai.task_id
|
||||
LEFT JOIN ma_machine mm ON bcd.ma_id = mm.ma_id
|
||||
LEFT JOIN ma_type mt ON mm.type_id = mt.type_id
|
||||
AND mt.del_flag = '0'
|
||||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
||||
AND mt1.del_flag = '0'
|
||||
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id
|
||||
AND mt2.del_flag = '0'
|
||||
WHERE
|
||||
parent_id=#{parentId}
|
||||
bcd.parent_id=#{parentId}
|
||||
and bcd.type_id=#{typeId}
|
||||
and bcd.back_status='1' and (bcd.is_finished is null or bcd.is_finished != 1)
|
||||
</select>
|
||||
|
|
@ -908,13 +924,25 @@
|
|||
bcd.create_by as createBy,
|
||||
bcd.ma_id as maId,
|
||||
bcd.repair_remark as repairRemark,
|
||||
bai.company_id as companyId
|
||||
bai.company_id as companyId,
|
||||
mm.ma_code as maCode,
|
||||
mm.ma_status AS maStatus,
|
||||
mt1.type_name AS typeName,
|
||||
mt.type_name AS materialName,
|
||||
mt2.type_name AS materialType
|
||||
FROM
|
||||
back_check_details bcd
|
||||
LEFT JOIN back_apply_info bai on bai.id=bcd.parent_id
|
||||
LEFT JOIN tm_task_agreement tta on tta.task_id=bai.task_id
|
||||
LEFT JOIN ma_machine mm ON bcd.ma_id = mm.ma_id
|
||||
LEFT JOIN ma_type mt ON mm.type_id = mt.type_id
|
||||
AND mt.del_flag = '0'
|
||||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
||||
AND mt1.del_flag = '0'
|
||||
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id
|
||||
AND mt2.del_flag = '0'
|
||||
WHERE
|
||||
parent_id=#{parentId}
|
||||
bcd.parent_id=#{parentId}
|
||||
and bcd.type_id=#{typeId}
|
||||
and bcd.back_status='2' and (bcd.is_finished is null or bcd.is_finished != 1)
|
||||
</select>
|
||||
|
|
@ -1210,5 +1238,22 @@
|
|||
<select id="getfileByUid" resultType="com.bonus.sgzb.base.api.domain.FileInfo">
|
||||
select * from sys_file_info where uid = #{uid}
|
||||
</select>
|
||||
<select id="selectFileInfoList" resultType="com.bonus.sgzb.base.api.domain.FileInfo">
|
||||
select
|
||||
file_name as fileName,
|
||||
file_url as fileUrl
|
||||
from sys_file_info
|
||||
<where>
|
||||
<if test="parentId != null">
|
||||
and model_id = #{parentId}
|
||||
</if>
|
||||
<if test="typeId != null">
|
||||
and type_id = #{typeId}
|
||||
</if>
|
||||
<if test="dicId != null">
|
||||
and dic_id = #{dicId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -452,6 +452,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
FROM back_apply_details
|
||||
WHERE parent_id = #{parentId} and type_id = #{typeId}
|
||||
</delete>
|
||||
<delete id="deleteBackApplyDetails">
|
||||
DELETE
|
||||
FROM back_apply_details
|
||||
WHERE parent_id = #{id}
|
||||
</delete>
|
||||
<delete id="delBackCheckDetailsById">
|
||||
DELETE
|
||||
FROM back_check_details
|
||||
WHERE parent_id = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="getBackApplyList" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
|
||||
SELECT
|
||||
|
|
@ -1061,9 +1071,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
WHEN bad.back_status = 2 THEN '维修'
|
||||
WHEN bad.back_status = 3 THEN '待报废'
|
||||
ELSE '' END AS backStatus,
|
||||
CASE WHEN bad.back_status = 1 THEN ''
|
||||
WHEN bad.back_status = 2 THEN bad.repair_remark
|
||||
WHEN bad.back_status = 3 THEN bad.scrap_remark END AS remark,
|
||||
bad.remark AS remark,
|
||||
bad.scrap_reason,
|
||||
bad.type_id as typeId,
|
||||
bad.back_num AS num,
|
||||
|
|
@ -1085,9 +1093,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
LEFT JOIN ma_machine mm ON bad.ma_id = mm.ma_id
|
||||
WHERE
|
||||
bai.task_id = #{taskId}
|
||||
<if test="companyId != null and companyId != ''">
|
||||
<!--<if test="companyId != null and companyId != ''">
|
||||
and bai.company_id = #{companyId}
|
||||
</if>
|
||||
</if>-->
|
||||
</select>
|
||||
<select id="getPreAuditNum" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
|
|
@ -1101,4 +1109,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
WHERE
|
||||
tta.agreement_id = #{agreementId} and bad.type_id =#{typeId} and tt.task_status != 40
|
||||
</select>
|
||||
|
||||
<select id="getMachineById" resultType="com.bonus.sgzb.base.api.domain.MaCodeDto">
|
||||
SELECT
|
||||
mm.ma_id AS maId,
|
||||
mm.ma_code AS maCode,
|
||||
mm.ma_status AS maStatus,
|
||||
mt1.type_name AS typeName,
|
||||
mm.type_id AS typeId,
|
||||
mt.type_name AS materialName,
|
||||
mt2.type_name AS materialType
|
||||
FROM
|
||||
lease_out_details lod
|
||||
LEFT JOIN ma_machine mm ON lod.ma_id = mm.ma_id
|
||||
LEFT JOIN ma_type mt ON mm.type_id = mt.type_id
|
||||
AND mt.del_flag = '0'
|
||||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
||||
AND mt1.del_flag = '0'
|
||||
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id
|
||||
AND mt2.del_flag = '0'
|
||||
LEFT JOIN slt_agreement_info sai on lod.type_id = sai.type_id
|
||||
and sai.ma_id = lod.ma_id
|
||||
LEFT JOIN bm_agreement_info ba ON sai.agreement_id = ba.agreement_id
|
||||
WHERE
|
||||
mm.ma_status = '16' and mm.type_id = #{typeId}
|
||||
AND ba.unit_id = #{unitId}
|
||||
AND ba.project_id = #{projectId}
|
||||
<if test="maCode != null and maCode != ''">
|
||||
and mm.ma_code like concat('%',#{maCode},'%')
|
||||
</if>
|
||||
GROUP BY mm.ma_code
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -267,7 +267,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
mt.LEVEL,
|
||||
mt.lease_price AS leasePrice,
|
||||
mt.is_storage AS isStorage,
|
||||
mt.is_replace AS isReplace
|
||||
mt.is_replace AS isReplace,
|
||||
mt.manage_type AS manageType
|
||||
FROM
|
||||
ma_type mt
|
||||
LEFT JOIN slt_agreement_info sai ON mt.type_id = sai.type_id
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ public class SysFileServiceImpl implements SysFileService {
|
|||
@Override
|
||||
public FileInfo uploadFile(MultipartFile file) throws Exception {
|
||||
String name = FileUploadUtils.upload(localFilePath, file);
|
||||
String url = domain + localFilePrefix + name;
|
||||
String url = localFilePath + name;
|
||||
FileInfo fileInfo = new FileInfo();
|
||||
fileInfo.setFileUrl(url);
|
||||
fileInfo.setFileName(name);
|
||||
|
|
|
|||
Loading…
Reference in New Issue