Merge remote-tracking branch 'origin/master'

This commit is contained in:
jiang 2025-07-28 18:41:42 +08:00
commit a114f6cb13
25 changed files with 963 additions and 329 deletions

View File

@ -7,6 +7,7 @@ import lombok.ToString;
import com.bonus.common.core.web.domain.BaseEntity;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
@ -119,6 +120,15 @@ public class LeaseOutDetails extends BaseEntity {
@ApiModelProperty(value = "是否退回 (0未退回1退回)")
private Integer isBack;
@ApiModelProperty("机具类型1机具2安全工器具")
private int jiJuType;
@ApiModelProperty(value = "本次检验日期")
private Date thisCheckTime;
@ApiModelProperty(value = "下次检验日期")
private Date nextCheckTime;
/**
* 领料出库机具编码集合
*/

View File

@ -10,11 +10,8 @@ import javax.validation.constraints.NotNull;
import cn.hutool.core.convert.Convert;
import com.bonus.common.biz.config.ListPagingUtil;
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
import com.bonus.common.biz.domain.lease.LeasePublishInfo;
import com.bonus.common.core.utils.ServletUtils;
import com.bonus.common.log.enums.OperaType;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.material.archives.service.ArchivesService;
import com.bonus.material.back.domain.BackApplyDetails;
import com.bonus.material.back.domain.HandlingOrder;
@ -72,6 +69,46 @@ public class BackApplyInfoController extends BaseController {
return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, list));
}
/**
* 查询未签字退料任务列表
* @param backApplyInfo
* @return
*/
@ApiOperation(value = "查询未签字退料任务列表")
@GetMapping("/getNoSignList")
public AjaxResult getNoSignList(BackApplyInfo backApplyInfo) {
Integer pageIndex = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
Integer pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
List<BackApplyInfo> list = backApplyInfoService.getNoSignList(backApplyInfo);
return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, list));
}
/**
* 查询材料员待确认的任务
* @param backApplyInfo
* @return
*/
@ApiOperation(value = "查询材料员待确认的任务")
@GetMapping("/getCompleteBackTaskList")
public AjaxResult getCompleteBackTaskList(BackApplyInfo backApplyInfo) {
Integer pageIndex = Convert.toInt(ServletUtils.getParameter("pageNum"), 1);
Integer pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10);
List<BackApplyInfo> list = backApplyInfoService.getCompleteBackTaskList(backApplyInfo);
return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, list));
}
/**
* 材料员确认接口
* @param backApplyInfo
* @return
*/
@ApiOperation(value = "材料员确认接口")
@PostMapping("/confirmMaterial")
public AjaxResult confirmMaterial(@RequestBody BackApplyInfo backApplyInfo) {
int confirmResult = backApplyInfoService.confirmMaterial(backApplyInfo);
return confirmResult > 0 ? success("确认成功") : error("确认失败");
}
/**
* 上传退料单PDF文件
*/

View File

@ -188,4 +188,19 @@ public class BackApplyInfo implements Serializable {
@ApiModelProperty(value = "一级类型id集合")
private String firstId;
@ApiModelProperty(value = "i8工程id")
private String externalId;
@ApiModelProperty(value = "材料员确认账号")
private String materialMan;
@ApiModelProperty(value = "材料员确认时间")
private String confirmTime;
@ApiModelProperty(value = "是否确认 0不需要确认1未确认 2已确认")
private Integer isConfirm;
@ApiModelProperty(value = "材料员确认备注")
private String confirmRemark;
}

View File

@ -190,5 +190,27 @@ public interface IBackApplyInfoService {
* @return
*/
AjaxResult uploadSort(HandlingOrder bean);
/**
* 查询未签字退料任务列表
* @param backApplyInfo
* @return
*/
List<BackApplyInfo> getNoSignList(BackApplyInfo backApplyInfo);
/**
* 查询材料员待确认的任务
* @param backApplyInfo
* @return
*/
List<BackApplyInfo> getCompleteBackTaskList(BackApplyInfo backApplyInfo);
/**
* 材料员确认接口
* @param backApplyInfo
* @return
*/
int confirmMaterial(BackApplyInfo backApplyInfo);
}

View File

@ -9,7 +9,6 @@ import cn.hutool.core.util.PhoneUtil;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.bonus.common.biz.constant.MaterialConstants;
import com.bonus.common.biz.domain.TypeTreeNode;
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
import com.bonus.common.biz.domain.lease.LeaseOutDetails;
import com.bonus.common.biz.enums.*;
import com.bonus.common.core.exception.ServiceException;
@ -24,6 +23,7 @@ import com.bonus.material.basic.mapper.BmFileInfoMapper;
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.lease.mapper.LeaseApplyInfoMapper;
import com.bonus.material.ma.mapper.MachineMapper;
import com.bonus.material.purchase.config.RemoteConfig;
import com.bonus.material.settlement.domain.SltAgreementInfo;
@ -74,8 +74,11 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
@Resource
private SelectMapper mapper;
@Resource
private LeaseApplyInfoMapper leaseApplyInfoMapper;
/**
* 查询退料任务
* 查询退料任务 - 性能优化版
*
* @param id 退料任务主键
* @return 退料任务
@ -86,198 +89,308 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
//先根据外层id查询上层信息
BackApplyInfo backApplyInfo = backApplyInfoMapper.selectBackApplyInfoById(id);
Long userId = SecurityUtils.getLoginUser().getUserid();
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
if (CollectionUtils.isEmpty(typeIdList)) {
backApplyInfo.setUserId(userId == 0 ? null : userId);
}
/** 设置审批人签名url 防止代码冲突 **/
String directAuditUrl = backApplyInfoMapper.getDirectAuditUrl(backApplyInfo);
String directAuditUrl = backApplyInfoMapper.getDirectAuditUrl(backApplyInfo);
backApplyInfo.setDirectAuditSignUrl(directAuditUrl);
/** 设置审批人签名url 防止代码冲突 **/
if (StringUtils.isNotBlank(backApplyInfo.getBackSignUrl())) {
backApplyInfo.setBackSignUrl("data:image/png;base64," + backApplyInfo.getBackSignUrl());
}
backApplyRequestVo.setBackApplyInfo(backApplyInfo);
//查询退料详情信息
backApplyInfo.setKeyWord(keyWord);
// 移出maCodeList集合中状态不为在用的数据
List<MaCodeVo> newCodeList = new ArrayList<>();
List<BackApplyDetails> backApplyDetailsList = backApplyInfoMapper.selectBackApplyDetailsListByTaskId(backApplyInfo);
if (CollectionUtils.isNotEmpty(backApplyDetailsList)) {
if (!CollectionUtils.isEmpty(typeIdList)) {
backApplyDetailsList = backApplyDetailsList.stream()
.filter(item -> typeIdList.contains(item.getFirstId()))
.collect(Collectors.toList());
}
// 批量查询附件信息减少数据库访问次数
List<BmFileInfo> bmFileInfos = fetchBmFileInfos(id, backApplyDetailsList);
// 查询编码设备信息
List<MaCodeVo> maCodeList = fetchMaCodeList(id);
if ("0".equals(backApplyInfo.getStatus())) {
if (CollectionUtils.isNotEmpty(maCodeList)) {
// 将maCodeList不等于2的收集到新集合中
for (MaCodeVo maCodeVo : maCodeList) {
if (StringUtils.isNotBlank(maCodeVo.getMaStatus()) && !"2".equals(maCodeVo.getMaStatus())) {
newCodeList.add(maCodeVo);
}
}
}
maCodeList = maCodeList.stream().filter(maCodeVo -> "2".equals(maCodeVo.getMaStatus())).collect(Collectors.toList());
// 核心优化减少数据库查询次数
// 1. 一次性查询编码设备信息
List<MaCodeVo> maCodeList = backApplyInfoMapper.selectByCode(id);
// 2. 处理状态不为在用的设备编码
if ("0".equals(backApplyInfo.getStatus()) && CollectionUtils.isNotEmpty(maCodeList)) {
newCodeList = filterNonInUseEquipment(maCodeList);
maCodeList = filterInUseEquipment(maCodeList);
}
// 根据协议id查询设备在用数
// 先查第四层类型
List<TypeTreeNode> listL4 = mapper.getUseTypeTreeL4(backApplyInfo);
// 3. 优化只有在有编码设备时才查询类型树减少不必要的复杂查询
Map<Long, BigDecimal> typeNumMap = new HashMap<>();
if (hasCodedEquipment(backApplyDetailsList)) {
List<TypeTreeNode> listL4 = mapper.getUseTypeTreeL4(backApplyInfo);
typeNumMap = buildTypeNumMappingSimple(listL4);
}
// 4. 一次性查询所有附件信息
Map<Long, List<BmFileInfo>> allFileInfoMap = fetchAllFileInfosOptimized(id);
// 5. 预构建映射表
Map<Long, List<MaCodeVo>> typeCodeMap = buildTypeCodeMappingSimple(maCodeList);
Map<Long, MaCodeVo> maIdCodeMap = buildMaIdCodeMappingSimple(maCodeList);
// 6. 快速处理每个退料详情
for (BackApplyDetails details : backApplyDetailsList) {
if (CollectionUtils.isNotEmpty(listL4)) {
for (TypeTreeNode node : listL4) {
if (node.getTypeId() == details.getTypeId()) {
details.setNum(node.getNum());
break;
}
}
}
if ("0".equals(details.getManageType())) {
List<MaCodeVo> list = backApplyInfoMapper.selectByCode(details.getParentId());
if (CollectionUtils.isNotEmpty(list)) {
// 过滤出list中typeId和details.getTypeId相等的MaCodeVo对象
list = list.stream().filter(type -> type.getTypeId().equals(details.getTypeId().toString())).collect(Collectors.toList());
// 将goodNum和badNum分别相加
details.setGoodNum(list.stream().map(MaCodeVo::getGoodNum).reduce(BigDecimal.ZERO, BigDecimal::add));
details.setBadNum(list.stream().map(MaCodeVo::getBadNum).reduce(BigDecimal.ZERO, BigDecimal::add));
}
}
// 为每个退料详情设置附件信息
setBmFileInfosForDetails(details, bmFileInfos);
// 如果是编码设备查询并设置相关的编码信息和附件
if ("0".equals(details.getManageType())) {
setMaCodeDetails(details, maCodeList);
}
if (CollectionUtils.isNotEmpty(newCodeList)) {
for (MaCodeVo maCodeVo : newCodeList) {
if (maCodeVo.getTypeId().equals(details.getTypeId().toString())) {
details.setPreNum(details.getPreNum().subtract(BigDecimal.valueOf(1)));
}
// 根据maId查询设备编码信息
BackApplyInfo dto = new BackApplyInfo();
dto.setId(id);
dto.setMaId(maCodeVo.getMaId());
MaCodeVo info = backApplyInfoMapper.selectDto(dto);
if (null != info) {
if (info.getMaId().equals(maCodeVo.getMaId())) {
if (info.getGoodNum() != null && info.getGoodNum().compareTo(BigDecimal.ZERO) > 0) {
details.setGoodNum(details.getGoodNum().subtract(info.getGoodNum()));
} else if (info.getBadNum() != null && info.getBadNum().compareTo(BigDecimal.ZERO) > 0) {
details.setBadNum(details.getBadNum().subtract(info.getBadNum()));
}
}
}
}
}
processBackApplyDetailsSimple(details, typeNumMap, typeCodeMap, allFileInfoMap, newCodeList, maIdCodeMap);
}
backApplyRequestVo.setBackApplyDetailsList(backApplyDetailsList);
}
AjaxResult ajaxResult = AjaxResult.success();
ajaxResult.put("data", backApplyRequestVo);
if (CollectionUtils.isNotEmpty(newCodeList)) {
// 拼接消息内容
StringBuffer msgBuilder = new StringBuffer("您所选择的编码设备编号");
for (int i = 0; i < newCodeList.size(); i++) {
String code = newCodeList.get(i).getMaCode();
msgBuilder.append(code);
if (i < newCodeList.size() - 1) {
msgBuilder.append(", ");
}
}
msgBuilder.append("已被他人完成退料,请注意查看!");
String msg = msgBuilder.toString();
msg = msg.replaceAll("\n","");
String msg = buildNotificationMessage(newCodeList);
ajaxResult.put("msg", msg);
}
return ajaxResult;
}
/**
* 批量查询附件信息
* @param id
* @param backApplyDetailsList
* @return
* 检查是否有编码设备
*/
private List<BmFileInfo> fetchBmFileInfos(Long id, List<BackApplyDetails> backApplyDetailsList) {
List<BmFileInfo> bmFileInfos = new ArrayList<>();
for (BackApplyDetails details : backApplyDetailsList) {
BmFileInfo bmFileInfo = new BmFileInfo();
bmFileInfo.setTaskId(id);
bmFileInfo.setTaskType(3);
bmFileInfo.setModelId(details.getId());
List<BmFileInfo> bmFileInfoList = bmFileInfoMapper.selectBmFileInfoList(bmFileInfo);
// 合并所有附件信息
bmFileInfos.addAll(bmFileInfoList);
private boolean hasCodedEquipment(List<BackApplyDetails> backApplyDetailsList) {
return backApplyDetailsList.stream().anyMatch(details -> "0".equals(details.getManageType()));
}
/**
* 过滤非在用设备
*/
private List<MaCodeVo> filterNonInUseEquipment(List<MaCodeVo> maCodeList) {
return maCodeList.stream()
.filter(maCodeVo -> StringUtils.isNotBlank(maCodeVo.getMaStatus()) && !"2".equals(maCodeVo.getMaStatus()))
.collect(Collectors.toList());
}
/**
* 过滤在用设备
*/
private List<MaCodeVo> filterInUseEquipment(List<MaCodeVo> maCodeList) {
return maCodeList.stream()
.filter(maCodeVo -> "2".equals(maCodeVo.getMaStatus()))
.collect(Collectors.toList());
}
/**
* 简化版类型数量映射构建
*/
private Map<Long, BigDecimal> buildTypeNumMappingSimple(List<TypeTreeNode> listL4) {
if (CollectionUtils.isEmpty(listL4)) {
return new HashMap<>();
}
return bmFileInfos;
Map<Long, BigDecimal> typeNumMap = new HashMap<>();
for (TypeTreeNode node : listL4) {
typeNumMap.put(node.getTypeId(), node.getNum());
}
return typeNumMap;
}
/**
* 简化版类型编码映射构建
*/
private Map<Long, List<MaCodeVo>> buildTypeCodeMappingSimple(List<MaCodeVo> maCodeList) {
Map<Long, List<MaCodeVo>> typeCodeMap = new HashMap<>();
for (MaCodeVo vo : maCodeList) {
if (StringUtils.isNotBlank(vo.getTypeId())) {
Long typeId = Long.parseLong(vo.getTypeId());
typeCodeMap.computeIfAbsent(typeId, k -> new ArrayList<>()).add(vo);
}
}
return typeCodeMap;
}
/**
* 简化版机具ID映射构建
*/
private Map<Long, MaCodeVo> buildMaIdCodeMappingSimple(List<MaCodeVo> maCodeList) {
Map<Long, MaCodeVo> maIdCodeMap = new HashMap<>();
for (MaCodeVo vo : maCodeList) {
maIdCodeMap.put(vo.getMaId(), vo);
}
return maIdCodeMap;
}
/**
* 优化版附件查询 - 一次性查询
*/
private Map<Long, List<BmFileInfo>> fetchAllFileInfosOptimized(Long taskId) {
// 一次性查询该任务的所有附件
BmFileInfo queryParam = new BmFileInfo();
queryParam.setTaskId(taskId);
queryParam.setTaskType(3);
List<BmFileInfo> allFileInfos = bmFileInfoMapper.selectBmFileInfoList(queryParam);
// 按modelId分组
Map<Long, List<BmFileInfo>> fileInfoMap = new HashMap<>();
for (BmFileInfo fileInfo : allFileInfos) {
fileInfoMap.computeIfAbsent(fileInfo.getModelId(), k -> new ArrayList<>()).add(fileInfo);
}
return fileInfoMap;
}
/**
* 简化版退料详情处理
*/
private void processBackApplyDetailsSimple(BackApplyDetails details,
Map<Long, BigDecimal> typeNumMap,
Map<Long, List<MaCodeVo>> typeCodeMap,
Map<Long, List<BmFileInfo>> allFileInfoMap,
List<MaCodeVo> newCodeList,
Map<Long, MaCodeVo> maIdCodeMap) {
// 1. 设置在用数量
BigDecimal num = typeNumMap.get(details.getTypeId());
if (num != null) {
details.setNum(num);
}
// 2. 设置附件信息
List<BmFileInfo> detailFileInfos = allFileInfoMap.get(details.getId());
if (CollectionUtils.isNotEmpty(detailFileInfos)) {
details.setBmFileInfos(detailFileInfos);
}
// 3. 处理编码设备
if ("0".equals(details.getManageType())) {
processCodedEquipmentSimple(details, typeCodeMap, allFileInfoMap);
}
// 4. 处理非在用状态的设备
processNonInUseEquipmentSimple(details, newCodeList, maIdCodeMap);
}
/**
* 简化版编码设备处理
*/
private void processCodedEquipmentSimple(BackApplyDetails details,
Map<Long, List<MaCodeVo>> typeCodeMap,
Map<Long, List<BmFileInfo>> allFileInfoMap) {
List<MaCodeVo> codeList = typeCodeMap.get(details.getTypeId());
if (CollectionUtils.isEmpty(codeList)) {
return;
}
// 计算总数
BigDecimal totalGoodNum = BigDecimal.ZERO;
BigDecimal totalBadNum = BigDecimal.ZERO;
List<MaCodeDto> maCodeDtos = new ArrayList<>();
for (MaCodeVo maCodeVo : codeList) {
if (StringUtils.isBlank(maCodeVo.getMaCode())) {
continue;
}
// 累加数量
if (maCodeVo.getGoodNum() != null) {
totalGoodNum = totalGoodNum.add(maCodeVo.getGoodNum());
}
if (maCodeVo.getBadNum() != null) {
totalBadNum = totalBadNum.add(maCodeVo.getBadNum());
}
// 创建编码DTO
MaCodeDto maCodeDto = createMaCodeDto(maCodeVo);
List<BmFileInfo> fileInfos = allFileInfoMap.get(maCodeVo.getMaId());
if (CollectionUtils.isNotEmpty(fileInfos)) {
maCodeDto.setBmFileInfos(fileInfos);
}
maCodeDtos.add(maCodeDto);
}
details.setGoodNum(totalGoodNum);
details.setBadNum(totalBadNum);
details.setMaCodeList(maCodeDtos);
}
/**
* 简化版非在用设备处理
*/
private void processNonInUseEquipmentSimple(BackApplyDetails details,
List<MaCodeVo> newCodeList,
Map<Long, MaCodeVo> maIdCodeMap) {
if (CollectionUtils.isEmpty(newCodeList)) {
return;
}
for (MaCodeVo maCodeVo : newCodeList) {
if (!maCodeVo.getTypeId().equals(details.getTypeId().toString())) {
continue;
}
details.setPreNum(details.getPreNum().subtract(BigDecimal.valueOf(1)));
MaCodeVo info = maIdCodeMap.get(maCodeVo.getMaId());
if (info != null) {
if (info.getGoodNum() != null && info.getGoodNum().compareTo(BigDecimal.ZERO) > 0) {
details.setGoodNum(details.getGoodNum().subtract(info.getGoodNum()));
} else if (info.getBadNum() != null && info.getBadNum().compareTo(BigDecimal.ZERO) > 0) {
details.setBadNum(details.getBadNum().subtract(info.getBadNum()));
}
}
}
}
/**
* 创建MaCodeDto对象
*/
private MaCodeDto createMaCodeDto(MaCodeVo maCodeVo) {
MaCodeDto maCodeDto = new MaCodeDto();
maCodeDto.setMaCode(maCodeVo.getMaCode());
maCodeDto.setMaId(maCodeVo.getMaId());
if (maCodeVo.getGoodNum() != null && maCodeVo.getGoodNum().compareTo(BigDecimal.ZERO) > 0) {
maCodeDto.setApDetection("完好");
} else if (maCodeVo.getBadNum() != null && maCodeVo.getBadNum().compareTo(BigDecimal.ZERO) > 0) {
maCodeDto.setApDetection("损坏");
}
maCodeDto.setTypeName(maCodeVo.getTypeName());
maCodeDto.setMaterialName(maCodeVo.getMaterialName());
maCodeDto.setTypeId(maCodeVo.getTypeId());
maCodeDto.setMaStatus(maCodeVo.getMaStatus());
maCodeDto.setMaterialType(maCodeVo.getMaterialType());
maCodeDto.setGoodNum(maCodeVo.getGoodNum());
maCodeDto.setBadNum(maCodeVo.getBadNum());
return maCodeDto;
}
/**
* 优化消息构建
*/
private String buildNotificationMessage(List<MaCodeVo> newCodeList) {
StringBuilder msgBuilder = new StringBuilder("您所选择的编码设备编号");
String codes = newCodeList.stream()
.map(MaCodeVo::getMaCode)
.collect(Collectors.joining(", "));
msgBuilder.append(codes).append("已被他人完成退料,请注意查看!");
return msgBuilder.toString().replaceAll("\n", "");
}
/**
* 查询编码设备信息
* @param id
* @return
*/
private List<MaCodeVo> fetchMaCodeList(Long id) {
return backApplyInfoMapper.selectByCode(id);
}
/**
* 为每个退料详情设置附件信息
* @param details
* @param bmFileInfos
*/
private void setBmFileInfosForDetails(BackApplyDetails details, List<BmFileInfo> bmFileInfos) {
// 为每个退料详情设置附件信息
List<BmFileInfo> relatedFileInfos = bmFileInfos.stream()
.filter(fileInfo -> fileInfo.getModelId().equals(details.getId()))
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(relatedFileInfos)) {
details.setBmFileInfos(relatedFileInfos);
}
}
/**
* 为编码设备详情设置编码信息和附件信息
* @param details
* @param maCodeList
*/
private void setMaCodeDetails(BackApplyDetails details, List<MaCodeVo> maCodeList) {
List<MaCodeVo> codeVos = maCodeList.stream()
.filter(maCodeVo -> StringUtils.isNotBlank(maCodeVo.getMaCode())
&& maCodeVo.getTypeId().equals(details.getTypeId().toString()))
.collect(Collectors.toList());
List<MaCodeDto> maCodeDtos = new ArrayList<>();
for (MaCodeVo maCodeVo : codeVos) {
MaCodeDto maCodeDto = new MaCodeDto();
maCodeDto.setMaCode(maCodeVo.getMaCode());
maCodeDto.setMaId(maCodeVo.getMaId());
if (maCodeVo.getGoodNum() != null && maCodeVo.getGoodNum().compareTo(BigDecimal.ZERO) > 0) {
maCodeDto.setApDetection("完好");
} else if (maCodeVo.getBadNum() != null && maCodeVo.getBadNum().compareTo(BigDecimal.ZERO) > 0) {
maCodeDto.setApDetection("损坏");
}
maCodeDto.setTypeName(maCodeVo.getTypeName());
maCodeDto.setMaterialName(maCodeVo.getMaterialName());
maCodeDto.setTypeId(maCodeVo.getTypeId());
maCodeDto.setMaStatus(maCodeVo.getMaStatus());
maCodeDto.setMaterialType(maCodeVo.getMaterialType());
maCodeDto.setGoodNum(maCodeVo.getGoodNum());
maCodeDto.setBadNum(maCodeVo.getBadNum());
// 查询并设置编码附件
List<BmFileInfo> bmFileInfoList = fetchBmFileInfos(details.getId(), maCodeVo.getMaId());
if (CollectionUtils.isNotEmpty(bmFileInfoList)) {
maCodeDto.setBmFileInfos(bmFileInfoList);
}
maCodeDtos.add(maCodeDto);
}
details.setMaCodeList(maCodeDtos);
}
/**
* 查询编码设备附件信息
* @param taskId
@ -315,27 +428,27 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
backApplyInfo.setUserId(userId == 0 ? null : userId);
}
list = backApplyInfoMapper.selectBackApplyInfoList(backApplyInfo);
for (BackApplyInfo applyInfo : list) {
if (!CollectionUtils.isEmpty(typeIdList)) {
// 使用流过滤符合条件的元素
list = list.stream()
.filter(item -> {
String firstIdStr = item.getFirstId();
if (firstIdStr == null) {
return false;
}
// 将逗号分隔的字符串转为集合
Set<Long> firstIds = Arrays.stream(firstIdStr.split(","))
.map(String::trim)
.filter(s -> !s.isEmpty())
.map(Long::parseLong)
.collect(Collectors.toSet());
if (!CollectionUtils.isEmpty(typeIdList)) {
// 使用流过滤符合条件的元素
list = list.stream()
.filter(item -> {
String firstIdStr = item.getFirstId();
if (firstIdStr == null) {
return false;
}
// 将逗号分隔的字符串转为集合
Set<Long> firstIds = Arrays.stream(firstIdStr.split(","))
.map(String::trim)
.filter(s -> !s.isEmpty())
.map(Long::parseLong)
.collect(Collectors.toSet());
// 判断两个集合是否有交集
return firstIds.stream().anyMatch(typeIdList::contains);
})
.collect(Collectors.toList());
}
// 判断两个集合是否有交集
return firstIds.stream().anyMatch(typeIdList::contains);
})
.collect(Collectors.toList());
}
for (BackApplyInfo applyInfo : list) {
if (StringUtils.isNotBlank(applyInfo.getBackSignUrl())) {
applyInfo.setBackSignUrl("data:image/png;base64," + applyInfo.getBackSignUrl());
}
@ -1591,6 +1704,94 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
}
}
/**
* 查询未签字退料任务列表
* @param backApplyInfo
* @return
*/
@Override
public List<BackApplyInfo> getNoSignList(BackApplyInfo backApplyInfo) {
backApplyInfo.setIsSign(1);
Long userId = SecurityUtils.getLoginUser().getUserid();
// 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
List<Long> typeIdList = backApplyInfoMapper.selectTypeIdList(userId);
if (CollectionUtils.isEmpty(typeIdList)) {
backApplyInfo.setUserId(userId == 0 ? null : userId);
}
List<BackApplyInfo> list = backApplyInfoMapper.selectBackApplyInfoList(backApplyInfo);
if (!CollectionUtils.isEmpty(typeIdList)) {
// 使用流过滤符合条件的元素
list = list.stream()
.filter(item -> {
String firstIdStr = item.getFirstId();
if (firstIdStr == null) {
return false;
}
// 将逗号分隔的字符串转为集合
Set<Long> firstIds = Arrays.stream(firstIdStr.split(","))
.map(String::trim)
.filter(s -> !s.isEmpty())
.map(Long::parseLong)
.collect(Collectors.toSet());
// 判断两个集合是否有交集
return firstIds.stream().anyMatch(typeIdList::contains);
})
.collect(Collectors.toList());
}
// 提取关键字
String keyWord = backApplyInfo.getKeyWord();
// 如果关键字不为空进行过滤
if (!StringUtils.isBlank(keyWord)) {
list = list.stream()
.filter(item -> containsKeyword(item, keyWord))
.collect(Collectors.toList());
}
return list;
}
/**
* 查询材料员待确认的任务
* @param backApplyInfo
* @return
*/
@Override
public List<BackApplyInfo> getCompleteBackTaskList(BackApplyInfo backApplyInfo) {
// 查询已签名数据
backApplyInfo.setIsSign(2);
List<BackApplyInfo> list = backApplyInfoMapper.selectBackApplyInfoList(backApplyInfo);
//材料站权限过滤
String username = SecurityUtils.getLoginUser().getUsername();
if(!CollectionUtils.isEmpty(list)) {
list = list.stream()
.filter(info -> {
// 调用 mapper 方法检查是否有符合条件的数据
int count = leaseApplyInfoMapper.checkPermission(info.getExternalId(), username);
return count > 0;
})
.collect(Collectors.toList());
}
// 提取关键字
String keyWord = backApplyInfo.getKeyWord();
// 如果关键字不为空进行过滤
if (!StringUtils.isBlank(keyWord)) {
list = list.stream()
.filter(item -> containsKeyword(item, keyWord))
.collect(Collectors.toList());
}
return list;
}
/**
* 材料员确认接口
* @param backApplyInfo
* @return
*/
@Override
public int confirmMaterial(BackApplyInfo backApplyInfo) {
return backApplyInfoMapper.updateBackApplyInfo(backApplyInfo);
}
/**
* 关键字搜索

View File

@ -702,105 +702,27 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
// 获取工器具领料出库详情
List<MaterialLeaseApplyDetails> details = materialLeaseInfoMapper.getOutDetailsById(dto);
if (!CollectionUtils.isEmpty(details)) {
leaseApplyRequestVo.setLeaseApplyDetailsList(details);
// 步骤4.1: 收集所有typeId进行批量查询
List<Long> typeIds = details.stream()
.map(MaterialLeaseApplyDetails::getTypeId)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());
SelectDto selectDto = new SelectDto();
selectDto.setProId(info.getProId());
List<AgreementVo> agreementList = mapper.getAgreementInfoBy(selectDto);
Map<Long, BigDecimal> storageNumMap = preCalculateStorageNums(info, agreementList, typeIds);
for (MaterialLeaseApplyDetails detail : details) {
SelectDto selectDto = new SelectDto();
selectDto.setProId(info.getProId());
List<AgreementVo> list = mapper.getAgreementInfoBy(selectDto);
// 先查第四层类型
List<TypeTreeNode> listL4 = new ArrayList<>();
List<TypeTreeNode> listL5 = new ArrayList<>();
List<TypeTreeNode> list7 = new ArrayList<>();
BackApplyInfo backApplyInfo = new BackApplyInfo();
if (!CollectionUtils.isEmpty(list)) {
for (AgreementVo agreementVo : list) {
backApplyInfo.setAgreementId(Long.valueOf(agreementVo.getAgreementId()));
listL4 = mapper.getUseTypeTreeL4(backApplyInfo);
if (!CollectionUtils.isEmpty(listL4)) {
listL4 = listL4.stream()
.filter(item -> StringUtils.isNotBlank(item.getMaterialName()) && StringUtils.isNotBlank(item.getTypeName()))
.collect(Collectors.toList());
// 将listL5中typeId相同的数据进行num相加
for (TypeTreeNode node : listL4) {
// 根据node中的typeId查询listL5中相同数据,如果在listL5中存在则将num相加,反之将node添加到list5中
TypeTreeNode node1 = listL5.stream()
.filter(item -> item.getTypeId() == (node.getTypeId()))
.findFirst()
.orElse(null);
if (node1 != null) {
node1.setNum(node1.getNum().add(node.getNum()));
}
if (node1 == null) {
listL5.add(node);
}
}
}
}
// 根据工程id去协议表中查询协议id
MaterialLeaseApplyInfo bean = new MaterialLeaseApplyInfo();
bean.setProId(info.getProId());
List<BmAgreementInfo> listAgreement = materialLeaseInfoMapper.getAgreementIdByProId(bean);
if (!CollectionUtils.isEmpty(listAgreement)) {
for (BmAgreementInfo agreementInfo : listAgreement) {
bean.setAgreementId(agreementInfo.getAgreementId());
List<TypeTreeNode> list6 = materialLeaseInfoMapper.getUseTypeTree(bean);
if (!CollectionUtils.isEmpty(list6)) {
for (TypeTreeNode node : list6) {
// 根据node中的typeId查询listL7中相同数据,如果在listL7中存在则将num相加,反之将node添加到list7中
TypeTreeNode node1 = list7.stream()
.filter(item -> item.getTypeId() == (node.getTypeId()))
.findFirst()
.orElse(null);
if (node1 != null) {
node1.setNum(node1.getNum().add(node.getNum()));
}
if (node1 == null) {
list7.add(node);
}
}
}
}
}
// 根据协议id去clz_slt_agreement_info材料站协议表中查询在用设备进行数据筛选去除
if (!CollectionUtils.isEmpty(listL5)) {
if (!CollectionUtils.isEmpty(list7)) {
// 将list5中typeId和list7中相同数据进行num相减并剔除相减后为0的数据
Map<Long, BigDecimal> typeIdToNum = list7.stream()
.collect(Collectors.toMap(
TypeTreeNode::getTypeId,
TypeTreeNode::getNum,
BigDecimal::add
));
Iterator<TypeTreeNode> iterator = listL5.iterator();
while (iterator.hasNext()) {
TypeTreeNode node = iterator.next();
Long typeId = node.getTypeId();
// 获取要减去的值默认值为BigDecimal.ZERO
BigDecimal subtractNum = typeIdToNum.getOrDefault(typeId, BigDecimal.ZERO);
// 计算新值处理num为null的情况若业务允许
BigDecimal currentNum = Optional.ofNullable(node.getNum())
.orElse(BigDecimal.ZERO);
BigDecimal newNum = currentNum.subtract(subtractNum);
if (newNum.compareTo(BigDecimal.ZERO) == 0) {
iterator.remove();
} else {
node.setNum(newNum);
}
}
}
// 根据details中的typeId去list5中获取库存
listL5.stream()
.filter(node -> detail.getTypeId().equals(node.getTypeId()))
.findFirst()
.ifPresent(node -> detail.setStorageNum(node.getNum()));
}
// 获取编码详情
List<MaterialLeaseMaCodeDto> maCodeVoList = materialLeaseInfoMapper.getCodeList(dto.getId(), detail.getTypeId());
if (!CollectionUtils.isEmpty(maCodeVoList)) {
detail.setMaCodeList(maCodeVoList);
}
// 直接从预计算的Map中获取库存数据避免复杂的嵌套循环
BigDecimal storageNum = storageNumMap.getOrDefault(detail.getTypeId(), BigDecimal.ZERO);
detail.setStorageNum(storageNum);
// 获取编码详情
List<MaterialLeaseMaCodeDto> maCodeVoList = materialLeaseInfoMapper.getCodeList(dto.getId(), detail.getTypeId());
if (!CollectionUtils.isEmpty(maCodeVoList)) {
detail.setMaCodeList(maCodeVoList);
}
}
leaseApplyRequestVo.setLeaseApplyDetailsList(details);
}
});
return leaseApplyRequestVo;
@ -1503,17 +1425,17 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
list.addAll(listL3);
list.addAll(listL21);
}
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(list)) {
/*if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(list)) {
// 创建树形结构数据集合作为参数
TypeTreeBuild treeBuild = new TypeTreeBuild(list);
// 原查询结果转换树形结构
groupList = treeBuild.buildTree();
}
}*/
}
} catch (Exception e) {
AjaxResult.error("类型树-查询失败", e);
}
return AjaxResult.success(groupList);
return AjaxResult.success(list);
}
/**
@ -1839,8 +1761,8 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
}
/**
* 预计算库存数据替代复杂的类型树计算
* 这个方法将原来每个detail都要执行的复杂计算优化为一次性预计算
* 预计算库存数据重现原始的类型树计算逻辑
* 业务逻辑总领料数量 - 已在用数量 = 剩余可用库存
*/
private Map<Long, BigDecimal> preCalculateStorageNums(MaterialLeaseApplyInfo info,
List<AgreementVo> agreementList,
@ -1848,27 +1770,67 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
Map<Long, BigDecimal> storageNumMap = new HashMap<>();
try {
// 简化的库存计算直接查询ma_type表的storage_num字段
for (Long typeId : typeIds) {
try {
// 查询单个类型的信息获取storage_num
Type typeInfo = typeMapper.selectTypeByTypeId(typeId);
if (typeInfo != null && typeInfo.getStorageNum() != null) {
storageNumMap.put(typeId, typeInfo.getStorageNum());
} else {
storageNumMap.put(typeId, BigDecimal.ZERO);
log.info("开始预计算库存,原始类型树逻辑,处理{}个类型", typeIds.size());
// 第1步从协议中获取总领料数量原listL5逻辑
Map<Long, BigDecimal> totalLeaseNums = new HashMap<>();
if (!CollectionUtils.isEmpty(agreementList)) {
for (AgreementVo agreementVo : agreementList) {
BackApplyInfo backApplyInfo = new BackApplyInfo();
backApplyInfo.setAgreementId(Long.valueOf(agreementVo.getAgreementId()));
List<TypeTreeNode> listL4 = mapper.getUseTypeTreeL4(backApplyInfo);
if (!CollectionUtils.isEmpty(listL4)) {
for (TypeTreeNode node : listL4) {
if (node.getTypeId() != 0L && node.getNum() != null) {
totalLeaseNums.merge(node.getTypeId(), node.getNum(), BigDecimal::add);
}
}
}
} catch (Exception e) {
log.warn("查询typeId {}的库存失败: {}", typeId, e.getMessage());
storageNumMap.put(typeId, BigDecimal.ZERO);
}
}
log.info("预计算库存完成,为{}个类型查询了库存值", typeIds.size());
// 第2步通过工程获取已在用数量原list7逻辑
Map<Long, BigDecimal> usedNums = new HashMap<>();
MaterialLeaseApplyInfo bean = new MaterialLeaseApplyInfo();
bean.setProId(info.getProId());
List<BmAgreementInfo> listAgreement = materialLeaseInfoMapper.getAgreementIdByProId(bean);
if (!CollectionUtils.isEmpty(listAgreement)) {
for (BmAgreementInfo agreementInfo : listAgreement) {
bean.setAgreementId(agreementInfo.getAgreementId());
List<TypeTreeNode> list6 = materialLeaseInfoMapper.getUseTypeTree(bean);
if (!CollectionUtils.isEmpty(list6)) {
for (TypeTreeNode node : list6) {
if (node.getTypeId() != 0L && node.getNum() != null) {
usedNums.merge(node.getTypeId(), node.getNum(), BigDecimal::add);
}
}
}
}
}
// 第3步计算剩余库存 = 总领料数量 - 已在用数量
for (Long typeId : typeIds) {
BigDecimal totalNum = totalLeaseNums.getOrDefault(typeId, BigDecimal.ZERO);
BigDecimal usedNum = usedNums.getOrDefault(typeId, BigDecimal.ZERO);
BigDecimal storageNum = totalNum.subtract(usedNum);
// 确保不为负数
if (storageNum.compareTo(BigDecimal.ZERO) < 0) {
storageNum = BigDecimal.ZERO;
}
storageNumMap.put(typeId, storageNum);
}
log.info("库存计算完成 - 总领料:{}项,已在用:{}项,计算库存:{}项",
totalLeaseNums.size(), usedNums.size(), storageNumMap.size());
} catch (Exception e) {
log.error("预计算库存数据失败: {}", e.getMessage());
// 发生错误时返回默认值
log.error("预计算库存失败: {}", e.getMessage(), e);
// 失败时为所有类型设置默认值
for (Long typeId : typeIds) {
storageNumMap.put(typeId, BigDecimal.ZERO);
}

View File

@ -552,6 +552,9 @@ public class MaterialMachineServiceImpl implements MaterialMachineService {
if (teamData == null) {
// 根据用户名查询项目部信息
String departId = mapper.getDepartId(username);
if (StringUtils.isBlank(departId)) {
return new MaterialRetainedEquipmentInfo();
}
// 根据项目部id查询工程信息
List<String> projectIdList = mapper.getProjectId(departId);
if (!org.springframework.util.CollectionUtils.isEmpty(projectIdList)) {

View File

@ -22,6 +22,12 @@ public interface SignProcessMapper
*/
List<PurchaseSignRecord> getPurchaseSignRecordByTask(Long taskId);
/**
* 批量查询采购任务的会签记录
* @param taskIds 任务id列表
*/
List<PurchaseSignRecord> getPurchaseSignRecordByTasksBatch(List<Long> taskIds);
/**
* 查询采新购验收任务已进行会签的签名地址
* @param taskId 任务id

View File

@ -586,7 +586,8 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
// 领用数据
List<LeaseApplyInfo> leaseApplyOutList = leaseApplyInfoMapper.selectPublish(leaseApplyInfo);
if (!CollectionUtils.isEmpty(leaseApplyOutList)) {
for (LeaseApplyInfo applyInfo : leaseApplyOutList) {
list.addAll(leaseApplyOutList);
for (LeaseApplyInfo applyInfo : list) {
// 根据id去查询出库数量
LeaseApplyInfo outList = leaseApplyInfoMapper.getOutList(applyInfo);
if (outList != null) {
@ -599,7 +600,6 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
applyInfo.setIsConfirm(1);
}
}
list.addAll(leaseApplyOutList);
}
//材料站权限过滤
String username = SecurityUtils.getLoginUser().getUsername();
@ -686,7 +686,8 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
// 领用数据
List<LeaseApplyInfo> leaseApplyOutList = leaseApplyInfoMapper.selectPublish(leaseApplyInfo);
if (!CollectionUtils.isEmpty(leaseApplyOutList)) {
for (LeaseApplyInfo applyInfo : leaseApplyOutList) {
list.addAll(leaseApplyOutList);
for (LeaseApplyInfo applyInfo : list) {
// 根据id去查询出库数量
LeaseApplyInfo outList = leaseApplyInfoMapper.getOutList(applyInfo);
if (outList != null) {
@ -699,7 +700,6 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
applyInfo.setIsConfirm(1);
}
}
list.addAll(leaseApplyOutList);
}
if (leaseApplyInfo.getIsConfirm()!=null) {

View File

@ -1,6 +1,7 @@
package com.bonus.material.lease.service.impl;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
import java.util.Objects;
import com.bonus.common.biz.constant.MaterialConstants;
@ -517,8 +518,17 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
if (res > 0) {
// 普通机具减少 (ma_type 设备规格表)的库存数量
res = typeMapper.updateMaTypeStockNum(record);
// 更新 (ma_machine 设备表)的状态
machineMapper.updateMaMachineStatus(record, MaMachineStatusEnum.IN_USE.getStatus());
if (record.getMaId() != null) {
if (record.getJiJuType() == 1) {
record.setThisCheckTime(DateUtils.getNowDate());
LocalDate currentDate = LocalDate.now();
// 计算下一次检验日期当前日期加一年减一天
LocalDate nextCheckDate = currentDate.plusYears(1).minusDays(1);
record.setNextCheckTime(DateUtils.toDate(nextCheckDate));
}
// 更新 (ma_machine 设备表)的状态
res = machineMapper.updateMaMachineStatus(record, MaMachineStatusEnum.IN_USE.getStatus());
}
}
}
return res;

View File

@ -265,7 +265,7 @@ public class LossAssessmentServiceImpl implements LossAssessmentService {
int status = mapper.selectTaskStatus(taskId);
final TmTask tmTask = mapper.selectTmTaskByTaskId(taskId);
if (status<=0){
//驳回操作不可跨月操作
//驳回操作不可跨月退料的创建时间操作
if (!StringHelper.isNullOrEmptyString(String.valueOf(tmTask.getCreateTime()))) {
// createTime 转换为 LocalDate
LocalDate taskCreationDate = tmTask.getCreateTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();

View File

@ -24,6 +24,14 @@ public interface PurchaseCheckDetailsMapper {
String selectMaTypeNameByTaskAndStatusList(@Param("taskId") Long taskId, @Param("statusList") List<Integer> statusList);
/**
* 批量查询任务的物资类型名称
*
* @param taskIds 任务ID列表
* @param statusList 状态列表
* @return Map<Long, String> 任务ID对应的物资类型名称
*/
List<PurchaseCheckInfo> selectMaTypeNameByTaskIdsBatch(@Param("taskIds") List<Long> taskIds, @Param("statusList") List<Integer> statusList);
/**
* 查询新购验收任务详细
@ -39,6 +47,13 @@ public interface PurchaseCheckDetailsMapper {
*/
List<PurchaseCheckDetails> selectPurchaseCheckDetailsListByTaskId(@Param("taskId") Long taskId, @Param("status") Integer status, @Param("userId") Long userId);
/**
* 批量查询多个任务的验收任务详细列表
* @param taskIds 任务ID列表
* @param userId 用户ID
*/
List<PurchaseCheckDetails> selectPurchaseCheckDetailsListByTaskIdsBatch(@Param("taskIds") List<Long> taskIds, @Param("userId") Long userId);
/**
* 根据任务id查询新购验收任务详细列表--Join查询
* @param obj 新购验收任务请求参数封装dto

View File

@ -5,8 +5,10 @@ import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.stream.Collectors;
import com.bonus.common.biz.config.DateTimeHelper;
import com.bonus.common.biz.constant.BmConfigItems;
import com.bonus.common.biz.enums.MaTypeManageTypeEnum;
import com.bonus.common.biz.enums.PurchaseTaskStageEnum;
@ -186,13 +188,248 @@ public class PurchaseCheckInfoServiceImpl implements IPurchaseCheckInfoService {
}
/**
* 查询新购验收任务列表
* 查询新购验收任务列表 - 性能优化版本
*
* @param purchaseQueryDto 新购验收任务请求参数
* @return 新购验收任务
*/
@Override
public List<PurchaseCheckInfo> selectPurchaseCheckInfoList(PurchaseQueryDto purchaseQueryDto) {
log.info("=== MaterialLeaseInfoServiceImpl.selectPurchaseCheckInfoList开始执行purchaseQueryDto: {}", purchaseQueryDto);
final List<PurchaseCheckInfo> purchaseCheckInfos = purchaseCheckInfoMapper.selectPurchaseCheckInfoJoinList(purchaseQueryDto);
if (CollectionUtils.isEmpty(purchaseCheckInfos)) {
return Collections.emptyList();
}
// 检查 SecurityUtils.getLoginUser() 是否为 null
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser == null) {
log.error("当前用户未登录或登录信息丢失无法获取用户ID");
return Collections.emptyList();
}
final Long loginUserId = loginUser.getUserid();
if (Objects.isNull(loginUserId) || Objects.isNull(purchaseQueryDto.getTaskStage())) {
return Collections.emptyList();
}
// 提取所有任务ID用于批量查询
List<Long> taskIds = purchaseCheckInfos.stream()
.map(PurchaseCheckInfo::getTaskId)
.collect(Collectors.toList());
// 批量查询所有任务的明细信息
List<PurchaseCheckDetails> allDetails = purchaseCheckDetailsMapper.selectPurchaseCheckDetailsListByTaskIdsBatch(taskIds, loginUserId);
Map<Long, List<PurchaseCheckDetails>> detailsMap = allDetails.stream()
.filter(detail -> detail.getTaskId() != null)
.collect(Collectors.groupingBy(PurchaseCheckDetails::getTaskId));
// 批量查询任务状态信息
List<TmTask> tmTasks = tmTaskMapper.selectTmTaskByTaskIdsBatch(taskIds);
Map<Long, TmTask> taskMap = tmTasks.stream()
.filter(task -> task.getTaskId() != null)
.collect(Collectors.toMap(TmTask::getTaskId, Function.identity()));
// 批量查询物资类型名称
final boolean isAllowPartTransfer = bmConfigService.isBmConfigEnabledWithDefaultFalse(BmConfigItems.BOOLEAN_ALLOW_PURCHASE_PART_TRANSFER);
List<PurchaseCheckInfo> maTypeNames;
if (isAllowPartTransfer) {
maTypeNames = purchaseCheckDetailsMapper.selectMaTypeNameByTaskIdsBatch(taskIds, purchaseQueryDto.getStatusList());
} else {
maTypeNames = purchaseCheckDetailsMapper.selectMaTypeNameByTaskIdsBatch(taskIds, new ArrayList<>());
}
Map<Long, String> maTypeNameMap = maTypeNames.stream()
.filter(info -> info.getTaskId() != null)
.collect(Collectors.toMap(PurchaseCheckInfo::getTaskId,
info -> info.getPurchaseMaTypeName() != null ? info.getPurchaseMaTypeName() : ""));
// 批量查询会签记录
List<PurchaseSignRecord> allSignRecords = signProcessMapper.getPurchaseSignRecordByTasksBatch(taskIds);
Map<Long, List<PurchaseSignRecord>> signRecordsMap = allSignRecords.stream()
.filter(record -> record.getTaskId() != null)
.collect(Collectors.groupingBy(PurchaseSignRecord::getTaskId));
// 查询会签配置这个查询量小可以保持原样
List<SignProcessVo> signProcessVoList = signProcessMapper.getList(new SignProcessVo());
List<PurchaseCheckInfo> purchaseCheckInfoResult = new ArrayList<>();
for (final PurchaseCheckInfo purchaseInfo : purchaseCheckInfos) {
Long taskId = purchaseInfo.getTaskId();
// 获取采购物资明细
List<PurchaseCheckDetails> purchaseCheckDetails = detailsMap.getOrDefault(taskId, Collections.emptyList());
if (CollectionUtils.isEmpty(purchaseCheckDetails)) {
continue;
}
// 过滤掉数量管理并且是待绑定状态或者驳回后待绑定状态的物资
purchaseCheckDetails = purchaseCheckDetails.stream().filter(o ->
!(MaTypeManageTypeEnum.NUMBER_DEVICE.getTypeId().equals(o.getManageType()) &&
(o.getStatus().equals(PurchaseTaskStatusEnum.TO_BIND.getStatus()) ||
o.getStatus().equals(PurchaseTaskStatusEnum.TO_BIND_AFTER_REJECT.getStatus())))).collect(Collectors.toList());
if (isAllowPartTransfer) {
// 根据任务阶段过滤
switch (purchaseQueryDto.getTaskStage()) {
case PURCHASE_TASK_STAGE_MANAGE:
// 新购管理阶段展示全部任务不进行过滤
break;
case PURCHASE_TASK_STAGE_CHECK:
purchaseCheckDetails = purchaseCheckDetails.stream().filter(o ->
!PurchaseTaskStatusEnum.TO_NOTICE.getStatus().equals(o.getStatus()) &&
!PurchaseTaskStatusEnum.TO_CHECK_AFTER_REJECT.getStatus().equals(o.getStatus())).collect(Collectors.toList());
break;
case PURCHASE_TASK_STAGE_BIND:
purchaseCheckDetails = purchaseCheckDetails.stream().filter(o ->
!PurchaseTaskStatusEnum.TO_NOTICE.getStatus().equals(o.getStatus()) &&
!PurchaseTaskStatusEnum.TO_CHECK_AFTER_REJECT.getStatus().equals(o.getStatus()) &&
!PurchaseTaskStatusEnum.TO_CHECK.getStatus().equals(o.getStatus()) &&
!PurchaseTaskStatusEnum.TO_BIND_AFTER_REJECT.getStatus().equals(o.getStatus())
).collect(Collectors.toList());
break;
case PURCHASE_TASK_STAGE_STORE:
purchaseCheckDetails = purchaseCheckDetails.stream().filter(o ->
PurchaseTaskStatusEnum.IN_STORE.getStatus().equals(o.getStatus()) ||
PurchaseTaskStatusEnum.TO_STORE.getStatus().equals(o.getStatus()) ||
PurchaseTaskStatusEnum.TASK_FINISHED.getStatus().equals(o.getStatus()) ||
(PurchaseTaskStatusEnum.TO_BIND.getStatus().equals(o.getStatus()) && null != o.getBindNum() && 0 < o.getBindNum().compareTo(BigDecimal.ZERO)) ||
(PurchaseTaskStatusEnum.TO_STORE_AFTER_REJECT.getStatus().equals(o.getStatus()) && null != o.getBindNum() && 0 < o.getBindNum().compareTo(BigDecimal.ZERO))
).collect(Collectors.toList());
break;
default:
System.err.println("未知的新购任务阶段:" + purchaseQueryDto.getTaskStage());
return Collections.emptyList();
}
}
// 设置物资类型名称
purchaseInfo.setPurchaseMaTypeName(maTypeNameMap.get(taskId));
if (!CollectionUtils.isEmpty(purchaseCheckDetails)) {
// 计算数量和金额
BigDecimal purchaseMaTotalNumber = BigDecimal.ZERO;
BigDecimal checkMaTotalNumber = BigDecimal.ZERO;
BigDecimal bindMaTotalNumber = BigDecimal.ZERO;
BigDecimal inputMaTotalNumber = BigDecimal.ZERO;
BigDecimal purchaseMaTotalPrice = BigDecimal.ZERO;
BigDecimal purchaseTaxPriceTotal = BigDecimal.ZERO;
boolean isIncludeStage = false;
for (final PurchaseCheckDetails detail : purchaseCheckDetails) {
if (null == detail.getPurchaseNum() || null == detail.getPurchasePrice()) {
continue;
}
if (0 > detail.getPurchaseNum().compareTo(BigDecimal.ZERO) || 0 > detail.getPurchasePrice().compareTo(BigDecimal.ZERO)) {
throw new IllegalArgumentException("采购数量和价格必须为非负数");
}
if (!isIncludeStage) {
isIncludeStage = PurchaseTaskStatusEnum.isStatusOfStage(detail.getStatus(), PurchaseTaskStageEnum.getByCode(purchaseQueryDto.getTaskStage()), detail.getManageType());
}
purchaseMaTotalNumber = purchaseMaTotalNumber.add(Optional.of(detail.getPurchaseNum()).orElse(BigDecimal.ZERO));
checkMaTotalNumber = checkMaTotalNumber.add(Optional.ofNullable(detail.getCheckNum()).orElse(BigDecimal.ZERO));
bindMaTotalNumber = bindMaTotalNumber.add(Optional.ofNullable(detail.getBindNum()).orElse(BigDecimal.ZERO));
inputMaTotalNumber = inputMaTotalNumber.add(Optional.ofNullable(detail.getInputNum()).orElse(BigDecimal.ZERO));
purchaseMaTotalPrice = purchaseMaTotalPrice.add(detail.getPurchaseNum().multiply(detail.getPurchasePrice()).setScale(10, RoundingMode.HALF_DOWN));
purchaseTaxPriceTotal = purchaseTaxPriceTotal.add(detail.getPurchaseNum().multiply(detail.getPurchaseTaxPrice()).setScale(10, RoundingMode.HALF_DOWN));
}
purchaseInfo.setPurchaseMaNumber(purchaseMaTotalNumber);
purchaseInfo.setPurchasePrice(purchaseMaTotalPrice);
purchaseInfo.setPurchaseTaxPrice(purchaseTaxPriceTotal);
purchaseInfo.setBindMaNumber(bindMaTotalNumber);
purchaseInfo.setCheckMaNumber(checkMaTotalNumber);
purchaseInfo.setInputMaNumber(inputMaTotalNumber);
purchaseInfo.setWaitInputNumber(purchaseMaTotalNumber.subtract(inputMaTotalNumber));
// 设置任务状态
final TmTask tmTask = taskMap.get(taskId);
purchaseInfo.setTaskStatusName(isIncludeStage ? "未完成" : "已完成");
if (null != purchaseQueryDto.getIsFinish()) {
if (1 == purchaseQueryDto.getIsFinish()) {
if (isIncludeStage) {continue;}
} else {
if (!isIncludeStage) {continue;}
}
}
// 设置采购状态
List<Integer> statusList = purchaseCheckDetails.stream()
.map(PurchaseCheckDetails::getStatus)
.collect(Collectors.toList());
if (!CollectionUtils.isEmpty(statusList)) {
if (statusList.contains(PurchaseTaskStatusEnum.TO_BIND.getStatus()) ||
statusList.contains(PurchaseTaskStatusEnum.TO_STORE.getStatus()) ||
statusList.contains(PurchaseTaskStatusEnum.TO_BIND_AFTER_REJECT.getStatus()) ||
statusList.contains(PurchaseTaskStatusEnum.TO_STORE_AFTER_REJECT.getStatus())) {
purchaseInfo.setPurchaseStatus(PurchaseTaskStatusEnum.TO_BIND.getStatus());
} else if (statusList.contains(PurchaseTaskStatusEnum.IN_STORE.getStatus()) ||
statusList.contains(PurchaseTaskStatusEnum.TASK_IN_PROGRESS.getStatus()) ||
statusList.contains(PurchaseTaskStatusEnum.TASK_FINISHED.getStatus())) {
purchaseInfo.setPurchaseStatus(PurchaseTaskStatusEnum.IN_STORE.getStatus());
} else {
purchaseInfo.setPurchaseStatus(0);
}
}
if (tmTask != null) {
purchaseInfo.setTaskStatus(tmTask.getTaskStatus());
}
// 检查是否应该加入结果列表
if (isAllowPartTransfer) {
purchaseCheckInfoResult.add(purchaseInfo);
} else {
final OptionalInt minStatus = purchaseCheckDetails.stream().mapToInt(PurchaseCheckDetails::getStatus).min();
if (minStatus.isPresent() && purchaseQueryDto.getStatusList().contains(minStatus.getAsInt())) {
purchaseCheckInfoResult.add(purchaseInfo);
}
}
}
}
if (!CollectionUtils.isEmpty(purchaseCheckInfoResult)) {
// 设置会签级别
for (PurchaseCheckInfo purchaseCheckInfo : purchaseCheckInfoResult) {
List<PurchaseSignRecord> purchaseSignRecordList = signRecordsMap.getOrDefault(purchaseCheckInfo.getTaskId(), Collections.emptyList());
if (!CollectionUtils.isEmpty(purchaseSignRecordList) && !CollectionUtils.isEmpty(signProcessVoList)) {
Set<Long> configSignOrgSet = signProcessVoList.stream().map(SignProcessVo::getOrgId).collect(Collectors.toSet());
Set<Long> signedOrgSet = purchaseSignRecordList.stream().map(PurchaseSignRecord::getOrgId).collect(Collectors.toSet());
configSignOrgSet.removeAll(signedOrgSet);
if (signedOrgSet.size() == 1) {
purchaseCheckInfo.setSignLevel("2");
} else {
purchaseCheckInfo.setSignLevel("3");
}
}
}
// 关键字过滤
String keyWord = purchaseQueryDto.getKeyWord();
if (!StringUtils.isBlank(keyWord)) {
purchaseCheckInfoResult = purchaseCheckInfoResult.stream()
.filter(item -> containsKeyword(item, keyWord))
.collect(Collectors.toList());
}
}
return purchaseCheckInfoResult;
}
/**
* 查询新购验收任务列表 - 原始版本保留作为备份
*
* @param purchaseQueryDto 新购验收任务请求参数
* @return 新购验收任务
*/
public List<PurchaseCheckInfo> selectPurchaseCheckInfoListOriginal(PurchaseQueryDto purchaseQueryDto) {
log.info("=== MaterialLeaseInfoServiceImpl.selectPurchaseCheckInfoList开始执行purchaseQueryDto: {}", purchaseQueryDto);
final List<PurchaseCheckInfo> purchaseCheckInfos = purchaseCheckInfoMapper.selectPurchaseCheckInfoJoinList(purchaseQueryDto);
if (CollectionUtils.isEmpty(purchaseCheckInfos)) {
return Collections.emptyList();
@ -226,9 +463,6 @@ public class PurchaseCheckInfoServiceImpl implements IPurchaseCheckInfoService {
if (isAllowPartTransfer) {
// 2024-12-23日 取消状态过滤修改由任务阶段来过滤 --- by 阮世耀
// if (!CollectionUtils.isEmpty(purchaseQueryDto.getStatusList())) {
// purchaseCheckDetails = purchaseCheckDetails.stream().filter(o -> purchaseQueryDto.getStatusList().contains(o.getStatus())).collect(Collectors.toList());
// }
switch (purchaseQueryDto.getTaskStage()) {
case PURCHASE_TASK_STAGE_MANAGE:
// 新购管理阶段展示全部任务不进行过滤

View File

@ -171,6 +171,8 @@ public class RepairTaskDetails extends BaseEntity {
private String userName;
private int isDs ;
private List<PartType> partTypeList;
@ApiModelProperty(value = "登录用户id")

View File

@ -858,7 +858,7 @@ public class RepairServiceImpl implements RepairService {
partDetails.setPartId(null != partDetails.getPartId() ? partDetails.getPartId() : partDetails.getId());
// 有维修配件时,如果价格为空设置为0
if (null == partDetails.getPartCost()) {partDetails.setPartCost(BigDecimal.ZERO);}
partDetails.setTaskId(bean.getTaskId()).setMaId(bean.getMaId()).setTypeId(bean.getTypeId()).setCompanyId(null);
partDetails.setCreateBy(String.valueOf(loginUser.getUserid()));
@ -1119,6 +1119,7 @@ public class RepairServiceImpl implements RepairService {
repairTaskDetail.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
repairTaskDetail.setStatus("0");
repairTaskDetail.setNewTaskId(newTaskId);
repairTaskDetail.setIsDs(1);
repairMapper.insertRepaired(repairTaskDetail);
}
} else {

View File

@ -22,6 +22,14 @@ public interface TmTaskMapper {
*/
TmTask selectTmTaskByTaskId(Long taskId);
/**
* 批量查询任务
*
* @param taskIds 任务主键列表
* @return 任务列表
*/
List<TmTask> selectTmTaskByTaskIdsBatch(List<Long> taskIds);
/**
* 查询当年当月最大任务序号用于生成任务编号 by 分类型查询
* @param year

View File

@ -49,7 +49,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
GROUP_CONCAT(DISTINCT mt2.type_name) AS typeName,
bai.`status` AS status,
bai.print_status as printStatus,
GROUP_CONCAT(DISTINCT mt4.type_id) as firstId
GROUP_CONCAT(DISTINCT mt4.type_id) as firstId,
bp.external_id as externalId,
su.nick_name as materialMan,
bai.confirm_time as confirmTime,
bai.is_confirm as isConfirm,
bai.confirm_remark as confirmRemark,
SUM(bad.pre_num) as backNum
FROM
back_apply_info bai
LEFT JOIN back_apply_details bad on bad.parent_id = bai.id
@ -65,6 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN ma_type mt2 ON mt2.type_id = mt1.parent_id AND mt2.del_flag = '0'
left join ma_type mt3 ON mt2.parent_id = mt3.type_id and mt3.del_flag = '0'
left join ma_type mt4 ON mt3.parent_id = mt4.type_id and mt4.del_flag = '0'
left join sys_user su on su.user_id = bai.material_man
<if test="userId != null">
JOIN ma_type_repair mtr ON mtr.type_id = bad.type_id AND mtr.user_id = #{userId}
</if>
@ -441,6 +448,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="agreementId != null">
AND ba.project_id = #{proId}
</if>
<if test="unitId != null">
AND ba.unit_id = #{unitId}
</if>
<if test="proId != null">
AND ba.project_id = #{proId}
</if>
</select>
<select id="getDetailsById" resultType="com.bonus.material.back.domain.BackApplyDetails">
@ -663,6 +676,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="status != null">`status` = #{status},</if>
<if test="directId != null">direct_id = #{directId},</if>
<if test="printStatus != null">print_status = #{printStatus},</if>
<if test="material_man != null and material_man != ''">material_man = #{materialMan},</if>
<if test="confirmTime != null and confirmTime != ''">confirm_time = #{confirmTime},</if>
<if test="isConfirm != null">is_confirm = #{isConfirm},</if>
<if test="confirmRemark != null and confirmRemark != ''">confirm_remark = #{confirmRemark},</if>
</trim>
where id = #{id}
</update>

View File

@ -552,7 +552,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{typeId}
</foreach>
</if>
ORDER BY mt.type_id, mm.ma_code
ORDER BY mt.type_id, mm.ma_id
</select>
<!-- 批量查询设备是否已被领料 -->

View File

@ -385,18 +385,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mt.unit_name as unitName,
mt.unit_value as unitValue,
mt.manage_type as manageType,
SUM( CASE WHEN sai.agreement_id = #{agreementId} AND sai.STATUS = '0' THEN sai.num ELSE 0 END ) AS num,
SUM( sai.num ) AS num,
mt.LEVEL as level
FROM
ma_type mt
LEFT JOIN slt_agreement_info sai ON mt.type_id = sai.type_id
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = '0'
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = '0'
WHERE
EXISTS ( SELECT 1 FROM slt_agreement_info sai2 WHERE sai2.type_id = mt.type_id AND sai2.agreement_id = #{agreementId}
AND sai2.STATUS = '0' and IFNULL(sai.lease_type,0) = 0 and sai2.num > 0)
and mt.manage_type = '1'
sai.agreement_id = #{agreementId} AND sai.STATUS = '0'
and mt.manage_type = '1'
GROUP BY
mt.type_id
HAVING num> 0
</select>
<select id="getMaType" resultType="com.bonus.material.common.domain.vo.SelectVo">

View File

@ -179,6 +179,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
par.task_id = #{taskId}
</select>
<!-- 新增:批量查询采购任务的会签记录 -->
<select id="getPurchaseSignRecordByTasksBatch" resultType="com.bonus.material.purchase.domain.PurchaseSignRecord">
SELECT
par.id,
par.task_id AS taskId,
par.auditor AS userId,
par.org_id AS orgId,
par.audit_status AS auditStatus,
par.create_time AS createTime,
su.nick_name AS userName,
sd.dept_name AS deptName,
par.audit_remark AS auditRemark
FROM
purchase_audit_record par
LEFT JOIN sys_user su ON par.auditor = su.user_id
LEFT JOIN sys_dept sd ON par.org_id = sd.dept_id
WHERE
par.task_id in
<foreach item="taskId" collection="list" open="(" separator="," close=")">
#{taskId}
</foreach>
</select>
<insert id="insertPurchaseSignRecord">
insert into purchase_audit_record(task_id, auditor, audit_time, audit_status, org_id, creator, create_time, audit_remark)
values(#{taskId}, #{userId}, #{createTime}, #{auditStatus} ,#{orgId}, #{userId}, #{createTime}, #{auditRemark})

View File

@ -86,29 +86,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectLeaseApplyInfoVoTwo">
select
lai.id, lai.code, lai.task_id, lai.lease_person as leasePerson, lai.phone, lai.type, lai.company_audit_by,
lai.company_audit_time, lai.company_audit_remark, lai.dept_audit_by, lai.dept_audit_time,
lai.dept_audit_remark, lai.direct_audit_by, lai.direct_audit_time, lai.direct_audit_remark,
lai.create_by, lai.create_time, lai.update_by, lai.update_time, lai.remark, lai.company_id,
lai.direct_id, lai.lease_type, lai.estimate_lease_time, lai.cost_bearing_party, lai.lease_sign_url, lai.lease_sign_type,
lai.material_man, lai.confirm_time, lai.is_confirm, lai.confirm_remark,
bai.unit_id,bai.project_id,bu.unit_name as unitName, bp.pro_name as projectName,bp.external_id as externalId, bai.agreement_code as agreementCode, tt.task_status as taskStatus,
sda.dict_label as taskStatusName,
IFNULL(sum(lad.pre_num),0) as preCountNum,
IFNULL(sum(lod.out_num),0) as alNum,
CASE
WHEN IFNULL(sum(lad.pre_num),0) = SUM(CASE WHEN lod.is_confirm = 2 THEN lod.out_num ELSE 0 END) THEN 2
ELSE 1
END as isConfirm,
GROUP_CONCAT(DISTINCT mt1.type_name) as maTypeNames,
bp.contract_part as contractPart,
sd.dept_name as impUnitName,
tt.task_type as taskType
lai.id, lai.code, lai.task_id, lai.lease_person as leasePerson, lai.phone, lai.type, lai.company_audit_by,
lai.company_audit_time, lai.company_audit_remark, lai.dept_audit_by, lai.dept_audit_time,
lai.dept_audit_remark, lai.direct_audit_by, lai.direct_audit_time, lai.direct_audit_remark,
lai.create_by, lai.create_time as createTime, lai.update_by, lai.update_time, lai.remark, lai.company_id,
lai.direct_id, lai.lease_type, lai.estimate_lease_time, lai.cost_bearing_party, lai.lease_sign_url, lai.lease_sign_type,
lai.material_man, lai.confirm_time, lai.is_confirm, lai.confirm_remark,
bai.unit_id,bai.project_id,bu.unit_name as unitName, bp.pro_name as projectName,bp.external_id as externalId, bai.agreement_code as agreementCode, tt.task_status as taskStatus,
sda.dict_label as taskStatusName,
IFNULL(sum(lad.pre_num),0) as preCountNum,
IFNULL(lod.num,0) as alNum,
GROUP_CONCAT(DISTINCT mt1.type_name) as maTypeNames,
bp.contract_part as contractPart,
sd.dept_name as impUnitName,
tt.task_type as taskType
from
lease_apply_info lai
lease_apply_info lai
left join tm_task tt on lai.task_id = tt.task_id
left join lease_apply_details lad on lai.id = lad.parent_id
left join lease_out_details lod on lai.id = lod.parent_id
LEFT JOIN (SELECT IFNULL( sum(out_num ), 0) AS num, parent_id, publish_task, is_confirm, confirm_remark, confirm_time, lease_sign_id from lease_out_details
GROUP BY parent_id) lod ON lai.id = lod.parent_id
left join tm_task_agreement tta on lai.task_id = tta.task_id
left join bm_agreement_info bai on tta.agreement_id = bai.agreement_id
left join bm_unit bu on bu.unit_id = bai.unit_id
@ -404,7 +401,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectCompleteOutList" resultType="com.bonus.common.biz.domain.lease.LeaseApplyInfo">
<include refid="selectLeaseApplyInfoVoTwo"/>
where
lod.out_num >0 and lod.lease_sign_id is not null and bp.external_id is not null
lod.num >0 and lod.lease_sign_id is not null and bp.external_id is not null
and tt.task_type = 2
<if test="code != null and code != ''"> and lai.code = #{code}</if>
<if test="taskId != null "> and lai.task_id = #{taskId}</if>
@ -435,7 +432,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="estimateLeaseTime != null "> and lai.estimate_lease_time = #{estimateLeaseTime}</if>
<if test="costBearingParty != null and costBearingParty != ''"> and lai.cost_bearing_party = #{costBearingParty}</if>
GROUP BY lai.id
ORDER BY tt.task_status,tt.create_time desc
ORDER BY tt.task_status,lai.create_time desc
</select>
<select id="checkPermission" resultType="java.lang.Integer">
SELECT COUNT(1)
@ -730,7 +727,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
lod.confirm_remark AS confirmRemark,
mt3.type_id AS firstId,
lpd.create_time AS releaseTime,
bp.external_id as externalId
bp.external_id as externalId,
lai.create_time as createTime
FROM
lease_apply_info lai
LEFT JOIN tm_task tt ON lai.task_id = tt.task_id

View File

@ -342,9 +342,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateMaMachineStatus">
UPDATE
ma_machine
ma_machine
SET
ma_status = #{status},create_time = NOW()
ma_status = #{status},create_time = NOW()
<if test="record.thisCheckTime != null">
,this_check_time = #{record.thisCheckTime}
</if>
<if test="record.nextCheckTime != null">
,next_check_time = #{record.nextCheckTime}
</if>
<where>
type_id = #{record.typeId}
<if test="record.maId != null and record.maId != ''">

View File

@ -295,6 +295,55 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
GROUP BY task_id
</select>
<!-- 新增:批量查询任务的物资类型名称 -->
<select id="selectMaTypeNameByTaskIdsBatch" resultType="com.bonus.material.purchase.domain.PurchaseCheckInfo">
select
task_id as taskId,
GROUP_CONCAT(type_name) as purchaseMaTypeName
from
(
select
distinct pcd.task_id, mt1.type_name
from
purchase_check_details pcd
left join
ma_type mt on pcd.type_id = mt.type_id
left join
ma_type mt1 on mt.parent_id = mt1.type_id
where
1=1
<if test="taskIds != null and taskIds.size() > 0">
and pcd.task_id in
<foreach item="taskId" collection="taskIds" open="(" separator="," close=")">
#{taskId}
</foreach>
</if>
<if test="statusList != null and statusList.size() > 0">
and pcd.status in
<foreach item="item" collection="statusList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
) t
GROUP BY task_id
</select>
<!-- 新增:批量查询多个任务的验收任务详细列表 -->
<select id="selectPurchaseCheckDetailsListByTaskIdsBatch" resultMap="PurchaseCheckDetailsResult">
<include refid="selectPurchaseCheckDetailsJoinVo"/>
<if test="userId != null">
right join ma_type_keeper mtk ON mtk.type_id = mt.type_id AND mtk.user_id = #{userId}
</if>
where 1=1
<if test="taskIds != null and taskIds.size() > 0">
and pcd.task_id in
<foreach item="taskId" collection="taskIds" open="(" separator="," close=")">
#{taskId}
</foreach>
</if>
order by pcd.task_id, pcd.id
</select>
<insert id="insertPurchaseCheckDetailsList">
insert into purchase_check_details(task_id,type_id,purchase_price,purchase_tax_price,
purchase_num,check_num,bind_num,check_result,supplier_id,

View File

@ -72,6 +72,9 @@
<if test="parentId != null">
parent_id,
</if>
<if test="isDs != null">
is_ds,
</if>
create_time
)
values (
@ -111,6 +114,9 @@
<if test="parentId != null">
#{parentId},
</if>
<if test="isDs != null">
#{isDs},
</if>
NOW()
)
</insert>

View File

@ -41,6 +41,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectTmTaskVo"/>
where task_id = #{taskId}
</select>
<!-- 新增:批量查询任务 -->
<select id="selectTmTaskByTaskIdsBatch" resultMap="TmTaskResult">
<include refid="selectTmTaskVo"/>
where task_id in
<foreach item="taskId" collection="list" open="(" separator="," close=")">
#{taskId}
</foreach>
</select>
<insert id="insertTmTask" parameterType="com.bonus.material.task.domain.TmTask" useGeneratedKeys="true" keyProperty="taskId">
insert into tm_task