bug修改

This commit is contained in:
Administrator 2023-06-02 13:59:52 +08:00
parent 05a0b927b4
commit 72af5999d5
6 changed files with 184 additions and 103 deletions

View File

@ -119,27 +119,31 @@
</select>
<select id="getProjectInspectRecordCount" resultType="java.util.Map">
select tp.*,
round(IFNULL(TRUNCATE(IFNULL(rectifyCompleteNum, 0) / IFNULL(inspectNum, 0), 4), 0) * 100,
2) completeRatio,
round(IFNULL(TRUNCATE(IFNULL(closeNum, 0) / IFNULL(totalNum, 0), 4), 0) * 100, 2) closeRatio
round(IFNULL(TRUNCATE(IFNULL(rectifyCompleteNum, 0) / IFNULL(inspectNum, 0), 4), 0) * 100,
2) completeRatio, <!--及时整改率-->
round(IFNULL(TRUNCATE(IFNULL(closeNum, 0) / IFNULL(totalNum, 0), 4), 0) * 100, 2) closeRatio,
tp.totalNum-tp.weekInspectNum-tp.monthInspectNum AS otherInspectNum <!--其他数量,就是除了月、周的检查数量-->
from (
SELECT count(1) totalNum,
IFNULL(SUM((CASE WHEN a.record_type = 2 THEN 1 ELSE 0 END)), 0) investigateNum,
IFNULL(SUM((CASE WHEN a.record_type = 1 THEN 1 ELSE 0 END)), 0) inspectNum,
IFNULL(SUM((CASE WHEN a.status = 1 or a.status = 4 THEN 1 ELSE 0 END)), 0) closeNum,
IFNULL(SUM((CASE WHEN a.status = 4 THEN 1 ELSE 0 END)), 0) rectifyCompleteNum,
IFNULL(SUM((CASE WHEN a.status = 2 OR a.status = 3 THEN 1 ELSE 0 END)), 0) notCloseNum,
IFNULL(SUM((CASE
WHEN (a.status = 2 OR a.status = 3)
AND DATE_FORMAT(now(), "%Y-%m-%d") > a.change_limit_time THEN 1
ELSE 0 END)), 0) overdueNotCloseNum,
IFNULL(SUM((CASE
WHEN a.status = 2 AND DATE_FORMAT(now(), "%Y-%m-%d") > a.change_limit_time THEN 1
ELSE 0 END)),
0) overdueRectificationNum,
IFNULL(SUM((CASE WHEN a.status = 2 THEN 1 ELSE 0 END)), 0) rectificationNum,
IFNULL(SUM((CASE WHEN a.status = 3 THEN 1 ELSE 0 END)), 0) reviewNum
SELECT count(1) totalNum,
IFNULL(SUM((CASE WHEN a.record_type = 2 THEN 1 ELSE 0 END)), 0) investigateNum,
IFNULL(SUM((CASE WHEN a.record_type = 1 THEN 1 ELSE 0 END)), 0) inspectNum,
IFNULL(SUM((CASE WHEN a.status = 1 or a.status = 4 THEN 1 ELSE 0 END)), 0) closeNum,
IFNULL(SUM((CASE WHEN a.status = 4 THEN 1 ELSE 0 END)), 0) rectifyCompleteNum, <!--合格,就是已整改-->
IFNULL(SUM((CASE WHEN a.status = 2 OR a.status = 3 THEN 1 ELSE 0 END)), 0) notCloseNum, <!--未整改-->
IFNULL(SUM((CASE
WHEN (a.status = 2 OR a.status = 3)
AND DATE_FORMAT(now(), "%Y-%m-%d") > a.change_limit_time THEN 1
ELSE 0 END)), 0) overdueNotCloseNum,
IFNULL(SUM((CASE
WHEN a.status = 2 AND DATE_FORMAT(now(), "%Y-%m-%d") > a.change_limit_time THEN 1
ELSE 0 END)),
0) overdueRectificationNum,
IFNULL(SUM((CASE WHEN a.status = 2 THEN 1 ELSE 0 END)), 0) rectificationNum,
IFNULL(SUM((CASE WHEN a.status = 3 THEN 1 ELSE 0 END)), 0) reviewNum, <!--待复查,待审核-->
IFNULL(SUM((CASE WHEN tr.frequency_type = 3 THEN 1 ELSE 0 END)), 0) weekInspectNum, <!--周检查数量-->
IFNULL(SUM((CASE WHEN tr.frequency_type = 4 THEN 1 ELSE 0 END)), 0) monthInspectNum <!--月检查数量-->
from hidden_danger_inspection_record a
left join inspect_task_record tr on tr.id=a.task_id
WHERE a.project_sn = #{projectSn}
<if test="createUser != null and createUser != ''">
and a.create_user = #{createUser}
@ -414,4 +418,4 @@
IFNULL(sum(if(`status` != 1 AND `status` != 4 AND project_sn = #{projectSn}, 1, 0)), 0) unResolveNum
FROM hidden_danger_inspection_record
</select>
</mapper>
</mapper>

View File

@ -743,12 +743,12 @@ public class EnvironmentAlarmServiceImpl extends ServiceImpl<EnvironmentAlarmMap
Map<String,Object> map=companyService.getCompanyType(param);
Integer dateType=MapUtils.getInteger(param,"dateType");
List<String> dayList=new ArrayList<>();
if(dateType==2){
//查询月所有天数
dayList=DateUtil.getNowMonthAllDayList();
}else{
//查询周所有天数
dayList=DateUtil.getNowWeekAllDayList();
if (dateType == 2) {
//查询近一月所有天数
dayList = DateUtil.getDaysBetweenLastMonth();
} else {
//查询近一周所有天数
dayList = DateUtil.getDaysBetweenLastWeek();
}
List<Map<String,Object>> list=companyService.selectComapnyOrProjectList(map);
if(list!=null&&list.size()>0){

View File

@ -36,7 +36,8 @@ public class GtMaterialDepartmentTeam implements Serializable {
*/
@Excel(name = "作业单位id", width = 15)
@ApiModelProperty(value = "作业单位id")
private String unitName;
private Long gtMaterialOperatingUnitId;
/**
* 班组
*/
@ -84,4 +85,13 @@ public class GtMaterialDepartmentTeam implements Serializable {
@ApiModelProperty(value = "更新时间")
private java.util.Date updateTime;
/**
* 单位名称
*/
@Excel(name = "单位名称", width = 15)
@ApiModelProperty(value = "单位名称")
@TableField(exist = false)
private String unitName;
}

View File

@ -2,8 +2,9 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhgd.xmgl.modules.gt.mapper.GtMaterialDepartmentTeamMapper">
<select id="queryPageList" resultType="com.zhgd.xmgl.modules.gt.entity.GtMaterialDepartmentTeam">
select dt.*
select dt.*,ou.unit_name,ou.id as gt_material_operating_unit_id
from gt_material_department_team dt
join gt_material_operating_unit ou on ou.id=dt.gt_material_operating_unit_id
${ew.customSqlSegment}
</select>
</mapper>

View File

@ -1,6 +1,7 @@
package com.zhgd.xmgl.modules.worker.controller;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zhgd.annotation.OperLog;
import com.zhgd.jeecg.common.api.vo.Result;
@ -19,10 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
/**

View File

@ -1,12 +1,18 @@
package com.zhgd.xmgl.util;
import cn.hutool.core.date.DateTime;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
* @program: wisdomSite
@ -19,6 +25,7 @@ public class DateUtil {
/**
* 时间格式化
*
* @param oldDate
* @return
*/
@ -28,7 +35,7 @@ public class DateUtil {
try {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
Date date = df.parse(oldDate);
Calendar beijingcal=Calendar.getInstance();
Calendar beijingcal = Calendar.getInstance();
beijingcal.setTime(date);
//SimpleDateFormat df1 = new SimpleDateFormat ("EEE MMM dd HH:mm:ss Z yyyy", Locale.UK);
//date1 = df1.parse(date.toString());
@ -59,7 +66,7 @@ public class DateUtil {
String formatStr2 = null;
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");//注意格式化的表达式
try {
Date time = format.parse(createTime );
Date time = format.parse(createTime);
String date = time.toString();
//将西方形式的日期字符串转换成java.util.Date对象
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", java.util.Locale.US);
@ -74,9 +81,10 @@ public class DateUtil {
/**
* 查询本周所有天数
*
* @return
*/
public static List<String> getNowWeekAllDayList(){
public static List<String> getNowWeekAllDayList() {
Calendar cal = Calendar.getInstance();
// 判断要计算的日期是否是周日如果是则减一天计算周六的否则会出问题计算到下一周去了
// 获得当前日期是一个星期的第几天
@ -91,46 +99,99 @@ public class DateUtil {
int day = cal.get(Calendar.DAY_OF_WEEK);
// 根据日历的规则给当前日期减去星期几与一个星期第一天的差值
cal.add(Calendar.DATE, cal.getFirstDayOfWeek() - day);
return findDates(cal.getTime(),new Date());
return findDates(cal.getTime(), new Date());
}
/**
* 查询本月所有天数Fix2023-06-01到2023-06-30
*
* @return
*/
public static List<String> getNowMonthAllDayListFix() {
ArrayList<String> rtList = new ArrayList<>();
Date now = new Date();
DateTime beginDate = cn.hutool.core.date.DateUtil.beginOfMonth(now);
DateTime endDate = cn.hutool.core.date.DateUtil.endOfMonth(now);
long offset = cn.hutool.core.date.DateUtil.betweenDay(beginDate, endDate, true);
for (int i = 0; i < offset + 1; i++) {
rtList.add(cn.hutool.core.date.DateUtil.formatDate(cn.hutool.core.date.DateUtil.offsetDay(beginDate, i)));
}
return rtList;
}
/**
* 查询一个月前内所有天数2023-06-10到2023-07-10
*
* @return
*/
public static List<String> getDaysBetweenLastMonth() {
ArrayList<String> rtList = new ArrayList<>();
DateTime beginDate = cn.hutool.core.date.DateUtil.lastMonth();
DateTime endDate = DateTime.now();
long offset = cn.hutool.core.date.DateUtil.betweenDay(beginDate, endDate, true);
for (int i = 0; i < offset + 1; i++) {
rtList.add(cn.hutool.core.date.DateUtil.formatDate(cn.hutool.core.date.DateUtil.offsetDay(beginDate, i)));
}
return rtList;
}
/**
* 查询一个周前内所有天数2023-06-10到2023-07-10
*
* @return
*/
public static List<String> getDaysBetweenLastWeek() {
ArrayList<String> rtList = new ArrayList<>();
DateTime beginDate = cn.hutool.core.date.DateUtil.lastWeek();
DateTime endDate = DateTime.now();
long offset = cn.hutool.core.date.DateUtil.betweenDay(beginDate, endDate, true);
for (int i = 0; i < offset + 1; i++) {
rtList.add(cn.hutool.core.date.DateUtil.formatDate(cn.hutool.core.date.DateUtil.offsetDay(beginDate, i)));
}
return rtList;
}
/**
* 查询现在时间几天前到现在之间的所有日期
*
* @param days
* @return
*/
public static List<String> getOtherDayAllDayList(int days){
public static List<String> getOtherDayAllDayList(int days) {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE,-days);
return findDates(cal.getTime(),new Date());
cal.add(Calendar.DATE, -days);
return findDates(cal.getTime(), new Date());
}
/**
* 查询本月所有天数
*
* @return
*/
public static List<String> getNowMonthAllDayList(){
public static List<String> getNowMonthAllDayList() {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, 1);
return findDates(cal.getTime(),new Date());
return findDates(cal.getTime(), new Date());
}
/**
* 获取两个时间段所有天数
*
* @param beginTime
* @param endTime
* @return
*/
public static List<String> getDiffTimeDayList(String beginTime,String endTime){
public static List<String> getDiffTimeDayList(String beginTime, String endTime) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
return findDates(sdf.parse(beginTime),sdf.parse(endTime));
return findDates(sdf.parse(beginTime), sdf.parse(endTime));
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
public static List<String> findDates(Date dBegin, Date dEnd){
public static List<String> findDates(Date dBegin, Date dEnd) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
List lDate = new ArrayList();
lDate.add(sdf.format(dBegin));
@ -141,10 +202,10 @@ public class DateUtil {
// 使用给定的 Date 设置此 Calendar 的时间
calEnd.setTime(dEnd);
// 测试此日期是否在指定日期之后
while (dEnd.after(calBegin.getTime())){
while (dEnd.after(calBegin.getTime())) {
// 根据日历的规则为给定的日历字段添加或减去指定的时间量
calBegin.add(Calendar.DAY_OF_MONTH, 1);
if(calBegin.getTimeInMillis()<=dEnd.getTime()) {
if (calBegin.getTimeInMillis() <= dEnd.getTime()) {
lDate.add(sdf.format(calBegin.getTime()));
}
}
@ -153,36 +214,37 @@ public class DateUtil {
/**
* 获取指定年份所有天数
*
* @param yearMonth
* @return
*/
public static List<String> getYearAllMonthList(String yearMonth) {
String year=yearMonth.substring(0,4);
List<String> list=new ArrayList<>();
for (int i = 1; i <=12 ; i++) {
if(i<10){
list.add(year+"0"+i);
}else{
list.add(year+i);
String year = yearMonth.substring(0, 4);
List<String> list = new ArrayList<>();
for (int i = 1; i <= 12; i++) {
if (i < 10) {
list.add(year + "0" + i);
} else {
list.add(year + i);
}
}
return list;
}
/**
*
* @param yearMonth 月份格式yyyy-MM
* @param yearMonth 月份格式yyyy-MM
* @return
*/
public static List<String> getMonthDayList(String yearMonth) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
//判断是否是当月
if(yearMonth.equals(sdf.format(new Date()))){
if (yearMonth.equals(sdf.format(new Date()))) {
return getNowMonthAllDayList();
}else{
} else {
return getDayListOfMonth(yearMonth);
}
}
public static List<String> getDayListOfMonth(String yearMonth) {
int year = Integer.parseInt(yearMonth.split("-")[0]); //
int month = Integer.parseInt(yearMonth.split("-")[1]); //
@ -205,14 +267,15 @@ public class DateUtil {
int firstDay = startCal.getActualMinimum(Calendar.DAY_OF_MONTH);
//设置日历中月份的最小天数
startCal.set(Calendar.DAY_OF_MONTH, firstDay);
return findDates(startCal.getTime(),endCal.getTime());
return findDates(startCal.getTime(), endCal.getTime());
}
/**
* 获取当前周第一天日期
*
* @return
*/
public static String getNowWeekStartTime(){
public static String getNowWeekStartTime() {
Calendar cal = Calendar.getInstance();
// 判断要计算的日期是否是周日如果是则减一天计算周六的否则会出问题计算到下一周去了
// 获得当前日期是一个星期的第几天
@ -230,16 +293,18 @@ public class DateUtil {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.format(cal.getTime());
}
public static List<String> getDiffTimeYearList(String beginTime,String endTime){
public static List<String> getDiffTimeYearList(String beginTime, String endTime) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
return findYear(sdf.parse(beginTime),sdf.parse(endTime));
return findYear(sdf.parse(beginTime), sdf.parse(endTime));
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
public static List<String> findYear(Date dBegin, Date dEnd){
public static List<String> findYear(Date dBegin, Date dEnd) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
List lDate = new ArrayList();
lDate.add(sdf.format(dBegin));
@ -250,25 +315,27 @@ public class DateUtil {
// 使用给定的 Date 设置此 Calendar 的时间
calEnd.setTime(dEnd);
// 测试此日期是否在指定日期之后
while (dEnd.after(calBegin.getTime())){
while (dEnd.after(calBegin.getTime())) {
// 根据日历的规则为给定的日历字段添加或减去指定的时间量
calBegin.add(Calendar.YEAR, 1);
if(calBegin.getTimeInMillis()<=dEnd.getTime()) {
if (calBegin.getTimeInMillis() <= dEnd.getTime()) {
lDate.add(sdf.format(calBegin.getTime()));
}
}
return lDate;
}
public static List<String> getDiffTimeMonthList(String beginTime,String endTime){
public static List<String> getDiffTimeMonthList(String beginTime, String endTime) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
return findMonth(sdf.parse(beginTime),sdf.parse(endTime));
return findMonth(sdf.parse(beginTime), sdf.parse(endTime));
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
public static List<String> findMonth(Date dBegin, Date dEnd){
public static List<String> findMonth(Date dBegin, Date dEnd) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
List lDate = new ArrayList();
lDate.add(sdf.format(dBegin));
@ -279,10 +346,10 @@ public class DateUtil {
// 使用给定的 Date 设置此 Calendar 的时间
calEnd.setTime(dEnd);
// 测试此日期是否在指定日期之后
while (dEnd.after(calBegin.getTime())){
while (dEnd.after(calBegin.getTime())) {
// 根据日历的规则为给定的日历字段添加或减去指定的时间量
calBegin.add(Calendar.MONTH, 1);
if(calBegin.getTimeInMillis()<=dEnd.getTime()) {
if (calBegin.getTimeInMillis() <= dEnd.getTime()) {
lDate.add(sdf.format(calBegin.getTime()));
}
}
@ -290,16 +357,16 @@ public class DateUtil {
}
public static List<String> getDiffTimeWeekList(String beginTime,String endTime){
public static List<String> getDiffTimeWeekList(String beginTime, String endTime) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate startDate = LocalDate.parse(beginTime,formatter);
LocalDate endDate = LocalDate.parse(endTime,formatter);
LocalDate startDate = LocalDate.parse(beginTime, formatter);
LocalDate endDate = LocalDate.parse(endTime, formatter);
List<String> lDate = new ArrayList();
while (endDate.isAfter(startDate)){
String start=startDate.format(formatter);
if(startDate.getDayOfWeek()==DayOfWeek.SUNDAY) {
while (endDate.isAfter(startDate)) {
String start = startDate.format(formatter);
if (startDate.getDayOfWeek() == DayOfWeek.SUNDAY) {
lDate.add(start + "/" + start);
}else{
} else {
LocalDate sunday = startDate.with(TemporalAdjusters.next(DayOfWeek.SUNDAY));
if (sunday.isAfter(endDate)) {
lDate.add(start + "/" + endDate.format(formatter));
@ -307,7 +374,7 @@ public class DateUtil {
lDate.add(start + "/" + sunday.format(formatter));
}
}
startDate=startDate.with(TemporalAdjusters.next(DayOfWeek.SUNDAY)).plusDays(1);
startDate = startDate.with(TemporalAdjusters.next(DayOfWeek.SUNDAY)).plusDays(1);
}
return lDate;
@ -315,15 +382,16 @@ public class DateUtil {
/**
* 获取当前时间和当天时间几天前之间的所有天数
* @param dayNum 当天时间以前具体几天
*
* @param dayNum 当天时间以前具体几天
* @return
*/
public static List<String> getNowFewDaysAgoList(int dayNum){
public static List<String> getNowFewDaysAgoList(int dayNum) {
try {
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, -dayNum);
Date date = calendar.getTime();
return findDates(date,new Date());
return findDates(date, new Date());
} catch (Exception e) {
e.printStackTrace();
}
@ -331,22 +399,20 @@ public class DateUtil {
}
/**
*
* @param type 1 今日24 小时2本周所有天3本月所有天
* @return
*/
public static List<String> getDayList(Integer type) {
if(type==1){
List<String> list=new ArrayList<>();
for(int i=0;i<=23;i++){
list.add(i+"");
if (type == 1) {
List<String> list = new ArrayList<>();
for (int i = 0; i <= 23; i++) {
list.add(i + "");
}
return list;
}else if(type==2){
return getNowWeekAllDayList();
}else if(type==3){
} else if (type == 2) {
return getDaysBetweenLastWeek();
} else if (type == 3) {
return getNowMonthAllDayList();
}
return null;
@ -354,42 +420,44 @@ public class DateUtil {
/**
* 比较两个日期大小
*
* @param time1
* @param time2
* @return
* @throws ParseException
*/
public static boolean compareTime(String time1,String time2){
public static boolean compareTime(String time1, String time2) {
try {
//如果想比较日期则写成"yyyy-MM-dd"就可以了
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//将字符串形式的时间转化为Date类型的时间
Date a=sdf.parse(time1);
Date b=sdf.parse(time2);
Date a = sdf.parse(time1);
Date b = sdf.parse(time2);
//Date类的一个方法如果a早于b返回true否则返回false
//a时间下雨b时间返回true,否正返回false
if(a.before(b)) {
if (a.before(b)) {
return true;
}else {
} else {
return false;
}
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
/**
* 查询当前时间指定天数之前的日期
* @Title: getBeginDayTime
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param @param days
* @param @return 参数
*
* @param @param days
* @param @return 参数
* @return String 返回类型
* @throws
* @Title: getBeginDayTime
*/
public static String getBeginDayTime(int days){
public static String getBeginDayTime(int days) {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE,-days);
cal.add(Calendar.DATE, -days);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return sdf.format(cal.getTime());
}