1.首页接口添加
This commit is contained in:
parent
ad20e3b8b1
commit
3ba463fd50
|
|
@ -32,12 +32,12 @@ public class DownloadController {
|
|||
*/
|
||||
@GetMapping("/workerEinTemplate")
|
||||
public ResponseEntity<Resource> workerEinTemplate(HttpServletRequest request) throws IOException {
|
||||
Resource resource = new ClassPathResource("templates/人员入场-模板.xlsx");
|
||||
Resource resource = new ClassPathResource("templates/人员入场-模版.xlsx");
|
||||
if (!resource.exists()) {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
String filename = "人员入场-模板.xlsx";
|
||||
return getResponseEntity(request, filename, resource);
|
||||
String filename = "人员入场-模版.xlsx";
|
||||
return getResponseEntity(request, filename, resource, MediaType.parseMediaType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -53,10 +53,10 @@ public class DownloadController {
|
|||
}
|
||||
String filename = "失信人员-模板.xlsx";
|
||||
// 兼容方案:提供 fallback 文件名(如 ASCII)
|
||||
return getResponseEntity(request, filename, resource);
|
||||
return getResponseEntity(request, filename, resource, MediaType.parseMediaType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"));
|
||||
}
|
||||
|
||||
private static ResponseEntity<Resource> getResponseEntity(HttpServletRequest request, String filename, Resource resource) throws UnsupportedEncodingException {
|
||||
private static ResponseEntity<Resource> getResponseEntity(HttpServletRequest request, String filename, Resource resource,MediaType mediaType) throws UnsupportedEncodingException {
|
||||
// 兼容方案:提供 fallback 文件名(如 ASCII)
|
||||
String userAgent = request.getHeader("User-Agent");
|
||||
String encodedFilename;
|
||||
|
|
@ -71,7 +71,7 @@ public class DownloadController {
|
|||
|
||||
return ResponseEntity.ok()
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; " + encodedFilename)
|
||||
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
.contentType(mediaType)
|
||||
.body(resource);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,99 @@
|
|||
package com.bonus.bmw.controller;
|
||||
import com.bonus.bmw.domain.po.HomePagePo;
|
||||
import com.bonus.bmw.service.HomePageService;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.log.annotation.SysLog;
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
import com.bonus.common.security.annotation.InnerAuth;
|
||||
import com.bonus.common.security.annotation.RequiresPermissions;
|
||||
import com.bonus.common.security.annotation.RequiresPermissionsOrInnerAuth;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* 首页
|
||||
* @author fly
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/homePage")
|
||||
public class HomePageController extends BaseController {
|
||||
/**
|
||||
* 服务对象
|
||||
*/
|
||||
@Autowired
|
||||
private HomePageService service;
|
||||
|
||||
/**
|
||||
* 首页-数据概览
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth(isUser = false), requiresPermissions = @RequiresPermissions("home:page:query"))
|
||||
@PostMapping("/getDataOverview")
|
||||
@SysLog(title = "数据概览", businessType = OperaType.QUERY, logType = 0, module = "首页->数据概览", details = "数据概览")
|
||||
public AjaxResult getDataOverview(@Validated @RequestBody HomePagePo o) {
|
||||
try {
|
||||
return service.getDataOverview(o);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return error("系统异常,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页-人员考勤
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth(isUser = false), requiresPermissions = @RequiresPermissions("home:page:query"))
|
||||
@PostMapping("/getWorkerAtt")
|
||||
@SysLog(title = "人员考勤", businessType = OperaType.QUERY, logType = 0, module = "首页->人员考勤", details = "人员考勤")
|
||||
public AjaxResult getWorkerAtt(@Validated @RequestBody HomePagePo o) {
|
||||
try {
|
||||
return service.getWorkerAtt(o);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return error("系统异常,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页-工程信息
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth(isUser = false), requiresPermissions = @RequiresPermissions("home:page:query"))
|
||||
@PostMapping("/getProjectMsg")
|
||||
@SysLog(title = "工程信息", businessType = OperaType.QUERY, logType = 0, module = "首页->工程信息", details = "工程信息")
|
||||
public AjaxResult getProjectMsg(@Validated @RequestBody HomePagePo o) {
|
||||
try {
|
||||
return service.getProjectMsg(o);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return error("系统异常,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页-在场人员
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth(isUser = false), requiresPermissions = @RequiresPermissions("home:page:query"))
|
||||
@PostMapping("/getEinWorkerDistribution")
|
||||
@SysLog(title = "在场人员", businessType = OperaType.QUERY, logType = 0, module = "首页->在场人员", details = "在场人员")
|
||||
public AjaxResult getEinWorkerDistribution(@Validated @RequestBody HomePagePo o) {
|
||||
try {
|
||||
return service.getEinWorkerDistribution(o);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return error("系统异常,请联系管理员");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.bonus.bmw.domain.po;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class HomePagePo {
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
private Integer subComId;
|
||||
|
||||
private Integer proId;
|
||||
|
||||
private Integer subId;
|
||||
|
||||
private Integer teamId;
|
||||
|
||||
private String currentDay;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
package com.bonus.bmw.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class HomePageProVo {
|
||||
|
||||
/**
|
||||
* 项目总数
|
||||
*/
|
||||
private Integer proNum;
|
||||
|
||||
/**
|
||||
* 建设中项目数量(pro_status = 0)
|
||||
*/
|
||||
private Integer buildProNum;
|
||||
|
||||
/**
|
||||
* 待建项目数量(pro_status = 2)
|
||||
*/
|
||||
private Integer prepareProNum;
|
||||
|
||||
/**
|
||||
* 停建项目数量(pro_status = 1)
|
||||
*/
|
||||
private Integer stopProNum;
|
||||
|
||||
/**
|
||||
* 已竣工项目数量(pro_status = 4)
|
||||
*/
|
||||
private Integer completeProNum;
|
||||
|
||||
/**
|
||||
* 历史遗留项目数量(pro_status = 3)
|
||||
*/
|
||||
private Integer legacyProNum;
|
||||
|
||||
/**
|
||||
* 110kV 电压等级项目数量
|
||||
*/
|
||||
private Integer level110;
|
||||
|
||||
/**
|
||||
* 220kV 电压等级项目数量
|
||||
*/
|
||||
private Integer level220;
|
||||
|
||||
/**
|
||||
* 380kV 电压等级项目数量
|
||||
*/
|
||||
private Integer level380;
|
||||
|
||||
/**
|
||||
* 500kV 电压等级项目数量
|
||||
*/
|
||||
private Integer level500;
|
||||
|
||||
/**
|
||||
* 800kV 电压等级项目数量
|
||||
*/
|
||||
private Integer level800;
|
||||
|
||||
/**
|
||||
* 1000kV 电压等级项目数量
|
||||
*/
|
||||
private Integer level1000;
|
||||
|
||||
/**
|
||||
* 基建类-变电站项目数量(pro_type = 1)
|
||||
*/
|
||||
private Integer infrastructureSubstation;
|
||||
|
||||
/**
|
||||
* 基建类-线路项目数量(pro_type = 2)
|
||||
*/
|
||||
private Integer infrastructureLine;
|
||||
|
||||
/**
|
||||
* 生产类-变电站项目数量(pro_type = 3)
|
||||
*/
|
||||
private Integer productionSubstation;
|
||||
|
||||
/**
|
||||
* 生产类-线路项目数量(pro_type = 4)
|
||||
*/
|
||||
private Integer productionLine;
|
||||
|
||||
/**
|
||||
* 网络类项目数量(pro_type = 5)
|
||||
*/
|
||||
private Integer network;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
package com.bonus.bmw.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class HomePageVo {
|
||||
|
||||
/**
|
||||
* 主项目数
|
||||
*/
|
||||
private Integer mainProNum;
|
||||
|
||||
/**
|
||||
* 子项目数
|
||||
*/
|
||||
private Integer proNum;
|
||||
|
||||
/**
|
||||
* 团队数
|
||||
*/
|
||||
private Integer teamNum;
|
||||
|
||||
/**
|
||||
* 考勤数
|
||||
*/
|
||||
private Integer einNum;
|
||||
|
||||
/**
|
||||
* 子项目数
|
||||
*/
|
||||
private Integer subNum;
|
||||
|
||||
/**
|
||||
* 考勤数
|
||||
*/
|
||||
private Integer attNum;
|
||||
|
||||
/**
|
||||
* 黄牌数
|
||||
*/
|
||||
private Integer yellowNum;
|
||||
|
||||
/**
|
||||
* 7天以上黄牌数
|
||||
*/
|
||||
private Integer yellowThanSevenDayNum;
|
||||
|
||||
/**
|
||||
* 离职无文件数
|
||||
*/
|
||||
private Integer exitNoFileNum;
|
||||
|
||||
/**
|
||||
* 临时人员数
|
||||
*/
|
||||
private Integer tempNum;
|
||||
|
||||
/**
|
||||
* 临时人员数
|
||||
*/
|
||||
private Integer tempAttNum;
|
||||
|
||||
/**
|
||||
* 固定人员占比
|
||||
*/
|
||||
|
||||
private String workerPercentage;
|
||||
|
||||
|
||||
/**
|
||||
* 临时人员占比
|
||||
*/
|
||||
private String tempWorkerPercentage;
|
||||
|
||||
|
||||
/**
|
||||
* 固定人员考勤率
|
||||
*/
|
||||
private String workerAttPercentage;
|
||||
|
||||
/**
|
||||
* 临时人员考勤率
|
||||
*/
|
||||
private String tempWorkerAttPercentage;
|
||||
|
||||
/**
|
||||
* 考勤率
|
||||
*/
|
||||
private String einAttPercentage;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
package com.bonus.bmw.domain.vo;
|
||||
|
||||
import com.bonus.bmw.domain.po.HomePagePo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class HomePageWorkerVo {
|
||||
|
||||
/**
|
||||
* 男性工人数量
|
||||
*/
|
||||
private Integer mailNum;
|
||||
|
||||
/**
|
||||
* 女性工人数量
|
||||
*/
|
||||
private Integer feMailNum;
|
||||
|
||||
/**
|
||||
* 年龄小于 20 岁的工人数量
|
||||
*/
|
||||
private Integer num20;
|
||||
|
||||
/**
|
||||
* 年龄在 [20, 30) 区间的工人数量(含 20,不含 30)
|
||||
*/
|
||||
private Integer num30;
|
||||
|
||||
/**
|
||||
* 年龄在 [30, 40) 区间的工人数量(含 30,不含 40)
|
||||
*/
|
||||
private Integer num40;
|
||||
|
||||
/**
|
||||
* 年龄在 [40, 50) 区间的工人数量(含 40,不含 50)
|
||||
*/
|
||||
private Integer num50;
|
||||
|
||||
/**
|
||||
* 年龄大于等于 50 岁的工人数量
|
||||
*/
|
||||
private Integer num60;
|
||||
|
||||
/**
|
||||
* 黄灯状态(light_status = 1)的工人数量
|
||||
*/
|
||||
private Integer yellowNum;
|
||||
|
||||
/**
|
||||
* 绿灯状态(light_status = 2)的工人数量
|
||||
*/
|
||||
private Integer greenNum;
|
||||
|
||||
/**
|
||||
* 总工人数量(关联表中非空 worker_id 的数量)
|
||||
*/
|
||||
private Integer workerNum;
|
||||
|
||||
/**
|
||||
* 岗位信息
|
||||
*/
|
||||
List<MapBeanVo> postMsg;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
package com.bonus.bmw.mapper;
|
||||
|
||||
import com.bonus.bmw.domain.po.HomePagePo;
|
||||
import com.bonus.bmw.domain.vo.HomePageProVo;
|
||||
import com.bonus.bmw.domain.vo.HomePageVo;
|
||||
import com.bonus.bmw.domain.vo.HomePageWorkerVo;
|
||||
import com.bonus.bmw.domain.vo.MapBeanVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface HomePageMapper {
|
||||
|
||||
/**
|
||||
* 获取主工程数量和工程数量
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
HomePageVo getMainProjectNumAndProNum(HomePagePo o);
|
||||
|
||||
/**
|
||||
* 获取分包单位数量和班组数量
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
Integer getSubNum(HomePagePo o);
|
||||
|
||||
/**
|
||||
* 获取班组数量
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
Integer getTeamNum(HomePagePo o);
|
||||
|
||||
/**
|
||||
* 获取 Ein数量
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
Integer getEinNum(HomePagePo o);
|
||||
|
||||
/**
|
||||
* 获取考勤数量
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
Integer getAttNum(HomePagePo o);
|
||||
|
||||
/**
|
||||
* 获取退场无文件数量
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
Integer getExitNoFileNum(HomePagePo o);
|
||||
/**
|
||||
* 获取黄牌数量
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
HomePageVo getYellowNum(HomePagePo o);
|
||||
/**
|
||||
* 获取工程数量
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
HomePageProVo getProjectMsg(HomePagePo o);
|
||||
/**
|
||||
* 获取人员数量
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
HomePageWorkerVo getEinWorkerDistribution(HomePagePo o);
|
||||
|
||||
/**
|
||||
* 获取人员职位数量
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
List<MapBeanVo> setWorkerPostTop(HomePagePo o);
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package com.bonus.bmw.service;
|
||||
|
||||
import com.bonus.bmw.domain.po.HomePagePo;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
|
||||
public interface HomePageService{
|
||||
|
||||
/**
|
||||
* 获取数据概览
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
AjaxResult getDataOverview(HomePagePo o);
|
||||
|
||||
/**
|
||||
* 获取人员考勤
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
AjaxResult getWorkerAtt(HomePagePo o);
|
||||
|
||||
/**
|
||||
* 获取工程信息
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
AjaxResult getProjectMsg(HomePagePo o);
|
||||
|
||||
/**
|
||||
* 获取在场人员
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
AjaxResult getEinWorkerDistribution(HomePagePo o);
|
||||
}
|
||||
|
|
@ -0,0 +1,138 @@
|
|||
package com.bonus.bmw.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.bonus.bmw.domain.po.HomePagePo;
|
||||
import com.bonus.bmw.domain.vo.HomePageProVo;
|
||||
import com.bonus.bmw.domain.vo.HomePageVo;
|
||||
import com.bonus.bmw.domain.vo.HomePageWorkerVo;
|
||||
import com.bonus.bmw.domain.vo.MapBeanVo;
|
||||
import com.bonus.bmw.mapper.HomePageMapper;
|
||||
import com.bonus.bmw.service.HomePageService;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class HomePageServiceImpl implements HomePageService {
|
||||
|
||||
@Autowired
|
||||
private HomePageMapper mapper;
|
||||
|
||||
@Override
|
||||
public AjaxResult getDataOverview(HomePagePo o) {
|
||||
//总工程数量 标段工程数量
|
||||
HomePageVo totalProjectNum= mapper.getMainProjectNumAndProNum(o);
|
||||
//分包数量 班组数量
|
||||
int subNum= mapper.getSubNum(o);
|
||||
//班组数量
|
||||
int teamNum= mapper.getTeamNum(o);
|
||||
|
||||
//在场人员
|
||||
String today = DateUtil.today();
|
||||
o.setCurrentDay(today);
|
||||
int einNum= mapper.getEinNum(o);
|
||||
//黄灯和黄灯超七天
|
||||
HomePageVo yellowNum= mapper.getYellowNum(o);
|
||||
//今日打卡
|
||||
int attNum= mapper.getAttNum(o);
|
||||
//离场未结算人员
|
||||
int exitNum= mapper.getExitNoFileNum(o);
|
||||
|
||||
totalProjectNum.setSubNum(subNum);
|
||||
totalProjectNum.setTeamNum(teamNum);
|
||||
totalProjectNum.setEinNum(einNum);
|
||||
totalProjectNum.setYellowNum(yellowNum.getYellowNum());
|
||||
totalProjectNum.setYellowThanSevenDayNum(yellowNum.getYellowThanSevenDayNum());
|
||||
totalProjectNum.setAttNum(attNum);
|
||||
totalProjectNum.setExitNoFileNum(exitNum);
|
||||
return AjaxResult.success(totalProjectNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getWorkerAtt(HomePagePo o) {
|
||||
String today = DateUtil.today();
|
||||
o.setCurrentDay(today);
|
||||
//固定人员 在场
|
||||
int einNum= mapper.getEinNum(o);
|
||||
//固定人员 打卡
|
||||
int attNum= mapper.getAttNum(o);
|
||||
//临时人员数据(还未开发)
|
||||
int tempNum=0;
|
||||
int tempAttNum=0;
|
||||
//在场固定人员占比
|
||||
String workerPercentage = divideToPercentage(einNum, einNum + tempNum);
|
||||
|
||||
String tempWorkerPercentage = divideToPercentage(tempNum,einNum+tempNum);
|
||||
|
||||
String workerAttPercentage = divideToPercentage(attNum,einNum);
|
||||
|
||||
String tempWorkerAttPercentage = divideToPercentage(tempAttNum,tempNum);
|
||||
|
||||
String einAttPercentage = divideToPercentage(attNum+tempAttNum,einNum+tempNum);
|
||||
|
||||
|
||||
HomePageVo homePageVo = new HomePageVo();
|
||||
homePageVo.setEinNum(einNum);
|
||||
homePageVo.setAttNum(attNum);
|
||||
homePageVo.setTempNum(tempNum);
|
||||
homePageVo.setTempAttNum(tempAttNum);
|
||||
homePageVo.setWorkerPercentage(workerPercentage);
|
||||
homePageVo.setTempWorkerPercentage(tempWorkerPercentage);
|
||||
homePageVo.setWorkerAttPercentage(workerAttPercentage);
|
||||
homePageVo.setTempWorkerAttPercentage(tempWorkerAttPercentage);
|
||||
homePageVo.setEinAttPercentage(einAttPercentage);
|
||||
return AjaxResult.success(homePageVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getProjectMsg(HomePagePo o) {
|
||||
//工程信息
|
||||
HomePageProVo proMsg = mapper.getProjectMsg(o);
|
||||
return AjaxResult.success(proMsg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getEinWorkerDistribution(HomePagePo o) {
|
||||
//在场人员
|
||||
HomePageWorkerVo workerMsg = mapper.getEinWorkerDistribution(o);
|
||||
//工种查出前五和其它
|
||||
List<MapBeanVo> postMsg = mapper.setWorkerPostTop(o);
|
||||
workerMsg.setPostMsg(postMsg);
|
||||
return AjaxResult.success(workerMsg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算 a / b 的百分比,保留两位有效数字
|
||||
* @param a 被除数
|
||||
* @param b 除数
|
||||
* @return 百分比字符串,如 "0.00%", "43%", "1.2%", "100%"
|
||||
*/
|
||||
public static String divideToPercentage(int a, int b) {
|
||||
// 被除数为 0,直接返回 0.00%
|
||||
if (a == 0 || b == 0) {
|
||||
return "0.00%";
|
||||
}
|
||||
// 使用 BigDecimal 避免精度丢失:计算 (a * 100.0) / b
|
||||
BigDecimal numerator = BigDecimal.valueOf(a).multiply(BigDecimal.valueOf(100)); // a * 100
|
||||
BigDecimal denominator = BigDecimal.valueOf(b);
|
||||
BigDecimal value = numerator.divide(denominator, new MathContext(15, RoundingMode.HALF_UP)); // 高精度中间计算
|
||||
// 保留两位有效数字
|
||||
BigDecimal result;
|
||||
if (value.compareTo(BigDecimal.ZERO) == 0) {
|
||||
result = BigDecimal.ZERO;
|
||||
} else {
|
||||
result = value.round(new MathContext(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
// 去除末尾多余的0,转为普通字符串
|
||||
String numberStr = result.stripTrailingZeros().toPlainString();
|
||||
// 确保至少显示两位小数?不需要 —— 有效数字规则优先
|
||||
// 但题目要求被除数为0时返回"0.00%",其他情况按有效数字
|
||||
return numberStr + "%";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,216 @@
|
|||
<?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.bonus.bmw.mapper.HomePageMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.bonus.bmw.domain.vo.HomePageVo">
|
||||
<result column="mainProNum" property="mainProNum" />
|
||||
<result column="proNum" property="proNum" />
|
||||
<result column="subNum" property="subNum" />
|
||||
<result column="teamNum" property="teamNum" />
|
||||
<result column="einNum" property="einNum" />
|
||||
<result column="attNum" property="attNum" />
|
||||
<result column="yellowNum" property="yellowNum"/>
|
||||
<result column="yellowThanSevenDayNum" property="yellowThanSevenDayNum"/>
|
||||
<result column="exitNoFileNum" property="exitNoFileNum"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 注意:当传入 subComId 时,只统计该分公司下的子工程及其关联的主工程
|
||||
没有子工程的主工程不会被计入(因为它们不属于任何分公司) -->
|
||||
<select id="getMainProjectNumAndProNum" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
COUNT(DISTINCT pmp.id) AS mainProNum,
|
||||
COUNT(DISTINCT pp.id) AS proNum
|
||||
FROM pm_main_project pmp
|
||||
LEFT JOIN pm_project pp
|
||||
ON pmp.id = pp.main_pro_id
|
||||
AND pp.is_active = 1
|
||||
WHERE
|
||||
pmp.is_active = 1
|
||||
<if test="subComId != null">
|
||||
AND pp.sub_com_id = #{subComId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getSubNum" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
COUNT(DISTINCT ps.id) AS subNum
|
||||
FROM pm_sub ps
|
||||
INNER JOIN bm_sub_contract psc
|
||||
ON ps.id = psc.sub_id and psc.is_active = 1 and psc.sub_ein_status = 1
|
||||
INNER JOIN pm_project pp on pp.id = psc.pro_id
|
||||
AND pp.is_active = 1
|
||||
WHERE
|
||||
ps.is_active = 1
|
||||
<if test="subComId != null">
|
||||
AND pp.sub_com_id = #{subComId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getTeamNum" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
COUNT(DISTINCT pst.id) AS teamNum
|
||||
FROM pm_sub_team pst
|
||||
INNER JOIN pm_sub_team_contract pstc on pst.id = pstc.team_id and pstc.is_active = 1 and pstc.team_ein_status = 1
|
||||
INNER JOIN pm_sub ps on pst.sub_id = ps.id and ps.is_active = 1
|
||||
INNER JOIN bm_sub_contract psc
|
||||
ON ps.id = psc.sub_id and psc.is_active = 1 and psc.sub_ein_status = 1
|
||||
INNER JOIN pm_project pp on pp.id = psc.pro_id
|
||||
WHERE
|
||||
pst.is_active = 1
|
||||
<if test="subComId != null">
|
||||
AND pp.sub_com_id = #{subComId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getEinNum" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
COUNT(DISTINCT bwem.worker_id) AS einNum
|
||||
FROM bm_worker_ein_msg bwem
|
||||
INNER JOIN pm_project pp
|
||||
ON bwem.pro_id = pp.id and pp.is_active = 1
|
||||
<where>
|
||||
bwem.is_active = 1
|
||||
<if test="subComId != null">
|
||||
AND pp.sub_com_id = #{subComId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="getYellowNum" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
COUNT(DISTINCT IF(bwem.light_status = 1, bwem.worker_id, null)) as yellowNum,
|
||||
COUNT(DISTINCT IF(bwem.light_status = 1 AND DATE_SUB(CURDATE(), INTERVAL 7 DAY) > IF(bwem.yellow_date is null, CURRENT_DATE, bwem.yellow_date), bwem.worker_id, null)) as yellowThanSevenDayNum
|
||||
FROM bm_worker_ein_msg bwem
|
||||
INNER JOIN pm_project pp
|
||||
ON bwem.pro_id = pp.id and pp.is_active = 1
|
||||
<where>
|
||||
bwem.is_active = 1
|
||||
<if test="subComId != null">
|
||||
AND pp.sub_com_id = #{subComId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="getAttNum" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
COUNT(DISTINCT bap.worker_id) AS attNum
|
||||
FROM bm_att_person bap
|
||||
INNER JOIN pm_project pp
|
||||
ON bap.pro_id = pp.id and pp.is_active = 1
|
||||
<where>
|
||||
bap.is_active = 1 and bap.att_day = #{currentDay}
|
||||
<if test="subComId != null">
|
||||
AND pp.sub_com_id = #{subComId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="getExitNoFileNum" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
COUNT(bwem.worker_id) AS exitNoFileNum
|
||||
FROM bm_worker_ein_pro_record bwem
|
||||
INNER JOIN pm_project pp
|
||||
ON bwem.pro_id = pp.id and pp.is_active = 1
|
||||
<where>
|
||||
bwem.is_active = 1 and bwem.ein_status = 2 and bwem.is_upload_file = 0
|
||||
<if test="subComId != null">
|
||||
AND pp.sub_com_id
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="getProjectMsg" resultType="com.bonus.bmw.domain.vo.HomePageProVo">
|
||||
SELECT
|
||||
count(pp.id) AS proNum,
|
||||
count(IF(pp.pro_status = 0, 1, NULL)) AS buildProNum,
|
||||
count(IF(pp.pro_status = 2, 1, NULL)) AS prepareProNum,
|
||||
count(IF(pp.pro_status = 1, 1, NULL)) AS stopProNum,
|
||||
count(IF(pp.pro_status = 4, 1, NULL)) AS completeProNum,
|
||||
count(IF(pp.pro_status = 3, 1, NULL)) AS legacyProNum,
|
||||
count(IF(pp.vol_level = '110kV', 1, NULL)) AS level110,
|
||||
count(IF(pp.vol_level = '220kV', 1, NULL)) AS level220,
|
||||
count(IF(pp.vol_level = '380kV', 1, NULL)) AS level380,
|
||||
count(IF(pp.vol_level = '500kV', 1, NULL)) AS level500,
|
||||
count(IF(pp.vol_level = '800kV', 1, NULL)) AS level800,
|
||||
count(IF(pp.vol_level = '1000kV以上', 1, NULL)) AS level1000,
|
||||
count(IF(pp.pro_type = 1, 1, NULL)) AS infrastructureSubstation,
|
||||
count(IF(pp.pro_type = 2, 1, NULL)) AS infrastructureLine,
|
||||
count(IF(pp.pro_type = 3, 1, NULL)) AS productionSubstation,
|
||||
count(IF(pp.pro_type = 4, 1, NULL)) AS productionLine,
|
||||
count(IF(pp.pro_type = 5, 1, NULL)) AS network
|
||||
FROM
|
||||
pm_project pp
|
||||
WHERE
|
||||
pp.is_active = '1'
|
||||
<if test="subComId != null">
|
||||
AND pp.sub_com_id
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getEinWorkerDistribution" resultType="com.bonus.bmw.domain.vo.HomePageWorkerVo">
|
||||
|
||||
SELECT
|
||||
count(IF(pw.sex = '男', pw.id, NULL)) AS mailNum,
|
||||
count(IF(pw.sex = '女', pw.id, NULL)) AS feMailNum,
|
||||
count(IF(pw.age < 20, pw.id, NULL)) AS num20,
|
||||
count(IF(pw.age >= 20 AND pw.age < 30, pw.id, NULL)) AS num30,
|
||||
count(IF(pw.age >= 30 AND pw.age < 40, pw.id, NULL)) AS num40,
|
||||
count(IF(pw.age >= 40 AND pw.age < 50, pw.id, NULL)) AS num50,
|
||||
count(IF(pw.age >= 50, pw.id, NULL)) AS num60,
|
||||
count(IF(bwem.light_status = 1, bwem.worker_id, NULL)) AS yellowNum,
|
||||
count(IF(bwem.light_status = 2, bwem.worker_id, NULL)) AS greenNum,
|
||||
count(bwem.worker_id) AS workerNum
|
||||
FROM
|
||||
bm_worker_ein_msg bwem
|
||||
INNER JOIN pm_worker pw
|
||||
ON bwem.worker_id = pw.id and pw.is_active = 1
|
||||
WHERE
|
||||
bwem.is_active = '1'
|
||||
<if test="subComId != null">
|
||||
AND bwem.pro_id IN (SELECT id FROM pm_project WHERE sub_com_id = #{subComId})
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="setWorkerPostTop" resultType="com.bonus.bmw.domain.vo.MapBeanVo">
|
||||
SELECT
|
||||
post_name as `key`,
|
||||
worker_count as `value`
|
||||
FROM (
|
||||
(SELECT
|
||||
ppt.post_name,
|
||||
COUNT(pw.id) AS worker_count
|
||||
|
||||
FROM bm_worker_ein_msg bwem
|
||||
INNER JOIN pm_worker pw ON bwem.worker_id = pw.id AND pw.is_active = 1
|
||||
LEFT JOIN pm_post_type ppt ON bwem.post_id = ppt.id
|
||||
WHERE bwem.is_active = 1
|
||||
GROUP BY ppt.id
|
||||
ORDER BY worker_count DESC
|
||||
LIMIT 5)
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
'其他' AS post_name,
|
||||
COUNT(pw.id) AS worker_count
|
||||
|
||||
FROM bm_worker_ein_msg bwem
|
||||
INNER JOIN pm_worker pw ON bwem.worker_id = pw.id AND pw.is_active = 1
|
||||
LEFT JOIN pm_post_type ppt ON bwem.post_id = ppt.id
|
||||
WHERE bwem.is_active = '1'
|
||||
AND ppt.id NOT IN (
|
||||
SELECT id FROM (
|
||||
SELECT ppt.id
|
||||
FROM bm_worker_ein_msg bwem
|
||||
INNER JOIN pm_worker pw ON bwem.worker_id = pw.id AND pw.is_active = 1
|
||||
LEFT JOIN pm_post_type ppt ON bwem.post_id = ppt.id
|
||||
WHERE bwem.is_active = '1'
|
||||
GROUP BY ppt.id
|
||||
ORDER BY COUNT(pw.id) DESC
|
||||
LIMIT 5
|
||||
) AS top5
|
||||
)
|
||||
) AS combined
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -34,7 +34,7 @@
|
|||
</select>
|
||||
<!--下发用户信息-->
|
||||
<select id="getTaskUserInfoList" resultType="com.bonus.urk.vo.TaskUserVo">
|
||||
select pw.id userId,pw.name userName,pw.face_photo photo
|
||||
select pw.id userId,pw.name userName
|
||||
from kq_task_user_list ktu
|
||||
left join pm_worker pw on pw.id=ktu.user_id
|
||||
where ktu.task_id=#{taskId}
|
||||
|
|
|
|||
Loading…
Reference in New Issue