12 changed files with 716 additions and 2 deletions
@ -0,0 +1,102 @@ |
|||||
|
/** |
||||
|
* 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 lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* 绩效考核公式 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2019-11-26 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class KpiFormulaDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 主键 |
||||
|
*/ |
||||
|
private String id; |
||||
|
|
||||
|
/** |
||||
|
* 公式编码 |
||||
|
*/ |
||||
|
private String code; |
||||
|
|
||||
|
/** |
||||
|
* 公式名称 |
||||
|
*/ |
||||
|
private String name; |
||||
|
|
||||
|
/** |
||||
|
* 公式运行方法(Javascript) |
||||
|
*/ |
||||
|
private String formula; |
||||
|
|
||||
|
/** |
||||
|
* 公式参数数量 |
||||
|
*/ |
||||
|
private Integer paramAmount; |
||||
|
|
||||
|
/** |
||||
|
* 公式描述 |
||||
|
*/ |
||||
|
private String description; |
||||
|
|
||||
|
/** |
||||
|
* 备注 |
||||
|
*/ |
||||
|
private String remark; |
||||
|
|
||||
|
/** |
||||
|
* 乐观锁 |
||||
|
*/ |
||||
|
private Integer revision; |
||||
|
|
||||
|
/** |
||||
|
* 创建人 |
||||
|
*/ |
||||
|
private String createdBy; |
||||
|
|
||||
|
/** |
||||
|
* 创建时间 |
||||
|
*/ |
||||
|
private Date createdTime; |
||||
|
|
||||
|
/** |
||||
|
* 更新人 |
||||
|
*/ |
||||
|
private String updatedBy; |
||||
|
|
||||
|
/** |
||||
|
* 更新时间 |
||||
|
*/ |
||||
|
private Date updatedTime; |
||||
|
|
||||
|
/** |
||||
|
* 删除标记 |
||||
|
*/ |
||||
|
private String delFlag; |
||||
|
|
||||
|
} |
@ -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.dto.KpiFormulaDTO; |
||||
|
import com.elink.esua.epdc.excel.KpiFormulaExcel; |
||||
|
import com.elink.esua.epdc.service.KpiFormulaService; |
||||
|
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 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-11-26 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("kpiformula") |
||||
|
public class KpiFormulaController { |
||||
|
|
||||
|
@Autowired |
||||
|
private KpiFormulaService kpiFormulaService; |
||||
|
|
||||
|
@GetMapping("page") |
||||
|
public Result<PageData<KpiFormulaDTO>> page(@RequestParam Map<String, Object> params){ |
||||
|
PageData<KpiFormulaDTO> page = kpiFormulaService.page(params); |
||||
|
return new Result<PageData<KpiFormulaDTO>>().ok(page); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("{id}") |
||||
|
public Result<KpiFormulaDTO> get(@PathVariable("id") String id){ |
||||
|
KpiFormulaDTO data = kpiFormulaService.get(id); |
||||
|
return new Result<KpiFormulaDTO>().ok(data); |
||||
|
} |
||||
|
|
||||
|
@PostMapping |
||||
|
public Result save(@RequestBody KpiFormulaDTO dto){ |
||||
|
//效验数据
|
||||
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
||||
|
//kpiFormulaService.save(dto);
|
||||
|
return kpiFormulaService.saveKpiFormula(dto); |
||||
|
} |
||||
|
|
||||
|
@PutMapping |
||||
|
public Result update(@RequestBody KpiFormulaDTO dto){ |
||||
|
//效验数据
|
||||
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
||||
|
return kpiFormulaService.update(dto); |
||||
|
} |
||||
|
|
||||
|
@DeleteMapping |
||||
|
public Result delete(@RequestBody String[] ids){ |
||||
|
//效验数据
|
||||
|
AssertUtils.isArrayEmpty(ids, "id"); |
||||
|
kpiFormulaService.delete(ids); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("export") |
||||
|
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
||||
|
List<KpiFormulaDTO> list = kpiFormulaService.list(params); |
||||
|
ExcelUtils.exportExcelToTarget(response, null, list, KpiFormulaExcel.class); |
||||
|
} |
||||
|
|
||||
|
} |
@ -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.entity.KpiFormulaEntity; |
||||
|
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
/** |
||||
|
* 绩效考核公式 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2019-11-26 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface KpiFormulaDao extends BaseDao<KpiFormulaEntity> { |
||||
|
|
||||
|
} |
@ -0,0 +1,71 @@ |
|||||
|
/** |
||||
|
* 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-11-26 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper=false) |
||||
|
@TableName("epdc_kpi_formula") |
||||
|
public class KpiFormulaEntity extends BaseEpdcEntity { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 公式编码 |
||||
|
*/ |
||||
|
private String code; |
||||
|
|
||||
|
/** |
||||
|
* 公式名称 |
||||
|
*/ |
||||
|
private String name; |
||||
|
|
||||
|
/** |
||||
|
* 公式运行方法(Javascript) |
||||
|
*/ |
||||
|
private String formula; |
||||
|
|
||||
|
/** |
||||
|
* 公式参数数量 |
||||
|
*/ |
||||
|
private Integer paramAmount; |
||||
|
|
||||
|
/** |
||||
|
* 公式描述 |
||||
|
*/ |
||||
|
private String description; |
||||
|
|
||||
|
/** |
||||
|
* 备注 |
||||
|
*/ |
||||
|
private String remark; |
||||
|
|
||||
|
} |
@ -0,0 +1,74 @@ |
|||||
|
/** |
||||
|
* 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-11-26 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class KpiFormulaExcel { |
||||
|
|
||||
|
@Excel(name = "主键") |
||||
|
private String id; |
||||
|
|
||||
|
@Excel(name = "公式编码") |
||||
|
private String code; |
||||
|
|
||||
|
@Excel(name = "公式名称") |
||||
|
private String name; |
||||
|
|
||||
|
@Excel(name = "公式运行方法(Javascript)") |
||||
|
private String formula; |
||||
|
|
||||
|
@Excel(name = "公式参数数量") |
||||
|
private Integer paramAmount; |
||||
|
|
||||
|
@Excel(name = "公式描述") |
||||
|
private String desc; |
||||
|
|
||||
|
@Excel(name = "备注") |
||||
|
private String remark; |
||||
|
|
||||
|
@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; |
||||
|
|
||||
|
|
||||
|
} |
@ -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-11-26 |
||||
|
*/ |
||||
|
@Component |
||||
|
public class KpiFormulaRedis { |
||||
|
@Autowired |
||||
|
private RedisUtils redisUtils; |
||||
|
|
||||
|
public void delete(Object[] ids) { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public void set(){ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public String get(String id){ |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,106 @@ |
|||||
|
/** |
||||
|
* 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.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.dto.KpiFormulaDTO; |
||||
|
import com.elink.esua.epdc.entity.KpiFormulaEntity; |
||||
|
import com.elink.esua.epdc.commons.mybatis.service.BaseService; |
||||
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 绩效考核公式 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2019-11-26 |
||||
|
*/ |
||||
|
public interface KpiFormulaService extends BaseService<KpiFormulaEntity> { |
||||
|
|
||||
|
/** |
||||
|
* 默认分页 |
||||
|
* |
||||
|
* @param params |
||||
|
* @return PageData<KpiFormulaDTO> |
||||
|
* @author generator |
||||
|
* @date 2019-11-26 |
||||
|
*/ |
||||
|
PageData<KpiFormulaDTO> page(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 默认查询 |
||||
|
* |
||||
|
* @param params |
||||
|
* @return java.util.List<KpiFormulaDTO> |
||||
|
* @author generator |
||||
|
* @date 2019-11-26 |
||||
|
*/ |
||||
|
List<KpiFormulaDTO> list(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 单条查询 |
||||
|
* |
||||
|
* @param id |
||||
|
* @return KpiFormulaDTO |
||||
|
* @author generator |
||||
|
* @date 2019-11-26 |
||||
|
*/ |
||||
|
KpiFormulaDTO get(String id); |
||||
|
|
||||
|
/** |
||||
|
* 默认保存 |
||||
|
* |
||||
|
* @param dto |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2019-11-26 |
||||
|
*/ |
||||
|
void save(KpiFormulaDTO dto); |
||||
|
|
||||
|
/** |
||||
|
* 默认更新 |
||||
|
* |
||||
|
* @param dto |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2019-11-26 |
||||
|
*/ |
||||
|
Result update(KpiFormulaDTO dto); |
||||
|
|
||||
|
/** |
||||
|
* 批量删除 |
||||
|
* |
||||
|
* @param ids |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2019-11-26 |
||||
|
*/ |
||||
|
void delete(String[] ids); |
||||
|
|
||||
|
/** |
||||
|
* @param dto |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @Author yinzuomei |
||||
|
* @Description 新增 |
||||
|
* @Date 2019/11/26 17:14 |
||||
|
**/ |
||||
|
Result saveKpiFormula(KpiFormulaDTO dto); |
||||
|
} |
@ -0,0 +1,165 @@ |
|||||
|
/** |
||||
|
* 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 com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
||||
|
import com.elink.esua.epdc.dao.KpiFormulaDao; |
||||
|
import com.elink.esua.epdc.dto.KpiFormulaDTO; |
||||
|
import com.elink.esua.epdc.entity.KpiFormulaEntity; |
||||
|
import com.elink.esua.epdc.redis.KpiFormulaRedis; |
||||
|
import com.elink.esua.epdc.service.KpiFormulaService; |
||||
|
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 org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import javax.script.Invocable; |
||||
|
import javax.script.ScriptEngine; |
||||
|
import javax.script.ScriptEngineManager; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Arrays; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* 绩效考核公式 |
||||
|
* |
||||
|
* @author qu qu@elink-cn.com |
||||
|
* @since v1.0.0 2019-11-26 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class KpiFormulaServiceImpl extends BaseServiceImpl<KpiFormulaDao, KpiFormulaEntity> implements KpiFormulaService { |
||||
|
|
||||
|
@Autowired |
||||
|
private KpiFormulaRedis kpiFormulaRedis; |
||||
|
|
||||
|
@Override |
||||
|
public PageData<KpiFormulaDTO> page(Map<String, Object> params) { |
||||
|
QueryWrapper<KpiFormulaEntity> wrapper=new QueryWrapper<>(); |
||||
|
String name =(String)params.get(FieldConstant.NAME_HUMP); |
||||
|
wrapper.like(StringUtils.isNotBlank(name),FieldConstant.NAME,name); |
||||
|
|
||||
|
IPage<KpiFormulaEntity> page = baseDao.selectPage( |
||||
|
getPage(params, FieldConstant.CREATED_TIME, false), |
||||
|
wrapper |
||||
|
); |
||||
|
return getPageData(page, KpiFormulaDTO.class); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<KpiFormulaDTO> list(Map<String, Object> params) { |
||||
|
List<KpiFormulaEntity> entityList = baseDao.selectList(getWrapper(params)); |
||||
|
|
||||
|
return ConvertUtils.sourceToTarget(entityList, KpiFormulaDTO.class); |
||||
|
} |
||||
|
|
||||
|
private QueryWrapper<KpiFormulaEntity> getWrapper(Map<String, Object> params){ |
||||
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
||||
|
QueryWrapper<KpiFormulaEntity> wrapper = new QueryWrapper<>(); |
||||
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
||||
|
return wrapper; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public KpiFormulaDTO get(String id) { |
||||
|
KpiFormulaEntity entity = baseDao.selectById(id); |
||||
|
return ConvertUtils.sourceToTarget(entity, KpiFormulaDTO.class); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void save(KpiFormulaDTO dto) { |
||||
|
KpiFormulaEntity entity = ConvertUtils.sourceToTarget(dto, KpiFormulaEntity.class); |
||||
|
insert(entity); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public Result update(KpiFormulaDTO dto) { |
||||
|
try{ |
||||
|
if(StringUtils.isNotBlank(dto.getFormula())){ |
||||
|
//获得一个javascipt的执行引擎
|
||||
|
ScriptEngine engine = new ScriptEngineManager().getEngineByName("javascript"); |
||||
|
//执行js代码
|
||||
|
engine.eval(dto.getFormula()); |
||||
|
//是否可调用方法
|
||||
|
boolean flag=engine instanceof Invocable; |
||||
|
if(!flag){ |
||||
|
return new Result().error("运行方法异常"); |
||||
|
} |
||||
|
// else{
|
||||
|
// Invocable in = (Invocable)engine;
|
||||
|
// //执行js中的函数
|
||||
|
// Double result=(Double) in.invokeFunction(dto.getCode(), 5,2);
|
||||
|
// //打印出调用方法的结果:
|
||||
|
// System.out.println("的运算结果是:"+result);
|
||||
|
// }
|
||||
|
} |
||||
|
}catch(Exception e){ |
||||
|
e.printStackTrace(); |
||||
|
return new Result().error("运行方法异常"+e.getMessage()); |
||||
|
} |
||||
|
KpiFormulaEntity entity = ConvertUtils.sourceToTarget(dto, KpiFormulaEntity.class); |
||||
|
updateById(entity); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void delete(String[] ids) { |
||||
|
// 逻辑删除(@TableLogic 注解)
|
||||
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @param dto |
||||
|
* @return com.elink.esua.epdc.commons.tools.utils.Result |
||||
|
* @Author yinzuomei |
||||
|
* @Description 新增 |
||||
|
* @Date 2019/11/26 17:14 |
||||
|
**/ |
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public Result saveKpiFormula(KpiFormulaDTO dto) { |
||||
|
try{ |
||||
|
if(StringUtils.isNotBlank(dto.getFormula())){ |
||||
|
//获得一个javascipt的执行引擎
|
||||
|
ScriptEngine engine = new ScriptEngineManager().getEngineByName("javascript"); |
||||
|
//执行js代码
|
||||
|
engine.eval(dto.getFormula()); |
||||
|
//是否可调用方法
|
||||
|
boolean flag=engine instanceof Invocable; |
||||
|
if(!flag){ |
||||
|
return new Result().error("运行方法异常"); |
||||
|
} |
||||
|
} |
||||
|
}catch(Exception e){ |
||||
|
return new Result().error("运行方法异常"+e.getMessage()); |
||||
|
} |
||||
|
KpiFormulaEntity entity = ConvertUtils.sourceToTarget(dto, KpiFormulaEntity.class); |
||||
|
insert(entity); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,23 @@ |
|||||
|
<?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.KpiFormulaDao"> |
||||
|
|
||||
|
<resultMap type="com.elink.esua.epdc.entity.KpiFormulaEntity" id="kpiFormulaMap"> |
||||
|
<result property="id" column="ID"/> |
||||
|
<result property="code" column="CODE"/> |
||||
|
<result property="name" column="NAME"/> |
||||
|
<result property="formula" column="FORMULA"/> |
||||
|
<result property="paramAmount" column="PARAM_AMOUNT"/> |
||||
|
<result property="description" column="DESCRIPTION"/> |
||||
|
<result property="remark" column="REMARK"/> |
||||
|
<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…
Reference in new issue