package com.ruoyi.project.tr.dataStatistics.controller;
|
|
import com.github.pagehelper.util.StringUtil;
|
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.framework.web.controller.BaseController;
|
import com.ruoyi.framework.web.page.TableDataInfo;
|
import com.ruoyi.project.mobile.service.ApiAllDataStatisticsService;
|
import com.ruoyi.project.mobile.service.ApiHiddenDangerCheckService;
|
import com.ruoyi.project.system.company.domain.Company;
|
import com.ruoyi.project.system.company.service.ICompanyService;
|
import com.ruoyi.project.system.dept.service.IDeptService;
|
import com.ruoyi.project.system.role.service.IRoleService;
|
import com.ruoyi.project.system.user.domain.User;
|
import com.ruoyi.project.system.user.service.IUserService;
|
import com.ruoyi.project.tr.dataStatistics.service.DataStatisticsService;
|
import com.ruoyi.project.tr.hiddenDangerCheck.service.IHiddenDangerCheckService;
|
import com.ruoyi.project.tr.hiddenDangerCheckPoint.domain.HiddenDangerCheckPoint;
|
import com.ruoyi.project.tr.hiddenDangerCheckPoint.service.IHiddenDangerCheckPointService;
|
import com.ruoyi.project.tr.region.service.IRegionService;
|
import com.ruoyi.project.tr.riskCheckPoint.domain.RiskCheckPoint;
|
import com.ruoyi.project.tr.riskCheckPoint.service.IRiskCheckPointService;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.ui.ModelMap;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.io.UnsupportedEncodingException;
|
import java.math.BigDecimal;
|
import java.net.URLDecoder;
|
import java.text.NumberFormat;
|
import java.text.ParseException;
|
import java.text.SimpleDateFormat;
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* app端,数据统计功能
|
*/
|
@Controller
|
@RequestMapping("/tr/dataStatisticsTotalByApp")
|
public class DataStatisticsTotalByAppController extends BaseController {
|
private static Logger logger = LoggerFactory.getLogger(DataStatisticsTotalByAppController.class);
|
@Autowired
|
private DataStatisticsService dataStatisticsService;
|
@Autowired
|
private IRoleService roleService;
|
@Autowired
|
private IUserService userService;
|
@Autowired
|
private IDeptService deptService;
|
|
@Autowired
|
private IHiddenDangerCheckPointService hiddenDangerCheckPointService;
|
@Autowired
|
private IHiddenDangerCheckService hiddenDangerCheckService;
|
@Autowired
|
private IRiskCheckPointService riskCheckPointService;
|
|
|
@Autowired
|
private IRegionService regionService;
|
|
@Autowired
|
private ICompanyService companyService;
|
|
private String prefix = "tr/dataStatisticsTotalByApp";
|
|
|
/**
|
* 获取隐患台账页面
|
*/
|
@GetMapping("/dangerLedgerListTotal")
|
public String dangerLedgerListTotal(ModelMap modelMap,
|
String pageLevel,
|
String companyRegion,
|
String companyIndustryType,
|
String companySubIndustryType) {
|
Company companyQuery = new Company();
|
if ("firstPage".equals(pageLevel)) {
|
|
} else if ("secondPage".equals(pageLevel)) {
|
modelMap.put("companyRegion", companyRegion);
|
|
companyQuery.setCompanyRegion(companyRegion);
|
} else if ("thirdPage".equals(pageLevel)) {
|
modelMap.put("companyRegion", companyRegion);
|
modelMap.put("companyIndustryType", companyIndustryType);
|
modelMap.put("companySubIndustryType", companySubIndustryType);
|
|
companyQuery.setCompanyRegion(companyRegion);
|
companyQuery.setCompanyIndustry(companyIndustryType);
|
companyQuery.setCompanySubIndustry(companySubIndustryType);
|
}
|
getDangerDataStatistics(modelMap, companyQuery);
|
return prefix + "/dangerLedgerListTotal";
|
}
|
|
|
//companyId下总的数据统计
|
public void getDangerDataStatistics(ModelMap mmap, Company companyQuery) {
|
|
int totalDangerNum = 0;//隐患数
|
int rectifyNum = 0;//已整改数目
|
int notRectifyNum = 0;//未整改数目
|
int totalRectifyNum = 0;//整改总条数(已整改数目+未整改数目)
|
String rectifyRate = "100%";//整改率
|
|
int onTimeRectifyNum = 0;//按期整改数
|
String onTimeRectifyRate = "100%";//按期率
|
int overdueRectifyNum = 0;//超期整改数
|
String overdueRectifyRate = "0%";//超期率
|
|
String monthOnMonthRate = "暂无";//环比-------(上个月 - 上上个月)/上上个月
|
String yearOnYearRate = "暂无";//同比-------(上个月 - 去年上个月)/去年上个月
|
|
|
HiddenDangerCheckPoint hdcpQuery = new HiddenDangerCheckPoint();
|
HiddenDangerCheckPoint hdcpQueryAll = new HiddenDangerCheckPoint();
|
HiddenDangerCheckPoint queryByTime = new HiddenDangerCheckPoint();
|
|
hdcpQuery.setRectifyUserIdIsNotNull("1");//隐患整改人ID 不为空
|
hdcpQueryAll.setRectifyUserIdIsNotNull("1");//隐患整改人ID 不为空
|
queryByTime.setRectifyUserIdIsNotNull("1");//隐患整改人ID 不为空
|
|
|
//有区域的公司列表的过滤
|
// Company companyQuery = new Company();
|
List<Company> companyListTemp = companyService.selectCompanyList(companyQuery);
|
List<Long> companyIdListLast = new ArrayList<>();
|
for (Company c : companyListTemp) {
|
if (!StringUtil.isEmpty(c.getCompanyRegion())) {
|
companyIdListLast.add(c.getCompanyId());
|
}
|
}
|
|
if (companyIdListLast.size() > 0) {
|
hdcpQuery.setCompanyIdList(companyIdListLast);
|
hdcpQueryAll.setCompanyIdList(companyIdListLast);
|
queryByTime.setCompanyIdList(companyIdListLast);
|
|
|
// User userQuery = new User();
|
// List<User> userList = userService.selectUserList(userQuery);
|
// List<Long> userIdList = new ArrayList<>();
|
// for (User user : userList) {
|
// userIdList.add(user.getUserId());
|
// }
|
|
|
// if (userIdList.size() > 0) {
|
// hdcpQueryAll.setLedgerUserIdList(userIdList);//隐患整改人ID 为登陆账号companyId下的userId的
|
// queryByTime.setLedgerUserIdList(userIdList);//隐患整改人ID 为登陆账号companyId下的userId的
|
|
//companyId下总的数据统计
|
List<HiddenDangerCheckPoint> resultListAll = hiddenDangerCheckPointService.selectHiddenDangerCheckPointList(hdcpQueryAll);//根据companyId 查询出的列表
|
|
for (HiddenDangerCheckPoint hdcp : resultListAll) {
|
if (!StringUtils.isEmpty(hdcp.getStage())) {
|
if ("3".equals(hdcp.getStage())) {
|
if (!StringUtil.isEmpty(hdcp.getExamineStatus())) {
|
if ("0".equals(hdcp.getExamineStatus())) {
|
notRectifyNum++;
|
}
|
}
|
} else if ("4".equals(hdcp.getStage())) {
|
if (!StringUtil.isEmpty(hdcp.getRectifyStatus())) {
|
if ("0".equals(hdcp.getRectifyStatus())) {
|
notRectifyNum++;
|
}
|
}
|
} else if ("5".equals(hdcp.getStage())) {
|
if (!StringUtil.isEmpty(hdcp.getAcceptStatus())) {
|
rectifyNum++;
|
SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
|
try {
|
if (f.parse(f.format(hdcp.getRectifyDeadlineTime())).before(f.parse(f.format(hdcp.getRectifyCompleteTime())))) {
|
overdueRectifyNum++;
|
} else {
|
onTimeRectifyNum++;
|
}
|
} catch (ParseException e) {
|
}
|
}
|
}
|
}
|
}
|
totalDangerNum = resultListAll.size();
|
totalRectifyNum = rectifyNum + notRectifyNum;
|
if (totalDangerNum > 0) {
|
//计算整改率
|
BigDecimal a = ApiHiddenDangerCheckService.divide(rectifyNum, totalDangerNum, 4);
|
//下面将结果转化成百分比
|
NumberFormat percent1 = NumberFormat.getPercentInstance();
|
percent1.setMaximumFractionDigits(2);
|
rectifyRate = percent1.format(a.doubleValue());
|
|
//计算按期率
|
BigDecimal b = ApiHiddenDangerCheckService.divide(onTimeRectifyNum, totalDangerNum, 4);
|
//下面将结果转化成百分比
|
NumberFormat percent2 = NumberFormat.getPercentInstance();
|
percent2.setMaximumFractionDigits(2);
|
onTimeRectifyRate = percent2.format(b.doubleValue());
|
|
|
//计算超期率
|
BigDecimal c = ApiHiddenDangerCheckService.divide(overdueRectifyNum, totalDangerNum, 4);
|
//下面将结果转化成百分比
|
NumberFormat percent3 = NumberFormat.getPercentInstance();
|
percent3.setMaximumFractionDigits(2);
|
overdueRectifyRate = percent3.format(c.doubleValue());
|
}
|
|
|
Map map1 = ApiHiddenDangerCheckService.getLastMonthTime(0, -1);//上个月
|
|
Map map2 = ApiHiddenDangerCheckService.getLastMonthTime(0, -2);//上上个月
|
|
Map map3 = ApiHiddenDangerCheckService.getLastMonthTime(-1, -1);//去年上个月
|
|
|
queryByTime.setParams(map1);
|
List<HiddenDangerCheckPoint> list1 = hiddenDangerCheckPointService.selectHiddenDangerCheckPointList(queryByTime);//上个月
|
queryByTime.setParams(map2);
|
List<HiddenDangerCheckPoint> list2 = hiddenDangerCheckPointService.selectHiddenDangerCheckPointList(queryByTime);//上上个月
|
queryByTime.setParams(map3);
|
List<HiddenDangerCheckPoint> list3 = hiddenDangerCheckPointService.selectHiddenDangerCheckPointList(queryByTime);//去年上个月
|
|
|
//计算环比
|
if (list2.size() > 0) {
|
BigDecimal d = ApiHiddenDangerCheckService.divide((list1.size() - list2.size()), list2.size(), 4);
|
//下面将结果转化成百分比
|
NumberFormat percent4 = NumberFormat.getPercentInstance();
|
percent4.setMaximumFractionDigits(2);
|
monthOnMonthRate = percent4.format(d.doubleValue());
|
} else {
|
monthOnMonthRate = "暂无";
|
}
|
|
|
//计算同比
|
if (list3.size() > 0) {
|
BigDecimal e = ApiHiddenDangerCheckService.divide((list1.size() - list3.size()), list3.size(), 4);
|
//下面将结果转化成百分比
|
NumberFormat percent5 = NumberFormat.getPercentInstance();
|
percent5.setMaximumFractionDigits(2);
|
yearOnYearRate = percent5.format(e.doubleValue());
|
} else {
|
yearOnYearRate = "暂无";
|
}
|
// }
|
}
|
|
mmap.put("totalDangerNum", totalDangerNum);
|
mmap.put("rectifyNum", rectifyNum);
|
mmap.put("notRectifyNum", notRectifyNum);
|
mmap.put("rectifyRate", rectifyRate);
|
mmap.put("onTimeRectifyNum", onTimeRectifyNum);
|
mmap.put("onTimeRectifyRate", onTimeRectifyRate);
|
mmap.put("overdueRectifyNum", overdueRectifyNum);
|
mmap.put("overdueRectifyRate", overdueRectifyRate);
|
|
mmap.put("monthOnMonthRate", monthOnMonthRate);
|
mmap.put("yearOnYearRate", yearOnYearRate);
|
}
|
|
/**
|
* thisMonthHighDanger隐患台账 列表页面
|
*/
|
@GetMapping("/dangerLedgerListTotal/thisMonthHighDanger")
|
// String pageLevel,第几个层级
|
// String companyRegion,公司区域
|
// String companyIndustryType,行业分类
|
// String companySubIndustryType,行业子分类
|
public String dangerLedgerListTotalByThisMonthHighDanger(ModelMap modelMap,
|
String pageLevel,
|
String companyRegion,
|
String companyIndustryType,
|
String companySubIndustryType) {
|
if ("firstPage".equals(pageLevel)) {
|
|
} else if ("secondPage".equals(pageLevel)) {
|
modelMap.put("companyRegion", companyRegion);
|
} else if ("thirdPage".equals(pageLevel)) {
|
modelMap.put("companyRegion", companyRegion);
|
modelMap.put("companyIndustryType", companyIndustryType);
|
modelMap.put("companySubIndustryType", companySubIndustryType);
|
}
|
return prefix + "/dangerLedgerListTotalByThisMonthHighDanger";
|
}
|
|
/**
|
* thisMonthNormalDanger隐患台账 列表页面
|
*/
|
@GetMapping("/dangerLedgerListTotal/thisMonthNormalDanger")
|
// String pageLevel,第几个层级
|
// String companyRegion,公司区域
|
// String companyIndustryType,行业分类
|
// String companySubIndustryType,行业子分类
|
public String dangerLedgerListTotalByThisMonthNormalDanger(ModelMap modelMap,
|
String pageLevel,
|
String companyRegion,
|
String companyIndustryType,
|
String companySubIndustryType) {
|
if ("firstPage".equals(pageLevel)) {
|
|
} else if ("secondPage".equals(pageLevel)) {
|
modelMap.put("companyRegion", companyRegion);
|
} else if ("thirdPage".equals(pageLevel)) {
|
modelMap.put("companyRegion", companyRegion);
|
modelMap.put("companyIndustryType", companyIndustryType);
|
modelMap.put("companySubIndustryType", companySubIndustryType);
|
}
|
return prefix + "/dangerLedgerListTotalByThisMonthNormalDanger";
|
}
|
|
/**
|
* unRectifyDanger隐患台账 列表页面
|
*/
|
@GetMapping("/dangerLedgerListTotal/unRectifyDanger")
|
// String pageLevel,第几个层级
|
// String companyRegion,公司区域
|
// String companyIndustryType,行业分类
|
// String companySubIndustryType,行业子分类
|
public String dangerLedgerListTotalByUnRectifyDanger(ModelMap modelMap,
|
String pageLevel,
|
String companyRegion,
|
String companyIndustryType,
|
String companySubIndustryType) {
|
if ("firstPage".equals(pageLevel)) {
|
|
} else if ("secondPage".equals(pageLevel)) {
|
modelMap.put("companyRegion", companyRegion);
|
} else if ("thirdPage".equals(pageLevel)) {
|
modelMap.put("companyRegion", companyRegion);
|
modelMap.put("companyIndustryType", companyIndustryType);
|
modelMap.put("companySubIndustryType", companySubIndustryType);
|
}
|
return prefix + "/dangerLedgerListTotalByUnRectifyDanger";
|
}
|
|
|
/**
|
* 查询隐患台账列表
|
*/
|
@PostMapping("/dangerLedgerListTotal")
|
@ResponseBody
|
public TableDataInfo dangerLedgerListTotal(HiddenDangerCheckPoint hiddenDangerCheckPoint, String dateRangeLedger, String rectifyStatusLedger, String rectifyDeptIdLedger,
|
Company companyQuery) {
|
// User userQuery = new User();
|
// List<User> userList = userService.selectUserList(userQuery);
|
// List<Long> userIdList = new ArrayList<>();
|
// for (User user : userList) {
|
// userIdList.add(user.getUserId());
|
// }
|
//
|
// if (userIdList.size() == 0) {
|
// return getDataTable(new ArrayList<HiddenDangerCheckPoint>());
|
// }
|
//
|
// hiddenDangerCheckPoint.setLedgerUserIdList(userIdList);//隐患整改人ID 为登陆账号companyId下的userId的
|
|
hiddenDangerCheckPoint.setRectifyUserIdIsNotNull("1");//隐患整改人ID 不为空
|
|
//有区域的公司列表的过滤
|
// Company companyQuery = new Company();
|
List<Company> companyListTemp = companyService.selectCompanyList(companyQuery);
|
List<Long> companyIdListLast = new ArrayList<>();
|
for (Company c : companyListTemp) {
|
if (!StringUtil.isEmpty(c.getCompanyRegion())) {
|
companyIdListLast.add(c.getCompanyId());
|
}
|
}
|
hiddenDangerCheckPoint.setCompanyIdList(companyIdListLast);
|
|
List<HiddenDangerCheckPoint> list = new ArrayList<>();
|
if (companyIdListLast.size() > 0) {
|
//日期区间
|
if (!StringUtils.isEmpty(dateRangeLedger)) {
|
if (("近一周").equals(dateRangeLedger)) {
|
hiddenDangerCheckPoint.setParams(ApiHiddenDangerCheckService.getDaySevenRange());
|
} else if (("近一月").equals(dateRangeLedger)) {
|
hiddenDangerCheckPoint.setParams(ApiHiddenDangerCheckService.getMonthRange());
|
} else if (("近一年").equals(dateRangeLedger)) {
|
hiddenDangerCheckPoint.setParams(ApiHiddenDangerCheckService.getYearRange());
|
} else if (("当月").equals(dateRangeLedger)) {
|
hiddenDangerCheckPoint.setParams(ApiHiddenDangerCheckService.getLastMonthTime(0, 0));
|
}
|
}
|
//整改状态
|
if (!StringUtils.isEmpty(rectifyStatusLedger)) {
|
if (("未整改").equals(rectifyStatusLedger)) {
|
hiddenDangerCheckPoint.setStage("4");
|
hiddenDangerCheckPoint.setRectifyStatus("0");
|
} else if (("未验收").equals(rectifyStatusLedger)) {
|
hiddenDangerCheckPoint.setStage("5");
|
hiddenDangerCheckPoint.setAcceptStatus("0");
|
} else if (("已验收").equals(rectifyStatusLedger)) {
|
hiddenDangerCheckPoint.setStage("5");
|
hiddenDangerCheckPoint.setAcceptStatus("1");
|
} else if (("超期改").equals(rectifyStatusLedger)) {
|
hiddenDangerCheckPoint.setStage("5");
|
hiddenDangerCheckPoint.setOverdueRectify("1");
|
}
|
}
|
//整改部门
|
if (!StringUtils.isEmpty(rectifyDeptIdLedger)) {
|
hiddenDangerCheckPoint.setRectifyDeptId(Long.valueOf(rectifyDeptIdLedger));
|
}
|
|
startPage();
|
list = hiddenDangerCheckPointService.selectHiddenDangerCheckPointList(hiddenDangerCheckPoint);
|
}
|
return getDataTable(list);
|
}
|
|
|
/**
|
* 查询检查点及评价列表
|
*/
|
@PostMapping("/riskCheckPoint/ledger")
|
@ResponseBody
|
public TableDataInfo ledgerList(RiskCheckPoint riskCheckPoint, Company companyQuery) {
|
//有区域的公司列表的过滤
|
// Company companyQuery = new Company();
|
List<Company> companyListTemp = companyService.selectCompanyList(companyQuery);
|
List<Long> companyIdListLast = new ArrayList<>();
|
for (Company c : companyListTemp) {
|
if (!StringUtil.isEmpty(c.getCompanyRegion())) {
|
companyIdListLast.add(c.getCompanyId());
|
}
|
}
|
List<RiskCheckPoint> list = new ArrayList<>();
|
if (companyIdListLast.size() > 0) {
|
riskCheckPoint.setCompanyIdList(companyIdListLast);
|
startPage();
|
list = riskCheckPointService.selectRiskCheckPointList(riskCheckPoint);
|
}
|
return getDataTable(list);
|
}
|
|
|
/**
|
* 用于记录风险清单台账
|
*
|
* @return
|
*/
|
// String pageLevel,第几个层级
|
// String companyRegion,公司区域
|
// String companyIndustryType,行业分类
|
// String companySubIndustryType,行业子分类
|
@RequestMapping("/riskCheckPoint/ledger/{level}")
|
public String ledgerTotalAndRiskLevel(ModelMap modelMap,
|
@PathVariable("level") String level,
|
String pageLevel,
|
String companyRegion,
|
String companyIndustryType,
|
String companySubIndustryType) {
|
if ("major".equals(level)) {
|
//重大风险
|
modelMap.put("level", "重大");
|
} else if ("larger".equals(level)) {
|
//较大风险
|
modelMap.put("level", "较大");
|
} else if ("general".equals(level)) {
|
//一般风险
|
modelMap.put("level", "一般");
|
} else if ("low".equals(level)) {
|
modelMap.put("level", "低");
|
}
|
|
if ("firstPage".equals(pageLevel)) {
|
|
} else if ("secondPage".equals(pageLevel)) {
|
modelMap.put("companyRegion", companyRegion);
|
} else if ("thirdPage".equals(pageLevel)) {
|
modelMap.put("companyRegion", companyRegion);
|
modelMap.put("companyIndustryType", companyIndustryType);
|
modelMap.put("companySubIndustryType", companySubIndustryType);
|
}
|
|
return prefix + "/ledgerTotalAndRiskLevel";
|
}
|
|
|
}
|