|
@@ -42,7 +42,6 @@ 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.apache.commons.collections4.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -196,39 +195,6 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public Page<ProductInfoVo> getCustomerProductList(ProductInfoSelectDto dto) {
|
|
|
- IWrapper<ProductInfo> wrapper = getWrapper();
|
|
|
- wrapper.eq("json_unquote(pi.ehsd_json -> '$.type')", 2);//客户产品
|
|
|
- return getPageByEhsd(dto, wrapper);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Page<ProductInfoVo> getConditionProductList(ProductInfoSelectDto dto) {
|
|
|
- IWrapper<ProductInfo> wrapper = getWrapper();
|
|
|
- return getPageByEhsd(dto, wrapper);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 尔泓产品库分页公共代码
|
|
|
- */
|
|
|
- public Page<ProductInfoVo> getPageByEhsd(ProductInfoSelectDto dto, IWrapper<ProductInfo> wrapper) {
|
|
|
- //根据产品名称/产品编号过滤
|
|
|
- if (ObjectUtil.isNotEmpty(dto.getKeyword())) {
|
|
|
- wrapper.and(q -> q.like("pi", ProductInfo::getName, dto.getKeyword())
|
|
|
- .or().like("pi", ProductInfo::getCode, dto.getKeyword())//产品编号
|
|
|
- );//客户名称
|
|
|
- }
|
|
|
-
|
|
|
- //根据产品分类id过滤
|
|
|
- wrapper.eq("pi", ProductInfo::getProductClassifyId, dto.getProductClassifyId());
|
|
|
- wrapper.orderByDesc("pi", ProductInfo::getCreateTime);
|
|
|
-
|
|
|
- Page<ProductInfoVo> page = baseMapper.getCustomerProductList(dto.getPage(), wrapper);
|
|
|
- //赋值创建人名称
|
|
|
- UserUtil.assignmentNickName(page.getRecords(), ProductInfo::getCreateUser, ProductInfoVo::setCreateUserName);
|
|
|
- return page;
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
public ProductInfoVo detail(Long id) {
|
|
@@ -287,6 +253,49 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
ObsFileUtil.saveFile(productInfoDto.getFileList(), productInfoDto.getId());
|
|
|
}
|
|
|
|
|
|
+ @DSTransactional
|
|
|
+ @Override
|
|
|
+ public void edit(ProductInfoDto productInfoDto) {
|
|
|
+ // 禁止产品编号修改
|
|
|
+ productInfoDto.setCode(null);
|
|
|
+ //检查【产品名称】和【规格型号】不能同时重复,但可以单项重复。
|
|
|
+ long nameAndSpecCount = this.count(q -> q
|
|
|
+ .ne(ProductInfo::getId, productInfoDto.getId())
|
|
|
+ .eq(ProductInfo::getName, productInfoDto.getName())
|
|
|
+ .eq(ProductInfo::getSpec, productInfoDto.getSpec())
|
|
|
+ );
|
|
|
+ if (nameAndSpecCount != 0) {
|
|
|
+ throw new ServiceException("同名称同规格的产品已存在");
|
|
|
+ }
|
|
|
+ // 排除不为空的自定义编码重复
|
|
|
+ long count = this.count(q -> q
|
|
|
+ .ne(ProductInfo::getId, productInfoDto.getId())
|
|
|
+ .eq(ProductInfo::getCustomCode, productInfoDto.getCustomCode())
|
|
|
+ .ne(ProductInfo::getCustomCode, ""));
|
|
|
+ if (count != 0) {
|
|
|
+ throw new ServiceException("产品自定义编码重复");
|
|
|
+ }
|
|
|
+
|
|
|
+ //操作ftp文件
|
|
|
+ editFtpFile(productInfoDto);
|
|
|
+
|
|
|
+ //赋值产品归属公司
|
|
|
+ Long companyId = productInfoDto.getCompanyId();
|
|
|
+ if (ObjectUtil.isEmpty(companyId)) {
|
|
|
+ productInfoDto.setCompanyId(SecurityUtils.getCompanyId());
|
|
|
+ }
|
|
|
+
|
|
|
+ this.updateById(productInfoDto);
|
|
|
+ ObsFileUtil.editFile(productInfoDto.getFileList(), productInfoDto.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @DSTransactional
|
|
|
+ @Override
|
|
|
+ public void delete(Long id) {
|
|
|
+ this.removeById(id);
|
|
|
+ ObsFileUtil.removeFile(id);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 操作ftp文件
|
|
|
*/
|
|
@@ -382,49 +391,6 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
productAvailableRecordService.saveBatch(availableRecordList);
|
|
|
}
|
|
|
|
|
|
- @DSTransactional
|
|
|
- @Override
|
|
|
- public void edit(ProductInfoDto productInfoDto) {
|
|
|
- // 禁止产品编号修改
|
|
|
- productInfoDto.setCode(null);
|
|
|
- //检查【产品名称】和【规格型号】不能同时重复,但可以单项重复。
|
|
|
- long nameAndSpecCount = this.count(q -> q
|
|
|
- .ne(ProductInfo::getId, productInfoDto.getId())
|
|
|
- .eq(ProductInfo::getName, productInfoDto.getName())
|
|
|
- .eq(ProductInfo::getSpec, productInfoDto.getSpec())
|
|
|
- );
|
|
|
- if (nameAndSpecCount != 0) {
|
|
|
- throw new ServiceException("同名称同规格的产品已存在");
|
|
|
- }
|
|
|
- // 排除不为空的自定义编码重复
|
|
|
- long count = this.count(q -> q
|
|
|
- .ne(ProductInfo::getId, productInfoDto.getId())
|
|
|
- .eq(ProductInfo::getCustomCode, productInfoDto.getCustomCode())
|
|
|
- .ne(ProductInfo::getCustomCode, ""));
|
|
|
- if (count != 0) {
|
|
|
- throw new ServiceException("产品自定义编码重复");
|
|
|
- }
|
|
|
-
|
|
|
- //操作ftp文件
|
|
|
- editFtpFile(productInfoDto);
|
|
|
-
|
|
|
- //赋值产品归属公司
|
|
|
- Long companyId = productInfoDto.getCompanyId();
|
|
|
- if (ObjectUtil.isEmpty(companyId)) {
|
|
|
- productInfoDto.setCompanyId(SecurityUtils.getCompanyId());
|
|
|
- }
|
|
|
-
|
|
|
- this.updateById(productInfoDto);
|
|
|
- ObsFileUtil.editFile(productInfoDto.getFileList(), productInfoDto.getId());
|
|
|
- }
|
|
|
-
|
|
|
- @DSTransactional
|
|
|
- @Override
|
|
|
- public void delete(Long id) {
|
|
|
- this.removeById(id);
|
|
|
- ObsFileUtil.removeFile(id);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 根据产品IDS获取产品
|
|
|
*
|