Commit d1690f64 authored by zhuxiang's avatar zhuxiang
Browse files

联调优化,绩效分计算开发完成

parent ac8609a1
<?xml version="1.0" encoding="UTF-8"?>
<!--
This is the JRebel configuration file. It maps the running application to your IDE workspace, enabling JRebel reloading for this project.
Refer to https://manuals.jrebel.com/jrebel/standalone/config.html for more information.
-->
<application generated-by="intellij" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_3.xsd">
<id>sms</id>
<classpath>
<dir name="D:/Xiang/Java_project/OA/target/classes">
</dir>
</classpath>
</application>
...@@ -12,7 +12,6 @@ import org.springframework.scheduling.annotation.EnableScheduling; ...@@ -12,7 +12,6 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@EnableScheduling @EnableScheduling
@ServletComponentScan @ServletComponentScan
public class SmsApplication { public class SmsApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(SmsApplication.class, args); SpringApplication.run(SmsApplication.class, args);
} }
......
...@@ -36,13 +36,13 @@ public class ReportDataInfoController extends BaseController { ...@@ -36,13 +36,13 @@ public class ReportDataInfoController extends BaseController {
private ReportDataInfoService reportDataInfoService; private ReportDataInfoService reportDataInfoService;
@PostMapping("/page") @PostMapping("/page")
public TableDataInfo page(@RequestBody ReportDataInfoDTO reportDataInfoDTO){ public TableDataInfo page(@RequestBody ReportDataInfoDTO reportDataInfoDTO) {
UserEntity user = userService.getById(reportDataInfoDTO.getLoginUserId()); UserEntity user = userService.getById(reportDataInfoDTO.getLoginUserId());
startPage(reportDataInfoDTO.getPageNum(),reportDataInfoDTO.getPageSize()); startPage(reportDataInfoDTO.getPageNum(), reportDataInfoDTO.getPageSize());
if(user.getUserRole().equals(Constant.ADMIN)){ if (user.getUserRole().equals(Constant.ADMIN)) {
return getDataTable(reportDataInfoService.queryList(reportDataInfoDTO)); return getDataTable(reportDataInfoService.queryList(reportDataInfoDTO));
} }
if(user.getUserRole().equals(Constant.D_ADMIN)){ if (user.getUserRole().equals(Constant.D_ADMIN)) {
reportDataInfoDTO.setDeptId(user.getDeptId()); reportDataInfoDTO.setDeptId(user.getDeptId());
return getDataTable(reportDataInfoService.queryList(reportDataInfoDTO)); return getDataTable(reportDataInfoService.queryList(reportDataInfoDTO));
} }
...@@ -51,17 +51,22 @@ public class ReportDataInfoController extends BaseController { ...@@ -51,17 +51,22 @@ public class ReportDataInfoController extends BaseController {
} }
@GetMapping("/{id}") @GetMapping("/{id}")
public Result<ReportDataInfoVO> getInfo(@PathVariable String id){ public Result<ReportDataInfoVO> getInfo(@PathVariable String id) {
return Result.data(DozerUtils.convertBean(reportDataInfoService.getById(id),ReportDataInfoVO.class)); return Result.data(DozerUtils.convertBean(reportDataInfoService.getById(id), ReportDataInfoVO.class));
} }
@PostMapping("/saveOrUpdate") @PostMapping("/saveOrUpdate")
public Result saveOrUpdate(@RequestBody ReportDataInfoDTO reportDataInfoDTO){ public Result saveOrUpdate(@RequestBody ReportDataInfoDTO reportDataInfoDTO) {
return toAjax(reportDataInfoService.saveOrUpdateReportData(reportDataInfoDTO)); return toAjax(reportDataInfoService.saveOrUpdateReportData(reportDataInfoDTO));
} }
@DeleteMapping("/{id}")
public Result delete(@PathVariable String id) {
return toAjax(reportDataInfoService.removeById(id));
}
@GetMapping("/test") @GetMapping("/test")
public void test(){ public void test() {
reportDataInfoService.test(); reportDataInfoService.test();
} }
......
...@@ -28,18 +28,23 @@ public class ReportTemplateController extends BaseController { ...@@ -28,18 +28,23 @@ public class ReportTemplateController extends BaseController {
private ReportTemplateService reportTemplateService; private ReportTemplateService reportTemplateService;
@PostMapping("/page") @PostMapping("/page")
public TableDataInfo page(@RequestBody ReportTemplateDTO reportTemplateDTO){ public TableDataInfo page(@RequestBody ReportTemplateDTO reportTemplateDTO) {
startPage(reportTemplateDTO.getPageNum(),reportTemplateDTO.getPageSize()); startPage(reportTemplateDTO.getPageNum(), reportTemplateDTO.getPageSize());
return getDataTable(reportTemplateService.queryList(reportTemplateDTO)); return getDataTable(reportTemplateService.queryList(reportTemplateDTO));
} }
@PostMapping("/saveOrUpdate") @PostMapping("/saveOrUpdate")
public Result saveOrUpdate(@RequestBody ReportTemplateDTO reportTemplateDTO){ public Result saveOrUpdate(@RequestBody ReportTemplateDTO reportTemplateDTO) {
return toAjax(reportTemplateService.saveOrUpdate(reportTemplateDTO)); return toAjax(reportTemplateService.saveOrUpdate(reportTemplateDTO));
} }
@GetMapping("/{id}") @GetMapping("/{id}")
public Result<ReportTemplateEntity> getInfo(@PathVariable String id){ public Result<ReportTemplateEntity> getInfo(@PathVariable String id) {
return Result.data(reportTemplateService.getById(id)); return Result.data(reportTemplateService.getById(id));
} }
@DeleteMapping("/{id}")
public Result delete(@PathVariable String id) {
return toAjax(reportTemplateService.removeById(id));
}
} }
...@@ -18,7 +18,7 @@ import lombok.Data; ...@@ -18,7 +18,7 @@ import lombok.Data;
@TableName("report_data_info") @TableName("report_data_info")
public class ReportDataInfoEntity { public class ReportDataInfoEntity {
@TableId(value = "id",type = IdType.ASSIGN_ID) @TableId(value = "id", type = IdType.ASSIGN_ID)
private String id; private String id;
@TableField("key_value") @TableField("key_value")
...@@ -44,4 +44,7 @@ public class ReportDataInfoEntity { ...@@ -44,4 +44,7 @@ public class ReportDataInfoEntity {
@TableField("dept_id") @TableField("dept_id")
private String deptId; private String deptId;
@TableField("status")
private String status;
} }
...@@ -18,7 +18,7 @@ import lombok.Data; ...@@ -18,7 +18,7 @@ import lombok.Data;
@TableName("user_performance") @TableName("user_performance")
public class UserPerformanceEntity { public class UserPerformanceEntity {
@TableId(value = "id",type = IdType.ASSIGN_ID) @TableId(value = "id", type = IdType.ASSIGN_ID)
private String id; private String id;
@TableField("user_id") @TableField("user_id")
...@@ -33,4 +33,12 @@ public class UserPerformanceEntity { ...@@ -33,4 +33,12 @@ public class UserPerformanceEntity {
@TableField("dept_id") @TableField("dept_id")
private String deptId; private String deptId;
public void setPerformanceDate(int year, int month) {
if (month < 10) {
this.performanceDate = year + "-0" + month;
} else {
this.performanceDate = year + "-" + month;
}
}
} }
...@@ -15,4 +15,6 @@ import lombok.EqualsAndHashCode; ...@@ -15,4 +15,6 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Data @Data
public class DeptVO extends DeptEntity { public class DeptVO extends DeptEntity {
private String deptAdminName;
} }
...@@ -2,17 +2,22 @@ package com.ruzhoukj.sms.service.impl; ...@@ -2,17 +2,22 @@ package com.ruzhoukj.sms.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.utils.StringUtils;
import com.ruzhoukj.sms.dao.ReportDataInfoDao; import com.ruzhoukj.sms.dao.ReportDataInfoDao;
import com.ruzhoukj.sms.entity.ReportDataInfoEntity; import com.ruzhoukj.sms.entity.ReportDataInfoEntity;
import com.ruzhoukj.sms.entity.UserEntity; import com.ruzhoukj.sms.entity.UserEntity;
import com.ruzhoukj.sms.entity.UserPerformanceEntity;
import com.ruzhoukj.sms.model.dto.ReportDataInfoDTO; import com.ruzhoukj.sms.model.dto.ReportDataInfoDTO;
import com.ruzhoukj.sms.model.vo.ReportDataInfoVO; import com.ruzhoukj.sms.model.vo.ReportDataInfoVO;
import com.ruzhoukj.sms.service.ReportDataInfoService; import com.ruzhoukj.sms.service.ReportDataInfoService;
import com.ruzhoukj.sms.service.UserPerformanceService;
import com.ruzhoukj.sms.service.UserService; import com.ruzhoukj.sms.service.UserService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
/** /**
...@@ -28,6 +33,9 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re ...@@ -28,6 +33,9 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
@Resource @Resource
private UserService userService; private UserService userService;
@Resource
private UserPerformanceService userPerformanceService;
@Override @Override
public List<ReportDataInfoVO> queryList(ReportDataInfoDTO reportDataInfoDTO) { public List<ReportDataInfoVO> queryList(ReportDataInfoDTO reportDataInfoDTO) {
return baseMapper.queryList(reportDataInfoDTO); return baseMapper.queryList(reportDataInfoDTO);
...@@ -35,30 +43,72 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re ...@@ -35,30 +43,72 @@ public class ReportDataInfoServiceImpl extends ServiceImpl<ReportDataInfoDao, Re
@Override @Override
public void test() { public void test() {
ReportDataInfoEntity reportDataInfoEntity = getById(1); ReportDataInfoEntity reportDataInfoEntity = getById("1893947910320414721");
String content = reportDataInfoEntity.getContent(); String content = reportDataInfoEntity.getAllContent();
//解析json
//污水处理量 // 解析JSON字符串为JSONArray
JSONArray a = null; JSONArray jsonArray = JSONArray.parseArray(content);
JSONArray b = null;
String e = null;
try {
a = JSON.parseArray(content);
b = (JSONArray) a.get(3);
JSONArray c = (JSONArray) b.get(0);
System.out.println(b);
// JSONObject d = c.getJSONObject(column);
// e = d.getString("m");
} catch (Exception ex) {
// 获取第一个元素(假设第一个元素是Sheet1的数据)
if (jsonArray.size() > 0) {
JSONObject jsonObject = jsonArray.getJSONObject(0);
// 获取Sheet1中的data数组
JSONArray data = jsonObject.getJSONArray("data");
double totalScore = 0;
// 遍历data数组,从第6行开始
for (int i = 5; i < data.size(); i++) {
JSONArray row = data.getJSONArray(i);
//权重
if (row.getJSONObject(6).containsKey("v")) {
double weight = row.getJSONObject(6).getDouble("v");
int selfScore = row.getJSONObject(8).getIntValue("v");
int leaderScore = row.getJSONObject(9).getIntValue("v");
int adminScore = row.getJSONObject(10).getIntValue("v");
//计算每行的分数
double rowScore = countRowScore(weight, selfScore, leaderScore, adminScore);
totalScore = totalScore + rowScore;
}
JSONObject subjoin = row.getJSONObject(0);
String subjoinStr = subjoin.getString("v");
if (StringUtils.isNotEmpty(subjoinStr) && subjoinStr.contains("附加考核")) {
break;
} }
} }
//更新用户绩效分
UserPerformanceEntity userPerformanceEntity = new UserPerformanceEntity();
userPerformanceEntity.setUserId(reportDataInfoEntity.getUserId());
userPerformanceEntity.setPerformanceDate(reportDataInfoEntity.getYear(), reportDataInfoEntity.getMonth());
String formattedScore = String.format("%.2f", totalScore);
userPerformanceEntity.setPerformanceScore(formattedScore);
userPerformanceEntity.setDeptId(reportDataInfoEntity.getDeptId());
userPerformanceService.save(userPerformanceEntity);
reportDataInfoEntity.setStatus("4");
} else {
System.out.println("No data available in the JSON array.");
}
}
/**
* 计算每行的分数
*
* @param weight 权重
* @param selfScore 自评
* @param leaderScore 主管评价
* @param adminScore 总经理评价
* @return BigDecimal
*/
private double countRowScore(double weight, int selfScore, int leaderScore, int adminScore) {
return (selfScore * weight * 0.2) + (leaderScore * weight * 0.4) + (adminScore * weight * 0.4);
}
@Override @Override
public boolean saveOrUpdateReportData(ReportDataInfoDTO reportDataInfoDTO) { public boolean saveOrUpdateReportData(ReportDataInfoDTO reportDataInfoDTO) {
//查看当前用户所属部门 //查看当前用户所属部门
UserEntity user = userService.getById(reportDataInfoDTO.getLoginUserId()); UserEntity user = userService.getById(reportDataInfoDTO.getLoginUserId());
reportDataInfoDTO.setDeptId(user.getDeptId()); reportDataInfoDTO.setDeptId(user.getDeptId());
reportDataInfoDTO.setUserId(user.getId());
return saveOrUpdate(reportDataInfoDTO); return saveOrUpdate(reportDataInfoDTO);
} }
} }
...@@ -27,6 +27,7 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements ...@@ -27,6 +27,7 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
@Resource @Resource
private UserExtendService userExtendService; private UserExtendService userExtendService;
@Override @Override
public List<UserEntity> getUserList(String name, Integer page, Integer pageSize) { public List<UserEntity> getUserList(String name, Integer page, Integer pageSize) {
return baseMapper.getUserList(name, page, pageSize); return baseMapper.getUserList(name, page, pageSize);
...@@ -45,8 +46,9 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements ...@@ -45,8 +46,9 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void saveUser(UserDTO user) { public void saveUser(UserDTO user) {
if(save(user)){ if (save(user)) {
UserExtend userExtend = user.getUserExtend(); UserExtend userExtend = user.getUserExtend();
userExtend.setUserId(user.getId());
//保存用户扩展信息 //保存用户扩展信息
userExtendService.save(userExtend); userExtendService.save(userExtend);
} }
...@@ -54,24 +56,28 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements ...@@ -54,24 +56,28 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
@Override @Override
public void updateUser(UserDTO user) { public void updateUser(UserDTO user) {
if(updateById(user)){ if (updateById(user)) {
UserExtend userExtend = user.getUserExtend(); UserExtend userExtend = user.getUserExtend();
//查看用户扩展信息
UserExtend userExtendOld = userExtendService.getbyUserId(user.getId());
//保存用户扩展信息 //保存用户扩展信息
userExtendService.updateById(userExtend); userExtend.setId(userExtendOld.getId());
userExtend.setUserId(userExtendOld.getUserId());
userExtendService.saveOrUpdate(userExtend);
} }
} }
@Override @Override
public void removeUser(String id) { public void removeUser(String id) {
if(removeById(id)){ if (removeById(id)) {
userExtendService.removeByUserId(id); userExtendService.removeByUserId(id);
} }
} }
@Override @Override
public UserVO getUserInfo(String id) { public UserVO getUserInfo(String id) {
UserVO userVO = DozerUtils.convertBean(getById(id),UserVO.class); UserVO userVO = DozerUtils.convertBean(getById(id), UserVO.class);
if(userVO == null){ if (userVO == null) {
throw new BusinessException("用户ID有误"); throw new BusinessException("用户ID有误");
} }
UserExtend userExtend = userExtendService.getbyUserId(id); UserExtend userExtend = userExtendService.getbyUserId(id);
......
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
r.year year, r.year year,
r.month month, r.month month,
r.key_value keyValue, r.key_value keyValue,
u.name userName u.name userName,
r.status status
from from
report_data_info r report_data_info r
left join left join
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment