From 3000e5013486abe6d58dfe24dbe4948bef4889cd Mon Sep 17 00:00:00 2001 From: zhangyongzhangyong <2012005003@qq.coom> Date: Mon, 23 Dec 2019 15:42:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=BA=E7=9B=B4=E8=A1=97=E9=81=93=E6=80=BB?= =?UTF-8?q?=E8=A7=84=E5=88=99=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../esua/epdc/dto/KpiResultSuperiorDTO.java | 122 ++++++++++++++++ .../KpiResultSuperiorController.java | 94 ++++++++++++ .../esua/epdc/dao/KpiResultSuperiorDao.java | 33 +++++ .../epdc/entity/KpiResultSuperiorEntity.java | 92 ++++++++++++ .../epdc/excel/KpiResultSuperiorExcel.java | 87 ++++++++++++ .../epdc/redis/KpiResultSuperiorRedis.java | 47 ++++++ .../service/KpiResultSuperiorService.java | 95 +++++++++++++ .../impl/KpiResultSuperiorServiceImpl.java | 104 ++++++++++++++ .../epdc/service/impl/KpiRuleServiceImpl.java | 134 ++++++++++++++++++ .../resources/mapper/KpiResultSuperiorDao.xml | 27 ++++ 10 files changed, 835 insertions(+) create mode 100644 esua-epdc/epdc-module/epdc-kpi/epdc-kpi-client/src/main/java/com/elink/esua/epdc/dto/KpiResultSuperiorDTO.java create mode 100644 esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/controller/KpiResultSuperiorController.java create mode 100644 esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/dao/KpiResultSuperiorDao.java create mode 100644 esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/entity/KpiResultSuperiorEntity.java create mode 100644 esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/excel/KpiResultSuperiorExcel.java create mode 100644 esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/redis/KpiResultSuperiorRedis.java create mode 100644 esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/KpiResultSuperiorService.java create mode 100644 esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/impl/KpiResultSuperiorServiceImpl.java create mode 100644 esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/resources/mapper/KpiResultSuperiorDao.xml diff --git a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-client/src/main/java/com/elink/esua/epdc/dto/KpiResultSuperiorDTO.java b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-client/src/main/java/com/elink/esua/epdc/dto/KpiResultSuperiorDTO.java new file mode 100644 index 000000000..aea4416ff --- /dev/null +++ b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-client/src/main/java/com/elink/esua/epdc/dto/KpiResultSuperiorDTO.java @@ -0,0 +1,122 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 街道或区直绩效考核最终得分 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-12-23 + */ +@Data +public class KpiResultSuperiorDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 网格ID + */ + private Long deptId; + + /** + * 最终得分 + */ + private BigDecimal finalScore; + + /** + * 考核周期开始日 + */ + private Date startDate; + + /** + * 考核周期结束日 + */ + private Date endDate; + + /** + * 考核周期(字典值 代表月,季,年) + */ + private String kpiCycle; + + /** + * 机构类别 + */ + private String deptTypeKey; + + /** + * 所有上级机构id + */ + private String parentDeptIds; + + /** + * 所有上级机构名称 + */ + private String parentDeptNames; + + /** + * 所有机构id + */ + private String allDeptIds; + + /** + * 所有机构名称 + */ + private String allDeptNames; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + + /** + * 删除标记 + */ + private String delFlag; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/controller/KpiResultSuperiorController.java b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/controller/KpiResultSuperiorController.java new file mode 100644 index 000000000..0e50d7ba2 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/controller/KpiResultSuperiorController.java @@ -0,0 +1,94 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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.KpiResultSuperiorDTO; +import com.elink.esua.epdc.excel.KpiResultSuperiorExcel; +import com.elink.esua.epdc.service.KpiResultSuperiorService; +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-23 + */ +@RestController +@RequestMapping("kpiresultsuperior") +public class KpiResultSuperiorController { + + @Autowired + private KpiResultSuperiorService kpiResultSuperiorService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = kpiResultSuperiorService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + KpiResultSuperiorDTO data = kpiResultSuperiorService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody KpiResultSuperiorDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + kpiResultSuperiorService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody KpiResultSuperiorDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + kpiResultSuperiorService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + kpiResultSuperiorService.delete(ids); + return new Result(); + } + + @GetMapping("export") + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = kpiResultSuperiorService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, KpiResultSuperiorExcel.class); + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/dao/KpiResultSuperiorDao.java b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/dao/KpiResultSuperiorDao.java new file mode 100644 index 000000000..ec45c44e5 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/dao/KpiResultSuperiorDao.java @@ -0,0 +1,33 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.dao; + +import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; +import com.elink.esua.epdc.entity.KpiResultSuperiorEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 街道或区直绩效考核最终得分 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-12-23 + */ +@Mapper +public interface KpiResultSuperiorDao extends BaseDao { + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/entity/KpiResultSuperiorEntity.java b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/entity/KpiResultSuperiorEntity.java new file mode 100644 index 000000000..2cb59ee29 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/entity/KpiResultSuperiorEntity.java @@ -0,0 +1,92 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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.math.BigDecimal; +import java.util.Date; + +/** + * 街道或区直绩效考核最终得分 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-12-23 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("epdc_kpi_result_superior") +public class KpiResultSuperiorEntity extends BaseEpdcEntity { + + private static final long serialVersionUID = 1L; + + /** + * 网格ID + */ + private Long deptId; + + /** + * 最终得分 + */ + private BigDecimal finalScore; + + /** + * 考核周期开始日 + */ + private Date startDate; + + /** + * 考核周期结束日 + */ + private Date endDate; + + /** + * 考核周期(字典值 代表月,季,年) + */ + private String kpiCycle; + + /** + * 机构类别 + */ + private String deptTypeKey; + + /** + * 所有上级机构id + */ + private String parentDeptIds; + + /** + * 所有上级机构名称 + */ + private String parentDeptNames; + + /** + * 所有机构id + */ + private String allDeptIds; + + /** + * 所有机构名称 + */ + private String allDeptNames; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/excel/KpiResultSuperiorExcel.java b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/excel/KpiResultSuperiorExcel.java new file mode 100644 index 000000000..6e41e586c --- /dev/null +++ b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/excel/KpiResultSuperiorExcel.java @@ -0,0 +1,87 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 街道或区直绩效考核最终得分 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-12-23 + */ +@Data +public class KpiResultSuperiorExcel { + + @Excel(name = "主键") + private String id; + + @Excel(name = "网格ID") + private Long deptId; + + @Excel(name = "最终得分") + private BigDecimal finalScore; + + @Excel(name = "考核周期开始日") + private Date startDate; + + @Excel(name = "考核周期结束日") + private Date endDate; + + @Excel(name = "考核周期(字典值 代表月,季,年)") + private String kpiCycle; + + @Excel(name = "机构类别") + private String deptTypeKey; + + @Excel(name = "所有上级机构id") + private String parentDeptIds; + + @Excel(name = "所有上级机构名称") + private String parentDeptNames; + + @Excel(name = "所有机构id") + private String allDeptIds; + + @Excel(name = "所有机构名称") + private String allDeptNames; + + @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; + + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/redis/KpiResultSuperiorRedis.java b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/redis/KpiResultSuperiorRedis.java new file mode 100644 index 000000000..2cd65460f --- /dev/null +++ b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/redis/KpiResultSuperiorRedis.java @@ -0,0 +1,47 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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-23 + */ +@Component +public class KpiResultSuperiorRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/KpiResultSuperiorService.java b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/KpiResultSuperiorService.java new file mode 100644 index 000000000..f639c1fa4 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/KpiResultSuperiorService.java @@ -0,0 +1,95 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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.dto.KpiResultSuperiorDTO; +import com.elink.esua.epdc.entity.KpiResultSuperiorEntity; + +import java.util.List; +import java.util.Map; + +/** + * 街道或区直绩效考核最终得分 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-12-23 + */ +public interface KpiResultSuperiorService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2019-12-23 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2019-12-23 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return KpiResultSuperiorDTO + * @author generator + * @date 2019-12-23 + */ + KpiResultSuperiorDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2019-12-23 + */ + void save(KpiResultSuperiorDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2019-12-23 + */ + void update(KpiResultSuperiorDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2019-12-23 + */ + void delete(String[] ids); +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/impl/KpiResultSuperiorServiceImpl.java b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/impl/KpiResultSuperiorServiceImpl.java new file mode 100644 index 000000000..caf51dbea --- /dev/null +++ b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/impl/KpiResultSuperiorServiceImpl.java @@ -0,0 +1,104 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.elink.esua.epdc.service.impl; + +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.dao.KpiResultSuperiorDao; +import com.elink.esua.epdc.dto.KpiResultSuperiorDTO; +import com.elink.esua.epdc.entity.KpiResultSuperiorEntity; +import com.elink.esua.epdc.redis.KpiResultSuperiorRedis; +import com.elink.esua.epdc.service.KpiResultSuperiorService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 街道或区直绩效考核最终得分 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2019-12-23 + */ +@Service +public class KpiResultSuperiorServiceImpl extends BaseServiceImpl implements KpiResultSuperiorService { + + @Autowired + private KpiResultSuperiorRedis kpiResultSuperiorRedis; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, KpiResultSuperiorDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, KpiResultSuperiorDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public KpiResultSuperiorDTO get(String id) { + KpiResultSuperiorEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, KpiResultSuperiorDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(KpiResultSuperiorDTO dto) { + KpiResultSuperiorEntity entity = ConvertUtils.sourceToTarget(dto, KpiResultSuperiorEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(KpiResultSuperiorDTO dto) { + KpiResultSuperiorEntity entity = ConvertUtils.sourceToTarget(dto, KpiResultSuperiorEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/impl/KpiRuleServiceImpl.java b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/impl/KpiRuleServiceImpl.java index 15ec4c102..a7e4e9bc9 100644 --- a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/impl/KpiRuleServiceImpl.java +++ b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/impl/KpiRuleServiceImpl.java @@ -82,6 +82,9 @@ public class KpiRuleServiceImpl extends BaseServiceImpl page(Map params) { @@ -289,6 +292,8 @@ public class KpiRuleServiceImpl extends BaseServiceImpl ruleParamList = kpiRuleParamDao.queryFormulaParam(kpiRuleDTO.getId()); + List metaDateCodeList = Lists.newArrayList(); + for (int i = 0; i < ruleParamList.size(); i++) { + metaDateCodeList.add(ruleParamList.get(i).getMetaDataCode()); + } + //区 考核最终得分计算 + this.assessmentScoreCalculation(kpiRuleDTO.getReferenceId(), + kpiResultSuperiorEntity.getStartDate(),kpiResultSuperiorEntity.getEndDate(), + metaDateCodeList,OrganizationTypeConstant.ORG_TYPE_DISTRICT_DEPT,kpiCycle); + + //街区 考核最终得分计算 + this.assessmentScoreCalculation(kpiRuleDTO.getReferenceId(), + kpiResultSuperiorEntity.getStartDate(),kpiResultSuperiorEntity.getEndDate(), + metaDateCodeList,OrganizationTypeConstant.ORG_TYPE_STREET_DEPT,kpiCycle); + return new Result(); + } + + /** + * @Description: 根据 区直/街道考核最终得分 JS函数,得出总数 + * @Param: [referenceId] 考核规则表:公式ID + * metaDateCodeList 公式参数表:元数据编码 + * startDate 考核开始时间 + * endDate 考核结束时间 + * typeKey 部门类型 + * String kpiCycle 考核周期 + * @return: BigDecimal + * @Author: zy + * @Date: 2019-12-23 + */ + public Result assessmentScoreCalculation(String referenceId,Date startDate, Date endDate,List metaDateCodeList,String typeKey,String kpiCycle){ + // 根据 考核规则表-外键(公式id),查询绩效考核公式表,待运行公式方法 + KpiFormulaDTO kpiFormulaDTO = kpiFormulaDao.queryFormula(referenceId); + + int pageSize = NumConstant.THIRTY; + int pageIndex = NumConstant.ONE; + + List deptIdList = deptUtils.getDeptIdList(typeKey, pageSize, pageIndex); + do { + + for (Long deptId : deptIdList) { + BigDecimal[] paramValue = selectArrayOfMetaDate(deptId, startDate, endDate, metaDateCodeList); + //参数准备完全时,执行js运算 + if (paramValue.length == kpiFormulaDTO.getParamAmount()) { + BigDecimal calculationScore; + + Result score = this.runJavaScriptFunction(kpiFormulaDTO,paramValue); + calculationScore = score.getData(); + //插入到:街道或区直绩效考核最终得分表 + DeptLevelAndLeaderDTO deptLevelInfo = deptUtils.getDeptLevelInfo(deptId, YesOrNoEnum.YES); + KpiResultSuperiorEntity kpiResultSuperiorEntity = new KpiResultSuperiorEntity(); + kpiResultSuperiorEntity.setStartDate(startDate); + kpiResultSuperiorEntity.setEndDate(endDate); + kpiResultSuperiorEntity.setKpiCycle(kpiCycle); + kpiResultSuperiorEntity.setFinalScore(calculationScore); + kpiResultSuperiorEntity.setDeptId(deptId); + kpiResultSuperiorEntity.setDeptTypeKey(typeKey); + kpiResultSuperiorEntity.setParentDeptIds(deptLevelInfo.getParentDeptIds()); + kpiResultSuperiorEntity.setParentDeptNames(deptLevelInfo.getParentDeptNames()); + kpiResultSuperiorEntity.setAllDeptIds(deptLevelInfo.getAllDeptIds()); + kpiResultSuperiorEntity.setAllDeptNames(deptLevelInfo.getAllDeptNames()); + kpiResultSuperiorDao.insert(kpiResultSuperiorEntity); + } + } + pageIndex++; + deptIdList = deptUtils.getDeptIdList(typeKey, pageSize, pageIndex); + } while (CollUtil.isNotEmpty(deptIdList)); + return new Result(); + } + + /** + * @Description: js函数运行 + * @Param: [kpiFormulaDTO, paramValue] + * @return: com.elink.esua.epdc.commons.tools.utils.Result + * @Author: zy + * @Date: 2019-12-23 + */ + public Result runJavaScriptFunction(KpiFormulaDTO kpiFormulaDTO,BigDecimal[] paramValue){ + BigDecimal calculationScore = new BigDecimal(0); + try { + //获得一个javascipt的执行引擎 + ScriptEngine engine = new ScriptEngineManager().getEngineByName("javascript"); + //执行js代码:参数为:公式运行方法 + engine.eval(kpiFormulaDTO.getFormula()); + //是否可调用方法 + boolean flag = engine instanceof Invocable; + if (!flag) { + return new Result().error("运行方法异常"); + } + Invocable in = (Invocable) engine; + //执行js中的函数 参数:js方法名 + 参数 + Double result = (Double) in.invokeFunction(kpiFormulaDTO.getFunctionName(), paramValue); + Double workScoreDoouble = (double) Math.round(result * 100) / 100; + calculationScore = new BigDecimal(workScoreDoouble); + } catch (Exception e) { + e.printStackTrace(); + return new Result().error("运行方法异常" + e.getMessage()); + } + return new Result().ok(calculationScore); + } + } diff --git a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/resources/mapper/KpiResultSuperiorDao.xml b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/resources/mapper/KpiResultSuperiorDao.xml new file mode 100644 index 000000000..ebf30d163 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/resources/mapper/KpiResultSuperiorDao.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file