|
@@ -46,37 +46,30 @@ public class WorkCollectAccessoryService {
|
|
|
*/
|
|
|
public IPage<WorkCollectAccessory> findPageList(WorkCollectAccessory workCollectAccessory, Page<WorkCollectAccessory> page) throws Exception {
|
|
|
QueryWrapper<WorkCollectAccessory> workCollectAccessoryMapperQueryWrapper = QueryWrapperGenerator.buildQueryCondition(workCollectAccessory, WorkCollectAccessory.class);
|
|
|
-
|
|
|
// 确保 del_flag = 0 条件正确应用
|
|
|
workCollectAccessoryMapperQueryWrapper.eq("a.del_flag", 0);
|
|
|
-
|
|
|
// 附件名称
|
|
|
if (StringUtils.isNotBlank(workCollectAccessory.getFileName())) {
|
|
|
workCollectAccessoryMapperQueryWrapper.like("a.file_name", workCollectAccessory.getFileName());
|
|
|
}
|
|
|
-
|
|
|
// 上传人
|
|
|
if (StringUtils.isNotBlank(workCollectAccessory.getUserName())) {
|
|
|
workCollectAccessoryMapperQueryWrapper
|
|
|
.like("b.name", workCollectAccessory.getUserName()); // 使用 b.name 作为条件
|
|
|
}
|
|
|
-
|
|
|
// 收藏分类
|
|
|
if (StringUtils.isNotBlank(workCollectAccessory.getClassification())) {
|
|
|
workCollectAccessoryMapperQueryWrapper
|
|
|
.eq("a.classification", workCollectAccessory.getClassification()); // 使用 b.name 作为条件
|
|
|
}
|
|
|
-
|
|
|
// 公司
|
|
|
if (StringUtils.isNotBlank(workCollectAccessory.getCompanyId())) {
|
|
|
workCollectAccessoryMapperQueryWrapper.eq("a.company_id", workCollectAccessory.getCompanyId());
|
|
|
}
|
|
|
-
|
|
|
// 部门
|
|
|
if (StringUtils.isNotBlank(workCollectAccessory.getOfficeId())) {
|
|
|
workCollectAccessoryMapperQueryWrapper.eq("a.office_id", workCollectAccessory.getOfficeId());
|
|
|
}
|
|
|
-
|
|
|
if (StringUtils.isNotBlank(workCollectAccessory.getCreateById())) {
|
|
|
// 明确查询条件的优先级
|
|
|
workCollectAccessoryMapperQueryWrapper
|
|
@@ -108,33 +101,33 @@ public class WorkCollectAccessoryService {
|
|
|
workCollectAccessory.setCollectType("1");
|
|
|
workCollectAccessory.setCollectUserId(userId);
|
|
|
workCollectAccessory.setCreateTime(new Date());
|
|
|
- String classification = workCollectAccessory.getClassification();
|
|
|
- if(StringUtils.isNotEmpty(classification)){
|
|
|
- List<DictValue> dictList = getDictValueByName("classification");
|
|
|
- boolean containsValue = false;
|
|
|
- for (DictValue dictValue : dictList) {
|
|
|
- if (dictValue.getValue().equals(workCollectAccessory.getClassification())) {
|
|
|
- containsValue = true;
|
|
|
- break; // 一旦找到匹配值,退出循环
|
|
|
- }
|
|
|
- }
|
|
|
- if(!containsValue){
|
|
|
- DictType dictType = getDictByName("classification");
|
|
|
- DictValueDTO dictValue = new DictValueDTO();
|
|
|
- dictValue.setDictTypeId(dictType.getId());
|
|
|
- dictValue.setValue(classification);
|
|
|
- dictValue.setLabel(classification);
|
|
|
- dictValue.setSort(generateRandomString());
|
|
|
- dictValue.setId(generateId());
|
|
|
- dictValue.setCreateById(userId);
|
|
|
- dictValue.setCreateTime(new Date());
|
|
|
- dictValue.setUpdateById(userId);
|
|
|
- dictValue.setUpdateTime(new Date());
|
|
|
- dictValue.setDelFlag(0);
|
|
|
- dictValue.setTenantId("10000");
|
|
|
- workCollectAccessoryMapper.insertDictValue(dictValue);
|
|
|
- }
|
|
|
- }
|
|
|
+// String classification = workCollectAccessory.getClassification();
|
|
|
+// if(StringUtils.isNotEmpty(classification)){
|
|
|
+// List<DictValue> dictList = getDictValueByName("classification");
|
|
|
+// boolean containsValue = false;
|
|
|
+// for (DictValue dictValue : dictList) {
|
|
|
+// if (dictValue.getValue().equals(workCollectAccessory.getClassification())) {
|
|
|
+// containsValue = true;
|
|
|
+// break; // 一旦找到匹配值,退出循环
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if(!containsValue){
|
|
|
+// DictType dictType = getDictByName("classification");
|
|
|
+// DictValueDTO dictValue = new DictValueDTO();
|
|
|
+// dictValue.setDictTypeId(dictType.getId());
|
|
|
+// dictValue.setValue(classification);
|
|
|
+// dictValue.setLabel(classification);
|
|
|
+// dictValue.setSort(generateRandomString());
|
|
|
+// dictValue.setId(generateId());
|
|
|
+// dictValue.setCreateById(userId);
|
|
|
+// dictValue.setCreateTime(new Date());
|
|
|
+// dictValue.setUpdateById(userId);
|
|
|
+// dictValue.setUpdateTime(new Date());
|
|
|
+// dictValue.setDelFlag(0);
|
|
|
+// dictValue.setTenantId("10000");
|
|
|
+// workCollectAccessoryMapper.insertDictValue(dictValue);
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
workCollectAccessoryMapper.insert(workCollectAccessory);
|
|
|
}
|
|
@@ -149,7 +142,6 @@ public class WorkCollectAccessoryService {
|
|
|
// 判断并设置共享状态
|
|
|
if(StringUtils.isNotEmpty(companyId)){
|
|
|
if("1".equals(shareType)){
|
|
|
-
|
|
|
newAttachment.setOfficeId(companyId);
|
|
|
newAttachment.setOfficeShare("1");
|
|
|
}else{
|
|
@@ -195,34 +187,35 @@ public class WorkCollectAccessoryService {
|
|
|
WorkAttachmentInfo firstAttachment = workAttachments.get(0);
|
|
|
workCollectAccessory.setId(id);
|
|
|
workCollectAccessory.setFileDescription(workCollectAccessoryDTO.getFileDescription());
|
|
|
- String classification = workCollectAccessoryDTO.getClassification();
|
|
|
- if(StringUtils.isNotEmpty(classification)){
|
|
|
- workCollectAccessory.setClassification(classification);
|
|
|
- List<DictValue> dictList = getDictValueByName("classification");
|
|
|
- boolean containsValue = false;
|
|
|
- for (DictValue dictValue : dictList) {
|
|
|
- if (dictValue.getValue().equals(workCollectAccessory.getClassification()) && userDTO.getId().equals(dictValue.getCreateById()) ) {
|
|
|
- containsValue = true;
|
|
|
- break; // 一旦找到匹配值,退出循环
|
|
|
- }
|
|
|
- }
|
|
|
- if(!containsValue){
|
|
|
- DictType dictType = getDictByName("classification");
|
|
|
- DictValueDTO dictValue = new DictValueDTO();
|
|
|
- dictValue.setDictTypeId(dictType.getId());
|
|
|
- dictValue.setValue(classification);
|
|
|
- dictValue.setLabel(classification);
|
|
|
- dictValue.setSort(generateRandomString());
|
|
|
- dictValue.setId(generateId());
|
|
|
- dictValue.setCreateById(userDTO.getId());
|
|
|
- dictValue.setCreateTime(new Date());
|
|
|
- dictValue.setUpdateById(userDTO.getId());
|
|
|
- dictValue.setUpdateTime(new Date());
|
|
|
- dictValue.setDelFlag(0);
|
|
|
- dictValue.setTenantId("10000");
|
|
|
- workCollectAccessoryMapper.insertDictValue(dictValue);
|
|
|
- }
|
|
|
- }
|
|
|
+// String classification = workCollectAccessoryDTO.getClassification();
|
|
|
+// if(StringUtils.isNotEmpty(classification)){
|
|
|
+// workCollectAccessory.setClassification(classification);
|
|
|
+// List<DictValue> dictList = getDictValueByName("classification");
|
|
|
+// boolean containsValue = false;
|
|
|
+// for (DictValue dictValue : dictList) {
|
|
|
+// if (dictValue.getValue().equals(workCollectAccessory.getClassification()) && userDTO.getId().equals(dictValue.getCreateById()) ) {
|
|
|
+// containsValue = true;
|
|
|
+// break; // 一旦找到匹配值,退出循环
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if(!containsValue){
|
|
|
+// DictType dictType = getDictByName("classification");
|
|
|
+// DictValueDTO dictValue = new DictValueDTO();
|
|
|
+// dictValue.setDictTypeId(dictType.getId());
|
|
|
+// dictValue.setValue(classification);
|
|
|
+// dictValue.setLabel(classification);
|
|
|
+// dictValue.setSort(generateRandomString());
|
|
|
+// dictValue.setId(generateId());
|
|
|
+// dictValue.setCreateById(userDTO.getId());
|
|
|
+// dictValue.setCreateTime(new Date());
|
|
|
+// dictValue.setUpdateById(userDTO.getId());
|
|
|
+// dictValue.setUpdateTime(new Date());
|
|
|
+// dictValue.setDelFlag(0);
|
|
|
+// dictValue.setTenantId("10000");
|
|
|
+// workCollectAccessoryMapper.insertDictValue(dictValue);
|
|
|
+// }
|
|
|
+// }
|
|
|
+ workCollectAccessory.setClassification(workCollectAccessoryDTO.getClassification());
|
|
|
workCollectAccessory.setUrl(firstAttachment.getUrl());
|
|
|
workCollectAccessory.setFileName(firstAttachment.getName());
|
|
|
workCollectAccessory.setType("1");
|
|
@@ -235,7 +228,7 @@ public class WorkCollectAccessoryService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 上传附件
|
|
|
+ * 根据id修改
|
|
|
* @return
|
|
|
*/
|
|
|
public void updateById(WorkCollectAccessory workCollectAccessory) {
|
|
@@ -249,33 +242,33 @@ public class WorkCollectAccessoryService {
|
|
|
saveFiles(workAttachments, userDTO, id);
|
|
|
}
|
|
|
WorkAttachmentInfo firstAttachment = workAttachments.get(0);
|
|
|
- String classification = workCollectAccessory.getClassification();
|
|
|
- if(StringUtils.isNotEmpty(classification)){
|
|
|
- List<DictValue> dictList = getDictValueByName("classification");
|
|
|
- boolean containsValue = false;
|
|
|
- for (DictValue dictValue : dictList) {
|
|
|
- if (dictValue.getValue().equals(workCollectAccessory.getClassification()) && userDTO.getId().equals(dictValue.getCreateById())) {
|
|
|
- containsValue = true;
|
|
|
- break; // 一旦找到匹配值,退出循环
|
|
|
- }
|
|
|
- }
|
|
|
- if(!containsValue){
|
|
|
- DictType dictType = getDictByName("classification");
|
|
|
- DictValueDTO dictValue = new DictValueDTO();
|
|
|
- dictValue.setDictTypeId(dictType.getId());
|
|
|
- dictValue.setValue(classification);
|
|
|
- dictValue.setLabel(classification);
|
|
|
- dictValue.setSort(generateRandomString());
|
|
|
- dictValue.setId(generateId());
|
|
|
- dictValue.setCreateById(userDTO.getId());
|
|
|
- dictValue.setCreateTime(new Date());
|
|
|
- dictValue.setUpdateById(userDTO.getId());
|
|
|
- dictValue.setUpdateTime(new Date());
|
|
|
- dictValue.setDelFlag(0);
|
|
|
- dictValue.setTenantId("10000");
|
|
|
- workCollectAccessoryMapper.insertDictValue(dictValue);
|
|
|
- }
|
|
|
- }
|
|
|
+// String classification = workCollectAccessory.getClassification();
|
|
|
+// if(StringUtils.isNotEmpty(classification)){
|
|
|
+// List<DictValue> dictList = getDictValueByName("classification");
|
|
|
+// boolean containsValue = false;
|
|
|
+// for (DictValue dictValue : dictList) {
|
|
|
+// if (dictValue.getValue().equals(workCollectAccessory.getClassification()) && userDTO.getId().equals(dictValue.getCreateById())) {
|
|
|
+// containsValue = true;
|
|
|
+// break; // 一旦找到匹配值,退出循环
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if(!containsValue){
|
|
|
+// DictType dictType = getDictByName("classification");
|
|
|
+// DictValueDTO dictValue = new DictValueDTO();
|
|
|
+// dictValue.setDictTypeId(dictType.getId());
|
|
|
+// dictValue.setValue(classification);
|
|
|
+// dictValue.setLabel(classification);
|
|
|
+// dictValue.setSort(generateRandomString());
|
|
|
+// dictValue.setId(generateId());
|
|
|
+// dictValue.setCreateById(userDTO.getId());
|
|
|
+// dictValue.setCreateTime(new Date());
|
|
|
+// dictValue.setUpdateById(userDTO.getId());
|
|
|
+// dictValue.setUpdateTime(new Date());
|
|
|
+// dictValue.setDelFlag(0);
|
|
|
+// dictValue.setTenantId("10000");
|
|
|
+// workCollectAccessoryMapper.insertDictValue(dictValue);
|
|
|
+// }
|
|
|
+// }
|
|
|
workCollectAccessory.setUrl(firstAttachment.getUrl());
|
|
|
workCollectAccessory.setFileName(firstAttachment.getName());
|
|
|
workCollectAccessory.setFileSize(firstAttachment.getSize());
|
|
@@ -285,28 +278,6 @@ public class WorkCollectAccessoryService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 生成uuid
|
|
|
- * @return
|
|
|
- */
|
|
|
- public static String generateId() {
|
|
|
- UUID uuid = UUID.randomUUID();
|
|
|
- BigInteger id = new BigInteger(uuid.toString().replace("-", ""), 16);
|
|
|
- return id.toString();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 随机生成
|
|
|
- * @return
|
|
|
- */
|
|
|
- public static String generateRandomString() {
|
|
|
- Random random = new Random();
|
|
|
- // 随机生成一个 99 到 1000 之间的整数
|
|
|
- int randomNumber = 99 + random.nextInt(1000 - 99);
|
|
|
- // 返回整数转为字符串
|
|
|
- return String.valueOf(randomNumber);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 保存附件信息
|
|
|
* @param list 待保存的附件列表
|
|
|
* @param userDTO 当前登录用户
|
|
@@ -347,24 +318,72 @@ public class WorkCollectAccessoryService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 根据名称获取字典值
|
|
|
+ * 根据分类去重
|
|
|
+ */
|
|
|
+ public List<WorkCollectAccessory> getClassificationList(WorkCollectAccessory workCollectAccessory) throws Exception{
|
|
|
+ QueryWrapper<WorkCollectAccessory> workCollectAccessoryMapperQueryWrapper = QueryWrapperGenerator.buildQueryCondition(workCollectAccessory, WorkCollectAccessory.class);
|
|
|
+ // 确保 del_flag = 0 条件正确应用
|
|
|
+ workCollectAccessoryMapperQueryWrapper.eq("a.del_flag", 0);
|
|
|
+ // 公司
|
|
|
+ if (StringUtils.isNotBlank(workCollectAccessory.getCompanyId())) {
|
|
|
+ workCollectAccessoryMapperQueryWrapper.eq("a.company_id", workCollectAccessory.getCompanyId());
|
|
|
+ }
|
|
|
+ // 部门
|
|
|
+ if (StringUtils.isNotBlank(workCollectAccessory.getOfficeId())) {
|
|
|
+ workCollectAccessoryMapperQueryWrapper.eq("a.office_id", workCollectAccessory.getOfficeId());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(workCollectAccessory.getCreateById())) {
|
|
|
+ // 明确查询条件的优先级
|
|
|
+ workCollectAccessoryMapperQueryWrapper
|
|
|
+ .and(wrapper -> wrapper
|
|
|
+ .and(innerWrapper -> innerWrapper
|
|
|
+ .eq("a.create_by_id", workCollectAccessory.getCreateById())
|
|
|
+ .ne("a.collect_type", 1)) // 在 create_by_id 条件中添加 collect_type != 1
|
|
|
+ .or().eq("a.collect_user_id", workCollectAccessory.getCreateById())); // collect_user_id 条件单独处理
|
|
|
+ }
|
|
|
+ return workCollectAccessoryMapper.getClassificationList(workCollectAccessoryMapperQueryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据id查询当前附件信息
|
|
|
+ */
|
|
|
+ public WorkCollectAccessory queryById(String id) {
|
|
|
+ WorkCollectAccessory workCollectAccessory = workCollectAccessoryMapper.selectById(id);
|
|
|
+ return workCollectAccessory;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 根据字典名称获取字典值
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public DictType getDictByName(String dictName) {
|
|
|
- return workCollectAccessoryMapper.getDictByName(dictName);
|
|
|
+ return workCollectAccessoryMapper.getDictByName(dictName);
|
|
|
}
|
|
|
public List<DictValue> getDictValueByName(String dictName){
|
|
|
UserDTO userDTO = SpringUtil.getBean(IUserApi.class).getByToken(TokenProvider.getCurrentToken());
|
|
|
String userId = userDTO.getId();
|
|
|
return workCollectAccessoryMapper.getDictValueByName(dictName,userId);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- * 查询字典值
|
|
|
+ * 生成uuid
|
|
|
+ * @return
|
|
|
*/
|
|
|
- public WorkCollectAccessory queryById(String id) {
|
|
|
- WorkCollectAccessory workCollectAccessory = workCollectAccessoryMapper.selectById(id);
|
|
|
- return workCollectAccessory;
|
|
|
+ public static String generateId() {
|
|
|
+ UUID uuid = UUID.randomUUID();
|
|
|
+ BigInteger id = new BigInteger(uuid.toString().replace("-", ""), 16);
|
|
|
+ return id.toString();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 随机生成
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String generateRandomString() {
|
|
|
+ Random random = new Random();
|
|
|
+ // 随机生成一个 99 到 1000 之间的整数
|
|
|
+ int randomNumber = 99 + random.nextInt(1000 - 99);
|
|
|
+ // 返回整数转为字符串
|
|
|
+ return String.valueOf(randomNumber);
|
|
|
+ }
|
|
|
}
|