|
@@ -46,6 +46,7 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.dromara.customer.domain.vo.SupplierInfoVo;
|
|
import org.dromara.customer.domain.vo.SupplierInfoVo;
|
|
|
import org.dromara.customer.domain.SupplierInfo;
|
|
import org.dromara.customer.domain.SupplierInfo;
|
|
|
|
|
+import org.dromara.customer.mapper.SupplierInfoMapper;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
@@ -167,6 +168,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 修改供应商信息
|
|
* 修改供应商信息
|
|
|
*
|
|
*
|
|
@@ -346,12 +348,12 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
|
return baseMapper.updateById(update) > 0;
|
|
return baseMapper.updateById(update) > 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
|
|
|
+ /*@Override
|
|
|
public boolean srmUpdateByBo(SupplierInfoBo bo) throws JsonProcessingException {
|
|
public boolean srmUpdateByBo(SupplierInfoBo bo) throws JsonProcessingException {
|
|
|
Long id = bo.getId();
|
|
Long id = bo.getId();
|
|
|
SupplierInfo supplierInfo = baseMapper.selectById(id);
|
|
SupplierInfo supplierInfo = baseMapper.selectById(id);
|
|
|
//如果是待审核和审核不通过 随便改
|
|
//如果是待审核和审核不通过 随便改
|
|
|
- if (bo.getSupplyStatus() == SupplierStatusEnum.PENDING_REVIEW.getCode() || bo.getSupplyStatus() == SupplierStatusEnum.REVIEW_FAILED.getCode()) {
|
|
|
|
|
|
|
+ if (bo.getSupplyStatus() == SupplierStatusEnum.PENDING_REVIEW.getCode() || bo.getSupplyStatus() == SupplierStatusEnum.REVIEW_FAILED.getCode()){
|
|
|
SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
|
return baseMapper.updateById(update) > 0;
|
|
return baseMapper.updateById(update) > 0;
|
|
|
}
|
|
}
|
|
@@ -372,60 +374,199 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
|
supplierInfoTemporary.setAreaListJson(areaListJson);
|
|
supplierInfoTemporary.setAreaListJson(areaListJson);
|
|
|
supplierInfoTemporary.setSupplyStatus(SupplierStatusEnum.REVIEW_UPDATED.getCode());
|
|
supplierInfoTemporary.setSupplyStatus(SupplierStatusEnum.REVIEW_UPDATED.getCode());
|
|
|
boolean save = supplierInfoTemporaryService.save(supplierInfoTemporary);
|
|
boolean save = supplierInfoTemporaryService.save(supplierInfoTemporary);
|
|
|
- if (save == false) {
|
|
|
|
|
|
|
+ if (save == false){
|
|
|
throw new RuntimeException("保存供应商待审核数据失败");
|
|
throw new RuntimeException("保存供应商待审核数据失败");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
//一共三个地方
|
|
//一共三个地方
|
|
|
- boolean flag = false;
|
|
|
|
|
|
|
+ boolean flag =false;
|
|
|
//1.简称
|
|
//1.简称
|
|
|
- if (bo.getShortName() != null && StringUtils.isNotBlank(bo.getShortName())) {
|
|
|
|
|
|
|
+ if (bo.getShortName() != null && StringUtils.isNotBlank(bo.getShortName())){
|
|
|
supplierInfoTemporary.setShortName(bo.getShortName());
|
|
supplierInfoTemporary.setShortName(bo.getShortName());
|
|
|
flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
}
|
|
}
|
|
|
//2.供货品牌
|
|
//2.供货品牌
|
|
|
- if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())) {
|
|
|
|
|
|
|
+ if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())){
|
|
|
supplierInfoTemporary.setOperatingBrand(bo.getOperatingBrand());
|
|
supplierInfoTemporary.setOperatingBrand(bo.getOperatingBrand());
|
|
|
flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
}
|
|
}
|
|
|
//3.供货类目
|
|
//3.供货类目
|
|
|
- if (bo.getOperatingCategory() != null && StringUtils.isNotBlank(bo.getOperatingCategory())) {
|
|
|
|
|
|
|
+ if (bo.getOperatingCategory() != null && StringUtils.isNotBlank(bo.getOperatingCategory())){
|
|
|
supplierInfoTemporary.setOperatingCategory(bo.getOperatingCategory());
|
|
supplierInfoTemporary.setOperatingCategory(bo.getOperatingCategory());
|
|
|
flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
supplierInfo.setSupplyStatus(SupplierStatusEnum.REVIEW_UPDATED.getCode());
|
|
supplierInfo.setSupplyStatus(SupplierStatusEnum.REVIEW_UPDATED.getCode());
|
|
|
- boolean update = baseMapper.updateById(supplierInfo) > 0;
|
|
|
|
|
|
|
+ boolean update =baseMapper.updateById(supplierInfo) > 0;
|
|
|
return update && flag;
|
|
return update && flag;
|
|
|
}
|
|
}
|
|
|
//如果是待审核状态,依旧是待修改审核状态
|
|
//如果是待审核状态,依旧是待修改审核状态
|
|
|
- if (supplierInfo.getSupplyStatus() == SupplierStatusEnum.REVIEW_UPDATED.getCode()) {
|
|
|
|
|
|
|
+ if (supplierInfo.getSupplyStatus() == SupplierStatusEnum.REVIEW_UPDATED.getCode()){
|
|
|
SupplierInfoTemporary supplierInfoTemporary = supplierInfoTemporaryService.querBySupplierId(id);
|
|
SupplierInfoTemporary supplierInfoTemporary = supplierInfoTemporaryService.querBySupplierId(id);
|
|
|
//一共三个地方
|
|
//一共三个地方
|
|
|
- boolean flag = false;
|
|
|
|
|
|
|
+ boolean flag =false;
|
|
|
//1.简称
|
|
//1.简称
|
|
|
- if (bo.getShortName() != null && StringUtils.isNotBlank(bo.getShortName())) {
|
|
|
|
|
|
|
+ if (bo.getShortName() != null && StringUtils.isNotBlank(bo.getShortName())){
|
|
|
supplierInfoTemporary.setShortName(bo.getShortName());
|
|
supplierInfoTemporary.setShortName(bo.getShortName());
|
|
|
flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
}
|
|
}
|
|
|
//2.供货品牌
|
|
//2.供货品牌
|
|
|
- if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())) {
|
|
|
|
|
|
|
+ if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())){
|
|
|
supplierInfoTemporary.setOperatingBrand(bo.getOperatingBrand());
|
|
supplierInfoTemporary.setOperatingBrand(bo.getOperatingBrand());
|
|
|
flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
}
|
|
}
|
|
|
//3.供货类目
|
|
//3.供货类目
|
|
|
- if (bo.getOperatingCategory() != null && StringUtils.isNotBlank(bo.getOperatingCategory())) {
|
|
|
|
|
|
|
+ if (bo.getOperatingCategory() != null && StringUtils.isNotBlank(bo.getOperatingCategory())){
|
|
|
supplierInfoTemporary.setOperatingCategory(bo.getOperatingCategory());
|
|
supplierInfoTemporary.setOperatingCategory(bo.getOperatingCategory());
|
|
|
flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
}
|
|
}
|
|
|
return flag;
|
|
return flag;
|
|
|
}
|
|
}
|
|
|
// 停用呢 不能修改了
|
|
// 停用呢 不能修改了
|
|
|
- if (supplierInfo.getSupplyStatus() == SupplierStatusEnum.DISABLED.getCode()) {
|
|
|
|
|
|
|
+ if (supplierInfo.getSupplyStatus() == SupplierStatusEnum.DISABLED.getCode()){
|
|
|
throw new RuntimeException("供应商已停用,不能修改");
|
|
throw new RuntimeException("供应商已停用,不能修改");
|
|
|
}
|
|
}
|
|
|
return false;
|
|
return false;
|
|
|
|
|
+ }*/
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public boolean srmUpdateByBo(SupplierInfoBo bo) throws JsonProcessingException {
|
|
|
|
|
+
|
|
|
|
|
+ SupplierInfo supplier = baseMapper.selectById(bo.getId());
|
|
|
|
|
+ SupplierStatusEnum status = SupplierStatusEnum.getByCode(supplier.getSupplyStatus());
|
|
|
|
|
+
|
|
|
|
|
+ switch (status) {
|
|
|
|
|
+
|
|
|
|
|
+ // 待审核
|
|
|
|
|
+ case PENDING_REVIEW:
|
|
|
|
|
+ return updateSupplier(bo);
|
|
|
|
|
+
|
|
|
|
|
+ // 审核失败 -> 重新待审核
|
|
|
|
|
+ case REVIEW_FAILED:
|
|
|
|
|
+ SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
|
|
|
+ update.setSupplyStatus(SupplierStatusEnum.PENDING_REVIEW.getCode());
|
|
|
|
|
+ return baseMapper.updateById(update) > 0;
|
|
|
|
|
+
|
|
|
|
|
+ // 正式供应商 -> 进入修改审核
|
|
|
|
|
+ case OFFICIAL_SUPPLIER:
|
|
|
|
|
+ return handleOfficialSupplierUpdate(bo, supplier);
|
|
|
|
|
+
|
|
|
|
|
+ // 修改审核中
|
|
|
|
|
+ case REVIEW_UPDATED:
|
|
|
|
|
+ SupplierInfoTemporary temp = supplierInfoTemporaryService.querBySupplierId(bo.getId());
|
|
|
|
|
+ updateTemporaryFields(temp, bo);
|
|
|
|
|
+ return supplierInfoTemporaryService.updateById(temp);
|
|
|
|
|
+
|
|
|
|
|
+ // 停用
|
|
|
|
|
+ case DISABLED:
|
|
|
|
|
+ throw new ServiceException("供应商已停用,不能修改");
|
|
|
|
|
+
|
|
|
|
|
+ default:
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private boolean updateSupplier(SupplierInfoBo bo) {
|
|
|
|
|
+ SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
|
|
|
+ return baseMapper.updateById(update) > 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private boolean handleOfficialSupplierUpdate(SupplierInfoBo bo, SupplierInfo supplier) throws JsonProcessingException {
|
|
|
|
|
+
|
|
|
|
|
+ Long supplierId = supplier.getId();
|
|
|
|
|
+ SupplierInfoTemporary temp = supplierInfoTemporaryService.querBySupplierId(supplierId);
|
|
|
|
|
+
|
|
|
|
|
+ // 如果临时表不存在则创建
|
|
|
|
|
+ if (temp == null) {
|
|
|
|
|
+ temp = buildTemporarySupplier(supplier, bo);
|
|
|
|
|
+ supplierInfoTemporaryService.save(temp);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 更新字段
|
|
|
|
|
+ updateTemporaryFields(temp, bo);
|
|
|
|
|
+
|
|
|
|
|
+ boolean tempUpdate = supplierInfoTemporaryService.updateById(temp);
|
|
|
|
|
+
|
|
|
|
|
+ // 修改主表状态
|
|
|
|
|
+ supplier.setSupplyStatus(SupplierStatusEnum.REVIEW_UPDATED.getCode());
|
|
|
|
|
+ boolean mainUpdate = baseMapper.updateById(supplier) > 0;
|
|
|
|
|
+
|
|
|
|
|
+ return tempUpdate && mainUpdate;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private SupplierInfoTemporary buildTemporarySupplier(SupplierInfo supplier, SupplierInfoBo bo)
|
|
|
|
|
+ throws JsonProcessingException {
|
|
|
|
|
+
|
|
|
|
|
+ SupplierInfoTemporary temp = new SupplierInfoTemporary();
|
|
|
|
|
+
|
|
|
|
|
+ BeanUtils.copyProperties(supplier, temp, "id");
|
|
|
|
|
+
|
|
|
|
|
+ temp.setSupplierId(supplier.getId());
|
|
|
|
|
+ temp.setSupplyStatus(SupplierStatusEnum.REVIEW_UPDATED.getCode());
|
|
|
|
|
+
|
|
|
|
|
+ // 查询供应区域
|
|
|
|
|
+ SupplyAreaBo areaBo = new SupplyAreaBo();
|
|
|
|
|
+ areaBo.setSupplierId(bo.getId());
|
|
|
|
|
+
|
|
|
|
|
+ TableDataInfo<SupplyAreaVo> table =
|
|
|
|
|
+ supplyAreaService.queryPageList(areaBo, new PageQuery());
|
|
|
|
|
+
|
|
|
|
|
+ String areaListJson = objectMapper.writeValueAsString(table);
|
|
|
|
|
+ temp.setAreaListJson(areaListJson);
|
|
|
|
|
+
|
|
|
|
|
+ return temp;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void updateTemporaryFields(SupplierInfoTemporary temp, SupplierInfoBo bo) {
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isNotBlank(bo.getShortName()))
|
|
|
|
|
+ temp.setShortName(bo.getShortName());
|
|
|
|
|
+
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(bo.getBusinessName()))
|
|
|
|
|
+ temp.setBusinessName(bo.getBusinessName());
|
|
|
|
|
+
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(bo.getMembershipSize()))
|
|
|
|
|
+ temp.setMembershipSize(bo.getMembershipSize());
|
|
|
|
|
+
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(bo.getFixedPhone()))
|
|
|
|
|
+ temp.setFixedPhone(bo.getFixedPhone());
|
|
|
|
|
+
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(bo.getFax()))
|
|
|
|
|
+ temp.setFax(bo.getFax());
|
|
|
|
|
+
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(bo.getMailbox()))
|
|
|
|
|
+ temp.setMailbox(bo.getMailbox());
|
|
|
|
|
+
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(bo.getPostCode()))
|
|
|
|
|
+ temp.setPostCode(bo.getPostCode());
|
|
|
|
|
+
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(bo.getUrl()))
|
|
|
|
|
+ temp.setUrl(bo.getUrl());
|
|
|
|
|
+
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(bo.getOfficeProvince()))
|
|
|
|
|
+ temp.setOfficeProvince(bo.getOfficeProvince());
|
|
|
|
|
+
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(bo.getOfficeCity()))
|
|
|
|
|
+ temp.setOfficeCity(bo.getOfficeCity());
|
|
|
|
|
+
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(bo.getOfficeCounty()))
|
|
|
|
|
+ temp.setOfficeCounty(bo.getOfficeCounty());
|
|
|
|
|
+
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(bo.getOfficeAddress()))
|
|
|
|
|
+ temp.setOfficeAddress(bo.getOfficeAddress());
|
|
|
|
|
+
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(bo.getBusinessLicense()))
|
|
|
|
|
+ temp.setBusinessLicense(bo.getBusinessLicense());
|
|
|
|
|
+
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(bo.getPersonImage()))
|
|
|
|
|
+ temp.setPersonImage(bo.getPersonImage());
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isNotBlank(bo.getOperatingBrand()))
|
|
|
|
|
+ temp.setOperatingBrand(bo.getOperatingBrand());
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isNotBlank(bo.getOperatingCategory()))
|
|
|
|
|
+ temp.setOperatingCategory(bo.getOperatingCategory());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -473,6 +614,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 分页查询供应商信息列表
|
|
* 分页查询供应商信息列表
|
|
|
*
|
|
*
|
|
@@ -1415,6 +1557,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
private SupplierInfoVo handleProcurementInfo(SupplierInfoVo records) {
|
|
private SupplierInfoVo handleProcurementInfo(SupplierInfoVo records) {
|
|
|
|
|
|
|
|
// 查询管理人员和采购人员
|
|
// 查询管理人员和采购人员
|
|
@@ -1558,6 +1701,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Sup
|
|
|
}*/
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 处理采购员和产品经理信息和品牌和供应商类型
|
|
* 处理采购员和产品经理信息和品牌和供应商类型
|
|
|
*/
|
|
*/
|