|
|
@@ -4,8 +4,10 @@ import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
@@ -17,14 +19,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.dromara.customer.domain.SupplierBusinessInfo;
|
|
|
-import org.dromara.customer.domain.SupplierProcurement;
|
|
|
-import org.dromara.customer.domain.SupplyArea;
|
|
|
+import org.dromara.customer.domain.*;
|
|
|
import org.dromara.customer.domain.bo.EnterpriseScaleBo;
|
|
|
import org.dromara.customer.domain.bo.SupplierAuthorizeBo;
|
|
|
-import org.dromara.customer.domain.vo.EnterpriseScaleVo;
|
|
|
-import org.dromara.customer.domain.vo.SupplierBusinessInfoVo;
|
|
|
-import org.dromara.customer.domain.vo.SupplierInformationVo;
|
|
|
+import org.dromara.customer.domain.bo.SupplyAreaBo;
|
|
|
+import org.dromara.customer.domain.vo.*;
|
|
|
import org.dromara.customer.enums.SupplierStatusEnum;
|
|
|
import org.dromara.customer.mapper.SupplierAuthorizeMapper;
|
|
|
import org.dromara.customer.mapper.SupplierBusinessInfoMapper;
|
|
|
@@ -38,8 +37,6 @@ import org.dromara.system.api.domain.vo.RemoteSupplierTypeVo;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.dromara.customer.domain.bo.SupplierInfoBo;
|
|
|
-import org.dromara.customer.domain.vo.SupplierInfoVo;
|
|
|
-import org.dromara.customer.domain.SupplierInfo;
|
|
|
import org.dromara.customer.mapper.SupplierInfoMapper;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
@@ -69,6 +66,8 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
|
|
|
private final CommonSupplierAuthorizeService commonSupplierAuthorizeMapper;
|
|
|
|
|
|
+ private final ISupplierInfoTemporaryService supplierInfoTemporaryService;
|
|
|
+
|
|
|
@DubboReference
|
|
|
private final RemoteComStaffService remoteComStaffService;
|
|
|
|
|
|
@@ -157,42 +156,246 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
* @return 是否修改成功
|
|
|
*/
|
|
|
@Override
|
|
|
- public Boolean updateByBo(SupplierInfoBo bo) {
|
|
|
- SupplierInfoVo supplierInfoVo = baseMapper.selectVoById(bo.getId());
|
|
|
- //根据状态来更新
|
|
|
- //待审核or停用or修改待审核-> 正式供应商
|
|
|
- if (supplierInfoVo.getSupplyStatus() != bo.getSupplyStatus() && bo.getSupplyStatus() == SupplierStatusEnum.OFFICIAL_SUPPLIER.getCode()) {
|
|
|
+ public Boolean updateByBo(SupplierInfoBo bo) throws JsonProcessingException {
|
|
|
+ //SupplierInfoVo supplierInfoVo = baseMapper.selectVoById(bo.getId());
|
|
|
+ SupplierInfo supplierInfoVo = baseMapper.selectById(bo.getId());
|
|
|
+ // 状态 待审核 正式供应商 停用 审核未通过 修改待审核
|
|
|
+ // 正式供应商 -> 停用
|
|
|
+ if (supplierInfoVo.getSupplyStatus() == SupplierStatusEnum.OFFICIAL_SUPPLIER.getCode() && bo.getSupplyStatus() == SupplierStatusEnum.DISABLED.getCode()) {
|
|
|
SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
|
- update.setCooperative(1l);
|
|
|
+ update.setCooperative(0l);
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
}
|
|
|
- // 正式供应商-> 停用
|
|
|
- if (supplierInfoVo.getSupplyStatus() != bo.getSupplyStatus() && bo.getSupplyStatus() == SupplierStatusEnum.DISABLED.getCode()) {
|
|
|
+ //正式供应商 -> 修改待审核
|
|
|
+ if (supplierInfoVo.getSupplyStatus() == SupplierStatusEnum.OFFICIAL_SUPPLIER.getCode() && bo.getSupplyStatus() == SupplierStatusEnum.REVIEW_UPDATED.getCode()) {
|
|
|
+ //一、修改了基本信息
|
|
|
+ //状态为修改待审核
|
|
|
+ supplierInfoVo.setSupplyStatus(SupplierStatusEnum.REVIEW_UPDATED.getCode());
|
|
|
+ //先copy到临时表
|
|
|
+ SupplierInfoTemporary supplierInfoTemporary = new SupplierInfoTemporary();
|
|
|
+ BeanUtils.copyProperties(bo, supplierInfoTemporary,"id");
|
|
|
+ //修改待审核
|
|
|
+ //ID一对一
|
|
|
+ supplierInfoTemporary.setSupplierId(bo.getId());
|
|
|
+ supplierInfoTemporary.setSupplyStatus(SupplierStatusEnum.REVIEW_UPDATED.getCode());
|
|
|
+ //通过传参在set临时表
|
|
|
+ //查询供应地址 存入 areaListJson 为了回显
|
|
|
+ SupplyAreaBo supplyAreaBo = new SupplyAreaBo();
|
|
|
+ supplyAreaBo.setSupplierId(bo.getId());
|
|
|
+ PageQuery pageQuery = new PageQuery();
|
|
|
+ TableDataInfo<SupplyAreaVo> supplyAreaVoTableDataInfo = supplyAreaService.queryPageList(supplyAreaBo, pageQuery);
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ String areaListJson = objectMapper.writeValueAsString(supplyAreaVoTableDataInfo);
|
|
|
+ supplierInfoTemporary.setAreaListJson(areaListJson);
|
|
|
+ boolean save = supplierInfoTemporaryService.save(supplierInfoTemporary);
|
|
|
+ return baseMapper.updateById(supplierInfoVo) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //待审核 -> 正式供应商 审核未通过
|
|
|
+ if (supplierInfoVo.getSupplyStatus() == SupplierStatusEnum.PENDING_REVIEW.getCode() && bo.getSupplyStatus() == SupplierStatusEnum.OFFICIAL_SUPPLIER.getCode()) {
|
|
|
SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
|
- update.setCooperative(0l);
|
|
|
+ update.setCooperative(1L);
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
}
|
|
|
- //待审核 ->审核未通过
|
|
|
- if (supplierInfoVo.getSupplyStatus() != bo.getSupplyStatus() && bo.getSupplyStatus() == SupplierStatusEnum.REVIEW_FAILED.getCode()) {
|
|
|
+ //待审核 -> 审核未通过
|
|
|
+ if (supplierInfoVo.getSupplyStatus() == SupplierStatusEnum.PENDING_REVIEW.getCode() && bo.getSupplyStatus() == SupplierStatusEnum.REVIEW_FAILED.getCode()) {
|
|
|
SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
|
- update.setCooperative(0l);
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
}
|
|
|
|
|
|
- // 审核不通过->待审核
|
|
|
- if (supplierInfoVo.getSupplyStatus()==SupplierStatusEnum.REVIEW_FAILED.getCode() && supplierInfoVo.getSupplyStatus() != bo.getSupplyStatus() && bo.getSupplyStatus() == SupplierStatusEnum.PENDING_REVIEW.getCode()) {
|
|
|
+ //停用 ->正式供应商
|
|
|
+ if (supplierInfoVo.getSupplyStatus() ==SupplierStatusEnum.DISABLED.getCode() && bo.getSupplyStatus() == SupplierStatusEnum.OFFICIAL_SUPPLIER.getCode()) {
|
|
|
SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
|
- update.setCooperative(0l);
|
|
|
+ update.setCooperative(1L);
|
|
|
+ return baseMapper.updateById(update) > 0;
|
|
|
+ }
|
|
|
+ //审核未通过 -> 无
|
|
|
+
|
|
|
+ // 待修改审核 -> 正式供应商 审核未通过 待修改审核
|
|
|
+ if (supplierInfoVo.getSupplyStatus() == SupplierStatusEnum.REVIEW_UPDATED.getCode() && bo.getSupplyStatus() == SupplierStatusEnum.OFFICIAL_SUPPLIER.getCode()) {
|
|
|
+ //1.1 审核通过
|
|
|
+ //1.2 将临时表信息copy到info表
|
|
|
+ Long id = supplierInfoVo.getId();
|
|
|
+ SupplierInfoTemporary supplierInfoTemporary = supplierInfoTemporaryService.getOne(new LambdaQueryWrapper<SupplierInfoTemporary>()
|
|
|
+ .eq(SupplierInfoTemporary::getSupplierId, id));
|
|
|
+ // 临时表数据判空防护
|
|
|
+ if (supplierInfoTemporary == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ BeanUtils.copyProperties(supplierInfoTemporary, supplierInfoVo, "id");
|
|
|
+ supplierInfoVo.setId(id);
|
|
|
+
|
|
|
+ //删除SupplyArea 把 AreaList再存入SupplyArea
|
|
|
+ int i = supplyAreaService.deleteBySupplierId(id);
|
|
|
+ String areaListJson = supplierInfoTemporary.getAreaListJson();
|
|
|
+ if (areaListJson == null || areaListJson.trim().isEmpty()) {
|
|
|
+ // 无区域数据,直接更新主表即可
|
|
|
+ return baseMapper.updateById(supplierInfoVo) > 0;
|
|
|
+ }
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ try {
|
|
|
+ // 1. 解析JSON字符串为 TableDataInfo<SupplyAreaVo>(和存储时的类型一致)
|
|
|
+ // 注意:泛型解析需要用 TypeReference 明确类型,否则会解析为 LinkedHashMap
|
|
|
+ TableDataInfo<SupplyAreaVo> areaTableData = objectMapper.readValue(
|
|
|
+ areaListJson,
|
|
|
+ new TypeReference<TableDataInfo<SupplyAreaVo>>() {}
|
|
|
+ );
|
|
|
+ // 2. 提取 SupplyAreaVo 列表(判空避免空指针)
|
|
|
+ List<SupplyAreaVo> supplyAreaVoList = areaTableData.getRows();
|
|
|
+ if (supplyAreaVoList == null || supplyAreaVoList.isEmpty()) {
|
|
|
+ // 无地址数据,直接更新主表即可
|
|
|
+ return baseMapper.updateById(supplierInfoVo) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 转换 SupplyAreaVo -> SupplyArea(持久化实体)
|
|
|
+ List<SupplyArea> supplyAreaList = new ArrayList<>();
|
|
|
+ for (SupplyAreaVo vo : supplyAreaVoList) {
|
|
|
+ SupplyArea area = new SupplyArea();
|
|
|
+ // 方式1:使用 BeanUtils 复制属性(简单属性,无复杂嵌套时可用)
|
|
|
+ BeanUtils.copyProperties(vo, area, "id");
|
|
|
+ area.setId(IdWorker.getId());
|
|
|
+ // 关键:设置供应商ID(关联当前供应商)
|
|
|
+ area.setSupplierId(id);
|
|
|
+ supplyAreaList.add(area);
|
|
|
+ }
|
|
|
+ // 4. 批量存入 SupplyArea 表(推荐批量插入,效率高于循环单条插入)
|
|
|
+ // 假设 supplyAreaService 有批量插入方法(如果没有,可在Mapper中添加 batchInsert)
|
|
|
+ boolean batchSave = supplyAreaService.saveBatch(supplyAreaList);
|
|
|
+
|
|
|
+
|
|
|
+ // 5. 更新主表 SupplierInfo
|
|
|
+ supplierInfoVo.setSupplyStatus(SupplierStatusEnum.OFFICIAL_SUPPLIER.getCode());
|
|
|
+ boolean updateMain = baseMapper.updateById(supplierInfoVo) > 0;
|
|
|
+ if (updateMain == false){
|
|
|
+ throw new RuntimeException("更新供应商信息失败");
|
|
|
+ }
|
|
|
+ boolean remove = supplierInfoTemporaryService.remove(new LambdaQueryWrapper<SupplierInfoTemporary>().eq(SupplierInfoTemporary::getSupplierId, id));
|
|
|
+ // 6. 返回最终结果(地址批量插入 + 主表更新都成功才返回 true)
|
|
|
+ return batchSave && updateMain && remove;
|
|
|
+
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ // JSON解析异常处理(可打印日志、抛出业务异常等)
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new RuntimeException("解析供应商地址JSON失败", e);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //待修改审核 驳回
|
|
|
+ if (supplierInfoVo.getSupplyStatus() == SupplierStatusEnum.REVIEW_UPDATED.getCode() && bo.getSupplyStatus() == SupplierStatusEnum.REVIEW_FAILED.getCode()) {
|
|
|
+ SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
|
+ update.setCooperative(0L);
|
|
|
+ // 补充:审核未通过,建议同时删除临时表的待审核数据,避免残留
|
|
|
+ supplierInfoTemporaryService.remove(new LambdaQueryWrapper<SupplierInfoTemporary>()
|
|
|
+ .eq(SupplierInfoTemporary::getSupplierId, update.getId()));
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
}
|
|
|
|
|
|
+ //待修改审核 ->待修改审核
|
|
|
+ if (supplierInfoVo.getSupplyStatus() == SupplierStatusEnum.REVIEW_UPDATED.getCode() && bo.getSupplyStatus() == SupplierStatusEnum.REVIEW_UPDATED.getCode()) {
|
|
|
+ Long supplierId = supplierInfoVo.getId();
|
|
|
+ // 1. 校验核心参数(避免空指针)
|
|
|
+ if (supplierId == null || bo == null) {
|
|
|
+ throw new IllegalArgumentException("供应商ID不能为空,无法更新待审核数据");
|
|
|
+ }
|
|
|
+ // 3. 第二步:更新临时表的供应商基础信息(非区域部分,如联系人、电话等)
|
|
|
+ SupplierInfoTemporary tempSupplier = supplierInfoTemporaryService.getOne(
|
|
|
+ new LambdaQueryWrapper<SupplierInfoTemporary>()
|
|
|
+ .eq(SupplierInfoTemporary::getSupplierId, supplierId)
|
|
|
+ );
|
|
|
+ if (tempSupplier == null) {
|
|
|
+ throw new RuntimeException("临时表无待审核数据,无法更新基础信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3.1 用最新提交的bo数据,更新临时表基础信息(覆盖旧的待审核数据)
|
|
|
+ SupplierInfo tempMain = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
|
+ BeanUtils.copyProperties(tempMain, tempSupplier, "id", "supplierId", "areaListJson");
|
|
|
+ // 忽略:主键、关联字段、区域JSON(区域JSON已由insertByBo处理完成)
|
|
|
+ // 3.2 保持临时表状态仍为「待修改审核」(兜底,避免意外修改)
|
|
|
+ tempSupplier.setSupplyStatus(SupplierStatusEnum.REVIEW_UPDATED.getCode());
|
|
|
+ // 4. 更新临时表的基础信息(区域JSON已由insertByBo更新,此处仅更新基础信息)
|
|
|
+ try {
|
|
|
+ boolean operateResult = supplierInfoTemporaryService.saveOrUpdate(tempSupplier);
|
|
|
+ // 5. 主表状态无需修改(仍为4),直接返回结果
|
|
|
+ return operateResult;
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException("更新供应商待审核基础数据失败,请联系管理员", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- //变成修改待审核状态
|
|
|
SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
|
- update.setSupplyStatus(4L);
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean srmUpdateByBo(SupplierInfoBo bo) {
|
|
|
+ Long id = bo.getId();
|
|
|
+ SupplierInfo supplierInfo = baseMapper.selectById(id);
|
|
|
+ //如果是待审核 随便改
|
|
|
+ if (bo.getSupplyStatus() == SupplierStatusEnum.PENDING_REVIEW.getCode()){
|
|
|
+ SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
|
+ return baseMapper.updateById(update) > 0;
|
|
|
+ }
|
|
|
+ //如果是启用状态,就变成待修改审核状态
|
|
|
+ if (supplierInfo.getSupplyStatus() == SupplierStatusEnum.OFFICIAL_SUPPLIER.getCode()){
|
|
|
+ SupplierInfoTemporary supplierInfoTemporary = supplierInfoTemporaryService.querBySupplierId(id);
|
|
|
+ if (supplierInfoTemporary == null){
|
|
|
+ BeanUtils.copyProperties(bo, supplierInfoTemporary,"id");
|
|
|
+ supplierInfoTemporary.setSupplierId(id);
|
|
|
+ supplierInfoTemporary.setSupplyStatus(SupplierStatusEnum.REVIEW_UPDATED.getCode());
|
|
|
+ boolean save = supplierInfoTemporaryService.save(supplierInfoTemporary);
|
|
|
+ if (save == false){
|
|
|
+ throw new RuntimeException("保存供应商待审核数据失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //一共三个地方
|
|
|
+ boolean flag =false;
|
|
|
+ //1.简称
|
|
|
+ if (bo.getShortName() != null && StringUtils.isNotBlank(bo.getShortName())){
|
|
|
+ supplierInfoTemporary.setShortName(bo.getShortName());
|
|
|
+ flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
+ }
|
|
|
+ //2.供货品牌
|
|
|
+ if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())){
|
|
|
+ supplierInfoTemporary.setOperatingBrand(bo.getOperatingBrand());
|
|
|
+ flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
+ }
|
|
|
+ //3.供货类目
|
|
|
+ if (bo.getOperatingCategory() != null && StringUtils.isNotBlank(bo.getOperatingCategory())){
|
|
|
+ supplierInfoTemporary.setOperatingCategory(bo.getOperatingCategory());
|
|
|
+ flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
+ }
|
|
|
+
|
|
|
+ supplierInfo.setSupplyStatus(SupplierStatusEnum.REVIEW_UPDATED.getCode());
|
|
|
+ boolean update =baseMapper.updateById(supplierInfo) > 0;
|
|
|
+ return update && flag;
|
|
|
+ }
|
|
|
+ //如果是待审核状态,就变成待修改审核状态
|
|
|
+ if (supplierInfo.getSupplyStatus() == SupplierStatusEnum.REVIEW_UPDATED.getCode()){
|
|
|
+ SupplierInfoTemporary supplierInfoTemporary = supplierInfoTemporaryService.querBySupplierId(id);
|
|
|
+ //一共三个地方
|
|
|
+ boolean flag =false;
|
|
|
+ //1.简称
|
|
|
+ if (bo.getShortName() != null && StringUtils.isNotBlank(bo.getShortName())){
|
|
|
+ supplierInfoTemporary.setShortName(bo.getShortName());
|
|
|
+ flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
+ }
|
|
|
+ //2.供货品牌
|
|
|
+ if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())){
|
|
|
+ supplierInfoTemporary.setOperatingBrand(bo.getOperatingBrand());
|
|
|
+ flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
+ }
|
|
|
+ //3.供货类目
|
|
|
+ if (bo.getOperatingCategory() != null && StringUtils.isNotBlank(bo.getOperatingCategory())){
|
|
|
+ supplierInfoTemporary.setOperatingCategory(bo.getOperatingCategory());
|
|
|
+ flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
+ }
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 校验并批量删除供应商信息信息
|
|
|
*
|
|
|
@@ -216,7 +419,15 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
*/
|
|
|
@Override
|
|
|
public SupplierInfoVo queryById(Long id) throws JsonProcessingException {
|
|
|
- SupplierInfoVo supplierInfoVo = baseMapper.selectVoById(id);
|
|
|
+ SupplierInfoVo supplierInfoVo1 = baseMapper.selectVoOne(new LambdaQueryWrapper<SupplierInfo>().select(SupplierInfo::getSupplyStatus)
|
|
|
+ .eq(SupplierInfo::getId, id));
|
|
|
+ SupplierInfoVo supplierInfoVo =new SupplierInfoVo();
|
|
|
+ if (supplierInfoVo1.getSupplyStatus() == SupplierStatusEnum.REVIEW_UPDATED.getCode()) {
|
|
|
+ SupplierInfoTemporaryVo supplierInfoTemporaryVo = supplierInfoTemporaryService.getVoOne(id);
|
|
|
+ BeanUtils.copyProperties(supplierInfoTemporaryVo, supplierInfoVo);
|
|
|
+ }else {
|
|
|
+ supplierInfoVo = baseMapper.selectVoById(id);
|
|
|
+ }
|
|
|
SupplierInfoVo supplierInformationVo = handleProcurementInfo(supplierInfoVo);
|
|
|
//返回工商信息
|
|
|
SupplierBusinessInfoVo supplierBusinessInfoVo = supplierBusinessInfoMapper
|
|
|
@@ -225,7 +436,6 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
// 将工商信息复制到供应商信息对象中
|
|
|
copyBusinessInfoToSupplierInfoVo(supplierBusinessInfoVo, supplierInformationVo);
|
|
|
}
|
|
|
-
|
|
|
return supplierInformationVo;
|
|
|
}
|
|
|
|
|
|
@@ -256,8 +466,6 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
lqw.eq(SupplierInfo::getSupplyStatus,bo.getSupplyStatus());
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
// 2. 添加品牌条件
|
|
|
if (bo.getOperatingBrand()!= null && StringUtils.isNotBlank(bo.getOperatingBrand())){
|
|
|
if (StringUtils.isNotBlank(bo.getOperatingBrand())){
|
|
|
@@ -310,7 +518,164 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
|
|
|
@Override
|
|
|
public TableDataInfo<SupplierInfoVo> getSupplierApproveInformation(SupplierInfoBo bo, PageQuery pageQuery) {
|
|
|
+ if (bo.getSupplyStatus() == null){
|
|
|
+ // 步骤1:定义两个列表,存储主表(状态0)和临时表(状态4)的数据
|
|
|
+ List<SupplierInfoVo> mainTableVoList = new ArrayList<>();
|
|
|
+ List<SupplierInfoVo> tempTableVoList = new ArrayList<>();
|
|
|
+
|
|
|
+ // 步骤2:查询主表(info)状态为 0 的数据
|
|
|
+ LambdaQueryWrapper<SupplierInfo> mainLqw = buildCommonQueryWrapper(bo);
|
|
|
+ mainLqw.eq(SupplierInfo::getSupplyStatus, SupplierStatusEnum.PENDING_REVIEW.getCode()); // 状态0:待审核(可替换为 SupplierStatusEnum.PENDING_REVIEW.getCode())
|
|
|
+ Page<SupplierInfoVo> mainPage = baseMapper.selectVoPage(new Page<>(1, Integer.MAX_VALUE), mainLqw); // 查询全部符合条件的数据,不做分页
|
|
|
+ if (!CollectionUtils.isEmpty(mainPage.getRecords())) {
|
|
|
+ mainTableVoList = mainPage.getRecords();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 步骤3:查询临时表(temporary)状态为 4 的数据
|
|
|
+ LambdaQueryWrapper<SupplierInfoTemporary> tempLqw = new LambdaQueryWrapper<>();
|
|
|
+ tempLqw.eq(SupplierInfoTemporary::getSupplyStatus, SupplierStatusEnum.REVIEW_UPDATED.getCode()); // 状态4:修改待审核(可替换为 SupplierStatusEnum.REVIEW_UPDATED.getCode())
|
|
|
+ // 补充bo中的其他查询条件(如品牌,和主表查询保持一致)
|
|
|
+ if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())) {
|
|
|
+ Long productBrandIdByName = remoteProductService.getProductBrandIdByName(bo.getOperatingBrand());
|
|
|
+ if (productBrandIdByName != null) {
|
|
|
+ tempLqw.like(SupplierInfoTemporary::getOperatingBrand, productBrandIdByName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 若有区域、产品经理/采购人员过滤,需同步对临时表执行相同过滤逻辑(此处复用你原有的过滤方法)
|
|
|
+ List<Long> validSupplierIds = new ArrayList<>();
|
|
|
+ // 3.1 区域过滤(同步主表逻辑)
|
|
|
+ if (StringUtils.isNotBlank(bo.getProvince()) || StringUtils.isNotBlank(bo.getCity())) {
|
|
|
+ validSupplierIds = supplyAreaService.getSupplierIdsByArea(bo.getProvince(), bo.getCity());
|
|
|
+ if (CollectionUtils.isEmpty(validSupplierIds)) {
|
|
|
+ validSupplierIds.add(-1L); // 无数据时添加无效ID,避免查询全部
|
|
|
+ }
|
|
|
+ tempLqw.in(SupplierInfoTemporary::getId, validSupplierIds);
|
|
|
+ }
|
|
|
+ // 3.2 产品经理/采购人员过滤(同步主表逻辑)
|
|
|
+ if (bo.getProductManager() != null || bo.getBuyer() != null) {
|
|
|
+ validSupplierIds = supplierProcurementService.getSupplierIdsByProcurement(bo.getProductManager(), bo.getBuyer());
|
|
|
+ if (CollectionUtils.isEmpty(validSupplierIds)) {
|
|
|
+ validSupplierIds.add(-1L);
|
|
|
+ }
|
|
|
+ tempLqw.in(SupplierInfoTemporary::getId, validSupplierIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询临时表全部符合条件数据,并转换为 SupplierInfoVo(保证和主表数据结构一致)
|
|
|
+ List<SupplierInfoTemporary> tempTableList = supplierInfoTemporaryService.list(tempLqw);
|
|
|
+ if (!CollectionUtils.isEmpty(tempTableList)) {
|
|
|
+ // 转换:SupplierInfoTemporary -> SupplierInfoVo(可使用Mapstruct,此处用BeanUtils示例,需保证字段一致)
|
|
|
+ tempTableVoList = tempTableList.stream().map(temp -> {
|
|
|
+ SupplierInfoVo vo = new SupplierInfoVo();
|
|
|
+ org.springframework.beans.BeanUtils.copyProperties(temp, vo);
|
|
|
+ vo.setId(temp.getSupplierId());
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 步骤4:合并两个列表的数据
|
|
|
+ List<SupplierInfoVo> totalVoList = new ArrayList<>();
|
|
|
+ totalVoList.addAll(mainTableVoList);
|
|
|
+ totalVoList.addAll(tempTableVoList);
|
|
|
+
|
|
|
+ // 步骤5:按照 supplyNo 倒序排序(处理null值,避免排序异常)
|
|
|
+ if (!CollectionUtils.isEmpty(totalVoList)) {
|
|
|
+ totalVoList.sort((vo1, vo2) -> {
|
|
|
+ // 优先处理null值,null值排后面
|
|
|
+ if (vo1.getSupplierNo() == null && vo2.getSupplierNo() == null) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ if (vo1.getSupplierNo() == null) {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ if (vo2.getSupplierNo() == null) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ // 倒序排序(compareTo反过来)
|
|
|
+ return vo2.getSupplierNo().compareTo(vo1.getSupplierNo());
|
|
|
+ });
|
|
|
+
|
|
|
+ // 批量处理扩展信息(复用你原有的逻辑)
|
|
|
+ totalVoList = batchHandleBaseExtInfo(totalVoList);
|
|
|
+ handleEnterpriseScaleName(totalVoList);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 步骤6:手动实现分页(关键:内存数据分页)
|
|
|
+ int pageNum = pageQuery.getPageNum();
|
|
|
+ int pageSize = pageQuery.getPageSize();
|
|
|
+ int totalCount = totalVoList.size();
|
|
|
+
|
|
|
+ // 计算分页参数
|
|
|
+ int startIndex = (pageNum - 1) * pageSize;
|
|
|
+ int endIndex = Math.min(startIndex + pageSize, totalCount);
|
|
|
+ List<SupplierInfoVo> pageVoList = new ArrayList<>();
|
|
|
+
|
|
|
+ // 截取当前页数据
|
|
|
+ if (startIndex < totalCount) {
|
|
|
+ pageVoList = totalVoList.subList(startIndex, endIndex);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 步骤7:封装分页结果(构建Page对象,符合返回值要求)
|
|
|
+ Page<SupplierInfoVo> resultPage = new Page<>(pageNum, pageSize, totalCount);
|
|
|
+ resultPage.setRecords(pageVoList);
|
|
|
+
|
|
|
+ // 步骤8:返回封装后的TableDataInfo
|
|
|
+ return TableDataInfo.build(resultPage);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
// 1. 构建审批状态条件
|
|
|
+ LambdaQueryWrapper<SupplierInfo> lqw = new LambdaQueryWrapper<>();
|
|
|
+ lqw.eq(SupplierInfo::getSupplyStatus,bo.getSupplyStatus());
|
|
|
+
|
|
|
+ // 2.添加品牌条件
|
|
|
+ if (bo.getOperatingBrand()!= null && StringUtils.isNotBlank(bo.getOperatingBrand())){
|
|
|
+ if (StringUtils.isNotBlank(bo.getOperatingBrand())){
|
|
|
+ Long productBrandIdByName = remoteProductService.getProductBrandIdByName(bo.getOperatingBrand());
|
|
|
+ if (productBrandIdByName != null){
|
|
|
+ lqw.like(SupplierInfo::getOperatingBrand, productBrandIdByName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //3.可供货区域省和市 - 添加供应区域过滤
|
|
|
+ if (StringUtils.isNotBlank(bo.getProvince()) || StringUtils.isNotBlank(bo.getCity())) {
|
|
|
+ // 查询符合条件的供应商ID列表
|
|
|
+ List<Long> supplierIds = supplyAreaService.getSupplierIdsByArea(bo.getProvince(), bo.getCity());
|
|
|
+ if (supplierIds != null && !supplierIds.isEmpty()) {
|
|
|
+ lqw.in(SupplierInfo::getId, supplierIds);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ lqw.in(SupplierInfo::getId, -1L);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //产品经理和采购人员
|
|
|
+ if (bo.getProductManager() != null || bo.getBuyer() != null) {
|
|
|
+ // 查询符合条件的供应商ID列表
|
|
|
+ List<Long> supplierIds = supplierProcurementService.getSupplierIdsByProcurement(bo.getProductManager(), bo.getBuyer());
|
|
|
+ if (supplierIds != null && !supplierIds.isEmpty()) {
|
|
|
+ lqw.in(SupplierInfo::getId, supplierIds);
|
|
|
+ } else {
|
|
|
+ lqw.in(SupplierInfo::getId, -1L);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 2. 基础分页查询
|
|
|
+ Page<SupplierInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
+ List<SupplierInfoVo> supplierVos = result.getRecords();
|
|
|
+
|
|
|
+ // 3. 批量处理扩展信息
|
|
|
+ if (!CollectionUtils.isEmpty(supplierVos)) {
|
|
|
+ supplierVos = batchHandleBaseExtInfo(supplierVos);
|
|
|
+ handleEnterpriseScaleName(supplierVos);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 4. 封装分页结果
|
|
|
+ Page<SupplierInfoVo> newPage = copyPageResult(result, supplierVos);
|
|
|
+ return TableDataInfo.build(newPage);
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ // 1. 构建审批状态条件
|
|
|
LambdaQueryWrapper<SupplierInfo> lqw = new LambdaQueryWrapper<>();
|
|
|
if (bo.getSupplyStatus() == null) {
|
|
|
List<Long> status = Arrays.asList(0L, 4L);
|
|
|
@@ -318,7 +683,6 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
}else {
|
|
|
lqw.eq(SupplierInfo::getSupplyStatus,bo.getSupplyStatus());
|
|
|
}
|
|
|
-
|
|
|
// 2.添加品牌条件
|
|
|
if (bo.getOperatingBrand()!= null && StringUtils.isNotBlank(bo.getOperatingBrand())){
|
|
|
if (StringUtils.isNotBlank(bo.getOperatingBrand())){
|
|
|
@@ -340,7 +704,6 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
//产品经理和采购人员
|
|
|
if (bo.getProductManager() != null || bo.getBuyer() != null) {
|
|
|
// 查询符合条件的供应商ID列表
|
|
|
@@ -351,8 +714,6 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
lqw.in(SupplierInfo::getId, -1L);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
// 2. 基础分页查询
|
|
|
Page<SupplierInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
List<SupplierInfoVo> supplierVos = result.getRecords();
|
|
|
@@ -366,6 +727,43 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
// 4. 封装分页结果
|
|
|
Page<SupplierInfoVo> newPage = copyPageResult(result, supplierVos);
|
|
|
return TableDataInfo.build(newPage);
|
|
|
+ */
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构建公共查询条件(主表和临时表共用的查询条件,提取为公共方法,减少冗余)
|
|
|
+ */
|
|
|
+ private LambdaQueryWrapper<SupplierInfo> buildCommonQueryWrapper(SupplierInfoBo bo) {
|
|
|
+ LambdaQueryWrapper<SupplierInfo> lqw = new LambdaQueryWrapper<>();
|
|
|
+
|
|
|
+ // 品牌条件(复用你原有的逻辑)
|
|
|
+ if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())) {
|
|
|
+ Long productBrandIdByName = remoteProductService.getProductBrandIdByName(bo.getOperatingBrand());
|
|
|
+ if (productBrandIdByName != null) {
|
|
|
+ lqw.like(SupplierInfo::getOperatingBrand, productBrandIdByName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 区域条件(复用你原有的逻辑)
|
|
|
+ if (StringUtils.isNotBlank(bo.getProvince()) || StringUtils.isNotBlank(bo.getCity())) {
|
|
|
+ List<Long> supplierIds = supplyAreaService.getSupplierIdsByArea(bo.getProvince(), bo.getCity());
|
|
|
+ if (!CollectionUtils.isEmpty(supplierIds)) {
|
|
|
+ lqw.in(SupplierInfo::getId, supplierIds);
|
|
|
+ } else {
|
|
|
+ lqw.in(SupplierInfo::getId, -1L);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 产品经理/采购人员条件(复用你原有的逻辑)
|
|
|
+ if (bo.getProductManager() != null || bo.getBuyer() != null) {
|
|
|
+ List<Long> supplierIds = supplierProcurementService.getSupplierIdsByProcurement(bo.getProductManager(), bo.getBuyer());
|
|
|
+ if (!CollectionUtils.isEmpty(supplierIds)) {
|
|
|
+ lqw.in(SupplierInfo::getId, supplierIds);
|
|
|
+ } else {
|
|
|
+ lqw.in(SupplierInfo::getId, -1L);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return lqw;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -434,6 +832,31 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public SupplierInfoVo querySrmById(Long id) {
|
|
|
+ SupplierInfoVo supplierInfoVo = baseMapper.selectVoById(id);
|
|
|
+
|
|
|
+ SupplierInfoVo supplierInformationVo = handleProcurementInfo(supplierInfoVo);
|
|
|
+ //返回工商信息
|
|
|
+ SupplierBusinessInfoVo supplierBusinessInfoVo = supplierBusinessInfoMapper
|
|
|
+ .selectVoOne(new LambdaQueryWrapper<SupplierBusinessInfo>().eq(SupplierBusinessInfo::getSupplierId, id));
|
|
|
+ if (supplierBusinessInfoVo != null) {
|
|
|
+ // 将工商信息复制到供应商信息对象中
|
|
|
+ copyBusinessInfoToSupplierInfoVo(supplierBusinessInfoVo, supplierInformationVo);
|
|
|
+ }
|
|
|
+ return supplierInformationVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Long getSupplierStatus(Long id) {
|
|
|
+ SupplierInfoVo supplierInfoVo1 = baseMapper.selectVoOne(new LambdaQueryWrapper<SupplierInfo>().select(SupplierInfo::getSupplyStatus)
|
|
|
+ .eq(SupplierInfo::getId,id));
|
|
|
+
|
|
|
+ return supplierInfoVo1.getSupplyStatus();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 将工商信息复制到供应商信息VO中
|
|
|
*
|