Browse Source

项目时限管理

dev
尹作梅 6 years ago
parent
commit
aebc491bf6
  1. 20
      esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/category/form/CategoryInfoFormDTO.java
  2. 38
      esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/category/result/CategoryInfoResultDTO.java
  3. 16
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/controller/CategoryController.java
  4. 11
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/service/CategoryService.java
  5. 45
      esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/service/impl/CategoryServiceImpl.java
  6. 113
      esua-epdc/epdc-module/epdc-kpi/epdc-kpi-client/src/main/java/com/elink/esua/epdc/dto/KpiTimeLimitItemDTO.java
  7. 7
      esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/pom.xml
  8. 93
      esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/controller/KpiTimeLimitItemController.java
  9. 33
      esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/dao/KpiTimeLimitItemDao.java
  10. 76
      esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/entity/KpiTimeLimitItemEntity.java
  11. 77
      esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/excel/KpiTimeLimitItemExcel.java
  12. 31
      esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/feign/EventFeignClient.java
  13. 25
      esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/feign/fallback/EventFeignClientFallback.java
  14. 47
      esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/redis/KpiTimeLimitItemRedis.java
  15. 96
      esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/KpiTimeLimitItemService.java
  16. 156
      esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/impl/KpiTimeLimitItemServiceImpl.java
  17. 24
      esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/resources/mapper/KpiTimeLimitItemDao.xml

20
esua-epdc/epdc-module/epdc-events/epdc-events-client/src/main/java/com/elink/esua/epdc/dto/category/form/CategoryInfoFormDTO.java

@ -0,0 +1,20 @@
package com.elink.esua.epdc.dto.category.form;
import lombok.Data;
import java.io.Serializable;
/**
* @Description
* @Author yinzuomei
* @Date 2019/12/4 10:29
*/
@Data
public class CategoryInfoFormDTO implements Serializable {
private static final long serialVersionUID = -8214790072156444793L;
/**
* 主键集合
*/
private Long[] ids;
}

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

@ -0,0 +1,38 @@
package com.elink.esua.epdc.dto.category.result;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Description
* @Author yinzuomei
* @Date 2019/12/4 9:05
*/
@Data
public class CategoryInfoResultDTO implements Serializable {
private static final long serialVersionUID = 229431634619504645L;
/**
* 主键
*/
private Long id;
/**
* 分类名称
*/
private String categoryName;
/**
* 上级分类ID
*/
private Long pid;
/**
* 所有上级分类ID用逗号分开
*/
private String pids;
/**
* 所有上级分类名称用逗号分开
*/
private List<String> parentNames;
}

16
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/controller/CategoryController.java

@ -20,13 +20,14 @@ package com.elink.esua.epdc.modules.category.controller;
import com.elink.esua.epdc.commons.tools.annotation.LogOperation;
import com.elink.esua.epdc.commons.tools.utils.ExcelUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.commons.tools.validator.AssertUtils;
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils;
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup;
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup;
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup;
import com.elink.esua.epdc.dto.category.CategoryDTO;
import com.elink.esua.epdc.dto.category.CategoryOption;
import com.elink.esua.epdc.dto.category.form.CategoryInfoFormDTO;
import com.elink.esua.epdc.dto.category.result.CategoryInfoResultDTO;
import com.elink.esua.epdc.modules.category.excel.CategoryExcel;
import com.elink.esua.epdc.modules.category.service.CategoryService;
import io.swagger.annotations.ApiOperation;
@ -127,4 +128,17 @@ public class CategoryController {
public Result<CategoryOption> getCategoryTree() {
return categoryService.getCategoryTree();
}
/**
* @param formDTO
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List < com.elink.esua.epdc.dto.category.result.CategoryInfoResultDTO>>
* @Author yinzuomei
* @Description 根据id查询事件分类基本信息
* @Date 2019/12/4 9:43
**/
@PostMapping("queryCategoryInfo")
public Result<List<CategoryInfoResultDTO>> queryCategoryInfo(@RequestBody CategoryInfoFormDTO formDTO) {
List<CategoryInfoResultDTO> data = categoryService.listCategoryInfo(formDTO);
return new Result<List<CategoryInfoResultDTO>>().ok(data);
}
}

11
esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/service/CategoryService.java

@ -21,6 +21,8 @@ import com.elink.esua.epdc.commons.mybatis.service.BaseService;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.category.CategoryDTO;
import com.elink.esua.epdc.dto.category.CategoryOption;
import com.elink.esua.epdc.dto.category.form.CategoryInfoFormDTO;
import com.elink.esua.epdc.dto.category.result.CategoryInfoResultDTO;
import com.elink.esua.epdc.modules.category.entity.CategoryEntity;
import org.springframework.web.multipart.MultipartFile;
@ -120,4 +122,13 @@ public interface CategoryService extends BaseService<CategoryEntity> {
* @Date 2019/12/3 18:04
**/
Result<CategoryOption> getCategoryTree();
/**
* @param formDTO
* @return java.util.List<com.elink.esua.epdc.dto.category.result.CategoryInfoResultDTO>
* @Author yinzuomei
* @Description 根据id查询事件分类基本信息
* @Date 2019/12/4 9:43
**/
List<CategoryInfoResultDTO> listCategoryInfo(CategoryInfoFormDTO formDTO);
}

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

@ -33,6 +33,8 @@ import com.elink.esua.epdc.commons.tools.utils.TreeUtils;
import com.elink.esua.epdc.dto.category.CategoryDTO;
import com.elink.esua.epdc.dto.category.CategoryOption;
import com.elink.esua.epdc.dto.category.CategoryTreeDTO;
import com.elink.esua.epdc.dto.category.form.CategoryInfoFormDTO;
import com.elink.esua.epdc.dto.category.result.CategoryInfoResultDTO;
import com.elink.esua.epdc.modules.category.dao.CategoryDao;
import com.elink.esua.epdc.modules.category.entity.CategoryEntity;
import com.elink.esua.epdc.modules.category.redis.CategoryRedis;
@ -111,13 +113,6 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn
this.packageCategoryOption();
}
@Override
public List<CategoryEntity> getPidListById(Long id) {
//所有的分类列表
CategoryEntity categoryEntity = baseDao.selectById(id);
return getPidListByPid(categoryEntity.getPid());
}
/**
* 获取所有上级分类
*
@ -147,6 +142,13 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn
return pCategoryEntityList;
}
@Override
public List<CategoryEntity> getPidListById(Long id) {
//所有的分类列表
CategoryEntity categoryEntity = baseDao.selectById(id);
return getPidListByPid(categoryEntity.getPid());
}
private void getPidTree(Long pid, Map<Long, CategoryEntity> map, List<CategoryEntity> pCategoryEntityList) {
//顶级,无上级
if (Constant.CATEGORY_ROOT.equals(pid)) {
@ -250,6 +252,35 @@ public class CategoryServiceImpl extends BaseServiceImpl<CategoryDao, CategoryEn
return new Result<CategoryOption>().ok((CategoryOption) obj);
}
/**
* @param formDTO
* @return java.util.List<com.elink.esua.epdc.dto.category.result.CategoryInfoResultDTO>
* @Author yinzuomei
* @Description 根据id查询事件分类基本信息
* @Date 2019/12/4 9:43
**/
@Override
public List<CategoryInfoResultDTO> listCategoryInfo(CategoryInfoFormDTO formDTO) {
List<CategoryInfoResultDTO> categoryInfoResultDTOList = new ArrayList<>();
for (Long id : formDTO.getIds()) {
CategoryEntity entity = baseDao.getById(id);
if (null != entity) {
List<String> parentNameList = new ArrayList<>();
if (StringUtils.isNotBlank(entity.getPids())) {
String[] pidList = entity.getPids().split(",");
for (String pid : pidList) {
CategoryEntity parentEntity = baseDao.getById(Long.valueOf(pid));
parentNameList.add(parentEntity.getCategoryName());
}
}
CategoryInfoResultDTO categoryInfoResultDTO = ConvertUtils.sourceToTarget(entity, CategoryInfoResultDTO.class);
categoryInfoResultDTO.setParentNames(parentNameList);
categoryInfoResultDTOList.add(categoryInfoResultDTO);
}
}
return categoryInfoResultDTOList;
}
/**
* @param
* @return void

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

@ -0,0 +1,113 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.dto;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import lombok.Data;
/**
* 项目响应时限
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-12-02
*/
@Data
public class KpiTimeLimitItemDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private String id;
/**
* 有效响应时间小时数
*/
private Integer validRespondTime;
/**
* 有效结案时间小时数
*/
private Integer validCloseTime;
/**
* 项目类别id
*/
private String categoryId;
/**
* 所有上级项目类别id
*/
private String parentCategoryIds;
/**
* 所有上级项目类别名称
*/
private String parentCategoryNames;
/**
* 所有项目类别id
*/
private String allCategoryIds;
/**
* 所有项目类别名称
*/
private String allCategoryNames;
/**
* 乐观锁
*/
private Integer revision;
/**
* 创建人
*/
private String createdBy;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新人
*/
private String updatedBy;
/**
* 更新时间
*/
private Date updatedTime;
/**
* 删除标记
*/
private String delFlag;
/**
* 项目类别集合
*/
private List<String> categoryIds;
}

7
esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/pom.xml

@ -18,6 +18,11 @@
<artifactId>epdc-kpi-client</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.esua.epdc</groupId>
<artifactId>epdc-events-client</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.esua.epdc</groupId>
<artifactId>epdc-commons-tools</artifactId>
@ -168,4 +173,4 @@
</profile>
</profiles>
</project>
</project>

93
esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/controller/KpiTimeLimitItemController.java

@ -0,0 +1,93 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.controller;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ExcelUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.commons.tools.validator.AssertUtils;
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils;
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup;
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup;
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup;
import com.elink.esua.epdc.dto.KpiTimeLimitItemDTO;
import com.elink.esua.epdc.excel.KpiTimeLimitItemExcel;
import com.elink.esua.epdc.service.KpiTimeLimitItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* 项目响应时限
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-12-02
*/
@RestController
@RequestMapping("kpitimelimititem")
public class KpiTimeLimitItemController {
@Autowired
private KpiTimeLimitItemService kpiTimeLimitItemService;
@GetMapping("page")
public Result<PageData<KpiTimeLimitItemDTO>> page(@RequestParam Map<String, Object> params){
PageData<KpiTimeLimitItemDTO> page = kpiTimeLimitItemService.page(params);
return new Result<PageData<KpiTimeLimitItemDTO>>().ok(page);
}
@GetMapping("{id}")
public Result<KpiTimeLimitItemDTO> get(@PathVariable("id") String id){
KpiTimeLimitItemDTO data = kpiTimeLimitItemService.get(id);
return new Result<KpiTimeLimitItemDTO>().ok(data);
}
@PostMapping
public Result save(@RequestBody KpiTimeLimitItemDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
return kpiTimeLimitItemService.save(dto);
}
@PutMapping
public Result update(@RequestBody KpiTimeLimitItemDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
kpiTimeLimitItemService.update(dto);
return new Result();
}
@DeleteMapping
public Result delete(@RequestBody String[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
kpiTimeLimitItemService.delete(ids);
return new Result();
}
@GetMapping("export")
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<KpiTimeLimitItemDTO> list = kpiTimeLimitItemService.list(params);
ExcelUtils.exportExcelToTarget(response, null, list, KpiTimeLimitItemExcel.class);
}
}

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

@ -0,0 +1,33 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.dao;
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
import com.elink.esua.epdc.entity.KpiTimeLimitItemEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 项目响应时限
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-12-02
*/
@Mapper
public interface KpiTimeLimitItemDao extends BaseDao<KpiTimeLimitItemEntity> {
}

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

@ -0,0 +1,76 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 项目响应时限
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-12-02
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("epdc_kpi_time_limit_item")
public class KpiTimeLimitItemEntity extends BaseEpdcEntity {
private static final long serialVersionUID = 1L;
/**
* 有效响应时间小时数
*/
private Integer validRespondTime;
/**
* 有效结案时间小时数
*/
private Integer validCloseTime;
/**
* 项目类别id
*/
private String categoryId;
/**
* 所有上级项目类别id
*/
private String parentCategoryIds;
/**
* 所有上级项目类别名称
*/
private String parentCategoryNames;
/**
* 所有项目类别id
*/
private String allCategoryIds;
/**
* 所有项目类别名称
*/
private String allCategoryNames;
}

77
esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/excel/KpiTimeLimitItemExcel.java

@ -0,0 +1,77 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.excel;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.util.Date;
/**
* 项目响应时限
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-12-02
*/
@Data
public class KpiTimeLimitItemExcel {
@Excel(name = "主键")
private String id;
@Excel(name = "有效响应时间(小时数)")
private Integer validRespondTime;
@Excel(name = "有效结案时间(小时数)")
private Integer validCloseTime;
@Excel(name = "项目类别id")
private String categoryId;
@Excel(name = "所有上级项目类别id")
private String parentCategoryIds;
@Excel(name = "所有上级项目类别名称")
private String parentCategoryNames;
@Excel(name = "所有项目类别id")
private String allCategoryIds;
@Excel(name = "所有项目类别名称")
private String allCategoryNames;
@Excel(name = "乐观锁")
private Integer revision;
@Excel(name = "创建人")
private String createdBy;
@Excel(name = "创建时间")
private Date createdTime;
@Excel(name = "更新人")
private String updatedBy;
@Excel(name = "更新时间")
private Date updatedTime;
@Excel(name = "删除标记")
private String delFlag;
}

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

@ -0,0 +1,31 @@
package com.elink.esua.epdc.feign;
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.category.form.CategoryInfoFormDTO;
import com.elink.esua.epdc.dto.category.result.CategoryInfoResultDTO;
import com.elink.esua.epdc.feign.fallback.EventFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import java.util.List;
/**
* @Auther: yinzuomei
* @Date: 2019/12/4 09:28
* @Description: 事件接口
*/
@FeignClient(name = ServiceConstant.EPDC_EVENTS_SERVER, fallback = EventFeignClientFallback.class,url = "http://127.0.0.1:9066")
public interface EventFeignClient {
/**
* @param categoryInfoFormDTO
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List < com.elink.esua.epdc.dto.category.result.CategoryInfoResultDTO>>
* @Author yinzuomei
* @Description 根据id查询事件分类基本信息
* @Date 2019/12/4 10:37
**/
@PostMapping(value = "events/category/queryCategoryInfo", consumes = MediaType.APPLICATION_JSON_VALUE)
Result<List<CategoryInfoResultDTO>> queryCategoryInfo(CategoryInfoFormDTO categoryInfoFormDTO);
}

25
esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/feign/fallback/EventFeignClientFallback.java

@ -0,0 +1,25 @@
package com.elink.esua.epdc.feign.fallback;
import com.elink.esua.epdc.commons.tools.constant.ServiceConstant;
import com.elink.esua.epdc.commons.tools.utils.ModuleUtils;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.category.form.CategoryInfoFormDTO;
import com.elink.esua.epdc.dto.category.result.CategoryInfoResultDTO;
import com.elink.esua.epdc.feign.EventFeignClient;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @Description
* @Author yinzuomei
* @Date 2019/12/4 9:45
*/
@Component
public class EventFeignClientFallback implements EventFeignClient {
@Override
public Result<List<CategoryInfoResultDTO>> queryCategoryInfo(CategoryInfoFormDTO categoryInfoFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPDC_EVENTS_SERVER, "queryCategoryInfo", categoryInfoFormDTO);
}
}

47
esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/redis/KpiTimeLimitItemRedis.java

@ -0,0 +1,47 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.redis;
import com.elink.esua.epdc.commons.tools.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 项目响应时限
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-12-02
*/
@Component
public class KpiTimeLimitItemRedis {
@Autowired
private RedisUtils redisUtils;
public void delete(Object[] ids) {
}
public void set(){
}
public String get(String id){
return null;
}
}

96
esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/KpiTimeLimitItemService.java

@ -0,0 +1,96 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.service;
import com.elink.esua.epdc.commons.mybatis.service.BaseService;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.KpiTimeLimitItemDTO;
import com.elink.esua.epdc.entity.KpiTimeLimitItemEntity;
import java.util.List;
import java.util.Map;
/**
* 项目响应时限
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-12-02
*/
public interface KpiTimeLimitItemService extends BaseService<KpiTimeLimitItemEntity> {
/**
* 默认分页
*
* @param params
* @return PageData<KpiTimeLimitItemDTO>
* @author generator
* @date 2019-12-02
*/
PageData<KpiTimeLimitItemDTO> page(Map<String, Object> params);
/**
* 默认查询
*
* @param params
* @return java.util.List<KpiTimeLimitItemDTO>
* @author generator
* @date 2019-12-02
*/
List<KpiTimeLimitItemDTO> list(Map<String, Object> params);
/**
* 单条查询
*
* @param id
* @return KpiTimeLimitItemDTO
* @author generator
* @date 2019-12-02
*/
KpiTimeLimitItemDTO get(String id);
/**
* 默认保存
*
* @param dto
* @return void
* @author generator
* @date 2019-12-02
*/
Result save(KpiTimeLimitItemDTO dto);
/**
* 默认更新
*
* @param dto
* @return void
* @author generator
* @date 2019-12-02
*/
void update(KpiTimeLimitItemDTO dto);
/**
* 批量删除
*
* @param ids
* @return void
* @author generator
* @date 2019-12-02
*/
void delete(String[] ids);
}

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

@ -0,0 +1,156 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.elink.esua.epdc.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
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.constant.FieldConstant;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dao.KpiTimeLimitItemDao;
import com.elink.esua.epdc.dto.KpiTimeLimitItemDTO;
import com.elink.esua.epdc.dto.category.form.CategoryInfoFormDTO;
import com.elink.esua.epdc.dto.category.result.CategoryInfoResultDTO;
import com.elink.esua.epdc.entity.KpiTimeLimitItemEntity;
import com.elink.esua.epdc.feign.EventFeignClient;
import com.elink.esua.epdc.redis.KpiTimeLimitItemRedis;
import com.elink.esua.epdc.service.KpiTimeLimitItemService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.File;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 项目响应时限
*
* @author qu qu@elink-cn.com
* @since v1.0.0 2019-12-02
*/
@Service
public class KpiTimeLimitItemServiceImpl extends BaseServiceImpl<KpiTimeLimitItemDao, KpiTimeLimitItemEntity> implements KpiTimeLimitItemService {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private KpiTimeLimitItemRedis kpiTimeLimitItemRedis;
@Autowired
private EventFeignClient eventFeignClient;
@Override
public PageData<KpiTimeLimitItemDTO> page(Map<String, Object> params) {
String categoryId = params.containsKey("categoryId") ? params.get("categoryId").toString() : null;
QueryWrapper<KpiTimeLimitItemEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(categoryId), "CATEGORY_ID", categoryId);
IPage<KpiTimeLimitItemEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
wrapper
);
return getPageData(page, KpiTimeLimitItemDTO.class);
}
@Override
public List<KpiTimeLimitItemDTO> list(Map<String, Object> params) {
List<KpiTimeLimitItemEntity> entityList = baseDao.selectList(getWrapper(params));
return ConvertUtils.sourceToTarget(entityList, KpiTimeLimitItemDTO.class);
}
private QueryWrapper<KpiTimeLimitItemEntity> getWrapper(Map<String, Object> params){
String id = (String)params.get(FieldConstant.ID_HUMP);
QueryWrapper<KpiTimeLimitItemEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
return wrapper;
}
@Override
public KpiTimeLimitItemDTO get(String id) {
KpiTimeLimitItemEntity entity = baseDao.selectById(id);
return ConvertUtils.sourceToTarget(entity, KpiTimeLimitItemDTO.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public Result save(KpiTimeLimitItemDTO dto) {
for (String categoryIds : dto.getCategoryIds()) {
categoryIds = categoryIds.replaceAll("\\[", "").replaceAll("\\]", "").replace("\"", "");
String[] categoryIdArray = categoryIds.split(",");
String categoryId = categoryIdArray[categoryIdArray.length - 1];
CategoryInfoFormDTO categoryInfoFormDTO = new CategoryInfoFormDTO();
Long[] ids = new Long[1];
ids[0] = Long.valueOf(categoryId);
categoryInfoFormDTO.setIds(ids);
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());
}
String allCategoryNames = "";
String parentCategoryIds = "";
String parentCategoryNames = "";
CategoryInfoResultDTO categoryInfoResultDTO = res.getData().get(0);
for (String parentName : categoryInfoResultDTO.getParentNames()) {
parentCategoryNames += (parentName + "-");
}
//去除最后一个-
parentCategoryNames = parentCategoryNames.substring(0, parentCategoryNames.length() - 1);
allCategoryNames = parentCategoryNames + "-" + categoryInfoResultDTO.getCategoryName();
int index = categoryIds.lastIndexOf(",");
// logger.info("最后一个逗号所在的位置"+index);
parentCategoryIds = categoryIds.substring(0, index);
dto.setCategoryId(categoryId);
dto.setAllCategoryIds(categoryIds);
dto.setAllCategoryNames(allCategoryNames);
dto.setParentCategoryIds(parentCategoryIds);
dto.setParentCategoryNames(parentCategoryNames);
KpiTimeLimitItemEntity entity = ConvertUtils.sourceToTarget(dto, KpiTimeLimitItemEntity.class);
// 删除已存在的记录
QueryWrapper<KpiTimeLimitItemEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(categoryId), "CATEGORY_ID", categoryId);
baseDao.delete(wrapper);
//插入
insert(entity);
}
return new Result();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(KpiTimeLimitItemDTO dto) {
KpiTimeLimitItemEntity entity = ConvertUtils.sourceToTarget(dto, KpiTimeLimitItemEntity.class);
updateById(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}
}

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

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.elink.esua.epdc.dao.KpiTimeLimitItemDao">
<resultMap type="com.elink.esua.epdc.entity.KpiTimeLimitItemEntity" id="kpiTimeLimitItemMap">
<result property="id" column="ID"/>
<result property="validRespondTime" column="VALID_RESPOND_TIME"/>
<result property="validCloseTime" column="VALID_CLOSE_TIME"/>
<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>
Loading…
Cancel
Save