Browse Source

项目类别时限设置功能优化

feature/dangjian
yujintao 6 years ago
parent
commit
66f2e574ff
  1. 4
      esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/UserSysDeptInfoFormDTO.java
  2. 2
      esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/category/result/CategoryInfoResultDTO.java
  3. 124
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/service/impl/CategoryServiceImpl.java
  4. 4
      esua-epdc/epdc-module/epdc-kpi/epdc-kpi-client/src/main/java/com/elink/esua/epdc/dto/KpiTimeLimitItemDTO.java
  5. 14
      esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/dao/KpiTimeLimitItemDao.java
  6. 2
      esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/entity/KpiTimeLimitItemEntity.java
  7. 4
      esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/feign/EventFeignClient.java
  8. 118
      esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/impl/KpiTimeLimitItemServiceImpl.java
  9. 20
      esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/resources/mapper/KpiTimeLimitItemDao.xml

4
esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/UserSysDeptInfoFormDTO.java

@ -16,14 +16,10 @@ public class UserSysDeptInfoFormDTO implements Serializable {
/** /**
* 主键集合 * 主键集合
*/ */
// @NotEmpty(message = "deptIdList不能为空")
// @Valid
private List<Long> deptIdList; private List<Long> deptIdList;
/** /**
* 部门类型键值 * 部门类型键值
*/ */
// @NotEmpty(message = "部门类型不能为空")
// @Valid
private List<String> typeKeyList; private List<String> typeKeyList;
} }

2
esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/category/result/CategoryInfoResultDTO.java

@ -34,5 +34,5 @@ public class CategoryInfoResultDTO implements Serializable {
/** /**
* 所有上级分类名称用逗号分开 * 所有上级分类名称用逗号分开
*/ */
private List<String> parentNames; private String parentNames;
} }

124
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/service/impl/CategoryServiceImpl.java

@ -17,12 +17,14 @@
package com.elink.esua.epdc.modules.category.service.impl; package com.elink.esua.epdc.modules.category.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
import com.elink.esua.epdc.commons.tools.constant.Constant; import com.elink.esua.epdc.commons.tools.constant.Constant;
import com.elink.esua.epdc.commons.tools.constant.NumConstant; import com.elink.esua.epdc.commons.tools.constant.NumConstant;
import com.elink.esua.epdc.commons.tools.constant.StrConstant;
import com.elink.esua.epdc.commons.tools.exception.ErrorCode; import com.elink.esua.epdc.commons.tools.exception.ErrorCode;
import com.elink.esua.epdc.commons.tools.exception.RenException; import com.elink.esua.epdc.commons.tools.exception.RenException;
import com.elink.esua.epdc.commons.tools.redis.RedisKeys; import com.elink.esua.epdc.commons.tools.redis.RedisKeys;
@ -78,8 +80,7 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn
private int totalCells = 0;// 总条数 private int totalCells = 0;// 总条数
public static int Guid=100;//id自增值 public static int Guid = 100;//id自增值
private Logger logger = LoggerFactory.getLogger(getClass()); private Logger logger = LoggerFactory.getLogger(getClass());
@ -253,13 +254,13 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn
Result result = new Result(); Result result = new Result();
//需存储的实体 //需存储的实体
List<CategoryEntity> list = new ArrayList<CategoryEntity>(); List<CategoryEntity> list = new ArrayList<CategoryEntity>();
try{ try {
Workbook wb = null; Workbook wb = null;
InputStream is = file.getInputStream(); InputStream is = file.getInputStream();
if ("true".equals(isExcel2003)) { if ("true".equals(isExcel2003)) {
// 当excel是2003时,创建excel2003 // 当excel是2003时,创建excel2003
wb = new HSSFWorkbook(is); wb = new HSSFWorkbook(is);
}else if("false".equals(isExcel2003)){ } else if ("false".equals(isExcel2003)) {
// 当excel是2007时,创建excel2007 // 当excel是2007时,创建excel2007
wb = new XSSFWorkbook(is); wb = new XSSFWorkbook(is);
} else { } else {
@ -282,13 +283,13 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn
QueryWrapper<CategoryEntity> wrapper = new QueryWrapper<CategoryEntity>(categoryEntity); QueryWrapper<CategoryEntity> wrapper = new QueryWrapper<CategoryEntity>(categoryEntity);
List<CategoryEntity> categoryEntityList = baseDao.selectList(wrapper); List<CategoryEntity> categoryEntityList = baseDao.selectList(wrapper);
int numm = categoryEntityList.size(); int numm = categoryEntityList.size();
if(numm >= 0){ if (numm >= 0) {
numm -= 1; numm -= 1;
} }
//一级分类 //一级分类
String firstClassName = ""; String firstClassName = "";
Long firstClassId = 0L; Long firstClassId = 0L;
Integer firstClassSort = Integer.parseInt(numm+""); Integer firstClassSort = Integer.parseInt(numm + "");
//二级分类 //二级分类
String secondClassName = ""; String secondClassName = "";
Long secondClassId = 0L; Long secondClassId = 0L;
@ -319,7 +320,7 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn
//领域列 //领域列
firstClassNameCurrent = ""; firstClassNameCurrent = "";
String value = getCellContent(cell); String value = getCellContent(cell);
if(!"".equals(value)){ if (!"".equals(value)) {
firstClassName = value; firstClassName = value;
firstClassNameCurrent = value; firstClassNameCurrent = value;
firstClassId = getLongRandom(); firstClassId = getLongRandom();
@ -332,7 +333,7 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn
//大类列 //大类列
secondClassNameCurrent = ""; secondClassNameCurrent = "";
String value = getCellContent(cell); String value = getCellContent(cell);
if(!"".equals(value)){ if (!"".equals(value)) {
secondClassName = value; secondClassName = value;
secondClassNameCurrent = value; secondClassNameCurrent = value;
secondClassId = getLongRandom(); secondClassId = getLongRandom();
@ -344,7 +345,7 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn
//小类列 //小类列
thirdClassNameCurrent = ""; thirdClassNameCurrent = "";
String value = getCellContent(cell); String value = getCellContent(cell);
if(!"".equals(value)){ if (!"".equals(value)) {
thirdClassName = value; thirdClassName = value;
thirdClassNameCurrent = value; thirdClassNameCurrent = value;
thirdClassId = getLongRandom(); thirdClassId = getLongRandom();
@ -355,7 +356,7 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn
//细类名称列 //细类名称列
fourthClassNameCurrent = ""; fourthClassNameCurrent = "";
String value = getCellContent(cell); String value = getCellContent(cell);
if(!"".equals(value)){ if (!"".equals(value)) {
fourthClassName = value; fourthClassName = value;
fourthClassNameCurrent = value; fourthClassNameCurrent = value;
fourthClassId = getLongRandom(); fourthClassId = getLongRandom();
@ -364,36 +365,36 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn
} }
} }
} }
if(!"".equals(firstClassNameCurrent)){ if (!"".equals(firstClassNameCurrent)) {
//领域 //领域
CategoryEntity insertEntity = getCategoryEntity(firstClassId,0L,"0",firstClassName, CategoryEntity insertEntity = getCategoryEntity(firstClassId, 0L, "0", firstClassName,
firstClassId+"","0",firstClassSort,0,""); firstClassId + "", "0", firstClassSort, 0, "");
list.add(insertEntity); list.add(insertEntity);
} }
if(!"".equals(secondClassNameCurrent)){ if (!"".equals(secondClassNameCurrent)) {
//大类 //大类
CategoryEntity insertEntity = getCategoryEntity(secondClassId,firstClassId,firstClassId+"",secondClassName, CategoryEntity insertEntity = getCategoryEntity(secondClassId, firstClassId, firstClassId + "", secondClassName,
secondClassId+"","1",secondClassSort,0,firstClassName); secondClassId + "", "1", secondClassSort, 0, firstClassName);
list.add(insertEntity); list.add(insertEntity);
} }
if(!"".equals(thirdClassNameCurrent)){ if (!"".equals(thirdClassNameCurrent)) {
//小类 //小类
String pids = firstClassId + "," + secondClassId + ""; String pids = firstClassId + "," + secondClassId + "";
CategoryEntity insertEntity = getCategoryEntity(thirdClassId,secondClassId,pids,thirdClassName, CategoryEntity insertEntity = getCategoryEntity(thirdClassId, secondClassId, pids, thirdClassName,
thirdClassId+"","2",thirdClassSort,0,secondClassName); thirdClassId + "", "2", thirdClassSort, 0, secondClassName);
list.add(insertEntity); list.add(insertEntity);
} }
if(!"".equals(fourthClassNameCurrent)){ if (!"".equals(fourthClassNameCurrent)) {
//细分类 //细分类
String pids = firstClassId + "," + secondClassId + "," + thirdClassId + ""; String pids = firstClassId + "," + secondClassId + "," + thirdClassId + "";
CategoryEntity insertEntity = getCategoryEntity(fourthClassId,thirdClassId,pids,fourthClassName, CategoryEntity insertEntity = getCategoryEntity(fourthClassId, thirdClassId, pids, fourthClassName,
fourthClassId+"","3",fourthClassSort,0,thirdClassName); fourthClassId + "", "3", fourthClassSort, 0, thirdClassName);
list.add(insertEntity); list.add(insertEntity);
} }
} }
if(list.size() > 0){ if (list.size() > 0) {
CategoryEntity[] categoryEntities = new CategoryEntity[list.size()]; CategoryEntity[] categoryEntities = new CategoryEntity[list.size()];
for(int k = 0 ; k < list.size() ; k++){ for (int k = 0; k < list.size(); k++) {
categoryEntities[k] = list.get(k); categoryEntities[k] = list.get(k);
} }
baseDao.insertList(categoryEntities); baseDao.insertList(categoryEntities);
@ -402,7 +403,7 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn
result.setCode(0); result.setCode(0);
result.setData("数据导入成功!"); result.setData("数据导入成功!");
return result; return result;
}catch(Exception e){ } catch (Exception e) {
} }
result.setMsg("defeat"); result.setMsg("defeat");
@ -413,10 +414,11 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn
/** /**
* 获取单元格内容 * 获取单元格内容
*
* @param cell * @param cell
* @return * @return
*/ */
public String getCellContent(Cell cell){ public String getCellContent(Cell cell) {
String value = ""; String value = "";
if (cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) { if (cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) {
value = String.valueOf(cell.getNumericCellValue()); value = String.valueOf(cell.getNumericCellValue());
@ -424,33 +426,35 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn
value = cell.getStringCellValue(); value = cell.getStringCellValue();
} }
//内容超过25个字进行长度限制,否则数据库会超限 //内容超过25个字进行长度限制,否则数据库会超限
if(value.length() > 25){ if (value.length() > 25) {
value = value.substring(0,25) + "..."; value = value.substring(0, 25) + "...";
} }
return value; return value;
} }
/** /**
* 获取19位随机数 * 获取19位随机数
*
* @return * @return
*/ */
public Long getLongRandom(){ public Long getLongRandom() {
Guid+=1; Guid += 1;
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
SimpleDateFormat dateFormat=new SimpleDateFormat("MMdd"); SimpleDateFormat dateFormat = new SimpleDateFormat("MMdd");
String time=dateFormat.format(now); String time = dateFormat.format(now);
String currentTimeMillis=now+""; String currentTimeMillis = now + "";
int ran=0; int ran = 0;
if(Guid>999){ if (Guid > 999) {
Guid=100; Guid = 100;
} }
ran=Guid; ran = Guid;
String str = time+currentTimeMillis.substring(1, currentTimeMillis.length())+ran; String str = time + currentTimeMillis.substring(1, currentTimeMillis.length()) + ran;
return Long.parseLong(str); return Long.parseLong(str);
} }
/** /**
* 拼接entity * 拼接entity
*
* @param id ID * @param id ID
* @param pid 上级分类ID * @param pid 上级分类ID
* @param categoryName 分类名称 * @param categoryName 分类名称
@ -460,8 +464,8 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn
* @param delFlag 删除标识 0未删除 1删除 * @param delFlag 删除标识 0未删除 1删除
* @param parentName 上级部门名称 * @param parentName 上级部门名称
*/ */
public CategoryEntity getCategoryEntity(Long id,Long pid,String pids,String categoryName,String categoryCode, public CategoryEntity getCategoryEntity(Long id, Long pid, String pids, String categoryName, String categoryCode,
String categoryType,Integer sort,Integer delFlag,String parentName) { String categoryType, Integer sort, Integer delFlag, String parentName) {
CategoryEntity entity = new CategoryEntity(); CategoryEntity entity = new CategoryEntity();
Long userId = SecurityUser.getUserId(); Long userId = SecurityUser.getUserId();
entity.setId(id); entity.setId(id);
@ -482,6 +486,7 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn
/** /**
* 获取excle版本 * 获取excle版本
*
* @param mFile * @param mFile
* @return * @return
*/ */
@ -504,6 +509,7 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn
/** /**
* 验证EXCEL文件 * 验证EXCEL文件
*
* @param filePath * @param filePath
* @return * @return
*/ */
@ -518,6 +524,7 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn
public static boolean isExcel2003(String filePath) { public static boolean isExcel2003(String filePath) {
return filePath.matches("^.+\\.(?i)(xls)$"); return filePath.matches("^.+\\.(?i)(xls)$");
} }
// @描述:是否是2007的excel,返回true是2007 // @描述:是否是2007的excel,返回true是2007
public static boolean isExcel2007(String filePath) { public static boolean isExcel2007(String filePath) {
return filePath.matches("^.+\\.(?i)(xlsx)$"); return filePath.matches("^.+\\.(?i)(xlsx)$");
@ -550,24 +557,37 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn
**/ **/
@Override @Override
public List<CategoryInfoResultDTO> listCategoryInfo(CategoryInfoFormDTO formDTO) { public List<CategoryInfoResultDTO> listCategoryInfo(CategoryInfoFormDTO formDTO) {
List<CategoryInfoResultDTO> categoryInfoResultDTOList = new ArrayList<>(); List<CategoryInfoResultDTO> result = Lists.newArrayList();
CategoryInfoResultDTO categoryInfoResult;
for (Long id : formDTO.getIds()) { for (Long id : formDTO.getIds()) {
CategoryEntity entity = baseDao.getById(id); CategoryEntity entity = baseDao.getById(id);
if (null != entity) { if (null == entity) {
List<String> parentNameList = new ArrayList<>(); continue;
if (StringUtils.isNotBlank(entity.getPids())) { }
String[] pidList = entity.getPids().split(","); if(StringUtils.isBlank(entity.getPids())){
for (String pid : pidList) { categoryInfoResult = ConvertUtils.sourceToTarget(entity, CategoryInfoResultDTO.class);
CategoryEntity parentEntity = baseDao.getById(Long.valueOf(pid)); result.add(categoryInfoResult);
continue;
}
List<String> parentNameList = Lists.newArrayList();
String[] pidList = entity.getPids().split(StrConstant.COMMA);
if (null != pidList && pidList.length > NumConstant.ZERO) {
CategoryEntity parentEntity;
for (int i = 0; i < pidList.length; i++) {
parentEntity = baseDao.getById(Long.valueOf(pidList[i]));
if (null != parentEntity) {
parentNameList.add(parentEntity.getCategoryName()); parentNameList.add(parentEntity.getCategoryName());
} }
} }
CategoryInfoResultDTO categoryInfoResultDTO = ConvertUtils.sourceToTarget(entity, CategoryInfoResultDTO.class);
categoryInfoResultDTO.setParentNames(parentNameList);
categoryInfoResultDTOList.add(categoryInfoResultDTO);
} }
categoryInfoResult = ConvertUtils.sourceToTarget(entity, CategoryInfoResultDTO.class);
if (CollUtil.isNotEmpty(parentNameList)) {
categoryInfoResult.setParentNames(StringUtils.join(parentNameList, StrConstant.HYPHEN));
} }
return categoryInfoResultDTOList; result.add(categoryInfoResult);
}
return result;
} }
/** /**

4
esua-epdc/epdc-module/epdc-kpi/epdc-kpi-client/src/main/java/com/elink/esua/epdc/dto/KpiTimeLimitItemDTO.java

@ -53,7 +53,7 @@ public class KpiTimeLimitItemDTO implements Serializable {
/** /**
* 项目类别id * 项目类别id
*/ */
private String categoryId; private Long categoryId;
/** /**
* 所有上级项目类别id * 所有上级项目类别id
@ -108,6 +108,6 @@ public class KpiTimeLimitItemDTO implements Serializable {
/** /**
* 项目类别集合 * 项目类别集合
*/ */
private List<String> categoryIds; private List<Long[]> categoryIds;
} }

14
esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/dao/KpiTimeLimitItemDao.java

@ -20,6 +20,9 @@ package com.elink.esua.epdc.dao;
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
import com.elink.esua.epdc.entity.KpiTimeLimitItemEntity; import com.elink.esua.epdc.entity.KpiTimeLimitItemEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* 项目响应时限 * 项目响应时限
@ -30,4 +33,15 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface KpiTimeLimitItemDao extends BaseDao<KpiTimeLimitItemEntity> { public interface KpiTimeLimitItemDao extends BaseDao<KpiTimeLimitItemEntity> {
/**
* 按类别id批量删除配置
*
* @param categoryIds
* @return int
* @author work@yujt.net.cn
* @date 2019/12/16 19:19
*/
int deleteBatchByCategoryIds(@Param("categoryIds") List<Long> categoryIds);
} }

2
esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/entity/KpiTimeLimitItemEntity.java

@ -51,7 +51,7 @@ public class KpiTimeLimitItemEntity extends BaseEpdcEntity {
/** /**
* 项目类别id * 项目类别id
*/ */
private String categoryId; private Long categoryId;
/** /**
* 所有上级项目类别id * 所有上级项目类别id

4
esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/feign/EventFeignClient.java

@ -7,7 +7,7 @@ import com.elink.esua.epdc.dto.category.result.CategoryInfoResultDTO;
import com.elink.esua.epdc.feign.fallback.EventFeignClientFallback; import com.elink.esua.epdc.feign.fallback.EventFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.GetMapping;
import java.util.List; import java.util.List;
@ -26,6 +26,6 @@ public interface EventFeignClient {
* @Description 根据id查询事件分类基本信息 * @Description 根据id查询事件分类基本信息
* @Date 2019/12/4 10:37 * @Date 2019/12/4 10:37
**/ **/
@PostMapping(value = "events/category/queryCategoryInfo", consumes = MediaType.APPLICATION_JSON_VALUE) @GetMapping(value = "events/category/queryCategoryInfo", consumes = MediaType.APPLICATION_JSON_VALUE)
Result<List<CategoryInfoResultDTO>> queryCategoryInfo(CategoryInfoFormDTO categoryInfoFormDTO); Result<List<CategoryInfoResultDTO>> queryCategoryInfo(CategoryInfoFormDTO categoryInfoFormDTO);
} }

118
esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/impl/KpiTimeLimitItemServiceImpl.java

@ -21,6 +21,8 @@ import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
import com.elink.esua.epdc.commons.tools.constant.NumConstant;
import com.elink.esua.epdc.commons.tools.constant.StrConstant;
import com.elink.esua.epdc.commons.tools.page.PageData; import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
@ -33,6 +35,7 @@ import com.elink.esua.epdc.entity.KpiTimeLimitItemEntity;
import com.elink.esua.epdc.feign.EventFeignClient; import com.elink.esua.epdc.feign.EventFeignClient;
import com.elink.esua.epdc.redis.KpiTimeLimitItemRedis; import com.elink.esua.epdc.redis.KpiTimeLimitItemRedis;
import com.elink.esua.epdc.service.KpiTimeLimitItemService; import com.elink.esua.epdc.service.KpiTimeLimitItemService;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -55,8 +58,6 @@ import java.util.Map;
public class KpiTimeLimitItemServiceImpl extends BaseServiceImpl<KpiTimeLimitItemDao, KpiTimeLimitItemEntity> implements KpiTimeLimitItemService { public class KpiTimeLimitItemServiceImpl extends BaseServiceImpl<KpiTimeLimitItemDao, KpiTimeLimitItemEntity> implements KpiTimeLimitItemService {
private Logger logger = LoggerFactory.getLogger(getClass()); private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private KpiTimeLimitItemRedis kpiTimeLimitItemRedis;
@Autowired @Autowired
private EventFeignClient eventFeignClient; private EventFeignClient eventFeignClient;
@ -80,8 +81,8 @@ public class KpiTimeLimitItemServiceImpl extends BaseServiceImpl<KpiTimeLimitIte
return ConvertUtils.sourceToTarget(entityList, KpiTimeLimitItemDTO.class); return ConvertUtils.sourceToTarget(entityList, KpiTimeLimitItemDTO.class);
} }
private QueryWrapper<KpiTimeLimitItemEntity> getWrapper(Map<String, Object> params){ private QueryWrapper<KpiTimeLimitItemEntity> getWrapper(Map<String, Object> params) {
String id = (String)params.get(FieldConstant.ID_HUMP); String id = (String) params.get(FieldConstant.ID_HUMP);
QueryWrapper<KpiTimeLimitItemEntity> wrapper = new QueryWrapper<>(); QueryWrapper<KpiTimeLimitItemEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
@ -98,47 +99,82 @@ public class KpiTimeLimitItemServiceImpl extends BaseServiceImpl<KpiTimeLimitIte
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result save(KpiTimeLimitItemDTO dto) { public Result save(KpiTimeLimitItemDTO dto) {
for (String categoryIds : dto.getCategoryIds()) { List<Long[]> selectedCategoryIds = dto.getCategoryIds();
categoryIds = categoryIds.replaceAll("\\[", "").replaceAll("\\]", "").replace("\"", ""); // 用户选择的所有部门id(去重之后)
String[] categoryIdArray = categoryIds.split(","); List<Long> distinctCategoryIds = Lists.newArrayList();
String categoryId = categoryIdArray[categoryIdArray.length - 1];
CategoryInfoFormDTO categoryInfoFormDTO = new CategoryInfoFormDTO(); for (Long[] oneOptionCategoryIdArray : selectedCategoryIds) {
Long[] ids = new Long[1]; for (Long categoryId : oneOptionCategoryIdArray) {
ids[0] = Long.valueOf(categoryId); if (!distinctCategoryIds.contains(categoryId)) {
categoryInfoFormDTO.setIds(ids); distinctCategoryIds.add(categoryId);
Result<List<CategoryInfoResultDTO>> res = eventFeignClient.queryCategoryInfo(categoryInfoFormDTO); }
if (res.getCode() != 0 || CollUtil.isEmpty(res.getData()) || res.getData().size() == 0) { }
return new Result().error("查询分类详情失败" + res.getMsg()); }
} CategoryInfoFormDTO categoryInfoFormDto = new CategoryInfoFormDTO();
String allCategoryNames = ""; categoryInfoFormDto.setIds(distinctCategoryIds.toArray(new Long[distinctCategoryIds.size()]));
String parentCategoryIds = ""; Result<List<CategoryInfoResultDTO>> eventResult = eventFeignClient.queryCategoryInfo(categoryInfoFormDto);
String parentCategoryNames = ""; if (!eventResult.success() || CollUtil.isEmpty(eventResult.getData())) {
CategoryInfoResultDTO categoryInfoResultDTO = res.getData().get(0); return new Result().error();
for (String parentName : categoryInfoResultDTO.getParentNames()) { }
parentCategoryNames += (parentName + "-");
} List<CategoryInfoResultDTO> categoryInfoList = eventResult.getData();
//去除最后一个-
parentCategoryNames = parentCategoryNames.substring(0, parentCategoryNames.length() - 1); KpiTimeLimitItemEntity timeLimit;
allCategoryNames = parentCategoryNames + "-" + categoryInfoResultDTO.getCategoryName(); List<KpiTimeLimitItemEntity> entityList = Lists.newArrayList();
int index = categoryIds.lastIndexOf(",");
// logger.info("最后一个逗号所在的位置"+index); for (CategoryInfoResultDTO categoryInfo : categoryInfoList) {
parentCategoryIds = categoryIds.substring(0, index); delteTimeLimitByCategoryId(categoryInfo.getId());
dto.setCategoryId(categoryId);
dto.setAllCategoryIds(categoryIds); timeLimit = new KpiTimeLimitItemEntity();
dto.setAllCategoryNames(allCategoryNames); timeLimit.setValidCloseTime(dto.getValidCloseTime());
dto.setParentCategoryIds(parentCategoryIds); timeLimit.setValidRespondTime(dto.getValidRespondTime());
dto.setParentCategoryNames(parentCategoryNames);
KpiTimeLimitItemEntity entity = ConvertUtils.sourceToTarget(dto, KpiTimeLimitItemEntity.class); timeLimit.setCategoryId(categoryInfo.getId());
// 删除已存在的记录 // 父id为根节点0,表示一级类别,不拼接根节点
QueryWrapper<KpiTimeLimitItemEntity> wrapper = new QueryWrapper<>(); if (categoryInfo.getPids().equals(NumConstant.ZERO_STR)) {
wrapper.eq(StringUtils.isNotBlank(categoryId), "CATEGORY_ID", categoryId); timeLimit.setAllCategoryIds(String.valueOf(categoryInfo.getId()));
baseDao.delete(wrapper); timeLimit.setAllCategoryNames(categoryInfo.getCategoryName());
//插入 } else {
insert(entity); timeLimit.setAllCategoryIds(categoryInfo.getPids().concat(StrConstant.COMMA).concat(String.valueOf(categoryInfo.getId())));
timeLimit.setAllCategoryNames(categoryInfo.getParentNames().concat(StrConstant.HYPHEN.concat(categoryInfo.getCategoryName())));
} }
timeLimit.setParentCategoryIds(categoryInfo.getPids());
timeLimit.setParentCategoryNames(categoryInfo.getParentNames());
entityList.add(timeLimit);
}
baseDao.deleteBatchByCategoryIds(distinctCategoryIds);
this.insertBatch(entityList, NumConstant.THIRTY);
return new Result(); return new Result();
} }
/**
* 根据类别id删除类别设置
*
* @param categoryId
* @return int
* @author work@yujt.net.cn
* @date 2019/12/16 17:49
*/
private int delteTimeLimitByCategoryId(Long categoryId) {
QueryWrapper<KpiTimeLimitItemEntity> wrapper = new QueryWrapper<>();
wrapper.eq("CATEGORY_ID", categoryId);
return baseDao.delete(wrapper);
}
public static void main(String[] args) {
List<Long> aa = Lists.newArrayList();
aa.add(0L);
aa.add(1L);
Long[] bb = aa.toArray(new Long[aa.size()]);
for (Long aLong : bb) {
System.out.println(aLong);
}
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void update(KpiTimeLimitItemDTO dto) { public void update(KpiTimeLimitItemDTO dto) {

20
esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/resources/mapper/KpiTimeLimitItemDao.xml

@ -3,22 +3,10 @@
<mapper namespace="com.elink.esua.epdc.dao.KpiTimeLimitItemDao"> <mapper namespace="com.elink.esua.epdc.dao.KpiTimeLimitItemDao">
<resultMap type="com.elink.esua.epdc.entity.KpiTimeLimitItemEntity" id="kpiTimeLimitItemMap"> <delete id="deleteBatchByCategoryIds">
<result property="id" column="ID"/> delete from epdc_kpi_time_limit_item where category_id in
<result property="validRespondTime" column="VALID_RESPOND_TIME"/> <foreach collection="categoryIds" item="item" open="(" separator="," close=")">#{item}</foreach>
<result property="validCloseTime" column="VALID_CLOSE_TIME"/> </delete>
<result property="categoryId" column="CATEGORY_ID"/>
<result property="parentCategoryIds" column="PARENT_CATEGORY_IDS"/>
<result property="parentCategoryNames" column="PARENT_CATEGORY_NAMES"/>
<result property="allCategoryIds" column="ALL_CATEGORY_IDS"/>
<result property="allCategoryNames" column="ALL_CATEGORY_NAMES"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
<result property="delFlag" column="DEL_FLAG"/>
</resultMap>
</mapper> </mapper>
Loading…
Cancel
Save