|
@@ -174,55 +174,27 @@ 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());
|
|
|
- //客户名称过滤
|
|
|
- wrapper.like("c.name", dto.getCustomerName());
|
|
|
-
|
|
|
- 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;
|
|
|
+ return getPageByEhsd(dto, wrapper);
|
|
|
}
|
|
|
|
|
|
@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);//公司产品
|
|
|
+ return getPageByEhsd(dto, wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 尔泓产品库分页公共代码
|
|
|
+ */
|
|
|
+ public Page<ProductInfoVo> getPageByEhsd(ProductInfoSelectDto dto, IWrapper<ProductInfo> wrapper) {
|
|
|
//根据产品名称/产品编号过滤
|
|
|
- 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());
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getKeyword())) {
|
|
|
+ wrapper.and(q -> q.like("pi", ProductInfo::getName, dto.getKeyword()))
|
|
|
+ .or().like("json_unquote(pi.ehsd_json -> '$.nameEnglish')", dto.getKeyword())
|
|
|
+ .or().like("pi", ProductInfo::getCode, dto.getKeyword())//产品编号
|
|
|
+ .or().like("c.name", dto.getKeyword());//客户名称
|
|
|
}
|
|
|
//根据产品分类id过滤
|
|
|
wrapper.eq("pi", ProductInfo::getProductClassifyId, dto.getProductClassifyId());
|
|
@@ -272,8 +244,6 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
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);
|
|
@@ -286,26 +256,28 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
// 排除名称重复
|
|
|
this.nameDuplication(ProductInfo::getName, productInfoDto.getName(), "产品名称重复");
|
|
|
this.save(productInfoDto);
|
|
|
- //图片列表
|
|
|
- ObsFileUtil.saveFile(productInfoDto.getImgList(), productInfoDto.getId(), 1);
|
|
|
- //附件列表
|
|
|
- ObsFileUtil.saveFile(productInfoDto.getMinorImgList(), productInfoDto.getId(), 2);
|
|
|
//附件列表
|
|
|
- ObsFileUtil.saveFile(productInfoDto.getFileList(), productInfoDto.getId(), 3);
|
|
|
+ ObsFileUtil.saveFile(productInfoDto.getFileList(), productInfoDto.getId());
|
|
|
}
|
|
|
|
|
|
@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.getMinorImgList(), productInfoDto.getId(), 2);
|
|
|
- ObsFileUtil.editFile(productInfoDto.getFileList(), productInfoDto.getId(), 3);
|
|
|
-
|
|
|
+ ProductInfoEhsdJson newProductInfoEhsdJson = JSONObject.parseObject(productInfoDto.getEhsdJson(), ProductInfoEhsdJson.class);
|
|
|
+ //只允许修改以下字段 销售指导价、成本价、净重、图片、备注
|
|
|
+ ProductInfo productInfo = getById(productInfoDto.getId());
|
|
|
+ if (ObjectUtil.isEmpty(productInfo)) {
|
|
|
+ throw new ServiceException("无法查询到改产品的产品信息,产品id" + productInfoDto.getId());
|
|
|
+ }
|
|
|
+ ProductInfoEhsdJson productInfoEhsdJson = JSONObject.parseObject(productInfo.getEhsdJson(), ProductInfoEhsdJson.class);
|
|
|
+ productInfoEhsdJson.setPrice(newProductInfoEhsdJson.getPrice());//销售指导价
|
|
|
+ productInfoEhsdJson.setCostPrice(newProductInfoEhsdJson.getCostPrice());//成本价
|
|
|
+ productInfoEhsdJson.setNetWeight(newProductInfoEhsdJson.getNetWeight());//净重
|
|
|
+ productInfo.setRemark(productInfoDto.getRemark());//备注
|
|
|
+ productInfo.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson));
|
|
|
+ this.updateById(productInfo);
|
|
|
+ //修改图片
|
|
|
+ ObsFileUtil.editFile(productInfoDto.getFileList(), productInfoDto.getId());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -318,7 +290,7 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
if (ObjectUtil.isNotEmpty(productInfoEhsdJson) && ObjectUtil.isNotEmpty(productInfoEhsdJson.getCustomerId())) {
|
|
|
//赋值客户名称
|
|
|
Customer customer = customerService.getById(productInfoEhsdJson.getCustomerId());
|
|
|
- if(ObjectUtil.isNotEmpty(customer)) {
|
|
|
+ if (ObjectUtil.isNotEmpty(customer)) {
|
|
|
productInfoEhsdJson.setCustomerName(customer.getName());
|
|
|
result.setEhsdJson(JSONObject.toJSONString(productInfoEhsdJson));
|
|
|
}
|