Commit b3dab61c authored by tianbo's avatar tianbo

防火监督报告提交

parent a1ef59e2
...@@ -24,6 +24,8 @@ public class DateUtils { ...@@ -24,6 +24,8 @@ public class DateUtils {
public static final String MINUTE_ONLY_PATTERN = "mm"; public static final String MINUTE_ONLY_PATTERN = "mm";
public static final String HOUR_ONLY_PATTERN = "HH"; public static final String HOUR_ONLY_PATTERN = "HH";
public static final String DATE_PATTERN_NUM = "yyyyMMdd"; public static final String DATE_PATTERN_NUM = "yyyyMMdd";
public static final String CHN_DATE_PATTERN_YEAR = "yyyy年";
public static final String CHN_DATE_PATTERN_MONTH = "MM月";
/** /**
* 获取 当前年、半年、季度、月、日、小时 开始结束时间 * 获取 当前年、半年、季度、月、日、小时 开始结束时间
...@@ -604,7 +606,7 @@ public class DateUtils { ...@@ -604,7 +606,7 @@ public class DateUtils {
System.out.println(dateTimeToDateStringIfTimeEndZero(dateTimeToDate(new Date())));*/ System.out.println(dateTimeToDateStringIfTimeEndZero(dateTimeToDate(new Date())));*/
//System.out.println(dateBetween(dateParse("2017-01-30", null), dateParse("2017-02-01", null))); //System.out.println(dateBetween(dateParse("2017-01-30", null), dateParse("2017-02-01", null)));
//System.out.println(dateBetweenIncludeToday(dateParse("2017-01-30", null), dateParse("2017-02-01", null))); //System.out.println(dateBetweenIncludeToday(dateParse("2017-01-30", null), dateParse("2017-02-01", null)));
System.out.println(getDate(dateParse("2017-01-17", null))); // System.out.println(getDate(dateParse("2017-01-17", null)));
/* /*
System.out.println(getDaysOfMonth(dateParse("2017-02-01", null))); System.out.println(getDaysOfMonth(dateParse("2017-02-01", null)));
System.out.println(getDaysOfYear(dateParse("2017-01-30", null)));*/ System.out.println(getDaysOfYear(dateParse("2017-01-30", null)));*/
...@@ -612,6 +614,13 @@ public class DateUtils { ...@@ -612,6 +614,13 @@ public class DateUtils {
// .MONTH_PATTERN)); // .MONTH_PATTERN));
/*System.out.println(dateFormat(maxDateOfMonth(dateParse("2016-02", "yyyy-MM")), null)); /*System.out.println(dateFormat(maxDateOfMonth(dateParse("2016-02", "yyyy-MM")), null));
System.out.println(dateFormat(minDateOfMonth(dateParse("2016-03-31", null)), null));*/ System.out.println(dateFormat(minDateOfMonth(dateParse("2016-03-31", null)), null));*/
System.out.println(dateFormat(new Date(), CHN_DATE_PATTERN_YEAR));
System.out.println(dateFormat(new Date(), CHN_DATE_PATTERN_MONTH));
System.out.println(getWeekOfYear(new Date()));
System.out.println(getQuarterStr(getMonth(dateParse("2021-5-11", null))));
System.out.println(getWeekBeginDate(dateParse("2021-10-11", null)));
System.out.println(getWeekEndDate(dateParse("2021-10-11", null)));
} }
/** /**
...@@ -720,4 +729,77 @@ public class DateUtils { ...@@ -720,4 +729,77 @@ public class DateUtils {
String dateString = formatter.format(currentTime); String dateString = formatter.format(currentTime);
return dateString; return dateString;
} }
/**
* 获取一年的第几周
*
* @param date
* @return
*/
public static int getWeekOfYear(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
int week_of_year = c.get(Calendar.WEEK_OF_YEAR);
return week_of_year;
}
/**
* 通过月份计算季度
* @param month
* @return
*/
public static int getQuarter(int month) {
if(month < 1 || month > 12) {
throw new IllegalArgumentException("month is invalid.");
}
return (month - 1) / 3 + 1;
}
/**
* 通过月份计算季度
* @param month
* @return
*/
public static String getQuarterStr(int month) {
if(month < 1 || month > 12) {
throw new IllegalArgumentException("month is invalid.");
}
return (month - 1) / 3 + 1 + "";
}
/**
* 获取指定时间所在周的第一天日期
* @param date
* @return
*/
public static int getWeekBeginDate(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setFirstDayOfWeek(Calendar.MONDAY);
calendar.setTime(date);
calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
System.out.println(calendar.getTime());
return getDate(calendar.getTime());
}
/**
* 获取指定时间所在周的最后一天日期
* @param date
* @return
*/
public static int getWeekEndDate(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setFirstDayOfWeek(Calendar.MONDAY);
calendar.setTime(date);
calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
System.out.println(calendar.getTime());
return getDate(calendar.getTime());
}
public static String getWeekDate(Date date) throws ParseException {
String month = dateFormat(date, CHN_DATE_PATTERN_MONTH);
String weekDateStr = getWeekBeginDate(date) + "-" + getWeekEndDate(date);
return month + weekDateStr + "日";
}
} }
...@@ -89,4 +89,6 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> { ...@@ -89,4 +89,6 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> {
void updatelistByParentId(String codex, String code); void updatelistByParentId(String codex, String code);
List< Map<String,String>> getPersonSimpleDetail(); List< Map<String,String>> getPersonSimpleDetail();
List<Map<String, Long>> countDeptByCompanyId(@Param("companyIdList") List<String> companyIdList);
} }
...@@ -659,4 +659,20 @@ LEFT JOIN ( ...@@ -659,4 +659,20 @@ LEFT JOIN (
AND field_code = 'telephone' AND field_code = 'telephone'
) cdf ON person.sequence_nbr = cdf.instance_id ) cdf ON person.sequence_nbr = cdf.instance_id
</select> </select>
<select id="countDeptByCompanyId" resultType="java.util.Map">
SELECT (SELECT count(1)
FROM cb_org_usr
WHERE biz_org_code LIKE
concat((SELECT biz_org_code FROM `cb_org_usr` WHERE sequence_nbr = t1.sequence_nbr),
'%'
)
AND biz_org_type = 'DEPARTMENT'
AND parent_id = t1.sequence_nbr) count,
sequence_nbr
FROM cb_org_usr t1
WHERE sequence_nbr IN
<foreach collection ='companyIdList' item='companyId' index='index' open="(" close= ")" separator=",">
#{companyId}
</foreach>
</select>
</mapper> </mapper>
...@@ -220,4 +220,16 @@ public class LatentDanger extends BasicEntity { ...@@ -220,4 +220,16 @@ public class LatentDanger extends BasicEntity {
*/ */
@TableField(exist = false) @TableField(exist = false)
private String processStateName; private String processStateName;
/**
* 隐患创建人名称
*/
@TableField(exist = false)
private String checkUserName;
/**
* 复查执行人名称
*/
@TableField(exist = false)
private String executeUserName;
} }
package com.yeejoin.amos.supervision.common.enums;
/**
* 计划频次类型枚举
*/
public enum PlanFrequencyEnum {
WEEK("周", "2", "周检查报告"),
MONTH("月", "3", "月检查报告"),
QUARTER("季度", "4", "季度检查报告");
String name;
String code;
String reportName;
PlanFrequencyEnum(String name, String code, String reportName) {
this.name = name;
this.code = code;
this.reportName = reportName;
}
public static PlanFrequencyEnum getEnumByCode(String code) {
for (PlanFrequencyEnum c : PlanFrequencyEnum.values()) {
if (c.getCode().equals(code)) {
return c;
}
}
return null;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getExtraInfo() {
return reportName;
}
public void setExtraInfo(String reportName) {
this.reportName = reportName;
}
}
package com.yeejoin.amos.supervision.core.common.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
public class CheckReportCompanyDto implements Serializable {
@ApiModelProperty(value = "单位id")
String id;
@ApiModelProperty(value = "单位名称")
String name;
@ApiModelProperty(value = "点位数量")
Integer deptCount;
@ApiModelProperty(value = "检查陪同人员")
String escortUser;
@ApiModelProperty(value = "检查结果")
String checkResult;
}
package com.yeejoin.amos.supervision.core.common.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class CheckReportDangerDto implements Serializable {
@ApiModelProperty(value = "单位id")
String companyId;
@ApiModelProperty(value = "单位名称")
String companyName;
@ApiModelProperty(value = "隐患id")
String dangerId;
@ApiModelProperty(value = "存在问题")
String dangerName;
@ApiModelProperty(value = "隐患状态")
String dangerStateName;
@ApiModelProperty(value = "检查时间")
Date createDate;
@ApiModelProperty(value = "检查人员")
String checkUserName;
@ApiModelProperty(value = "复查人员")
String reviewUser;
@ApiModelProperty(value = "备注")
String remark;
}
package com.yeejoin.amos.supervision.core.common.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@Data
public class CheckReportDto implements Serializable {
@ApiModelProperty(value = "检查报告id")
Long id;
@ApiModelProperty(value = "报告名称")
String name;
@ApiModelProperty(value = "所属计划名称")
String planName;
@ApiModelProperty(value = "计划检查类型")
String planCheckType;
@ApiModelProperty(value = "检查级别")
String planCheckLevel;
@ApiModelProperty(value = "计划开始时间")
Date startPlanTaskDate;
@ApiModelProperty(value = "计划结束时间")
Date endPlanTaskDate;
@ApiModelProperty(value = "执行人")
String checkUser;
@ApiModelProperty(value = "计划任务id")
Long planTaskId;
@ApiModelProperty(value = "实际开始时间")
Date startCheckDate;
@ApiModelProperty(value = "实际结束时间")
Date endCheckDate;
@ApiModelProperty(value = "检查单位数量")
Integer companyCount;
@ApiModelProperty(value = "存在问题单位数量")
Integer problemCompanyCount;
@ApiModelProperty(value = "是否有重大隐患(1有,0无)")
Boolean hasMajorDanger;
@ApiModelProperty(value = "存在安全隐患数量")
Integer dangerCount;
@ApiModelProperty(value = "现场已整改隐患数量")
Integer onsiteReformCount;
@ApiModelProperty(value = "复查隐患数量")
Integer reviewDangerCount;
@ApiModelProperty(value = "复查已整改隐患数量")
Integer reviewReformedCount;
@ApiModelProperty(value = "复查整改中隐患数量")
Integer reviewReformingCount;
@ApiModelProperty(value = "剩余隐患数量")
Integer remainderDangerCount;
@ApiModelProperty(value = "机构代码")
String orgCode;
@ApiModelProperty(value = "创建时间")
Date createDate;
@ApiModelProperty(value = "检查单位列表")
List<CheckReportCompanyDto> checkCompanyList;
@ApiModelProperty(value = "本次检查隐患列表")
List<CheckReportDangerDto> checkDangerList;
@ApiModelProperty(value = "本次隐患复查列表")
List<CheckReportDangerDto> reviewDangerList;
@ApiModelProperty(value = "本次隐患id")
String dangerIds;
@ApiModelProperty(value = "本次复查隐患id")
String reviewDangerIds;
}
package com.yeejoin.amos.supervision.core.common.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class CheckReportParamDto implements Serializable {
@ApiModelProperty(value = "报告名称")
String name;
@ApiModelProperty(value = "计划名称")
String planName;
@ApiModelProperty(value = "计划检查类型")
String planCheckType;
@ApiModelProperty(value = "检查级别")
String checkLevel;
@ApiModelProperty(value = "检查开始时间")
Date startCheckTime;
@ApiModelProperty(value = "检查结束时间")
Date endCheckTime;
@ApiModelProperty(value = "检查执行人")
String checkUser;
@ApiModelProperty(value = "组织机构代码")
String orgCode;
}
...@@ -20,6 +20,11 @@ public class DangerDto implements Serializable { ...@@ -20,6 +20,11 @@ public class DangerDto implements Serializable {
private Long id; private Long id;
/** /**
* 隐患id
*/
private Long dangerId;
/**
* 隐患名称 * 隐患名称
*/ */
private String dangerName; private String dangerName;
...@@ -156,4 +161,13 @@ public class DangerDto implements Serializable { ...@@ -156,4 +161,13 @@ public class DangerDto implements Serializable {
*/ */
private Map bizInfo; private Map bizInfo;
/**
* 复核人员名称
*/
private String executeUserName;
/**
* 创建时间
*/
private Date createDate;
} }
package com.yeejoin.amos.supervision.dao.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
@EqualsAndHashCode(callSuper = true)
@Data
@Entity
@TableName("p_check_report")
public class CheckReport extends BasicEntity {
@ApiModelProperty(value = "报告名称")
String name;
@ApiModelProperty(value = "计划类型(0单位级,1公司级)")
int planType;
@ApiModelProperty(value = "计划任务id")
Long planTaskId;
@ApiModelProperty(value = "任务执行人")
String checkUser;
@ApiModelProperty(value = "实际开始时间")
Date startCheckDate;
@ApiModelProperty(value = "实际结束时间")
Date endCheckDate;
@ApiModelProperty(value = "检查单位数量")
Integer companyCount;
@ApiModelProperty(value = "存在问题单位数量")
Integer problemCompanyCount;
@ApiModelProperty(value = "是否有重大隐患(1有,0无)")
Boolean hasMajorDanger;
@ApiModelProperty(value = "存在安全隐患id(逗号分割)")
String dangerIds;
@ApiModelProperty(value = "存在安全隐患数量")
Integer dangerCount;
@ApiModelProperty(value = "复查隐患id(逗号分割)")
String reviewDangerIds;
@ApiModelProperty(value = "现场已整改隐患数量")
Integer onsiteReformCount;
@ApiModelProperty(value = "复查隐患数量")
Integer reviewDangerCount;
@ApiModelProperty(value = "复查已整改隐患数量")
Integer reviewReformedCount;
@ApiModelProperty(value = "复查整改中隐患数量")
Integer reviewReformingCount;
@ApiModelProperty(value = "剩余隐患数量")
Integer remainingDangerCount;
@ApiModelProperty(value = "机构代码")
String orgCode;
}
...@@ -545,4 +545,17 @@ public class OrgUsrController extends BaseController { ...@@ -545,4 +545,17 @@ public class OrgUsrController extends BaseController {
public ResponseModel getUnSyncOrgCompanyList(@RequestParam List<Long> companyIdList) { public ResponseModel getUnSyncOrgCompanyList(@RequestParam List<Long> companyIdList) {
return ResponseHelper.buildResponse(iOrgUsrService.getUnSyncOrgCompanyList(companyIdList)); return ResponseHelper.buildResponse(iOrgUsrService.getUnSyncOrgCompanyList(companyIdList));
} }
/**
* 根据机场单位id获取各单位下部门数量
*
* @param
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "根据机场单位id获取各单位下部门数量", notes = "根据机场单位id获取各单位下部门数量")
@GetMapping(value = "/amos/companyIds")
public ResponseModel<Map<String, Integer>> getDeptCountByCompanyIds(@RequestParam List<String> companyIdList) throws Exception {
return ResponseHelper.buildResponse(iOrgUsrService.getDeptCountByCompanyIds(companyIdList));
}
} }
\ No newline at end of file
...@@ -15,6 +15,7 @@ import java.util.stream.Collectors; ...@@ -15,6 +15,7 @@ import java.util.stream.Collectors;
import javax.annotation.Resource; import javax.annotation.Resource;
import com.google.common.collect.Maps;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -1842,4 +1843,18 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp ...@@ -1842,4 +1843,18 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
return orgUsrMapper.getPersonSimpleDetail(); return orgUsrMapper.getPersonSimpleDetail();
} }
public Map<String, Integer> getDeptCountByCompanyIds(List<String> companyIdList) {
Map<String, Integer> resultMap = Maps.newHashMap();
List<Map<String, Long>> companyDeptCountMapList;
if (!ValidationUtil.isEmpty(companyIdList)) {
companyDeptCountMapList = this.baseMapper.countDeptByCompanyId(companyIdList);
if (!ValidationUtil.isEmpty(companyDeptCountMapList)) {
companyDeptCountMapList.forEach(c -> {
resultMap.put(c.get("sequence_nbr").toString(), Integer.valueOf(c.get("count").intValue()));
});
}
}
return resultMap;
}
} }
...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.bo.RoleBo; import com.yeejoin.amos.boot.biz.common.bo.RoleBo;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.latentdanger.business.dto.DangerExecuteSubmitDto; import com.yeejoin.amos.latentdanger.business.dto.DangerExecuteSubmitDto;
import com.yeejoin.amos.latentdanger.business.dto.ExecuteSubmitDto; import com.yeejoin.amos.latentdanger.business.dto.ExecuteSubmitDto;
...@@ -376,4 +377,13 @@ public class LatentDangerController extends BaseController { ...@@ -376,4 +377,13 @@ public class LatentDangerController extends BaseController {
public ResponseModel getUnFinishedDangerCount() { public ResponseModel getUnFinishedDangerCount() {
return ResponseHelper.buildResponse((iLatentDangerService.getUnFinishedDangerCount())); return ResponseHelper.buildResponse((iLatentDangerService.getUnFinishedDangerCount()));
} }
@ApiOperation(value = "获取隐患复查信息", notes = "获取隐患复查信息")
@GetMapping(value = "/supervision/reviewInfo")
@TycloudOperation(ApiLevel = UserType.AGENCY)
public ResponseModel getSupervisionReviewInfo(@RequestParam String orgCode, @RequestParam String t1,
@RequestParam String t2) {
return ResponseHelper.buildResponse(iLatentDangerService.getSupervisionReviewInfo(orgCode,
DateUtils.longStr2Date(t1), DateUtils.longStr2Date(t2)));
}
} }
...@@ -13,5 +13,5 @@ public class LatentDangerFlowRecordBoExtend { ...@@ -13,5 +13,5 @@ public class LatentDangerFlowRecordBoExtend {
private Integer dangerOvertimeState; private Integer dangerOvertimeState;
private Integer dangerState; private String dangerState;
} }
...@@ -3,6 +3,8 @@ package com.yeejoin.amos.latentdanger.business.param; ...@@ -3,6 +3,8 @@ package com.yeejoin.amos.latentdanger.business.param;
import com.yeejoin.amos.latentdanger.core.common.request.CommonPageable; import com.yeejoin.amos.latentdanger.core.common.request.CommonPageable;
import lombok.Data; import lombok.Data;
import java.util.Date;
/** /**
* @author keyong * @author keyong
* @title: LatentDangerListParam * @title: LatentDangerListParam
...@@ -41,4 +43,14 @@ public class LatentDangerListParam extends CommonPageable { ...@@ -41,4 +43,14 @@ public class LatentDangerListParam extends CommonPageable {
private String dangerIds; private String dangerIds;
private String orgCode; private String orgCode;
/**
* 隐患开始时间
*/
private Date startTime;
/**
* 隐患结束时间
*/
private Date endTime;
} }
...@@ -69,7 +69,6 @@ import com.yeejoin.amos.latentdanger.common.remote.RemoteWorkFlowService; ...@@ -69,7 +69,6 @@ import com.yeejoin.amos.latentdanger.common.remote.RemoteWorkFlowService;
import com.yeejoin.amos.latentdanger.core.async.AsyncTask; import com.yeejoin.amos.latentdanger.core.async.AsyncTask;
import com.yeejoin.amos.latentdanger.core.common.request.LatentDangerResultPushSpcRequest; import com.yeejoin.amos.latentdanger.core.common.request.LatentDangerResultPushSpcRequest;
import com.yeejoin.amos.latentdanger.core.common.response.DangerListResponse; import com.yeejoin.amos.latentdanger.core.common.response.DangerListResponse;
//import com.yeejoin.amos.latentdanger.core.util.StringUtil;
import com.yeejoin.amos.latentdanger.dao.entity.LatentDanger; import com.yeejoin.amos.latentdanger.dao.entity.LatentDanger;
import com.yeejoin.amos.latentdanger.dao.entity.LatentDangerFlowRecord; import com.yeejoin.amos.latentdanger.dao.entity.LatentDangerFlowRecord;
import com.yeejoin.amos.latentdanger.exception.YeeException; import com.yeejoin.amos.latentdanger.exception.YeeException;
...@@ -109,6 +108,8 @@ import java.util.stream.Collectors; ...@@ -109,6 +108,8 @@ import java.util.stream.Collectors;
import static com.yeejoin.amos.latentdanger.business.util.RandomUtil.buildOrderNo; import static com.yeejoin.amos.latentdanger.business.util.RandomUtil.buildOrderNo;
import static org.typroject.tyboot.core.foundation.context.RequestContext.getProduct; import static org.typroject.tyboot.core.foundation.context.RequestContext.getProduct;
//import com.yeejoin.amos.latentdanger.core.util.StringUtil;
//import org.springframework.data.domain.Page; //import org.springframework.data.domain.Page;
//import org.springframework.data.domain.PageImpl; //import org.springframework.data.domain.PageImpl;
...@@ -1137,11 +1138,12 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD ...@@ -1137,11 +1138,12 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
return executeSubmitDto; return executeSubmitDto;
} }
private DangerExecuteSubmitDto executeSupervisionBiz(LatentDangerExecuteParam param, LatentDanger latentDanger, @Transactional(rollbackFor = Exception.class)
String userId, String userRealName, String departmentId, DangerExecuteSubmitDto executeSupervisionBiz(LatentDangerExecuteParam param, LatentDanger latentDanger,
String departmentName, String userId, String userRealName, String departmentId,
DangerExecuteSubmitDto executeSubmitDto, String departmentName,
ReginParams reginParams) throws Exception { DangerExecuteSubmitDto executeSubmitDto,
ReginParams reginParams) throws Exception {
// 隐患的巡查信息 // 隐患的巡查信息
JSONObject bizInfo = latentDanger.getBizInfo(); JSONObject bizInfo = latentDanger.getBizInfo();
if (ValidationUtil.isEmpty(bizInfo) || ValidationUtil.isEmpty(bizInfo.get("planType")) || ValidationUtil.isEmpty(bizInfo.get("accompanyingUserId"))) { if (ValidationUtil.isEmpty(bizInfo) || ValidationUtil.isEmpty(bizInfo.get("planType")) || ValidationUtil.isEmpty(bizInfo.get("accompanyingUserId"))) {
...@@ -1996,13 +1998,41 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD ...@@ -1996,13 +1998,41 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
if (!ValidationUtil.isEmpty(searchParam.getDangerIds())) { if (!ValidationUtil.isEmpty(searchParam.getDangerIds())) {
lambdaQueryWrapper.in(LatentDanger::getId, Lists.newArrayList(searchParam.getDangerIds().split(","))); lambdaQueryWrapper.in(LatentDanger::getId, Lists.newArrayList(searchParam.getDangerIds().split(",")));
} }
if (!ValidationUtil.isEmpty(searchParam.getEndTime())) {
// 防火监督报告查询需要根据t1(startTime),t2(endTime)时间来查询
if (!ValidationUtil.isEmpty(searchParam.getStartTime())) {
lambdaQueryWrapper.gt(LatentDanger::getCreateDate, searchParam.getStartTime());
}
lambdaQueryWrapper.le(LatentDanger::getCreateDate, searchParam.getEndTime());
}
lambdaQueryWrapper.and(o -> lambdaQueryWrapper.and(o ->
o.likeRight(LatentDanger::getOrgCode, searchParam.getOrgCode() + "*") o.likeRight(LatentDanger::getOrgCode, searchParam.getOrgCode() + "*")
.or().likeRight(LatentDanger::getOrgCode, searchParam.getOrgCode() + "-") .or().likeRight(LatentDanger::getOrgCode, searchParam.getOrgCode() + "-")
.or().eq(LatentDanger::getOrgCode, searchParam.getOrgCode())); .or().eq(LatentDanger::getOrgCode, searchParam.getOrgCode()));
List<LatentDanger> latentDangers = this.baseMapper.selectList(lambdaQueryWrapper); List<LatentDanger> latentDangerList = this.baseMapper.selectList(lambdaQueryWrapper);
if (!ValidationUtil.isEmpty(latentDangerList)) {
return latentDangers; // 防火监督报告用该字段(复核执行人名称)
latentDangerList.forEach(danger -> {
List<LatentDangerFlowRecordBo> recordList = latentDangerFlowRecordMapper.listByDangerId(danger.getId());
if (!ValidationUtil.isEmpty(recordList)) {
List<LatentDangerState.SupervisionDangerStateEnum> stateEnums =
LatentDangerState.SupervisionDangerStateEnum.getEnumListByProcessState(LatentDangerProcessStateEnum.待复核.getCode());
Set<String> stateSet = Sets.newHashSet();
List<String> stateList = Lists.transform(stateEnums,
LatentDangerState.SupervisionDangerStateEnum::getCode);
stateSet.addAll(stateList);
List<LatentDangerFlowRecordBo> firstRecord =
recordList.stream().filter(r -> LatentDangerState.SupervisionDangerStateEnum.提交隐患.getCode().equals(r.getActionFlag())).collect(Collectors.toList());
danger.setCheckUserName(firstRecord.get(0).getExecuteUserName());
recordList =
recordList.stream().filter(r -> stateSet.contains(r.getDangerState())).collect(Collectors.toList());
Set<String> nameSet = Sets.newHashSet();
nameSet.addAll(Lists.transform(recordList, LatentDangerFlowRecordBo::getExecuteUserName));
danger.setExecuteUserName(Joiner.on(",").join(nameSet));
}
});
}
return latentDangerList;
} }
@Override @Override
...@@ -2119,4 +2149,58 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD ...@@ -2119,4 +2149,58 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
return this.baseMapper.selectUnFinishedCount(pDangerStateEnumList.stream().map(LatentDangerState.PatrolDangerStateEnum::getCode).collect(Collectors.toList()), sDangerStateEnumList.stream().map(LatentDangerState.SupervisionDangerStateEnum::getCode).collect(Collectors.toList())); return this.baseMapper.selectUnFinishedCount(pDangerStateEnumList.stream().map(LatentDangerState.PatrolDangerStateEnum::getCode).collect(Collectors.toList()), sDangerStateEnumList.stream().map(LatentDangerState.SupervisionDangerStateEnum::getCode).collect(Collectors.toList()));
} }
@Override
public Object getSupervisionReviewInfo(String orgCode, Date t1, Date t2) {
LatentDangerListParam param = new LatentDangerListParam();
param.setOrgCode(orgCode);
param.setStartTime(t1);
param.setEndTime(t2);
List<LatentDanger> dangerList = listAllDanger(param);
Map<String, List<LatentDanger>> map = Maps.newHashMap();
List<LatentDangerState.SupervisionDangerStateEnum> reviewEnum1 =
LatentDangerState.SupervisionDangerStateEnum.getEnumListByProcessState(LatentDangerProcessStateEnum.待整改资料提交.getCode());
List<LatentDangerState.SupervisionDangerStateEnum> reviewEnum2 =
LatentDangerState.SupervisionDangerStateEnum.getEnumListByProcessState(LatentDangerProcessStateEnum.待复核.getCode());
Set<String> reviewStateNameSet = Sets.newHashSet();
Set<String> finishStateNameSet = Sets.newHashSet();
// 复查隐患指的是在本次在T1至 T2时间段内,提交隐患整改资料,并进入隐患整改审核流程 的隐患
reviewStateNameSet.addAll(reviewEnum1.stream().map(supervisionDangerStateEnum ->
supervisionDangerStateEnum != null ? supervisionDangerStateEnum.getCode() : null).collect(Collectors.toList()));
reviewStateNameSet.addAll(reviewEnum2.stream().map(supervisionDangerStateEnum ->
supervisionDangerStateEnum != null ? supervisionDangerStateEnum.getCode() : null).collect(Collectors.toList()));
// 复查已整改隐患指的是在本次在T1至 T2时间段内,已经审核通过(全部审核流程通过)的隐患
List<LatentDangerState.SupervisionDangerStateEnum> reviewEnum3 =
LatentDangerState.SupervisionDangerStateEnum.getEnumListByProcessState(LatentDangerProcessStateEnum.治理完毕.getCode());
finishStateNameSet.addAll(reviewEnum3.stream().map(supervisionDangerStateEnum ->
supervisionDangerStateEnum != null ? supervisionDangerStateEnum.getCode() : null).collect(Collectors.toList()));
// 复查隐患
map.put("reviewDangerList", dangerList.stream().filter(d -> reviewStateNameSet.contains(d.getDangerState())).collect(Collectors.toList()));
// 复查已整改隐患
map.put("reviewReformedList", dangerList.stream().filter(d -> finishStateNameSet.contains(d.getDangerState())).collect(Collectors.toList()));
// 遗留隐患问题:指的是截止T2时间,尚未提交隐患整改资料的 隐患数量。
param.setStartTime(null);
List<LatentDanger> dangerList2 = listAllDanger(param);
Set<String> remainingStateNameSet = Sets.newHashSet();
List<LatentDangerState.SupervisionDangerStateEnum> reviewEnum4 =
LatentDangerState.SupervisionDangerStateEnum.getEnumListByProcessState(LatentDangerProcessStateEnum.未审核.getCode());
List<LatentDangerState.SupervisionDangerStateEnum> reviewEnum5 =
LatentDangerState.SupervisionDangerStateEnum.getEnumListByProcessState(LatentDangerProcessStateEnum.待审核.getCode());
List<LatentDangerState.SupervisionDangerStateEnum> reviewEnum6 =
LatentDangerState.SupervisionDangerStateEnum.getEnumListByProcessState(LatentDangerProcessStateEnum.待整改.getCode());
remainingStateNameSet.addAll(reviewEnum4.stream().map(supervisionDangerStateEnum ->
supervisionDangerStateEnum != null ? supervisionDangerStateEnum.getCode() : null).collect(Collectors.toList()));
remainingStateNameSet.addAll(reviewEnum5.stream().map(supervisionDangerStateEnum ->
supervisionDangerStateEnum != null ? supervisionDangerStateEnum.getCode() : null).collect(Collectors.toList()));
remainingStateNameSet.addAll(reviewEnum6.stream().map(supervisionDangerStateEnum ->
supervisionDangerStateEnum != null ? supervisionDangerStateEnum.getCode() : null).collect(Collectors.toList()));
map.put("remainingList", dangerList2.stream().filter(d -> remainingStateNameSet.contains(d.getDangerState())).collect(Collectors.toList()));
return map;
}
} }
...@@ -19,6 +19,7 @@ import com.yeejoin.amos.latentdanger.core.common.response.DangerListResponse; ...@@ -19,6 +19,7 @@ import com.yeejoin.amos.latentdanger.core.common.response.DangerListResponse;
import com.yeejoin.amos.latentdanger.dao.entity.LatentDanger; import com.yeejoin.amos.latentdanger.dao.entity.LatentDanger;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -173,4 +174,14 @@ public interface ILatentDangerService { ...@@ -173,4 +174,14 @@ public interface ILatentDangerService {
* @return * @return
*/ */
Integer getUnFinishedDangerCount(); Integer getUnFinishedDangerCount();
/**
* 获取消防监督复查隐患信息
*
* @param orgCode
* @param t1
* @param t2
* @return
*/
Object getSupervisionReviewInfo(String orgCode, Date t1, Date t2);
} }
package com.yeejoin.amos.supervision.business.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.supervision.business.feign.DangerFeignClient;
import com.yeejoin.amos.supervision.business.service.intfc.ICheckReportService;
import com.yeejoin.amos.supervision.core.common.dto.CheckReportParamDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.Date;
@RestController
@RequestMapping(value = "/check/report")
@Api(tags = "消防监督检查报告api")
public class CheckReportController extends BaseController {
@Autowired
ICheckReportService iCheckReportService;
@Autowired
DangerFeignClient dangerFeignClient;
/**
* 分页查询
*
* @param queryParam
* @param current
* @param size
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "分页查询检查报告", notes = "分页查询检查报告")
@PostMapping(value = "/page")
public ResponseModel queryPage(@RequestParam(value = "当前页") int current, @RequestParam(value = "分页大小") int size, @RequestBody(required = false) CheckReportParamDto queryParam) {
ReginParams reginParams = getSelectedOrgInfo();
String loginOrgCode = getOrgCode(reginParams);
if (loginOrgCode.contains("-")) {
loginOrgCode = loginOrgCode.substring(0, loginOrgCode.indexOf("-"));
}
queryParam.setOrgCode(loginOrgCode);
Page page = new Page<>(current, size);
return ResponseHelper.buildResponse(iCheckReportService.pageList(page, queryParam));
}
/**
* 分页查询
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "查询检查报告详情", notes = "查询检查报告详情")
@GetMapping(value = "/detail/{id}")
public ResponseModel getDetailById(@PathVariable(value = "id") String id) {
return ResponseHelper.buildResponse(iCheckReportService.getDetailById(id));
}
}
package com.yeejoin.amos.supervision.business.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.supervision.business.dto.CheckReportMapperDto;
import com.yeejoin.amos.supervision.core.common.dto.CheckReportCompanyDto;
import com.yeejoin.amos.supervision.core.common.dto.CheckReportDto;
import com.yeejoin.amos.supervision.core.common.dto.CheckReportParamDto;
import com.yeejoin.amos.supervision.dao.entity.CheckReport;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface CheckReportMapper extends BaseMapper<CheckReport> {
/**
* 根据计划任务ID获取相关数据
* @param id
*/
CheckReportMapperDto queryByPlanTaskId(long id);
IPage<CheckReportDto> selectPageList(Page page, @Param("queryParam") CheckReportParamDto queryParam);
CheckReportDto selectDetailById(@Param("checkReportId") Long id);
List<CheckReportCompanyDto> getCheckReportCompanyList(Long planTaskId);
}
package com.yeejoin.amos.supervision.business.dao.mapper; package com.yeejoin.amos.supervision.business.dao.mapper;
import java.util.List;
import java.util.Map; import java.util.Map;
import com.yeejoin.amos.supervision.dao.entity.PlanTaskDetail;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
public interface PlanTaskDetailMapper extends BaseMapper { public interface PlanTaskDetailMapper extends BaseMapper {
...@@ -10,7 +12,7 @@ public interface PlanTaskDetailMapper extends BaseMapper { ...@@ -10,7 +12,7 @@ public interface PlanTaskDetailMapper extends BaseMapper {
Map findPlanTaskByTaskIdAndPointId(@Param(value="planTaskId") long planTaskId,@Param(value="pointId") long pointId); Map findPlanTaskByTaskIdAndPointId(@Param(value="planTaskId") long planTaskId,@Param(value="pointId") long pointId);
int findPlanTaskDetailByTaskId( @Param(value="planTaskId") long planTaskId); List<PlanTaskDetail> findPlanTaskDetailByTaskId(@Param(value="planTaskId") long planTaskId);
/** /**
* 更新隐患信息 * 更新隐患信息
......
package com.yeejoin.amos.supervision.business.dao.repository;
import com.yeejoin.amos.supervision.dao.entity.CheckReport;
import org.springframework.stereotype.Repository;
@Repository("iCheckReportDao")
public interface ICheckReportDao extends BaseDao<CheckReport, Long> {
}
package com.yeejoin.amos.supervision.business.dto;
import lombok.Data;
import java.util.Date;
@Data
public class CheckReportMapperDto {
Integer companyCount;
Long planTaskId;
String checkUser;
String checkTime;
Date planBeginDate;
Date planEndDate;
String latentDangerId;
String problemPointId;
Boolean hasMajorDanger;
}
...@@ -5,19 +5,22 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -5,19 +5,22 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel; import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import com.yeejoin.amos.supervision.core.common.dto.CheckReportDangerDto;
import com.yeejoin.amos.supervision.core.common.dto.DangerDto; import com.yeejoin.amos.supervision.core.common.dto.DangerDto;
import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Delete;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* @author DELL * @author DELL
*/ */
@FeignClient(value = "AMOS-LATENT-DANGER", path = "latentDanger/api/latent/danger", configuration = {FeignConfiguration.class,FeignClientErrorDecoder.class}) @FeignClient(value = "AMOS-LATENT-DANGER", path = "latentDanger/api/latent/danger", configuration =
{FeignConfiguration.class,FeignClientErrorDecoder.class})
public interface DangerFeignClient { public interface DangerFeignClient {
/** /**
...@@ -79,4 +82,17 @@ public interface DangerFeignClient { ...@@ -79,4 +82,17 @@ public interface DangerFeignClient {
*/ */
@DeleteMapping("/delete") @DeleteMapping("/delete")
FeignClientResult<Boolean> deleteDangerBatch(@RequestParam String ids); FeignClientResult<Boolean> deleteDangerBatch(@RequestParam String ids);
/**
* 根据参数获取隐患复查信息
*
* @param orgCode
* @param t1
* @param t2
* @return
*/
@GetMapping(value = "/supervision/reviewInfo")
FeignClientResult<Map<String, List<CheckReportDangerDto>>> getReviewInfoList(@RequestParam String orgCode,
@RequestParam String t1,
@RequestParam String t2);
} }
...@@ -5,6 +5,7 @@ import org.springframework.cloud.openfeign.FeignClient; ...@@ -5,6 +5,7 @@ import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @author DELL * @author DELL
...@@ -35,4 +36,13 @@ public interface JCSFeignClient { ...@@ -35,4 +36,13 @@ public interface JCSFeignClient {
*/ */
@RequestMapping(value = "jcs/org-usr/amos/orgUserIds", method = RequestMethod.GET) @RequestMapping(value = "jcs/org-usr/amos/orgUserIds", method = RequestMethod.GET)
FeignClientResult getAmosIdListByUserIds(@RequestParam String orgUserIds); FeignClientResult getAmosIdListByUserIds(@RequestParam String orgUserIds);
/**
* 根据机场单位id批量获取各单位下的部门数量
*
* @param companyIdList 机场单位人员id
* @return
*/
@RequestMapping(value = "jcs/org-usr/amos/companyIds", method = RequestMethod.GET)
FeignClientResult<Map<String, Integer>> getDeptCountByCompanyIds(@RequestParam("companyIdList") List<String> companyIdList);
} }
package com.yeejoin.amos.supervision.business.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.supervision.business.dao.mapper.CheckReportMapper;
import com.yeejoin.amos.supervision.business.dao.mapper.PlanTaskMapper;
import com.yeejoin.amos.supervision.business.dto.CheckReportMapperDto;
import com.yeejoin.amos.supervision.business.feign.DangerFeignClient;
import com.yeejoin.amos.supervision.business.feign.JCSFeignClient;
import com.yeejoin.amos.supervision.business.service.intfc.ICheckReportService;
import com.yeejoin.amos.supervision.business.service.intfc.IPlanService;
import com.yeejoin.amos.supervision.common.enums.DangerCheckTypeLevelEnum;
import com.yeejoin.amos.supervision.common.enums.PlanCheckLevelEnum;
import com.yeejoin.amos.supervision.common.enums.PlanFrequencyEnum;
import com.yeejoin.amos.supervision.common.enums.PlanTaskFinishStatusEnum;
import com.yeejoin.amos.supervision.core.common.dto.CheckReportCompanyDto;
import com.yeejoin.amos.supervision.core.common.dto.CheckReportDangerDto;
import com.yeejoin.amos.supervision.core.common.dto.CheckReportDto;
import com.yeejoin.amos.supervision.core.common.dto.CheckReportParamDto;
import com.yeejoin.amos.supervision.core.common.dto.DangerDto;
import com.yeejoin.amos.supervision.dao.entity.CheckReport;
import com.yeejoin.amos.supervision.dao.entity.Plan;
import com.yeejoin.amos.supervision.dao.entity.PlanTask;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.text.ParseException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
@Service("checkReportService")
public class CheckReportServiceImpl extends BaseService<CheckReportDto, CheckReport, CheckReportMapper> implements ICheckReportService {
@Autowired
IPlanService iPlanService;
@Autowired
CheckReportMapper checkReportMapper;
@Autowired
DangerFeignClient dangerFeignClient;
@Autowired
PlanTaskMapper planTaskMapper;
@Autowired
JCSFeignClient jcsFeignClient;
private static String[] stringSplit(String str) {
String[] strs = new String[0];
if (!ValidationUtil.isEmpty(str)) {
strs = str.split(",");
return strs;
}
return strs;
}
/**
* 生成检查报告
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void genCheckReport(PlanTask planTask) throws ParseException {
Map taskMap = planTaskMapper.queryPlanTaskById(planTask.getId());
// 所有任务执行完成才生成报告
if (PlanTaskFinishStatusEnum.FINISHED.getValue() == (Integer) taskMap.get("finishStatus")) {
Plan plan = iPlanService.queryPlanById(planTask.getPlanId());
String reportName = getReportName(plan, planTask);
CheckReportMapperDto checkReportMapperDto = checkReportMapper.queryByPlanTaskId(planTask.getId());
if (!ValidationUtil.isEmpty(checkReportMapperDto)) {
CheckReport checkReport = new CheckReport();
BeanUtils.copyProperties(checkReportMapperDto, checkReport);
checkReport.setName(reportName);
String[] checkTime = stringSplit(checkReportMapperDto.getCheckTime());
checkReport.setStartCheckDate(DateUtils.dateParse(checkTime[0], DateUtils.DATE_PATTERN));
checkReport.setEndCheckDate(DateUtils.dateParse(checkTime[checkTime.length - 1], DateUtils.DATE_PATTERN));
String[] dangerIds = stringSplit(checkReportMapperDto.getLatentDangerId());
checkReport.setDangerCount(dangerIds.length);
checkReport.setDangerIds(checkReportMapperDto.getLatentDangerId());
if (DangerCheckTypeLevelEnum.DEPARTMENT.getCode().equals(plan.getCheckLevel())) {
checkReport.setPlanType(0);
} else {
checkReport.setPlanType(1);
}
checkReport.setOrgCode(getParentOrgCode(plan.getOrgCode()));
String[] problemPointIds = stringSplit(checkReportMapperDto.getProblemPointId());
checkReport.setProblemCompanyCount(problemPointIds.length);
// 获取复查信息
getReviewInfo(checkReport);
checkReportMapper.insert(checkReport);
}
}
}
@Override
public IPage<CheckReportDto> pageList(Page page, CheckReportParamDto queryParam) {
return this.baseMapper.selectPageList(page, queryParam);
}
@Override
public CheckReportDto getDetailById(String checkReportId) {
CheckReportDto checkReportDto = this.baseMapper.selectDetailById(Long.valueOf(checkReportId));
if (!ValidationUtil.isEmpty(checkReportDto)) {
// 获取本次检查单位信息
List<CheckReportCompanyDto> companyDtoList =
this.baseMapper.getCheckReportCompanyList(checkReportDto.getPlanTaskId());
if (!ValidationUtil.isEmpty(companyDtoList)) {
List<String> companyIdList = Lists.transform(companyDtoList, CheckReportCompanyDto::getId);
Map<String, Integer> companyDeptCountMap =
jcsFeignClient.getDeptCountByCompanyIds(companyIdList).getResult();
companyDtoList.forEach(c -> {
c.setDeptCount(companyDeptCountMap.get(c.getId()));
});
}
checkReportDto.setCheckCompanyList(companyDtoList);
// 获取隐患信息
Map<String, String> dangerParamMap = Maps.newHashMap();
// 本次隐患id
List<String> dangerIdList = Arrays.asList(checkReportDto.getDangerIds().split(","));
// 复核隐患id
List<String> reviewDangerIdList = Arrays.asList(checkReportDto.getReviewDangerIds().split(","));
Set<String> allDangerIdSet = Sets.newHashSet();
allDangerIdSet.addAll(dangerIdList);
allDangerIdSet.addAll(reviewDangerIdList);
dangerParamMap.put("dangerIds", Joiner.on(",").join(allDangerIdSet));
List<DangerDto> dangerDtoList = dangerFeignClient.listAll(dangerParamMap).getResult();
List<CheckReportDangerDto> dangerList = Lists.newArrayList();
List<CheckReportDangerDto> reviewDangerList = Lists.newArrayList();
if (!ValidationUtil.isEmpty(dangerDtoList)) {
dangerDtoList.forEach(dangerDto -> {
CheckReportDangerDto checkReportDangerDto = new CheckReportDangerDto();
BeanUtils.copyProperties(dangerDto, checkReportDangerDto);
Map<String, String> bizInfo = dangerDto.getBizInfo();
checkReportDangerDto.setCompanyId(bizInfo.get("pointId"));
checkReportDangerDto.setCompanyName(bizInfo.get("pointName"));
if (dangerIdList.contains(dangerDto.getId().toString())) {
dangerList.add(checkReportDangerDto);
}
if (reviewDangerIdList.contains(dangerDto.getId().toString())) {
checkReportDangerDto.setReviewUser(dangerDto.getExecuteUserName());
reviewDangerList.add(checkReportDangerDto);
}
});
}
checkReportDto.setCheckDangerList(dangerList);
checkReportDto.setReviewDangerList(reviewDangerList);
}
return checkReportDto;
}
/**
* 获取复查信息
*
* @param checkReport
*/
void getReviewInfo(CheckReport checkReport) {
String t1 = getLastReportDate(checkReport);
String t2 = DateUtils.getDateNowString();
Map<String, Object> param = new HashMap<>();
param.put("dangerIds", checkReport.getDangerIds());
List<DangerDto> dangerDtoList = dangerFeignClient.listAll(param).getResult();
// 现场整改的隐患
dangerDtoList =
dangerDtoList.stream().filter(dangerDto -> "onSiteRectification".equals(dangerDto.getReformType())).collect(Collectors.toList());
checkReport.setOnsiteReformCount(dangerDtoList.size());
Map<String, List<CheckReportDangerDto>> result = dangerFeignClient.getReviewInfoList(checkReport.getOrgCode(), t1, t2).getResult();
// 复查隐患
List<CheckReportDangerDto> reviewDangerList = result.get("reviewDangerList");
// 复查已整改隐患
List<CheckReportDangerDto> reviewReformedList = result.get("reviewReformedList");
Set<String> reviewDangerIdSet = Sets.newHashSet();
reviewDangerIdSet.addAll(Lists.transform(reviewDangerList, CheckReportDangerDto::getDangerId));
reviewDangerIdSet.addAll(Lists.transform(reviewReformedList, CheckReportDangerDto::getDangerId));
// 保存本次复查隐患id
checkReport.setReviewDangerIds(Joiner.on(",").join(reviewDangerIdSet));
// List<CheckReportDangerDto> reviewReformingList = result.get("reviewReformingList");
List<CheckReportDangerDto> remainingList = result.get("remainingList");
checkReport.setReviewDangerCount(reviewDangerList.size());
checkReport.setReviewReformedCount(reviewReformedList.size());
// checkReport.setReviewReformingCount(reviewReformingList.size());
checkReport.setRemainingDangerCount(remainingList.size());
}
/**
* 获取上次报告的创建时间
*
* @param checkReport
* @return
*/
private String getLastReportDate(CheckReport checkReport) {
// 根据计划类型获取上一次报告生成时间(T1)到本次报告生成时间(T2)之间的数据
String t1 = DateUtils.getDateNowString();
LambdaQueryWrapper<CheckReport> queryWrapper = new LambdaQueryWrapper<>();
if (PlanCheckLevelEnum.DRAFT.getValue() == checkReport.getPlanType()) {
// 单位级根据orgCode获取本单位上一次报告生成时间t1
queryWrapper.eq(CheckReport::getOrgCode, checkReport.getOrgCode()).orderByDesc(CheckReport::getCreateDate);
List<CheckReport> reportList = this.baseMapper.selectList(queryWrapper);
if (!ValidationUtil.isEmpty(reportList)) {
t1 = DateUtils.date2LongStr(reportList.get(0).getCreateDate());
}
} else {
// 公司级根据类型获取上一次公司级报告生成时间t1
queryWrapper.eq(CheckReport::getPlanType, checkReport.getPlanType()).orderByDesc(CheckReport::getCreateDate);
List<CheckReport> reportList = this.baseMapper.selectList(queryWrapper);
if (!ValidationUtil.isEmpty(reportList)) {
t1 = DateUtils.date2LongStr(reportList.get(0).getCreateDate());
}
}
return t1;
}
/**
* 获取检查报告名称
*
* @param plan
* @return
*/
private String getReportName(Plan plan, PlanTask planTask) throws ParseException {
Date planTaskBeginDate = DateUtils.dateParse(planTask.getBeginTime(), DateUtils.DATE_PATTERN);
String dateStr = DateUtils.dateFormat(planTaskBeginDate, DateUtils.CHN_DATE_PATTERN_YEAR);
PlanFrequencyEnum frequencyEnum = Objects.requireNonNull(PlanFrequencyEnum.getEnumByCode(plan.getPlanType()));
switch (frequencyEnum) {
case WEEK:
dateStr =
dateStr + DateUtils.getWeekDate(planTaskBeginDate) + frequencyEnum.getExtraInfo();
break;
case MONTH:
dateStr = dateStr + DateUtils.getMonth(planTaskBeginDate) + frequencyEnum.getExtraInfo();
break;
case QUARTER:
dateStr = dateStr + DateUtils.getQuarterStr(DateUtils.getMonth(planTaskBeginDate)) + frequencyEnum.getExtraInfo();
break;
}
return plan.getName() + "--" + dateStr;
}
/**
* 获取本单位orgCode
*
* @param orgCode
* @return
*/
private String getParentOrgCode(String orgCode) {
if (orgCode.contains("-")) {
return orgCode.substring(0, orgCode.indexOf("-"));
}
return orgCode;
}
}
...@@ -8,6 +8,7 @@ import com.google.common.collect.Lists; ...@@ -8,6 +8,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.yeejoin.amos.boot.biz.common.bo.DepartmentBo; import com.yeejoin.amos.boot.biz.common.bo.DepartmentBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel; import com.yeejoin.amos.feign.privilege.model.CompanyModel;
...@@ -51,6 +52,7 @@ import org.typroject.tyboot.core.foundation.utils.Bean; ...@@ -51,6 +52,7 @@ import org.typroject.tyboot.core.foundation.utils.Bean;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.transaction.Transactional; import javax.transaction.Transactional;
import java.text.ParseException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -105,6 +107,12 @@ public class CheckServiceImpl implements ICheckService { ...@@ -105,6 +107,12 @@ public class CheckServiceImpl implements ICheckService {
@Autowired @Autowired
IHiddenDangerDao hiddenDangerDao; IHiddenDangerDao hiddenDangerDao;
@Autowired
IPlanService iPlanService;
@Autowired
ICheckReportService iCheckReportService;
private final int HTTP_OK_STATUS = 200; private final int HTTP_OK_STATUS = 200;
@Value("${file.url}") @Value("${file.url}")
...@@ -1568,6 +1576,9 @@ public class CheckServiceImpl implements ICheckService { ...@@ -1568,6 +1576,9 @@ public class CheckServiceImpl implements ICheckService {
saveDanger(allDanger, planTask, check, recordParam); saveDanger(allDanger, planTask, check, recordParam);
} }
// 任务完成后生成检查报告
iCheckReportService.genCheckReport(planTask);
return checkInputItemDtoList; return checkInputItemDtoList;
} catch (Exception e) { } catch (Exception e) {
throw new Exception(e.getMessage(), e); throw new Exception(e.getMessage(), e);
......
package com.yeejoin.amos.supervision.business.service.intfc;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.supervision.core.common.dto.CheckReportDto;
import com.yeejoin.amos.supervision.core.common.dto.CheckReportParamDto;
import com.yeejoin.amos.supervision.core.common.request.CommonPageable;
import com.yeejoin.amos.supervision.dao.entity.PlanTask;
import java.text.ParseException;
public interface ICheckReportService {
void genCheckReport(PlanTask planTask) throws ParseException;
/**
* 分页查询检查报告列表
*
* @param page
* @param queryParam
*/
IPage<CheckReportDto> pageList(Page page, CheckReportParamDto queryParam);
/**
* 根据报告id获取报告详情
*
* @param id
* @return
*/
CheckReportDto getDetailById(String id);
}
...@@ -17,7 +17,7 @@ ribbon.MaxAutoRetriesNextServer = 2 ...@@ -17,7 +17,7 @@ ribbon.MaxAutoRetriesNextServer = 2
ribbon.MaxAutoRetries = 1 ribbon.MaxAutoRetries = 1
#DB properties: #DB properties:
spring.datasource.url = jdbc:mysql://172.16.10.66:3306/safety-business-3.0.1?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai spring.datasource.url = jdbc:mysql://172.16.6.60:3306/safety-business-3.0.1?useUnicode=true&characterEncoding=utf-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
spring.datasource.username= root spring.datasource.username= root
spring.datasource.password= root_123 spring.datasource.password= root_123
spring.datasource.driver-class-name = com.mysql.jdbc.Driver spring.datasource.driver-class-name = com.mysql.jdbc.Driver
......
<?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.yeejoin.amos.supervision.business.dao.mapper.CheckReportMapper">
<select id="queryByPlanTaskId" resultType="com.yeejoin.amos.supervision.business.dto.CheckReportMapperDto">
SELECT
count( DISTINCT ptd.id ) companyCount,
ptd.task_no planTaskId,
GROUP_CONCAT( DISTINCT executor_name ) checkUser,
GROUP_CONCAT( DISTINCT c.check_time ) checkTime,
pt.begin_time planBeginDate,
pt.end_time planEndDate,
GROUP_CONCAT( DISTINCT hd.latent_danger_id ) latentDangerId,
GROUP_CONCAT( DISTINCT hd.point_id ) problemPointId,
IF
( count( DISTINCT ptd.major_danger_num ) > 0, 1, 0 ) hasMajorDanger
FROM
`p_plan_task_detail` ptd
LEFT JOIN p_check c ON c.plan_task_detail_id = ptd.id
LEFT JOIN p_plan_task pt ON pt.id = ptd.task_no
LEFT JOIN p_hidden_danger hd ON hd.check_id = c.id
<where>
<if test="planTaskId !=null and planTaskId != ''">ptd.task_no = #{planTaskId}</if>
</where>
</select>
<select id="selectPageList" resultType="com.yeejoin.amos.supervision.core.common.dto.CheckReportDto">
select cr.*,
p.name planName,
p.check_type_name planCheckType,
p.check_level planCheckLevel
from p_check_report cr
LEFT JOIN p_plan_task pt ON pt.id = cr.plan_task_id
LEFT JOIN p_plan p ON p.id = pt.plan_id
<where>
1=1
<if test="queryParam != null and queryParam.name != null and queryParam.name != ''">
and cr.name like concat('%', #{queryParam.name}, '%')
</if>
<if test="queryParam != null and queryParam.planName != null and queryParam.planName != ''">
and p.name like concat('%', #{queryParam.planName}, '%')
</if>
<if test="queryParam != null and queryParam.planCheckType != null and queryParam.planCheckType != ''">
and p.check_type_id = #{queryParam.planCheckType}
</if>
<if test="queryParam != null and queryParam.checkLevel != null and queryParam.checkLevel != ''">
and p.check_level = #{queryParam.checkLevel}
</if>
<if test="queryParam != null and queryParam.startCheckTime != null and queryParam.startCheckTime != ''">
and cr.start_check_date <![CDATA[>=]]> #{queryParam.startCheckTime}
</if>
<if test="queryParam != null and queryParam.endCheckTime != null and queryParam.endCheckTime != ''">
and cr.end_check_date <![CDATA[<=]]> #{queryParam.endCheckTime}
</if>
<if test="queryParam != null and queryParam.checkUser != null and queryParam.checkUser != ''">
and cr.check_user like concat('%', #{queryParam.checkUser}, '%')
</if>
<if test="queryParam != null and queryParam.orgCode != null and queryParam.orgCode != ''">
and cr.org_code like concat(#{queryParam.orgCode}, '%')
</if>
</where>
order by cr.create_date desc
</select>
<select id="selectDetailById" resultType="com.yeejoin.amos.supervision.core.common.dto.CheckReportDto">
select cr.*,
p.name planName,
p.check_type_name planCheckType,
p.check_level planCheckLevel,
DATE_FORMAT(pt.begin_time, '%Y-%m-%d') startPlanTaskDate,
DATE_FORMAT(pt.end_time, '%Y-%m-%d') endPlanTaskDate
from p_check_report cr
LEFT JOIN p_plan_task pt on pt.id = cr.plan_task_id
left join p_plan p on p.id = pt.plan_id
where 1 = 1
and cr.id = #{checkReportId}
</select>
<select id="getCheckReportCompanyList"
resultType="com.yeejoin.amos.supervision.core.common.dto.CheckReportCompanyDto">
SELECT c.point_name name,
p.original_id id,
GROUP_CONCAT(DISTINCT ci.user_name) escortUser,
CASE
WHEN ci.safety_danger_num > 0 THEN
'存在隐患'
WHEN ci.is_ok = '1' THEN
'正常'
ELSE '异常'
END checkResult
FROM p_check c
LEFT JOIN p_check_input ci ON ci.check_id = c.id
LEFT JOIN p_point p ON p.id = c.point_id
WHERE c.plan_task_id = #{planTaskId}
GROUP BY c.id
</select>
</mapper>
\ No newline at end of file
...@@ -18,6 +18,9 @@ ...@@ -18,6 +18,9 @@
where pp.id = #{pointId} where pp.id = #{pointId}
and pt.id = #{planTaskId} and pt.id = #{planTaskId}
</select> </select>
<select id="findPlanTaskDetailByTaskId" resultType="com.yeejoin.amos.supervision.dao.entity.PlanTaskDetail">
select * from p_plan_task_detail where task_no = #{planTaskId}
</select>
<update id="updateDanger"> <update id="updateDanger">
UPDATE p_plan_task_detail pptd, UPDATE p_plan_task_detail pptd,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment