This commit is contained in:
guo 2023-09-22 18:15:28 +08:00
parent 33890e25f6
commit c2e327d9a0
18 changed files with 290 additions and 204 deletions

View File

@ -28,14 +28,15 @@ public class SectorOneVo {
@ApiModelProperty("百分比")
@JsonInclude(JsonInclude.Include.NON_NULL)
private String percent;
@ApiModelProperty("类型")
@JsonInclude(JsonInclude.Include.NON_NULL)
private Integer enumType;
@ApiModelProperty(hidden = true)
@JsonIgnore
private Integer state;
@ApiModelProperty(hidden = true)
@JsonIgnore
private Integer personType;
@ApiModelProperty(hidden = true)
@JsonIgnore
private Integer engineeringType;
public static List<SectorOneVo> getSectorOneVosForGovernment(List<SectorOneVo> list, GovernmentMapper governmentMapper) {

View File

@ -1,13 +1,70 @@
package com.zhgd.xmgl.base.entity.vo;
import cn.hutool.core.util.NumberUtil;
import com.zhgd.xmgl.util.BaseEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SectorVo {
@ApiModelProperty("数量")
private String count;
private List<SectorOneVo> data;
/**
* 计算data的百分比
*
* @param vo
*/
public static void calPercent(SectorVo vo) {
String count = vo.getCount();
for (SectorOneVo one : vo.getData()) {
Double d = Double.valueOf(count);
if (d.equals(0.0)) {
one.setPercent("0");
} else {
one.setPercent(NumberUtil.roundStr(Double.valueOf(one.getCount()) / d * 100, 2));
}
}
}
public static SectorVo getSectorVo(List<SectorOneVo> list, BaseEnum[] enums) {
SectorVo vo = new SectorVo();
List<SectorOneVo> rtList = new ArrayList<>();
Map<Integer, SectorOneVo> map = list.stream().collect(Collectors.toMap(SectorOneVo::getEnumType, Function.identity()));
for (BaseEnum type : enums) {
SectorOneVo vo1 = map.get(type.getValue());
if (vo1 == null) {
vo1 = new SectorOneVo();
vo1.setCount("0");
}
vo1.setName(type.getDesc());
vo1.setEnumType(type.getValue());
rtList.add(vo1);
}
vo.setData(rtList);
vo.setCount(String.valueOf(rtList.stream().map(o -> Integer.parseInt(o.getCount())).mapToInt(value -> value).sum()));
calPercent(vo);
return vo;
}
/**
* 计算总count
*
* @param vo
*/
public static void calCount(SectorVo vo) {
vo.setCount(String.valueOf(vo.getData().stream().mapToInt(o -> Integer.parseInt(o.getCount())).sum()));
}
}

View File

@ -92,7 +92,7 @@ public class DustNoiseDataServiceImpl extends ServiceImpl<DustNoiseDataMapper, D
} else if (Objects.equals(type, 2)) {
times = DateUtils.getDaysBetweenLastMonth();
} else if (Objects.equals(type, 3)) {
times = DateUtils.getMonthsBetweenLastYear();
times = DateUtils.getMonthsLast(12,"yyyy-MM");
}
for (String time : times) {
DustNoiseData dustNoiseData = timeMap.get(time);

View File

@ -101,77 +101,6 @@ public class MonitorDevController {
return result;
}
/**
* 添加
*
* @param monitorDev
* @return
*/
@OperLog(operModul = "项目视频管理", operType = "新增", operDesc = "添加视频管理表信息")
@ApiOperation(value = " 添加视频管理表信息", notes = "添加视频管理表信息", httpMethod = "POST")
@PostMapping(value = "/add")
public Result<MonitorDev> add(@RequestBody MonitorDev monitorDev) {
Result<MonitorDev> result = new Result<MonitorDev>();
MonitorDev monitorDevEntity = monitorDevService.getOne(Wrappers.<MonitorDev>lambdaQuery().eq(MonitorDev::getCode, monitorDev.getCode()));
if (monitorDevEntity != null) {
result.error500("该设备编码已存在!");
} else {
monitorDevService.saveInfo(monitorDev);
result.success("添加成功!");
}
return result;
}
/**
* 编辑
*
* @param monitorDev
* @return
*/
@OperLog(operModul = "项目视频管理", operType = "修改", operDesc = "编辑视频管理表信息")
@ApiOperation(value = "编辑视频管理表信息", notes = "编辑视频管理表信息", httpMethod = "POST")
@PostMapping(value = "/edit")
public Result<MonitorDev> edit(@RequestBody MonitorDev monitorDev) {
Result<MonitorDev> result = new Result<MonitorDev>();
MonitorDev monitorDevEntity = monitorDevService.getById(monitorDev.getMonitorId());
if (monitorDevEntity == null) {
result.error500("未找到对应实体");
} else {
SecurityUser user = SecurityUtil.getUser();
monitorDev.setProjectSn(user.getSn());
boolean ok = monitorDevService.updateInfo(monitorDev);
if (ok) {
result.success("修改成功!");
}
}
return result;
}
/**
* 通过id删除
*
* @param monitorDevEntity
* @return
*/
@OperLog(operModul = "项目视频管理", operType = "删除", operDesc = "删除视频管理表信息")
@ApiOperation(value = "删除视频管理表信息", notes = "删除视频管理表信息", httpMethod = "POST")
@ApiImplicitParam(name = "id", value = "视频管理表ID", paramType = "body", required = true, dataType = "Integer")
@PostMapping(value = "/delete")
public Result<MonitorDev> delete(@ApiIgnore @RequestBody MonitorDev monitorDevEntity) {
Result<MonitorDev> result = new Result<MonitorDev>();
MonitorDev monitorDev = monitorDevService.getById(monitorDevEntity.getMonitorId());
if (monitorDev == null) {
result.error500("未找到对应实体");
} else {
boolean ok = monitorDevService.removeById(monitorDevEntity.getMonitorId());
if (ok) {
result.success("删除成功!");
}
}
return result;
}
/**
* 通过id查询
*

View File

@ -54,50 +54,6 @@ public class MonitorQuestionController {
return Result.success(monitorQuestionService.getPageList(map));
}
/**
* 问题整改
*
* @param monitorQuestion
* @return
*/
@OperLog(operModul = "视频抓拍管理", operType = "修改", operDesc = "问题整改")
@ApiOperation(value = "问题整改", notes = "问题整改", httpMethod = "POST")
@PostMapping(value = "/edit")
public Result<MonitorQuestion> edit(@RequestBody MonitorQuestion monitorQuestion) {
Result<MonitorQuestion> result = new Result<MonitorQuestion>();
MonitorQuestion monitorQuestionEntity = monitorQuestionService.getById(monitorQuestion.getId());
if (monitorQuestionEntity == null) {
result.error500("未找到对应实体");
} else {
boolean ok = monitorQuestionService.updateById(monitorQuestion);
if (ok) {
result.success("修改成功!");
}
}
return result;
}
/**
* 通过id删除
* @return
*/
@OperLog(operModul = "视频抓拍管理", operType = "删除", operDesc = "删除视频抓拍记录信息")
@ApiOperation(value = "删除视频抓拍记录信息", notes = "删除视频抓拍记录信息", httpMethod = "POST")
@ApiImplicitParam(name = "id", value = "视频抓拍记录ID", paramType = "body", required = true, dataType = "String")
@PostMapping(value = "/delete")
public Result<MonitorQuestion> delete(@ApiIgnore @RequestBody Map<String, Object> map) {
Result<MonitorQuestion> result = new Result<MonitorQuestion>();
MonitorQuestion monitorQuestion = monitorQuestionService.getById(MapUtils.getString(map, "id"));
if (monitorQuestion == null) {
result.error500("未找到对应实体");
} else {
boolean ok = monitorQuestionService.removeById(MapUtils.getString(map, "id"));
if (ok) {
result.success("删除成功!");
}
}
return result;
}
/**
* 通过id查询

View File

@ -44,34 +44,6 @@ public class WorkerAttendanceController {
@Autowired
private IWorkerAttendanceService workerAttendanceService;
@Autowired
private IWorkerInfoService workerInfoService;
/**
* 添加
*
* @param workerAttendance
* @return
*/
@OperLog(operModul = "人员考勤管理", operType = "新增", operDesc = "添加人员考勤信息")
@ApiOperation(value = " 添加人员考勤信息", notes = "添加人员考勤信息", httpMethod = "POST")
@PostMapping(value = "/add")
public Result<WorkerAttendance> add(@RequestBody WorkerAttendance workerAttendance) {
Result<WorkerAttendance> result = new Result<WorkerAttendance>();
WorkerInfo workerInfo = workerInfoService.getOne(Wrappers.<WorkerInfo>lambdaQuery().eq(WorkerInfo::getId, workerAttendance.getWorkerId()));
if (workerInfo == null) {
result.error500("未找到对应人员信息");
} else {
workerAttendance.setPersonType(workerInfo.getPersonType());
workerAttendance.setEngineeringSn(workerInfo.getEngineeringSn());
workerAttendance.setProjectSn(workerInfo.getProjectSn());
workerAttendance.setCreateTime(new Date());
workerAttendanceService.save(workerAttendance);
result.ok("操作成功");
}
return result;
}
/**
* 获取人员打卡信息
*
@ -95,15 +67,16 @@ public class WorkerAttendanceController {
return Result.success(WorkerAttendanceDto);
}
@OperLog(operModul = "人员考勤管理", operType = "统计", operDesc = "统计每月人员考勤")
@ApiOperation(value = " 统计每月人员考勤", notes = "统计每月人员考勤", httpMethod = "POST")
@OperLog(operModul = "人员考勤管理", operType = "统计", operDesc = "统计每月人员考勤(一年)")
@ApiOperation(value = " 统计每月人员考勤(一年)", notes = "统计每月人员考勤(一年)", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "engineeringSn", value = "工程SN", paramType = "body", dataType = "String"),
@ApiImplicitParam(name = "type", value = "1今年2近半年", required = true, paramType = "body", dataType = "Integer"),
@ApiImplicitParam(name = "personType", value = "人员类别(1:管理;2:工人)", required = false, paramType = "body", dataType = "Integer"),
})
@PostMapping(value = "/countWorkerAttendanceEveryMonth")
public Result<List<TrendVo>> countWorkerAttendanceEveryMonth(@ApiIgnore @RequestBody HashMap<String, Object> paramMap) {
return Result.success(workerAttendanceService.countWorkerAttendanceEveryMonth(paramMap));
}
}

View File

@ -8,8 +8,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhgd.annotation.OperLog;
import com.zhgd.jeecg.common.api.vo.Result;
import com.zhgd.xmgl.base.entity.vo.SectorOneVo;
import com.zhgd.xmgl.base.entity.vo.TrendVo;
import com.zhgd.xmgl.base.entity.vo.MultiTrendVo;
import com.zhgd.xmgl.base.entity.vo.SectorVo;
import com.zhgd.xmgl.modules.city.worker.entity.WorkerInfo;
import com.zhgd.xmgl.modules.city.worker.service.IWorkerInfoService;
import com.zhgd.xmgl.modules.wisdom.dto.WorkerInfoDto;
@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -112,20 +113,37 @@ public class WorkerInfoController {
@ApiImplicitParams({
})
@PostMapping(value = "/countWorkerInfoPersonType")
public Result<List<SectorOneVo>> countWorkerInfoPersonType() {
List<SectorOneVo> enterpriseList = workerInfoService.countWorkerInfoPersonType();
return Result.success(enterpriseList);
public Result<SectorVo> countWorkerInfoPersonType() {
return Result.success(workerInfoService.countWorkerInfoPersonType());
}
@OperLog(operModul = "人员管理", operType = "统计", operDesc = "统计劳务人员分布区域")
@ApiOperation(value = "统计劳务人员分布区域", notes = "统计劳务人员分布区域", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "personType", value = "人员类别(1:管理;2:工人)", required = false, paramType = "body", dataType = "Integer"),
@ApiImplicitParam(name = "dimension", value = "统计维度(1:全部;2:人员类别),多选逗号分隔", required = true, paramType = "body", dataType = "String"),
})
@PostMapping(value = "/countWorkerInfoDistrict")
public Result<List<TrendVo>> countWorkerInfoDistrict() {
List<TrendVo> enterpriseList = workerInfoService.countWorkerInfoDistrict();
return Result.success(enterpriseList);
public Result<MultiTrendVo> countWorkerInfoDistrict(@ApiIgnore @RequestBody HashMap<String, Object> paramMap) {
return Result.success(workerInfoService.countWorkerInfoDistrict(paramMap));
}
@OperLog(operModul = "人员管理", operType = "统计", operDesc = "统计劳务人员年龄")
@ApiOperation(value = "统计劳务人员年龄", notes = "统计劳务人员年龄", httpMethod = "POST")
@ApiImplicitParams({
})
@PostMapping(value = "/countWorkerInfoAge")
public Result<SectorVo> countWorkerInfoAge(@ApiIgnore @RequestBody(required = false) HashMap<String, Object> paramMap) {
return Result.success(workerInfoService.countWorkerInfoAge(paramMap));
}
@OperLog(operModul = "人员管理", operType = "统计", operDesc = "建筑工人工种统计")
@ApiOperation(value = "建筑工人工种统计", notes = "建筑工人工种统计", httpMethod = "POST")
@ApiImplicitParams({
})
@PostMapping(value = "/countWorkerType")
public Result<SectorVo> countWorkerType() {
return Result.success(workerInfoService.countWorkerType());
}
}

View File

@ -0,0 +1,12 @@
package com.zhgd.xmgl.modules.city.worker.entity.bo;
import lombok.Data;
@Data
public class WorkerInfoAgeBo {
private Integer lt25;
private Integer ge25Andlt35;
private Integer ge35Andlt50;
private Integer gt50;
private Integer other;
}

View File

@ -7,8 +7,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhgd.annotation.DataScope;
import com.zhgd.xmgl.base.entity.vo.SectorOneVo;
import com.zhgd.xmgl.base.entity.vo.TrendVo;
import com.zhgd.xmgl.modules.wisdom.dto.WorkerInfoDto;
import com.zhgd.xmgl.modules.city.worker.entity.WorkerInfo;
import com.zhgd.xmgl.modules.city.worker.entity.bo.WorkerInfoAgeBo;
import com.zhgd.xmgl.modules.wisdom.dto.WorkerInfoDto;
import com.zhgd.xmgl.modules.wisdom.statistics.WorkerAttributeStat;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -19,7 +20,7 @@ import java.util.Map;
/**
* @Description: 人员
* @author pengj
* @date 2023-03-13
* @date 2023-03-13
* @version V1.0
*/
@Mapper
@ -48,5 +49,9 @@ public interface WorkerInfoMapper extends BaseMapper<WorkerInfo> {
List<SectorOneVo> countWorkerInfoPersonType();
List<TrendVo> countWorkerInfoDistrict();
List<TrendVo> countWorkerInfoDistrict(Map<String, Object> map);
WorkerInfoAgeBo countWorkerInfoAge();
List<SectorOneVo> countWorkerType();
}

View File

@ -20,8 +20,16 @@
<select id="countWorkerAttendanceEveryMonth" resultType="com.zhgd.xmgl.base.entity.vo.TrendVo">
select count(*) y, date_format(create_time, '%Y%m') x
from worker_attendance
where create_time >= concat(year(now()), '-01-01')
and person_type = 2
where 1 = 1
<if test="thisYear != null and thisYear != ''">
and create_time >= concat(year(now()), '-01-01')
</if>
<if test="halfYear != null and halfYear != ''">
and create_time >= date_format(date_sub(now(), interval 6 month), '%Y-%m')
</if>
<if test="personType != null and personType != ''">
and person_type = #{personType}
</if>
<if test="engineeringSn != null and engineeringSn != ''">
and engineering_sn = #{engineeringSn}
</if>

View File

@ -90,16 +90,39 @@
</select>
<select id="countWorkerInfoPersonType" resultType="com.zhgd.xmgl.base.entity.vo.SectorOneVo">
select person_type, count(*) count
select person_type enumType, count(*) count
from worker_info
group by person_type
</select>
<select id="countWorkerInfoDistrict" resultType="com.zhgd.xmgl.base.entity.vo.TrendVo">
select e.district x,count(*) y
select g.government_name x, count(*) y
from worker_info i
join engineering e on e.engineering_sn = i.engineering_sn
where i.person_type = 2
group by e.province,e.city,e.district
join project p on p.project_sn = i.project_sn
join government g on p.government_sn = g.government_sn
where 1 = 1
<if test="personType != null">
and i.person_type = #{personType}
</if>
group by g.government_sn
</select>
<select id="countWorkerInfoAge" resultType="com.zhgd.xmgl.modules.city.worker.entity.bo.WorkerInfoAgeBo">
select sum(if(t.age <![CDATA[<]]> 25, 1, 0)) lt25,
sum(if(t.age <![CDATA[>=]]> 25 and t.age <![CDATA[<]]> 35, 1, 0)) ge25Andlt35,
sum(if(t.age <![CDATA[>=]]> 35 and t.age <![CDATA[<]]> 50, 1, 0)) ge35Andlt50,
sum(if(t.age <![CDATA[>=]]> 50, 1, 0)) gt50,
sum(if(t.age is null, 1, 0)) other
from (select TIMESTAMPDIFF(YEAR, birthday, CURDATE()) age
from worker_info) t
</select>
<select id="countWorkerType" resultType="com.zhgd.xmgl.base.entity.vo.SectorOneVo">
SELECT
t.type_name name,count(i.id) count
FROM
`worker_type` t
left JOIN worker_info i ON i.worker_type = t.id
GROUP BY t.id
</select>
</mapper>

View File

@ -24,4 +24,5 @@ public interface IWorkerAttendanceService extends IService<WorkerAttendance> {
List<WorkerAttendanceDto> getList(Wrapper<WorkerAttendance> wrapper);
List<TrendVo> countWorkerAttendanceEveryMonth(HashMap<String, Object> paramMap);
}

View File

@ -3,12 +3,13 @@ package com.zhgd.xmgl.modules.city.worker.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zhgd.xmgl.base.entity.vo.SectorOneVo;
import com.zhgd.xmgl.base.entity.vo.TrendVo;
import com.zhgd.xmgl.base.entity.vo.MultiTrendVo;
import com.zhgd.xmgl.base.entity.vo.SectorVo;
import com.zhgd.xmgl.modules.wisdom.dto.WorkerInfoDto;
import com.zhgd.xmgl.modules.city.worker.entity.WorkerInfo;
import com.zhgd.xmgl.modules.wisdom.statistics.WorkerInfoStat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -40,7 +41,11 @@ public interface IWorkerInfoService extends IService<WorkerInfo> {
Page<WorkerInfoDto> getDetail(Page page, Wrapper<WorkerInfo> wrapper);
List<SectorOneVo> countWorkerInfoPersonType();
SectorVo countWorkerInfoPersonType();
List<TrendVo> countWorkerInfoDistrict();
MultiTrendVo countWorkerInfoDistrict(HashMap<String, Object> paramMap);
SectorVo countWorkerInfoAge(HashMap<String, Object> paramMap);
SectorVo countWorkerType();
}

View File

@ -14,6 +14,7 @@ import com.zhgd.xmgl.modules.city.worker.service.IWorkerAttendanceService;
import com.zhgd.xmgl.modules.wisdom.dto.WorkerAttendanceDto;
import com.zhgd.xmgl.modules.wisdom.dto.WorkerAttendanceStatDto;
import com.zhgd.xmgl.util.DateUtils;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -55,11 +56,24 @@ public class WorkerAttendanceServiceImpl extends ServiceImpl<WorkerAttendanceMap
@Override
public List<TrendVo> countWorkerAttendanceEveryMonth(HashMap<String, Object> paramMap) {
List<TrendVo> list = baseMapper.countWorkerAttendanceEveryMonth(paramMap);
List<TrendVo> rtList = new ArrayList<>();
Integer type = MapUtils.getInteger(paramMap, "type");
List<TrendVo> list = new ArrayList<>();
if (Objects.equals(type, 1)) {
paramMap.put("thisYear", true);
list = baseMapper.countWorkerAttendanceEveryMonth(paramMap);
} else if (Objects.equals(type, 2)) {
paramMap.put("halfYear", true);
list = baseMapper.countWorkerAttendanceEveryMonth(paramMap);
}
Map<String, TrendVo> map = list.stream().collect(Collectors.toMap(TrendVo::getX, Function.identity()));
List<TrendVo> rtList = new ArrayList<>();
int year = DateUtil.year(new Date());
List<String> yearMonthList = DateUtils.getAllYearMonthList(year + "");
List<String> yearMonthList = new ArrayList<>();
if (Objects.equals(type, 1)) {
yearMonthList = DateUtils.getAllYearMonthList(year + "");
} else if (Objects.equals(type, 2)) {
yearMonthList = DateUtils.getMonthsLast(6,"yyyyMM");
}
for (String month : yearMonthList) {
TrendVo trendVo = map.get(month);
if (trendVo == null) {

View File

@ -1,7 +1,9 @@
package com.zhgd.xmgl.modules.city.worker.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -11,12 +13,17 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhgd.xmgl.async.AsyncAttendance;
import com.zhgd.xmgl.base.entity.vo.MultiTrendOne;
import com.zhgd.xmgl.base.entity.vo.MultiTrendVo;
import com.zhgd.xmgl.base.entity.vo.SectorOneVo;
import com.zhgd.xmgl.base.entity.vo.TrendVo;
import com.zhgd.xmgl.base.entity.vo.SectorVo;
import com.zhgd.xmgl.modules.basicdata.constant.ParamConstants;
import com.zhgd.xmgl.modules.basicdata.entity.SystemDictData;
import com.zhgd.xmgl.modules.basicdata.service.ISystemDictDataService;
import com.zhgd.xmgl.modules.city.government.entity.Government;
import com.zhgd.xmgl.modules.city.government.mapper.GovernmentMapper;
import com.zhgd.xmgl.modules.city.worker.entity.WorkerInfo;
import com.zhgd.xmgl.modules.city.worker.entity.bo.WorkerInfoAgeBo;
import com.zhgd.xmgl.modules.city.worker.mapper.WorkerInfoMapper;
import com.zhgd.xmgl.modules.city.worker.service.IWorkerInfoService;
import com.zhgd.xmgl.modules.wisdom.dto.WorkerInfoDto;
@ -26,6 +33,7 @@ import com.zhgd.xmgl.modules.wisdom.mapper.AttendanceStatisticsMapper;
import com.zhgd.xmgl.modules.wisdom.mapper.WorkerTypeMapper;
import com.zhgd.xmgl.modules.wisdom.statistics.WorkerAttributeStat;
import com.zhgd.xmgl.modules.wisdom.statistics.WorkerInfoStat;
import com.zhgd.xmgl.security.SecurityUtil;
import com.zhgd.xmgl.util.CommonUtil;
import com.zhgd.xmgl.util.ParamEnum;
import org.apache.commons.collections.MapUtils;
@ -33,10 +41,8 @@ import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.lang.reflect.Field;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -60,6 +66,8 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
@Autowired
private AsyncAttendance asyncAttendance;
@Autowired
private GovernmentMapper governmentMapper;
@Override
public Page<WorkerInfoDto> getDetailPageList(Page page, WorkerInfo workerInfo) {
@ -281,26 +289,63 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
}
@Override
public List<SectorOneVo> countWorkerInfoPersonType() {
public SectorVo countWorkerInfoPersonType() {
List<SectorOneVo> list = baseMapper.countWorkerInfoPersonType();
List<SectorOneVo> rtList = new ArrayList<>();
Map<Integer, SectorOneVo> map = list.stream().collect(Collectors.toMap(SectorOneVo::getPersonType, Function.identity()));
for (ParamEnum.WorkerInfoPersonType type : ParamEnum.WorkerInfoPersonType.values()) {
SectorOneVo vo = map.get(type.getValue());
if (vo == null) {
vo = new SectorOneVo();
vo.setCount("0");
}
vo.setName(type.getDesc());
rtList.add(vo);
SectorVo vo = SectorVo.getSectorVo(list, ParamEnum.WorkerInfoPersonType.values());
return vo;
}
@Override
public MultiTrendVo countWorkerInfoDistrict(HashMap<String, Object> paramMap) {
List<Government> myGovernments = governmentMapper.getMyGovernments(SecurityUtil.getUser().getSn());
if (CollUtil.isEmpty(myGovernments)) {
return null;
}
return rtList;
String dimension = MapUtils.getString(paramMap, "dimension");
List<String> dimensions = Arrays.stream(StringUtils.split(dimension, ",")).collect(Collectors.toList());
List<String> names = myGovernments.stream().map(Government::getGovernmentName).collect(Collectors.toList());
MultiTrendVo vo = new MultiTrendVo();
vo.setX(names);
List<MultiTrendOne> data = new ArrayList<>();
if (dimensions.contains("1")) {
data.add(new MultiTrendOne("人员", MultiTrendVo.fillData(baseMapper.countWorkerInfoDistrict(paramMap), names)));
}
if (dimensions.contains("2")) {
paramMap.put("personType", 1);
data.add(new MultiTrendOne("管理人员", MultiTrendVo.fillData(baseMapper.countWorkerInfoDistrict(paramMap), names)));
paramMap.put("personType", 2);
data.add(new MultiTrendOne("建筑工人", MultiTrendVo.fillData(baseMapper.countWorkerInfoDistrict(paramMap), names)));
}
vo.setData(data);
return vo;
}
@Override
public List<TrendVo> countWorkerInfoDistrict() {
List<TrendVo> list = baseMapper.countWorkerInfoDistrict();
return list;
public SectorVo countWorkerInfoAge(HashMap<String, Object> paramMap) {
WorkerInfoAgeBo bo = baseMapper.countWorkerInfoAge();
Map<String, ParamEnum.WorkerInfoAgeEnum> map = Arrays.stream(ParamEnum.WorkerInfoAgeEnum.values()).collect(Collectors.toMap(ParamEnum.WorkerInfoAgeEnum::getValue, Function.identity()));
Field[] fields = ReflectUtil.getFields(WorkerInfoAgeBo.class);
SectorVo vo = new SectorVo();
List<SectorOneVo> data = new ArrayList<>();
vo.setData(data);
for (Field field : fields) {
SectorOneVo oneVo = new SectorOneVo();
oneVo.setName(map.get(field.getName()).getDesc());
oneVo.setCount(String.valueOf(ReflectUtil.getFieldValue(bo, field)));
data.add(oneVo);
}
SectorVo.calCount(vo);
SectorVo.calPercent(vo);
return vo;
}
@Override
public SectorVo countWorkerType() {
SectorVo vo = new SectorVo();
vo.setData(baseMapper.countWorkerType());
SectorVo.calCount(vo);
return vo;
}
private WorkerAttributeStat age(String attribute, Integer start, Integer end, List<WorkerInfo> workerByAge, Integer workerSum) {

View File

@ -0,0 +1,7 @@
package com.zhgd.xmgl.util;
public interface BaseEnum {
public Integer getValue();
public String getDesc();
}

View File

@ -483,12 +483,12 @@ public class DateUtils {
*
* @return
*/
public static List<String> getMonthsBetweenLastYear() {
public static List<String> getMonthsLast(int offset,String pattern) {
ArrayList<String> rtList = new ArrayList<>();
DateTime endDate = DateTime.now();
DateTime beginDate = cn.hutool.core.date.DateUtil.offsetMonth(endDate, -12);
for (int i = 0; i <= 12; i++) {
rtList.add(cn.hutool.core.date.DateUtil.format(cn.hutool.core.date.DateUtil.offsetMonth(beginDate, i),"yyyy-MM"));
DateTime beginDate = cn.hutool.core.date.DateUtil.offsetMonth(endDate, offset*-1);
for (int i = 0; i <= offset; i++) {
rtList.add(cn.hutool.core.date.DateUtil.format(cn.hutool.core.date.DateUtil.offsetMonth(beginDate, i),pattern));
}
return rtList;
}

View File

@ -245,7 +245,7 @@ public class ParamEnum {
}
}
public enum WorkerInfoPersonType {
public enum WorkerInfoPersonType implements BaseEnum {
MANAGER(1, "管理"),
WORKER(2, "工人"),
;
@ -275,12 +275,12 @@ public class ParamEnum {
}
}
public enum CheckAcceptType {
BASE_CHECK(1, "基础验收"),
COMPLETED_CHECK(2, "竣工验收"),
public enum CheckAcceptType {
BASE_CHECK(1, "基础验收"),
COMPLETED_CHECK(2, "竣工验收"),
;
CheckAcceptType(Integer value, String desc) {
CheckAcceptType(Integer value, String desc) {
this.value = value;
this.desc = desc;
}
@ -305,6 +305,38 @@ public class ParamEnum {
}
}
public enum WorkerInfoAgeEnum {
LT25("lt25", "25岁以下"),
GE25ANDLT35("ge25Andlt35", "25-35岁"),
GE35ANDLT50("ge35Andlt50", "35-50岁"),
GT50("gt50", "50岁以上"),
OTHER("other", "其他(未填)"),
;
WorkerInfoAgeEnum(String value, String desc) {
this.value = value;
this.desc = desc;
}
private String value;
private String desc;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
}