This commit is contained in:
杜建超 2020-09-14 17:42:37 +08:00
parent 8871de88b3
commit 3cb75b0b50
11 changed files with 210 additions and 2 deletions

View File

@ -1,17 +1,29 @@
package com.lz.modules.app.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lz.common.utils.R;
import com.lz.modules.app.dto.DepartmentsDto;
import com.lz.modules.app.dto.ResultProgressDto;
import com.lz.modules.app.entity.DepartmentsStaffRelateEntity;
import com.lz.modules.app.entity.StaffEntity;
import com.lz.modules.app.enums.ResultRecordStatusEnum;
import com.lz.modules.app.resp.OwnResultResp;
import com.lz.modules.app.resp.ReportChartResp;
import com.lz.modules.app.service.DepartmentsService;
import com.lz.modules.app.service.DepartmentsStaffRelateService;
import com.lz.modules.app.service.StaffService;
import com.lz.modules.sys.controller.AbstractController;
import com.lz.modules.sys.entity.app.ResultRecord;
import com.lz.modules.sys.service.app.ChartService;
import com.lz.modules.sys.service.app.ResultRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
@ -28,6 +40,29 @@ public class ReportResultController extends AbstractController{
private DepartmentsStaffRelateService departmentsStaffRelateService;
@Autowired
private DepartmentsService departmentsService;
@Autowired
private StaffService staffService;
@Autowired
private ChartService chartService;
@RequestMapping("chart")
public R reportChart(String monthTime){
ReportChartResp data = new ReportChartResp();
ResultProgressDto target = chartService.resultProgress(1,monthTime);
ResultProgressDto result = chartService.resultProgress(2,monthTime);
//人员等级分布
//部门等级占比
data.setTarget(target);
data.setResult(result);
return R.ok();
}
@RequestMapping("/own/result")
@ -44,8 +79,59 @@ public class ReportResultController extends AbstractController{
@RequestMapping("/team/result")
public R teamResult(){
return R.ok();
}
//是在这个地方查询出所有的部门选择 还是 通过关键字搜索
@RequestMapping("underDepartment")
public R underDepartment(){
DepartmentsStaffRelateEntity departmentsStaffRelateEntity = departmentsStaffRelateService.selectByStaffId(null);
if(departmentsStaffRelateEntity == null){
}
if(departmentsStaffRelateEntity.getIsLeader().equals(1)){
//如果是leader 查询负责几个部门
List<DepartmentsDto> departmentsDtos = departmentsService.selectByParentDepartmentId(departmentsStaffRelateEntity.getDepartmentId());
}
return R.ok();
}
public static void main(String[] args) {
List<String> list = getMonthBetween("2018-01","2018-07");
for(String s : list){
System.out.println("日期:"+s);
}
}
//获取日期之内的月份
private static List<String> getMonthBetween(String minDate, String maxDate){
ArrayList<String> result = new ArrayList<String>();
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");//格式化为年月
Calendar min = Calendar.getInstance();
Calendar max = Calendar.getInstance();
min.setTime(sdf.parse(minDate));
min.set(min.get(Calendar.YEAR), min.get(Calendar.MONTH), 1);
max.setTime(sdf.parse(maxDate));
max.set(max.get(Calendar.YEAR), max.get(Calendar.MONTH), 2);
Calendar curr = min;
while (curr.before(max)) {
result.add(sdf.format(curr.getTime()));
curr.add(Calendar.MONTH, 1);
}
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
}

View File

@ -56,4 +56,6 @@ public interface DepartmentsStaffRelateDao extends BaseMapper<DepartmentsStaffRe
DepartmentsStaffRelateEntity selectLeaderByDepartmentId(@Param("departmentId") String departmentId);
DepartmentsStaffRelateEntity selectDepartmentByDepartmentId(@Param("departmentId") String departmentId);
DepartmentsStaffRelateEntity selectByStaffId(@Param("staffId") Long staffId);
}

View File

@ -0,0 +1,18 @@
package com.lz.modules.app.dto;
import lombok.Data;
/**
* @Author: djc
* @Desc:
* @Date: 2020/9/14 16:34
*/
@Data
public class ResultProgressDto {
//未提交
private int noCommit;
//完成
private int finished;
//审核中
private int review;
}

View File

@ -0,0 +1,14 @@
package com.lz.modules.app.req;
/**
* @Author: djc
* @Desc:
* @Date: 2020/9/14 11:02
*/
public class OwnResultReq {
//用户id
private Long userId;
//起始时间
private String startTime;
}

View File

@ -0,0 +1,18 @@
package com.lz.modules.app.resp;
import com.lz.modules.app.dto.ResultProgressDto;
import lombok.Data;
/**
* @Author: djc
* @Desc:
* @Date: 2020/9/14 17:22
*/
@Data
public class ReportChartResp {
//月初目标
private ResultProgressDto target;
//月末结果
private ResultProgressDto result;
}

View File

@ -38,5 +38,7 @@ public interface DepartmentsStaffRelateService extends IService<DepartmentsStaff
DepartmentsStaffRelateEntity selectLeaderByDepartmentId(String departmentId);
DepartmentsStaffRelateEntity selectDepartmentByDepartmentId(String departmentId);
DepartmentsStaffRelateEntity selectByStaffId(Long staffId);
}

View File

@ -86,4 +86,8 @@ public class DepartmentsStaffRelateServiceImpl extends ServiceImpl<DepartmentsSt
}
@Override
public DepartmentsStaffRelateEntity selectByStaffId(Long staffId) {
return departmentsStaffRelateDao.selectByStaffId(staffId);
}
}

View File

@ -0,0 +1,17 @@
package com.lz.modules.sys.service.app;
import com.lz.modules.app.dto.ResultProgressDto;
import java.util.List;
/**
* @Author: djc
* @Desc:
* @Date: 2020/9/14 16:40
*/
public interface ChartService {
ResultProgressDto resultProgress(int type,String monthTime);
}

View File

@ -0,0 +1,43 @@
package com.lz.modules.sys.service.app.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lz.modules.app.dto.ResultProgressDto;
import com.lz.modules.app.entity.StaffEntity;
import com.lz.modules.app.enums.ResultRecordStatusEnum;
import com.lz.modules.app.service.StaffService;
import com.lz.modules.sys.entity.app.ResultRecord;
import com.lz.modules.sys.service.app.ChartService;
import com.lz.modules.sys.service.app.ResultRecordService;
import org.springframework.beans.factory.annotation.Autowired;
/**
* @Author: djc
* @Desc:
* @Date: 2020/9/14 16:54
*/
public class ChartServiceImpl implements ChartService {
@Autowired
private ResultRecordService resultRecordService;
@Autowired
private StaffService staffService;
@Override
public ResultProgressDto resultProgress(int type, String monthTime) {
ResultProgressDto resultProgressDto = new ResultProgressDto();
int total = staffService.count(new QueryWrapper<StaffEntity>().eq("is_delete", 0));
int commit = resultRecordService.count(new QueryWrapper<ResultRecord>()
.eq("is_delete", 0)
.eq("type", type)
.like("month_time",monthTime)
.ne("status", ResultRecordStatusEnum.CREATE.getStatus()));
int finished = resultRecordService.count(new QueryWrapper<ResultRecord>()
.eq("is_delete", 0)
.eq("type", type)
.like("month_time",monthTime)
.in("status", ResultRecordStatusEnum.REFUSE.getStatus(),ResultRecordStatusEnum.AGREE.getStatus()));
resultProgressDto.setNoCommit(total-commit);
resultProgressDto.setFinished(finished);
resultProgressDto.setReview(commit-finished);
return resultProgressDto;
}
}

View File

@ -249,7 +249,7 @@
<select id="ownResult" resultType="com.lz.modules.app.resp.OwnResultResp">
SELECT last_score,DATE_FORMAT(month_time, '%Y-%m-%d') month_time from lz_result_record where is_delete=0 and status = #{status} and type=2 and staff_id = #{userId} ORDER BY month_time limit 6
SELECT last_score,DATE_FORMAT(month_time, '%Y-%m') month_time from lz_result_record where is_delete=0 and status = #{status} and type=2 and staff_id = #{userId} ORDER BY month_time limit 6
</select>
</mapper>

View File

@ -77,4 +77,8 @@
</select>
<select id="selectByStaffId" resultType="com.lz.modules.app.entity.DepartmentsStaffRelateEntity">
select * from lz_departments_staff_relate where is_delete=0 and staff_id = #{staffId}
</select>
</mapper>