|
@@ -6,15 +6,17 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.common.constant.SourceConstant;
|
|
|
+import com.fjhx.customer.entity.customer.po.Customer;
|
|
|
+import com.fjhx.customer.service.customer.CustomerService;
|
|
|
import com.fjhx.file.utils.ObsFileUtil;
|
|
|
import com.fjhx.item.entity.product.dto.ProductInfoDto;
|
|
|
import com.fjhx.item.entity.product.dto.ProductInfoSelectDto;
|
|
|
+import com.fjhx.item.entity.product.po.ProductInfoEhsdJson;
|
|
|
import com.fjhx.item.entity.product.po.ProductClassify;
|
|
|
import com.fjhx.item.entity.product.po.ProductInfo;
|
|
|
import com.fjhx.item.entity.product.vo.ProductInfoVo;
|
|
@@ -33,14 +35,12 @@ import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import com.ruoyi.common.utils.wrapper.SqlField;
|
|
|
import com.ruoyi.system.service.ISysDeptService;
|
|
|
+import com.ruoyi.system.utils.UserUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -61,6 +61,8 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
private ProductClassifyService productClassifyService;
|
|
|
@Autowired
|
|
|
private ISysDeptService sysDeptService;
|
|
|
+ @Autowired
|
|
|
+ private CustomerService customerService;
|
|
|
|
|
|
@Autowired
|
|
|
private DictTenantDataService dictTenantDataService;
|
|
@@ -168,6 +170,82 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public Page<ProductInfoVo> getCustomerProductList(ProductInfoSelectDto dto) {
|
|
|
+ IWrapper<ProductInfo> wrapper = getWrapper();
|
|
|
+ wrapper.eq("json_unquote(pi.ehsd_json -> '$.status')", 0);//状态 启用
|
|
|
+ wrapper.eq("json_unquote(pi.ehsd_json -> '$.assessStatus')", 3);//评估状态 具备
|
|
|
+// wrapper.ne("json_unquote(pi.ehsd_json -> '$.customerId')", 0);//客户id不等于0
|
|
|
+ wrapper.eq("json_unquote(pi.ehsd_json -> '$.type')", 2);//客户产品
|
|
|
+ //根据产品名称/产品编号过滤
|
|
|
+ wrapper.like("pi", ProductInfo::getCode, dto.getCode());
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getName())) {
|
|
|
+ wrapper.and(q -> q.like("pi", ProductInfo::getName, dto.getName()))
|
|
|
+ .or().like("json_unquote(pi.ehsd_json -> '$.englishName')", dto.getName());
|
|
|
+ }
|
|
|
+ //根据产品分类id过滤
|
|
|
+ wrapper.eq("pi", ProductInfo::getProductClassifyId, dto.getProductClassifyId());
|
|
|
+
|
|
|
+ Page<ProductInfoVo> page = baseMapper.getCustomerProductList(dto.getPage(), wrapper);
|
|
|
+ List<ProductInfoVo> records = page.getRecords();
|
|
|
+ //赋值客户名称
|
|
|
+ List<Long> customerIds = new ArrayList<>();
|
|
|
+ for (ProductInfoVo record : records) {
|
|
|
+ ProductInfoEhsdJson productInfoEhsdJson = JSONObject.parseObject(record.getEhsdJson(), ProductInfoEhsdJson.class);
|
|
|
+ customerIds.add(productInfoEhsdJson.getCustomerId());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(customerIds)) {
|
|
|
+ Map<Long, String> customerMap = customerService.mapKV(Customer::getId, Customer::getName, q -> q.in(Customer::getId, customerIds));
|
|
|
+ for (ProductInfoVo record : records) {
|
|
|
+ ProductInfoEhsdJson productInfoEhsdJson = JSONObject.parseObject(record.getEhsdJson(), ProductInfoEhsdJson.class);
|
|
|
+ String customerName = customerMap.get(productInfoEhsdJson.getCustomerId());
|
|
|
+ productInfoEhsdJson.setCustomerName(customerName);
|
|
|
+ record.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //赋值创建人名称
|
|
|
+ UserUtil.assignmentNickName(page.getRecords(), ProductInfo::getCreateUser, ProductInfoVo::setCreateUserName);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<ProductInfoVo> getConditionProductList(ProductInfoSelectDto dto) {
|
|
|
+ IWrapper<ProductInfo> wrapper = getWrapper();
|
|
|
+ wrapper.eq("json_unquote(pi.ehsd_json -> '$.status')", 0);//状态 启用
|
|
|
+ wrapper.eq("json_unquote(pi.ehsd_json -> '$.assessStatus')", 3);//评估状态 具备
|
|
|
+// wrapper.eq("json_unquote(pi.ehsd_json -> '$.customerId')", 0);//客户id等于0
|
|
|
+ wrapper.eq("json_unquote(pi.ehsd_json -> '$.type')", 1);//公司产品
|
|
|
+ //根据产品名称/产品编号过滤
|
|
|
+ wrapper.like("pi", ProductInfo::getCode, dto.getCode());
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getName())) {
|
|
|
+ wrapper.and(q -> q.like("pi", ProductInfo::getName, dto.getName()))
|
|
|
+ .or().like("json_unquote(pi.ehsd_json -> '$.englishName')", dto.getName());
|
|
|
+ }
|
|
|
+ //根据产品分类id过滤
|
|
|
+ wrapper.eq("pi", ProductInfo::getProductClassifyId, dto.getProductClassifyId());
|
|
|
+
|
|
|
+ Page<ProductInfoVo> page = baseMapper.getCustomerProductList(dto.getPage(), wrapper);
|
|
|
+ List<ProductInfoVo> records = page.getRecords();
|
|
|
+ //赋值客户名称
|
|
|
+ List<Long> customerIds = new ArrayList<>();
|
|
|
+ for (ProductInfoVo record : records) {
|
|
|
+ ProductInfoEhsdJson productInfoEhsdJson = JSONObject.parseObject(record.getEhsdJson(), ProductInfoEhsdJson.class);
|
|
|
+ customerIds.add(productInfoEhsdJson.getCustomerId());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(customerIds)) {
|
|
|
+ Map<Long, String> customerMap = customerService.mapKV(Customer::getId, Customer::getName, q -> q.in(Customer::getId, customerIds));
|
|
|
+ for (ProductInfoVo record : records) {
|
|
|
+ ProductInfoEhsdJson productInfoEhsdJson = JSONObject.parseObject(record.getEhsdJson(), ProductInfoEhsdJson.class);
|
|
|
+ String customerName = customerMap.get(productInfoEhsdJson.getCustomerId());
|
|
|
+ productInfoEhsdJson.setCustomerName(customerName);
|
|
|
+ record.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //赋值创建人名称
|
|
|
+ UserUtil.assignmentNickName(page.getRecords(), ProductInfo::getCreateUser, ProductInfoVo::setCreateUserName);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public ProductInfoVo detail(Long id) {
|
|
|
ProductInfo ProductInfo = this.getById(id);
|
|
|
ProductInfoVo result = BeanUtil.toBean(ProductInfo, ProductInfoVo.class);
|
|
@@ -187,6 +265,57 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
|
|
|
@DSTransactional
|
|
|
@Override
|
|
|
+ public void addByEhsd(ProductInfoDto productInfoDto) {
|
|
|
+ //赋值初始状态
|
|
|
+ ProductInfoEhsdJson productInfoEhsdJson = JSONObject.parseObject(productInfoDto.getEhsdJson(), ProductInfoEhsdJson.class);
|
|
|
+ productInfoEhsdJson.setStatus(0);
|
|
|
+ productInfoEhsdJson.setAssessStatus(3);
|
|
|
+ if(ObjectUtil.isEmpty(productInfoEhsdJson.getCustomerId())){
|
|
|
+ //如果客户id为空就赋值为0 公司产品
|
|
|
+ productInfoEhsdJson.setCustomerId(0l);
|
|
|
+ }
|
|
|
+ productInfoDto.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson));
|
|
|
+
|
|
|
+ // 赋值产品编号
|
|
|
+ productInfoDto.setCode(CodeEnum.PRODUCT.getCode());
|
|
|
+ // 排除名称重复
|
|
|
+ this.nameDuplication(ProductInfo::getName, productInfoDto.getName(), "产品名称重复");
|
|
|
+ this.save(productInfoDto);
|
|
|
+ //图片列表
|
|
|
+ ObsFileUtil.saveFile(productInfoDto.getImgList(), productInfoDto.getId(),1);
|
|
|
+ //附件列表
|
|
|
+ ObsFileUtil.saveFile(productInfoDto.getFileList(), productInfoDto.getId(),2);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DSTransactional
|
|
|
+ @Override
|
|
|
+ public void editByEhsd(ProductInfoDto productInfoDto) {
|
|
|
+ // 禁止产品编号修改
|
|
|
+ productInfoDto.setCode(null);
|
|
|
+ // 排除名称重复
|
|
|
+ this.nameDuplication(ProductInfo::getName, productInfoDto.getName(), productInfoDto.getId(), "产品名称重复");
|
|
|
+ this.updateById(productInfoDto);
|
|
|
+ ObsFileUtil.editFile(productInfoDto.getImgList(), productInfoDto.getId(),1);
|
|
|
+ ObsFileUtil.editFile(productInfoDto.getFileList(), productInfoDto.getId(),2);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ProductInfoVo detailByEhsd(Long id) {
|
|
|
+ ProductInfo ProductInfo = this.getById(id);
|
|
|
+ ProductInfoVo result = BeanUtil.toBean(ProductInfo, ProductInfoVo.class);
|
|
|
+
|
|
|
+ ProductInfoEhsdJson productInfoEhsdJson = JSONObject.parseObject(result.getEhsdJson(), ProductInfoEhsdJson.class);
|
|
|
+ //赋值客户名称
|
|
|
+ Customer customer = customerService.getById(productInfoEhsdJson.getCustomerId());
|
|
|
+ productInfoEhsdJson.setCustomerName(customer.getName());
|
|
|
+ result.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson));
|
|
|
+ //赋值创建人名称
|
|
|
+ UserUtil.assignmentNickName(Arrays.asList(result), ProductInfoVo::getCreateUser, ProductInfoVo::setCreateUserName);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @DSTransactional
|
|
|
+ @Override
|
|
|
public void addByWdly(ProductInfoDto productInfoDto) {
|
|
|
//处理维多利亚扩展
|
|
|
String victoriatouristJson = productInfoDto.getVictoriatouristJson();
|