|
@@ -8,9 +8,7 @@ import cn.cslg.pas.common.model.request.QueryRequest;
|
|
|
import cn.cslg.pas.common.utils.CacheUtils;
|
|
|
import cn.cslg.pas.common.utils.LoginUtils;
|
|
|
import cn.cslg.pas.common.vo.business.ProductCategoryVO;
|
|
|
-import cn.cslg.pas.domain.business.AssoProductCategoryFile;
|
|
|
-import cn.cslg.pas.domain.business.AssoProductCategoryPerson;
|
|
|
-import cn.cslg.pas.domain.business.ProductCategory;
|
|
|
+import cn.cslg.pas.domain.business.*;
|
|
|
import cn.cslg.pas.exception.UnLoginException;
|
|
|
import cn.cslg.pas.exception.XiaoShiException;
|
|
|
import cn.cslg.pas.factorys.businessFactory.Business;
|
|
@@ -66,6 +64,9 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
|
|
|
@Autowired
|
|
|
private PermissionService permissionService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ProductService productService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询产品类别
|
|
|
* @param queryRequest
|
|
@@ -119,28 +120,39 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
|
|
|
//产品类别入表
|
|
|
ProductCategory productCategory = new ProductCategory();
|
|
|
BeanUtils.copyProperties(productCategoryDTO, productCategory);
|
|
|
- productCategory.setCreateId(personnelVO.getGuid());
|
|
|
+ productCategory.setCreateId(personnelVO.getId());
|
|
|
productCategory.setTenant(personnelVO.getTenantId());
|
|
|
productCategory.insert();
|
|
|
- //将创建人默认设置为管理员插入到产品类别与可见人员类型表中
|
|
|
+ //插入产品类别与可见人员类型表
|
|
|
+ List<AssoProductCategoryPerson> assoProductCategoryPeople = new ArrayList<>();
|
|
|
+ //默认管理员
|
|
|
AssoProductCategoryPerson assoProductCategoryAdmin = new AssoProductCategoryPerson();
|
|
|
assoProductCategoryAdmin.setProductCategoryId(productCategory.getId());
|
|
|
- assoProductCategoryAdmin.setPersonId(personnelVO.getGuid());
|
|
|
+ assoProductCategoryAdmin.setPersonId(personnelVO.getId());
|
|
|
assoProductCategoryAdmin.setRole(0);
|
|
|
- assoProductCategoryAdmin.setCreateId(personnelVO.getGuid());
|
|
|
- assoProductCategoryAdmin.insert();
|
|
|
+ assoProductCategoryAdmin.setCreateId(personnelVO.getId());
|
|
|
+ assoProductCategoryPeople.add(assoProductCategoryAdmin);
|
|
|
+ //设置的管理员
|
|
|
+ List<String> adminIds = productCategoryDTO.getAdminIds();
|
|
|
+ for (String adminId : adminIds) {
|
|
|
+ AssoProductCategoryPerson admin = new AssoProductCategoryPerson();
|
|
|
+ admin.setProductCategoryId(productCategory.getId());
|
|
|
+ admin.setPersonId(adminId);
|
|
|
+ admin.setRole(0);
|
|
|
+ admin.setCreateId(personnelVO.getId());
|
|
|
+ assoProductCategoryPeople.add(admin);
|
|
|
+ }
|
|
|
//判断可见类型:
|
|
|
Integer showType = productCategoryDTO.getShowType();
|
|
|
if(showType != 0 && showType != 1){
|
|
|
List<String> showPersonIds = productCategoryDTO.getShowPersonIds();
|
|
|
//0所有人可见,1本人可见
|
|
|
if(showPersonIds != null && showPersonIds.size() != 0){
|
|
|
- List<AssoProductCategoryPerson> assoProductCategoryPeople = new ArrayList<>();
|
|
|
for (String showPersonId : showPersonIds) {
|
|
|
AssoProductCategoryPerson assoProductCategoryPerson = new AssoProductCategoryPerson();
|
|
|
assoProductCategoryPerson.setProductCategoryId(productCategory.getId());
|
|
|
assoProductCategoryPerson.setPersonId(showPersonId);
|
|
|
- assoProductCategoryPerson.setCreateId(personnelVO.getGuid());
|
|
|
+ assoProductCategoryPerson.setCreateId(personnelVO.getId());
|
|
|
//2仅选定人可见
|
|
|
if (showType == 2) {
|
|
|
assoProductCategoryPerson.setRole(1);
|
|
@@ -166,7 +178,7 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
|
|
|
AssoProductCategoryFile assoProductCategoryFile = new AssoProductCategoryFile();
|
|
|
assoProductCategoryFile.setProductCategoryId(productCategory.getId());
|
|
|
assoProductCategoryFile.setFileGuid(item);
|
|
|
- assoProductCategoryFile.setCreateId(personnelVO.getGuid());
|
|
|
+ assoProductCategoryFile.setCreateId(personnelVO.getId());
|
|
|
assoProductCategoryFiles.add(assoProductCategoryFile);
|
|
|
}
|
|
|
if (assoProductCategoryFiles != null && assoProductCategoryFiles.size() != 0) {
|
|
@@ -188,12 +200,18 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Object deleteMessage(List<Integer> ids) throws IOException {
|
|
|
+ //TODO 若产品类别下有产品,或者产品类别的架构有关联的专利,或专题库,则系统提示
|
|
|
+ LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.in(Product::getCategoryId, ids);
|
|
|
+ List<Product> products = productService.list(queryWrapper);
|
|
|
+ if (products != null && products.size() != 0) {
|
|
|
+ throw new XiaoShiException("该产品分类下有产品");
|
|
|
+ }
|
|
|
//根据产品类别id删除产品类别和文件关联表
|
|
|
- LambdaQueryWrapper<AssoProductCategoryFile> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.in(AssoProductCategoryFile::getProductCategoryId, ids);
|
|
|
- List<AssoProductCategoryFile> assoProductCategoryFiles = assoProductCategoryFileService.list(queryWrapper);
|
|
|
+ LambdaQueryWrapper<AssoProductCategoryFile> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.in(AssoProductCategoryFile::getProductCategoryId, ids);
|
|
|
+ List<AssoProductCategoryFile> assoProductCategoryFiles = assoProductCategoryFileService.list(wrapper);
|
|
|
List<String> guids = assoProductCategoryFiles.stream().map(AssoProductCategoryFile::getFileGuid).collect(Collectors.toList());
|
|
|
- //TODO 根据guids删除文件
|
|
|
if (guids.size() != 0) {
|
|
|
fileManagerService.deleteFileFromFMS(guids);
|
|
|
}
|
|
@@ -217,6 +235,13 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
|
|
|
if(updateProductCategoryDTO == null || updateProductCategoryDTO.getId() == null){
|
|
|
throw new XiaoShiException("参数错误");
|
|
|
}
|
|
|
+ //获取登陆人信息 用于设置创建人
|
|
|
+ PersonnelVO personnelVO = new PersonnelVO();
|
|
|
+ try {
|
|
|
+ personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new UnLoginException("未登录");
|
|
|
+ }
|
|
|
ProductCategory productCategory = this.getById(updateProductCategoryDTO.getId());
|
|
|
//检测名称是否不规范
|
|
|
updateProductCategoryDTO.setName(updateProductCategoryDTO.getName().trim());
|
|
@@ -225,11 +250,65 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
|
|
|
LambdaQueryWrapper<ProductCategory> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.eq(ProductCategory::getName, name);
|
|
|
List<ProductCategory> productCategories = this.list(queryWrapper);
|
|
|
- if(updateProductCategoryDTO.getName() != productCategory.getName() && productCategories.size() != 0){
|
|
|
+ if(!updateProductCategoryDTO.getName().equals(productCategory.getName()) && productCategories.size() != 0){
|
|
|
throw new XiaoShiException("名称重复");
|
|
|
}
|
|
|
BeanUtils.copyProperties(updateProductCategoryDTO, productCategory);
|
|
|
productCategory.updateById();
|
|
|
+ /**
|
|
|
+ * 与产品类别有关的可见人员的处理
|
|
|
+ */
|
|
|
+ LambdaQueryWrapper<AssoProductCategoryPerson> personWrapper = new LambdaQueryWrapper<>();
|
|
|
+ personWrapper.eq(AssoProductCategoryPerson::getProductCategoryId, productCategory.getId());
|
|
|
+ assoProductCategoryPersonService.remove(personWrapper);
|
|
|
+ //插入产品类别与可见人员类型表
|
|
|
+ List<AssoProductCategoryPerson> assoProductCategoryPeople = new ArrayList<>();
|
|
|
+ //默认管理员
|
|
|
+ AssoProductCategoryPerson assoProductCategoryAdmin = new AssoProductCategoryPerson();
|
|
|
+ assoProductCategoryAdmin.setProductCategoryId(productCategory.getId());
|
|
|
+ assoProductCategoryAdmin.setPersonId(personnelVO.getId());
|
|
|
+ assoProductCategoryAdmin.setRole(0);
|
|
|
+ assoProductCategoryAdmin.setCreateId(personnelVO.getId());
|
|
|
+ assoProductCategoryPeople.add(assoProductCategoryAdmin);
|
|
|
+ //设置的管理员
|
|
|
+ List<String> adminIds = updateProductCategoryDTO.getAdminIds();
|
|
|
+ for (String adminId : adminIds) {
|
|
|
+ AssoProductCategoryPerson admin = new AssoProductCategoryPerson();
|
|
|
+ admin.setProductCategoryId(productCategory.getId());
|
|
|
+ admin.setPersonId(adminId);
|
|
|
+ admin.setRole(0);
|
|
|
+ admin.setCreateId(personnelVO.getId());
|
|
|
+ assoProductCategoryPeople.add(admin);
|
|
|
+ }
|
|
|
+ //判断可见类型:
|
|
|
+ Integer showType = updateProductCategoryDTO.getShowType();
|
|
|
+ if(showType != 0 && showType != 1){
|
|
|
+ List<String> showPersonIds = updateProductCategoryDTO.getShowPersonIds();
|
|
|
+ //0所有人可见,1本人可见
|
|
|
+ if(showPersonIds != null && showPersonIds.size() != 0){
|
|
|
+ for (String showPersonId : showPersonIds) {
|
|
|
+ AssoProductCategoryPerson assoProductCategoryPerson = new AssoProductCategoryPerson();
|
|
|
+ assoProductCategoryPerson.setProductCategoryId(productCategory.getId());
|
|
|
+ assoProductCategoryPerson.setPersonId(showPersonId);
|
|
|
+ assoProductCategoryPerson.setCreateId(personnelVO.getId());
|
|
|
+ //2仅选定人可见
|
|
|
+ if (showType == 2) {
|
|
|
+ assoProductCategoryPerson.setRole(1);
|
|
|
+ } else if (showType == 3) {//3选定人不可见
|
|
|
+ assoProductCategoryPerson.setRole(2);
|
|
|
+ } else {
|
|
|
+ throw new XiaoShiException("可见类型错误");
|
|
|
+ }
|
|
|
+ assoProductCategoryPeople.add(assoProductCategoryPerson);
|
|
|
+ }
|
|
|
+ if(assoProductCategoryPeople != null && assoProductCategoryPeople.size() != 0){
|
|
|
+ assoProductCategoryPersonService.saveBatch(assoProductCategoryPeople);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 与产品类别有关的文件的处理
|
|
|
+ */
|
|
|
//根据产品类别id查询对应的附件id
|
|
|
LambdaQueryWrapper<AssoProductCategoryFile> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(AssoProductCategoryFile::getProductCategoryId, updateProductCategoryDTO.getId());
|
|
@@ -254,13 +333,6 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- //获取登陆人信息 用于设置创建人
|
|
|
- PersonnelVO personnelVO = new PersonnelVO();
|
|
|
- try {
|
|
|
- personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
- } catch (Exception e) {
|
|
|
- throw new UnLoginException("未登录");
|
|
|
- }
|
|
|
//添加文件
|
|
|
if (files != null && files.size() != 0) {
|
|
|
try {
|
|
@@ -270,7 +342,7 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
|
|
|
AssoProductCategoryFile assoProductCategoryFile = new AssoProductCategoryFile();
|
|
|
assoProductCategoryFile.setProductCategoryId(productCategory.getId());
|
|
|
assoProductCategoryFile.setFileGuid(item);
|
|
|
- assoProductCategoryFile.setCreateId(personnelVO.getGuid());
|
|
|
+ assoProductCategoryFile.setCreateId(personnelVO.getId());
|
|
|
assoProductCategoryFiles.add(assoProductCategoryFile);
|
|
|
}
|
|
|
if (assoProductCategoryFiles != null && assoProductCategoryFiles.size() != 0) {
|
|
@@ -316,7 +388,6 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
-
|
|
|
List<Personnel> personnels = new ArrayList<>();
|
|
|
List<String> guids = new ArrayList<>();
|
|
|
List<SystemFile> systemFiles = new ArrayList<>();
|
|
@@ -340,8 +411,7 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
|
|
|
//查询文件
|
|
|
if (guids.size() != 0) {
|
|
|
String res = fileManagerService.getSystemFileFromFMS(guids);
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
- systemFiles = JSONObject.parseArray(jsonObject.getString("data"), SystemFile.class);
|
|
|
+ systemFiles = JSONObject.parseArray(res, SystemFile.class);
|
|
|
}
|
|
|
|
|
|
//装载信息
|
|
@@ -364,7 +434,7 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
|
|
|
}
|
|
|
//根据showType到产品类别与可见人员关联表中查询可见人员
|
|
|
Integer showType = productCategoryVO.getShowType();
|
|
|
- if(showType == 2 && showType == 3){
|
|
|
+ if(showType.equals(2) || showType.equals(3)){
|
|
|
LambdaQueryWrapper<AssoProductCategoryPerson> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.eq(AssoProductCategoryPerson::getProductCategoryId, productCategoryVO.getId());
|
|
|
queryWrapper.eq(AssoProductCategoryPerson::getRole,showType);
|
|
@@ -372,6 +442,12 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
|
|
|
List<String> showPersonIds = assoProductCategoryPeople.stream().map(AssoProductCategoryPerson::getPersonId).collect(Collectors.toList());
|
|
|
productCategoryVO.setShowPersonIds(showPersonIds);
|
|
|
}
|
|
|
+ LambdaQueryWrapper<AssoProductCategoryPerson> adminWrapper = new LambdaQueryWrapper<>();
|
|
|
+ adminWrapper.eq(AssoProductCategoryPerson::getProductCategoryId, productCategoryVO.getId());
|
|
|
+ adminWrapper.eq(AssoProductCategoryPerson::getRole,0);
|
|
|
+ List<AssoProductCategoryPerson> assoProductCategoryPeople = assoProductCategoryPersonService.list(adminWrapper);
|
|
|
+ List<String> adminIds = assoProductCategoryPeople.stream().map(AssoProductCategoryPerson::getPersonId).collect(Collectors.toList());
|
|
|
+ productCategoryVO.setAdminIds(adminIds);
|
|
|
}
|
|
|
}
|
|
|
}
|