feat(sip): 增加产品信息管理功能
- 在 ProjectOrderInfo 模型中添加软件、硬件和维护项目产品信息列表 - 实现产品信息的保存和查询功能 - 优化订单信息保存逻辑,支持产品信息的批量保存master
parent
99cdcf8e4e
commit
094f528e53
|
@ -171,4 +171,7 @@ public class ProjectOrderInfo extends BaseEntity {
|
|||
private List<ProjectOrderFileLog> contractFileList;
|
||||
private List<ProjectOrderFileLog> configFileList;
|
||||
|
||||
private List<ProjectProductInfo> softwareProjectProductInfoList;
|
||||
private List<ProjectProductInfo> hardwareProjectProductInfoList;
|
||||
private List<ProjectProductInfo> maintenanceProjectProductInfoList;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ruoyi.sip.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -9,15 +10,11 @@ import cn.hutool.core.collection.CollUtil;
|
|||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.ShiroUtils;
|
||||
import com.ruoyi.sip.domain.Cnarea;
|
||||
import com.ruoyi.sip.domain.ProjectOrderFileLog;
|
||||
import com.ruoyi.sip.service.ICnareaService;
|
||||
import com.ruoyi.sip.service.IProjectOrderFileLogService;
|
||||
import com.ruoyi.sip.domain.*;
|
||||
import com.ruoyi.sip.service.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.sip.mapper.ProjectOrderInfoMapper;
|
||||
import com.ruoyi.sip.domain.ProjectOrderInfo;
|
||||
import com.ruoyi.sip.service.IProjectOrderInfoService;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
|
||||
/**
|
||||
|
@ -34,6 +31,8 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService {
|
|||
@Autowired
|
||||
private IProjectOrderFileLogService fileLogService;
|
||||
@Autowired
|
||||
private IProjectProductInfoService productInfoService;
|
||||
@Autowired
|
||||
private ICnareaService cnareaService;
|
||||
/**
|
||||
* 查询订单管理
|
||||
|
@ -44,6 +43,16 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService {
|
|||
@Override
|
||||
public ProjectOrderInfo selectProjectOrderInfoById(Long id) {
|
||||
ProjectOrderInfo projectOrderInfo = projectOrderInfoMapper.selectProjectOrderInfoById(id);
|
||||
|
||||
List<ProjectProductInfo> projectProductInfos = productInfoService.selectProjectProductInfoListByProjectId(projectOrderInfo.getProjectId());
|
||||
Map<String, List<ProjectProductInfo>> productListMap = projectProductInfos.stream().collect(Collectors.groupingBy(ProjectProductInfo::getType));
|
||||
projectOrderInfo.setSoftwareProjectProductInfoList(productListMap.get(ProductInfo.ProductTypeEnum.SOFTWARE.getType()));
|
||||
projectOrderInfo.setHardwareProjectProductInfoList(productListMap.get(ProductInfo.ProductTypeEnum.HARDWARE.getType()));
|
||||
List<ProjectProductInfo> maintenanceProjectProductInfoList = productListMap.getOrDefault(ProductInfo.ProductTypeEnum.HARDWARE_MAINTENANCE.getType(), new ArrayList<>());
|
||||
maintenanceProjectProductInfoList.addAll(productListMap.getOrDefault(ProductInfo.ProductTypeEnum.SOFTWARE_MAINTENANCE.getType(), new ArrayList<>()));
|
||||
projectOrderInfo.setMaintenanceProjectProductInfoList(maintenanceProjectProductInfoList);
|
||||
|
||||
|
||||
List<ProjectOrderFileLog> projectOrderFileLogs = fileLogService.listByOrderId(Collections.singletonList(id));
|
||||
Map<String, List<ProjectOrderFileLog>> fileLogMap =
|
||||
projectOrderFileLogs.stream().collect(Collectors.groupingBy(ProjectOrderFileLog::getFileType));
|
||||
|
@ -76,9 +85,26 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService {
|
|||
projectOrderInfo.setOrderCode(orderNumber);
|
||||
projectOrderInfo.setCreateTime(DateUtils.getNowDate());
|
||||
projectOrderInfo.setCreateBy(ShiroUtils.getUserId().toString());
|
||||
saveProductInfo(projectOrderInfo);
|
||||
return projectOrderInfoMapper.insertProjectOrderInfo(projectOrderInfo);
|
||||
}
|
||||
|
||||
private void saveProductInfo(ProjectOrderInfo projectOrderInfo) {
|
||||
//插入产品信息
|
||||
List<ProjectProductInfo> projectProductInfoList = projectOrderInfo.getHardwareProjectProductInfoList();
|
||||
if (CollUtil.isEmpty(projectProductInfoList)) {
|
||||
projectProductInfoList = new ArrayList<>();
|
||||
}
|
||||
projectProductInfoList.addAll(CollUtil.isNotEmpty(projectOrderInfo.getSoftwareProjectProductInfoList()) ? projectOrderInfo.getSoftwareProjectProductInfoList() : new ArrayList<>());
|
||||
projectProductInfoList.addAll(CollUtil.isNotEmpty(projectOrderInfo.getMaintenanceProjectProductInfoList()) ? projectOrderInfo.getMaintenanceProjectProductInfoList() : new ArrayList<>());
|
||||
if (CollUtil.isNotEmpty(projectProductInfoList)) {
|
||||
for (ProjectProductInfo projectProductInfo : projectProductInfoList) {
|
||||
projectProductInfo.setProjectId(projectOrderInfo.getId());
|
||||
}
|
||||
productInfoService.saveBatch(projectProductInfoList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成订单编号
|
||||
*
|
||||
|
@ -122,6 +148,7 @@ public class ProjectOrderInfoServiceImpl implements IProjectOrderInfoService {
|
|||
}
|
||||
projectOrderInfo.setUpdateBy(ShiroUtils.getUserId().toString());
|
||||
projectOrderInfo.setUpdateTime(DateUtils.getNowDate());
|
||||
saveProductInfo(projectOrderInfo);
|
||||
return projectOrderInfoMapper.updateProjectOrderInfo(projectOrderInfo);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue