建筑施工安全检查标准大屏记录

This commit is contained in:
guoshengxiong 2024-07-29 20:38:16 +08:00
parent caecafc350
commit 999edf90ba
19 changed files with 660 additions and 18 deletions

View File

@ -0,0 +1,320 @@
package com.zhgd.xmgl.modules.xz.controller;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.google.common.collect.Lists;
import com.zhgd.jeecg.common.api.vo.Result;
import com.zhgd.jeecg.common.mybatis.EntityMap;
import com.zhgd.xmgl.modules.worker.service.IEnterpriseInfoService;
import com.zhgd.xmgl.modules.xz.entity.vo.SafetyDetailTotalScoreVo;
import com.zhgd.xmgl.modules.xz.entity.vo.SafetyScoreDetail;
import com.zhgd.xmgl.modules.xz.entity.vo.SafetyTypeScore;
import com.zhgd.xmgl.modules.xz.entity.vo.SafetyTypeScoreVo;
import com.zhgd.xmgl.modules.xz.security.entity.XzSecurityDangerItemRecord;
import com.zhgd.xmgl.modules.xz.security.entity.XzSecurityDangerTypeRecord;
import com.zhgd.xmgl.modules.xz.security.entity.vo.FiveScore;
import com.zhgd.xmgl.modules.xz.security.entity.vo.FiveScoresVo;
import com.zhgd.xmgl.modules.xz.security.entity.vo.XzSecurityQualityInspectionRecordVo;
import com.zhgd.xmgl.modules.xz.security.enums.TenSafetyTypeEnum;
import com.zhgd.xmgl.modules.xz.security.service.IXzSecurityDangerItemRecordService;
import com.zhgd.xmgl.modules.xz.security.service.IXzSecurityDangerTypeRecordService;
import com.zhgd.xmgl.modules.xz.security.service.IXzSecurityQualityInspectionRecordService;
import com.zhgd.xmgl.util.MapBuilder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
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.RestController;
import springfox.documentation.annotations.ApiIgnore;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/xmgl/safetyInspectionStandardBigScreen")
@Slf4j
@Api(tags = "建筑施工安全检查标准大屏记录")
public class SafetyInspectionStandardBigScreenController {
@Lazy
@Autowired
IXzSecurityDangerTypeRecordService xzSecurityDangerTypeRecordService;
@Lazy
@Autowired
IXzSecurityDangerItemRecordService xzSecurityDangerItemRecordService;
@Lazy
@Autowired
IXzSecurityQualityInspectionRecordService xzSecurityQualityInspectionRecordService;
@Lazy
@Autowired
IEnterpriseInfoService enterpriseInfoService;
@ApiOperation(value = "获取月度安全综合评分(五种)", notes = "获取月度安全综合评分(五种)", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
})
@PostMapping(value = "/getFiveScores")
public Result<FiveScoresVo> getFiveScores(@ApiIgnore @RequestBody Map<String, Object> param) {
FiveScoresVo vo = new FiveScoresVo();
String projectSn = MapUtils.getString(param, "projectSn");
SafetyTypeScoreVo thisMonthScoreVo = this.getScores(new MapBuilder<String, Object>().put("projectSn", projectSn).put("month", DateUtil.format(new Date(), "yyyy-MM")).build()).getResult();
SafetyTypeScoreVo lastMonthScoreVo = this.getScores(new MapBuilder<String, Object>().put("projectSn", projectSn).put("month", DateUtil.format(DateUtil.offsetMonth(new Date(), -1), "yyyy-MM")).build()).getResult();
List<SafetyTypeScore> safetyTypeScores = thisMonthScoreVo.getSafetyTypeScores();
FiveScore fiveScore = new FiveScore();
Map<Integer, List<SafetyTypeScore>> fiveTypeScoreMap = new HashMap<>(16);
//5种1安全管理2文明施工3施工支具脚手架模版支架4工程器械物料提升机与施工升降机塔式起重吊装施工用具5危险作业基坑工程高处作业施工用电
for (SafetyTypeScore safetyTypeScore : safetyTypeScores) {
int fiveType;
if (Objects.equals(safetyTypeScore.getTenType(), 1)) {
fiveType = 1;
} else if (Objects.equals(safetyTypeScore.getTenType(), 2)) {
fiveType = 2;
} else if (Objects.equals(safetyTypeScore.getTenType(), 3)
|| Objects.equals(safetyTypeScore.getTenType(), 6)
) {
fiveType = 3;
} else if (Objects.equals(safetyTypeScore.getTenType(), 8)
|| Objects.equals(safetyTypeScore.getTenType(), 9)
|| Objects.equals(safetyTypeScore.getTenType(), 10)
) {
fiveType = 4;
} else {
fiveType = 5;
}
List<SafetyTypeScore> typeScores = fiveTypeScoreMap.get(fiveType);
if (typeScores == null) {
typeScores = new ArrayList<>();
}
typeScores.add(safetyTypeScore);
fiveTypeScoreMap.putIfAbsent(fiveType, typeScores);
}
for (Map.Entry<Integer, List<SafetyTypeScore>> entry : fiveTypeScoreMap.entrySet()) {
List<SafetyTypeScore> list = entry.getValue();
BigDecimal score = list.stream().map(SafetyTypeScore::getScore).reduce(BigDecimal.ZERO, BigDecimal::add).divide(BigDecimal.valueOf(list.size()),2,BigDecimal.ROUND_HALF_UP);
switch (entry.getKey()) {
case 1:
fiveScore.setAqgl(score);
break;
case 2:
fiveScore.setWmsg(score);
break;
case 3:
fiveScore.setSgzj(score);
break;
case 4:
fiveScore.setGcqx(score);
break;
default:
fiveScore.setWxzy(score);
}
}
vo.setThisMonthScores(fiveScore);
vo.setMonthScore(thisMonthScoreVo.getScore());
vo.setLastMonthScore(lastMonthScoreVo.getScore());
vo.setDifferScoreRate(vo.getLastMonthScore().compareTo(BigDecimal.ZERO) == 0 ? new BigDecimal("0") : vo.getMonthScore().subtract(vo.getLastMonthScore()).divide(vo.getLastMonthScore(),4,BigDecimal.ROUND_HALF_UP).subtract(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP));
return Result.success(vo);
}
@ApiOperation(value = "获取月度安全综合评分(十种)", notes = "获取月度安全综合评分(十种)", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
@ApiImplicitParam(name = "month", value = "月份如2024-07", paramType = "body", required = true, dataType = "String"),
})
@PostMapping(value = "/getScores")
public Result<SafetyTypeScoreVo> getScores(@ApiIgnore @RequestBody Map<String, Object> param) {
SafetyTypeScoreVo vo = new SafetyTypeScoreVo();
String month = MapUtils.getString(param, "month");
String projectSn = MapUtils.getString(param, "projectSn");
List<String> topCodes = Arrays.asList("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19");
ArrayList<SafetyTypeScore> safetyTypeScores = Lists.newArrayList();
List<XzSecurityDangerTypeRecord> allTopTypes = xzSecurityDangerTypeRecordService.getTopTypes(topCodes);
List<XzSecurityDangerTypeRecord> allTypeRecords = xzSecurityDangerTypeRecordService.list();
List<XzSecurityDangerItemRecord> allItemRecords = xzSecurityDangerItemRecordService.list();
List<XzSecurityQualityInspectionRecordVo> inspectionRecords = xzSecurityQualityInspectionRecordService.selectQualityInspectionRecordPage(new MapBuilder<String, Object>().put("startMonth", month).put("status", 60).put("projectSn", projectSn).build()).getPage().getRecords();
List<EntityMap> enterpriseInfoList = enterpriseInfoService.getEnterpriseInfoList(new MapBuilder<String, Object>().put("projectSn", projectSn).build());
Map<Integer, List<XzSecurityDangerTypeRecord>> tenTopTypes = allTopTypes.stream().collect(Collectors.groupingBy(XzSecurityDangerTypeRecord::getTenType));
for (Map.Entry<Integer, List<XzSecurityDangerTypeRecord>> tenEntry : tenTopTypes.entrySet()) {
Integer tenType = tenEntry.getKey();
List<XzSecurityDangerTypeRecord> topTenTypes = tenEntry.getValue();
ArrayList<BigDecimal> oneOfTenScores = new ArrayList<>();
for (XzSecurityDangerTypeRecord topType : topTenTypes) {
//分项计算
SafetyDetailTotalScoreVo totalScore = new SafetyDetailTotalScoreVo();
List<XzSecurityDangerTypeRecord> typeRecords = allTypeRecords.stream().filter(x -> Objects.equals(x.getParentId(), topType.getId())).collect(Collectors.toList());
List<Long> typeIds = typeRecords.stream().map(XzSecurityDangerTypeRecord::getId).collect(Collectors.toList());
List<XzSecurityDangerItemRecord> itemRecords = allItemRecords.stream().filter(x -> typeIds.contains(x.getDangerTypeId())).collect(Collectors.toList());
List<SafetyScoreDetail> safetyScoreDetails = new ArrayList<>();
for (XzSecurityDangerTypeRecord typeRecord : typeRecords) {
Long typeId = typeRecord.getId();
List<XzSecurityDangerItemRecord> items = itemRecords.stream().filter(r -> Objects.equals(r.getDangerTypeId(), typeId)).collect(Collectors.toList());
Set<Long> itemIdSet = items.stream().map(XzSecurityDangerItemRecord::getId).collect(Collectors.toSet());
List<XzSecurityQualityInspectionRecordVo> records = inspectionRecords.stream().filter(r -> itemIdSet.contains(r.getDangerItemId())).collect(Collectors.toList());
SafetyScoreDetail safetyScoreDetail = new SafetyScoreDetail();
safetyScoreDetail.setName(typeRecord.getDangerName());
safetyScoreDetail.setProjectType(typeRecord.getProjectType());
safetyScoreDetail.setShouldScore(BigDecimal.valueOf(10));
BigDecimal reduceScore = records.stream().filter(v -> v.getDeductScore() != null).map(v -> v.getDeductScore()).reduce(BigDecimal.ZERO, BigDecimal::add);
//扣减分值总和不得超过该检查项目的应得分值
reduceScore = reduceScore.compareTo(safetyScoreDetail.getShouldScore()) > 0 ? safetyScoreDetail.getShouldScore() : reduceScore;
safetyScoreDetail.setDeductScore(reduceScore.setScale(2, BigDecimal.ROUND_HALF_UP));
safetyScoreDetail.setScore(safetyScoreDetail.getShouldScore().subtract(reduceScore).setScale(2, BigDecimal.ROUND_HALF_UP));
safetyScoreDetail.setDeductReasonList(records);
safetyScoreDetails.add(safetyScoreDetail);
}
BigDecimal tScore;
BigDecimal mustReduce = safetyScoreDetails.stream().filter(s -> Objects.equals(s.getProjectType(), 1)).map(s -> s.getScore()).reduce(BigDecimal.ZERO, BigDecimal::add);
if (safetyScoreDetails.stream().anyMatch(s -> s.getShouldScore().equals(new BigDecimal(0)))
|| mustReduce.compareTo(new BigDecimal(40)) < 0) {
//保证项目中有一项未得分或保证项目小计得分不足40分此分项检查评分表不应得分
tScore = new BigDecimal(0);
} else {
tScore = safetyScoreDetails.stream().map(SafetyScoreDetail::getScore).reduce(BigDecimal.ZERO, BigDecimal::add);
}
totalScore.setScore(tScore);
oneOfTenScores.add(tScore);
}
BigDecimal score = oneOfTenScores.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
score = score.divide(new BigDecimal(oneOfTenScores.size()),4,BigDecimal.ROUND_HALF_UP);
SafetyTypeScore safetyTypeScore = new SafetyTypeScore();
safetyTypeScore.setName(TenSafetyTypeEnum.getEnumByCode(tenType).getDesc());
safetyTypeScore.setWeight(TenSafetyTypeEnum.getEnumByCode(tenType).getWeight());
safetyTypeScore.setScore(score.divide(new BigDecimal("100"),4,BigDecimal.ROUND_HALF_UP).multiply(safetyTypeScore.getWeight()).setScale(2, BigDecimal.ROUND_HALF_UP));
safetyTypeScore.setDeductScore(safetyTypeScore.getWeight().subtract(safetyTypeScore.getScore()).setScale(2, BigDecimal.ROUND_HALF_UP));
safetyTypeScore.setTenType(tenType);
safetyTypeScores.add(safetyTypeScore);
}
BigDecimal score = safetyTypeScores.stream().map(SafetyTypeScore::getScore).reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setScore(score);
vo.setSafetyTypeScores(safetyTypeScores);
return Result.success(vo);
}
@ApiOperation(value = "获取分项检查评分表列表", notes = "获取分项检查评分表列表", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
@ApiImplicitParam(name = "tenType", value = "10大类型【1:安全管理;2:文明施工;3:脚手架(扣件式钢管脚手架/门式钢管脚手架/碗扣式钢管脚手架/承插型盘扣式钢管脚手架/满堂式脚手架/悬挑式脚手架/附着式升降脚手架);4:高处作业(高处作业/高处作业吊篮);5:基坑工程;6:模板支架;7:施工用电;8:物料提升机和施工升降机(物料提升机和施工升降机);9:塔式起重机和起重吊装(塔式起重机和起重吊装);10:施工机具;】", paramType = "body", required = true, dataType = "String"),
})
@PostMapping(value = "/getTypeRecordList")
public Result<List<XzSecurityDangerTypeRecord>> getTypeRecordList(@ApiIgnore @RequestBody Map<String, Object> param) {
return Result.success(xzSecurityDangerTypeRecordService.getTypeRecordList(param));
}
@ApiOperation(value = "获取分项检查评分表详情", notes = "获取分项检查评分表详情", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
@ApiImplicitParam(name = "month", value = "月份如2024-07", paramType = "body", required = true, dataType = "String"),
@ApiImplicitParam(name = "code", value = "编码(包含自定义编码)", paramType = "body", required = true, dataType = "String"),
})
@PostMapping(value = "/getScoresDetails")
public Result<SafetyDetailTotalScoreVo> getScoresDetails(@ApiIgnore @RequestBody Map<String, Object> param) {
SafetyDetailTotalScoreVo totalScore = new SafetyDetailTotalScoreVo();
String month = MapUtils.getString(param, "month");
String code = MapUtils.getString(param, "code");
String projectSn = MapUtils.getString(param, "projectSn");
XzSecurityDangerTypeRecord topType = xzSecurityDangerTypeRecordService.getOne(new LambdaQueryWrapper<XzSecurityDangerTypeRecord>().eq(XzSecurityDangerTypeRecord::getCode, code));
List<XzSecurityDangerTypeRecord> typeRecords = xzSecurityDangerTypeRecordService.list(new LambdaQueryWrapper<XzSecurityDangerTypeRecord>().eq(XzSecurityDangerTypeRecord::getParentId, topType.getId()));
List<Long> typeIds = typeRecords.stream().map(XzSecurityDangerTypeRecord::getId).collect(Collectors.toList());
List<XzSecurityDangerItemRecord> itemRecords = xzSecurityDangerItemRecordService.list(new LambdaQueryWrapper<XzSecurityDangerItemRecord>().in(XzSecurityDangerItemRecord::getDangerTypeId, typeIds));
List<XzSecurityQualityInspectionRecordVo> inspectionRecords = xzSecurityQualityInspectionRecordService.selectQualityInspectionRecordPage(new MapBuilder<String, Object>().put("startMonth", month).put("status", 60).put("projectSn", projectSn).build()).getPage().getRecords();
List<EntityMap> enterpriseInfoList = enterpriseInfoService.getEnterpriseInfoList(new MapBuilder<String, Object>().put("projectSn", projectSn).build());
List<SafetyScoreDetail> safetyScoreDetails = new ArrayList<>();
for (XzSecurityDangerTypeRecord typeRecord : typeRecords) {
Long typeId = typeRecord.getId();
List<XzSecurityDangerItemRecord> items = itemRecords.stream().filter(r -> Objects.equals(r.getDangerTypeId(), typeId)).collect(Collectors.toList());
Set<Long> itemIdSet = items.stream().map(XzSecurityDangerItemRecord::getId).collect(Collectors.toSet());
List<XzSecurityQualityInspectionRecordVo> records = inspectionRecords.stream().filter(r -> itemIdSet.contains(r.getDangerItemId())).collect(Collectors.toList());
//设置总公司
for (XzSecurityQualityInspectionRecordVo record : records) {
String mainEnterpriseName;
Optional<EntityMap> optional = enterpriseInfoList.stream().filter(e -> Objects.equals(MapUtils.getLong(e, "id"), record.getEnterpriseId())).findFirst();
if (optional.isPresent()) {
EntityMap entityMap = optional.get();
String projectEnterpriseId = MapUtils.getString(entityMap, "projectEnterpriseId");
String ancestors = MapUtils.getString(entityMap, "ancestors");
if (Objects.equals(projectEnterpriseId, "0")) {
mainEnterpriseName = record.getEnterpriseName();
} else {
optional = enterpriseInfoList.stream().filter(e -> MapUtils.getString(e, "projectEnterpriseId").equals(ancestors.split(",")[1])).findFirst();
if (optional.isPresent()) {
mainEnterpriseName = MapUtils.getString(optional.get(), "enterpriseName");
} else {
mainEnterpriseName = record.getEnterpriseName();
}
}
} else {
mainEnterpriseName = record.getEnterpriseName();
}
record.setMainEnterpriseName(mainEnterpriseName);
}
SafetyScoreDetail safetyScoreDetail = new SafetyScoreDetail();
safetyScoreDetail.setName(typeRecord.getDangerName());
safetyScoreDetail.setProjectType(typeRecord.getProjectType());
safetyScoreDetail.setShouldScore(getShouldScore(code));
BigDecimal reduceScore = records.stream().filter(v -> v.getDeductScore() != null).map(v -> v.getDeductScore()).reduce(BigDecimal.ZERO, BigDecimal::add);
//扣减分值总和不得超过该检查项目的应得分值
reduceScore = reduceScore.compareTo(safetyScoreDetail.getShouldScore()) > 0 ? safetyScoreDetail.getShouldScore() : reduceScore;
safetyScoreDetail.setDeductScore(reduceScore.setScale(2, BigDecimal.ROUND_HALF_UP));
safetyScoreDetail.setScore(safetyScoreDetail.getShouldScore().subtract(reduceScore).setScale(2, BigDecimal.ROUND_HALF_UP));
safetyScoreDetail.setDeductReasonList(records);
safetyScoreDetails.add(safetyScoreDetail);
}
BigDecimal tScore;
BigDecimal mustReduce = safetyScoreDetails.stream().filter(s -> Objects.equals(s.getProjectType(), 1)).map(s -> s.getScore()).reduce(BigDecimal.ZERO, BigDecimal::add);
if (safetyScoreDetails.stream().anyMatch(s -> s.getShouldScore().equals(new BigDecimal(0)))
|| mustReduce.compareTo(new BigDecimal(40)) < 0) {
//保证项目中有一项未得分或保证项目小计得分不足40分此分项检查评分表不应得分
tScore = new BigDecimal(0);
} else {
tScore = safetyScoreDetails.stream().map(SafetyScoreDetail::getScore).reduce(BigDecimal.ZERO, BigDecimal::add);
}
totalScore.setScore(tScore);
totalScore.setSafetyScoreDetails(safetyScoreDetails);
return Result.success(totalScore);
}
private BigDecimal getShouldScore(String code) {
BigDecimal b;
switch (code) {
case "03.10":
case "03.11":
case "15.08":
case "15.10":
b = new BigDecimal(5);
break;
case "19.03":
case "19.07":
case "19.08":
case "19.10":
b = new BigDecimal(8);
break;
case "14.02":
case "14.04":
b = new BigDecimal(20);
break;
case "14.05":
case "14.06":
case "15.01":
case "15.02":
b = new BigDecimal(15);
break;
case "19.09":
b = new BigDecimal(6);
break;
case "19.11":
b = new BigDecimal(12);
break;
default:
b = new BigDecimal(10);
}
return b;
}
}

View File

@ -0,0 +1,15 @@
package com.zhgd.xmgl.modules.xz.entity.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Data
public
class SafetyDetailTotalScoreVo {
@ApiModelProperty(value = "总分数")
private BigDecimal score;
private List<SafetyScoreDetail> safetyScoreDetails;
}

View File

@ -0,0 +1,28 @@
package com.zhgd.xmgl.modules.xz.entity.vo;
import com.zhgd.xmgl.modules.xz.security.entity.vo.XzSecurityQualityInspectionRecordVo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Data
public
class SafetyScoreDetail {
@ApiModelProperty(value = "名称")
private String name;
/**
* 1保证项目2一般项目
*/
@ApiModelProperty(value = "1保证项目2一般项目")
private Integer projectType;
@ApiModelProperty(value = "应得分数")
private BigDecimal shouldScore;
@ApiModelProperty(value = "扣除分数")
private BigDecimal deductScore;
@ApiModelProperty(value = "实得分数")
private BigDecimal score;
@ApiModelProperty(value = "扣分原因")
private List<XzSecurityQualityInspectionRecordVo> deductReasonList;
}

View File

@ -0,0 +1,21 @@
package com.zhgd.xmgl.modules.xz.entity.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
public
class SafetyTypeScore {
@ApiModelProperty(value = "名称")
private String name;
@ApiModelProperty(value = "10大类型【1:安全管理;2:文明施工;3:脚手架(扣件式钢管脚手架/门式钢管脚手架/碗扣式钢管脚手架/承插型盘扣式钢管脚手架/满堂式脚手架/悬挑式脚手架/附着式升降脚手架);4:高处作业(高处作业/高处作业吊篮);5:基坑工程;6:模板支架;7:施工用电;8:物料提升机和施工升降机(物料提升机和施工升降机);9:塔式起重机和起重吊装(塔式起重机和起重吊装);10:施工机具;】")
private Integer tenType;
@ApiModelProperty(value = "单模块权重")
private BigDecimal weight;
@ApiModelProperty(value = "单项扣分")
private BigDecimal deductScore;
@ApiModelProperty(value = "单项得分")
private BigDecimal score;
}

View File

@ -0,0 +1,15 @@
package com.zhgd.xmgl.modules.xz.entity.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Data
public
class SafetyTypeScoreVo {
@ApiModelProperty(value = "总分数")
private BigDecimal score;
private List<SafetyTypeScore> safetyTypeScores;
}

View File

@ -177,7 +177,7 @@ public class XzSecurityDangerTypeRecordController {
response.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8");
response.setContentType("application/vnd.ms-excel;charset=gb2312"); response.setContentType("application/vnd.ms-excel;charset=gb2312");
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("安全检查模板_导入模板.xlsx", "UTF-8")); response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("安全检查模板_导入模板.xlsx", "UTF-8"));
InputStream fis = new ClassPathResource("excel/安全检查模板_导入模板.xlsx").getInputStream(); InputStream fis = new ClassPathResource("excel/安全检查模板_导入模板ag.xlsx").getInputStream();
IOUtils.copy(fis, out); IOUtils.copy(fis, out);
out.flush(); out.flush();
out.close(); out.close();

View File

@ -92,4 +92,10 @@ public class XzSecurityDangerItemRecord implements Serializable {
private String itemCode; private String itemCode;
@ApiModelProperty(value = "扣分数") @ApiModelProperty(value = "扣分数")
private Double deductScore; private Double deductScore;
/**
* 1保证项目2一般项目
*/
@Excel(name = "1保证项目2一般项目", width = 15)
@ApiModelProperty(value = "1保证项目2一般项目")
private Integer projectType;
} }

View File

@ -3,6 +3,7 @@ package com.zhgd.xmgl.modules.xz.security.entity;
import java.io.Serializable; import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
@ -91,4 +92,17 @@ public class XzSecurityDangerTypeRecord implements Serializable {
@Excel(name = "总企业sn", width = 15) @Excel(name = "总企业sn", width = 15)
@ApiModelProperty(value = "总企业sn") @ApiModelProperty(value = "总企业sn")
private String sn; private String sn;
/**
* 1保证项目2一般项目
*/
@Excel(name = "1保证项目2一般项目", width = 15)
@ApiModelProperty(value = "1保证项目2一般项目")
private Integer projectType;
@TableField(exist = false)
@ApiModelProperty(value = "10大类型【1:安全管理;2:文明施工;3:脚手架(扣件式钢管脚手架/门式钢管脚手架/碗扣式钢管脚手架/承插型盘扣式钢管脚手架/满堂式脚手架/悬挑式脚手架/附着式升降脚手架);4:高处作业(高处作业/高处作业吊篮);5:基坑工程;6:模板支架;7:施工用电;8:物料提升机和施工升降机(物料提升机和施工升降机);9:塔式起重机和起重吊装(塔式起重机和起重吊装);10:施工机具;】")
private Integer tenType;
@TableField(exist = false)
@ApiModelProperty(value = "5大类型")
private Integer fiveType;
} }

View File

@ -0,0 +1,15 @@
package com.zhgd.xmgl.modules.xz.security.entity.vo;
import lombok.Data;
import java.math.BigDecimal;
@Data
public
class FiveScore {
private BigDecimal aqgl;
private BigDecimal wmsg;
private BigDecimal sgzj;
private BigDecimal gcqx;
private BigDecimal wxzy;
}

View File

@ -0,0 +1,14 @@
package com.zhgd.xmgl.modules.xz.security.entity.vo;
import lombok.Data;
import java.math.BigDecimal;
@Data
public
class FiveScoresVo {
private BigDecimal monthScore;
private BigDecimal lastMonthScore;
private BigDecimal differScoreRate;
private FiveScore thisMonthScores;
}

View File

@ -5,6 +5,8 @@ import com.zhgd.xmgl.modules.xz.security.entity.XzSecurityQualityInspectionRecor
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
@Data @Data
public class XzSecurityQualityInspectionRecordVo extends XzSecurityQualityInspectionRecord { public class XzSecurityQualityInspectionRecordVo extends XzSecurityQualityInspectionRecord {
private String inspectManName; private String inspectManName;
@ -28,11 +30,13 @@ public class XzSecurityQualityInspectionRecordVo extends XzSecurityQualityInspec
private String dangerItemName; private String dangerItemName;
@ApiModelProperty(value = "危大工程名称") @ApiModelProperty(value = "危大工程名称")
private java.lang.String engineeringName; private java.lang.String engineeringName;
@TableField(exist = false)
@ApiModelProperty(value = "作业申请单位名称") @ApiModelProperty(value = "作业申请单位名称")
private String jobApplicationUnitName; private String jobApplicationUnitName;
@TableField(exist = false)
@ApiModelProperty(value = "作业票编号") @ApiModelProperty(value = "作业票编号")
private String workTicketCode; private String workTicketCode;
@ApiModelProperty(value = "扣分数")
private BigDecimal deductScore;
@ApiModelProperty(value = "总企业名称")
private String mainEnterpriseName;
} }

View File

@ -0,0 +1,25 @@
package com.zhgd.xmgl.modules.xz.security.enums;
import lombok.Getter;
import lombok.AllArgsConstructor;
@Getter
@AllArgsConstructor
public enum FiveSafetyTypeEnum {
ENUM0(1, "安全管理"),
ENUM1(2, "文明施工"),
ENUM2(3, "施工支具【脚手架、模版支架】"),
ENUM3(4, "工程器械【物料提升机与施工升降机、塔式起重吊装、施工用具】"),
ENUM4(5, "危险作业【基坑工程、高处作业、施工用电】");
private final Integer code;
private final String desc;
public static FiveSafetyTypeEnum getEnumByCode(Integer code) {
for (FiveSafetyTypeEnum e : FiveSafetyTypeEnum.values()) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@ -0,0 +1,34 @@
package com.zhgd.xmgl.modules.xz.security.enums;
import lombok.Getter;
import lombok.AllArgsConstructor;
import java.math.BigDecimal;
@Getter
@AllArgsConstructor
public enum TenSafetyTypeEnum {
ENUM0(1, new BigDecimal("10"),"安全管理"),
ENUM1(2, new BigDecimal("15"),"文明施工"),
ENUM2(3, new BigDecimal("10"),"脚手架(扣件式钢管脚手架/门式钢管脚手架/碗扣式钢管脚手架/承插型盘扣式钢管脚手架/满堂式脚手架/悬挑式脚手架/附着式升降脚手架)"),
ENUM3(4, new BigDecimal("10"),"高处作业(高处作业/高处作业吊篮)"),
ENUM4(5, new BigDecimal("10"),"基坑工程"),
ENUM5(6, new BigDecimal("10"),"模板支架"),
ENUM6(7, new BigDecimal("10"),"施工用电"),
ENUM7(8, new BigDecimal("10"),"物料提升机和施工升降机(物料提升机和施工升降机)"),
ENUM8(9, new BigDecimal("10"),"塔式起重机和起重吊装(塔式起重机和起重吊装)"),
ENUM9(10,new BigDecimal("5"), "施工机具");
private final Integer code;
private final BigDecimal weight;
private final String desc;
public static TenSafetyTypeEnum getEnumByCode(Integer code) {
for (TenSafetyTypeEnum e : TenSafetyTypeEnum.values()) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}

View File

@ -65,4 +65,20 @@ public interface XzSecurityDangerTypeRecordMapper extends BaseMapper<XzSecurityD
* @param sn * @param sn
*/ */
void updateDangerTypeRecordFullName(@Param("oldFullName") String oldFullName, @Param("newFullName") String fullName, @Param("sn") String sn); void updateDangerTypeRecordFullName(@Param("oldFullName") String oldFullName, @Param("newFullName") String fullName, @Param("sn") String sn);
/**
* 查询顶级的建筑施工安全检查标准类型
*
* @param topCodes
* @return
*/
List<XzSecurityDangerTypeRecord> getTopTypes(@Param("list") List<String> topCodes);
/**
* 获取分项检查评分表列表
* @param param
* @return
*/
List<XzSecurityDangerTypeRecord> getTypeRecordList(Map<String, Object> param);
} }

View File

@ -93,4 +93,76 @@
WHERE full_name LIKE N'${oldFullName}%' WHERE full_name LIKE N'${oldFullName}%'
and sn = #{sn}; and sn = #{sn};
</update> </update>
<select id="getTopTypes" resultType="com.zhgd.xmgl.modules.xz.security.entity.XzSecurityDangerTypeRecord">
select *,CASE code
WHEN '01' THEN 1
WHEN '02' THEN 2
WHEN '03' THEN 3
WHEN '04' THEN 3
WHEN '05' THEN 3
WHEN '06' THEN 3
WHEN '07' THEN 3
WHEN '08' THEN 3
WHEN '09' THEN 3
WHEN '10' THEN 4
WHEN '11' THEN 5
WHEN '12' THEN 6
WHEN '13' THEN 4
WHEN '14' THEN 7
WHEN '15' THEN 8
WHEN '16' THEN 8
WHEN '17' THEN 9
WHEN '18' THEN 9
ELSE 10 END tenType
from xz_security_danger_type_record
where code in
<foreach item="item" index="index" collection="list"
open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="getTypeRecordList" resultType="com.zhgd.xmgl.modules.xz.security.entity.XzSecurityDangerTypeRecord">
select *
from xz_security_danger_type_record
where code in
<if test="tenType == '1'.toString() ">
('01')
</if>
<if test="tenType == '2'.toString() ">
('02')
</if>
<if test="tenType == '3'.toString() ">
('03',
'04',
'05',
'06',
'07',
'08',
'09')
</if>
<if test="tenType == '4'.toString() ">
('10','13')
</if>
<if test="tenType == '5'.toString() ">
('11')
</if>
<if test="tenType == '6'.toString() ">
('12')
</if>
<if test="tenType == '7'.toString() ">
('14')
</if>
<if test="tenType == '8'.toString() ">
('15','16')
</if>
<if test="tenType == '9'.toString() ">
('17','18')
</if>
<if test="tenType == '10'.toString() ">
('19')
</if>
</select>
</mapper> </mapper>

View File

@ -254,10 +254,12 @@
ORDER BY create_time desc ORDER BY create_time desc
LIMIT 1) > t.change_limit_time LIMIT 1) > t.change_limit_time
ELSE t.change_limit_time <![CDATA[<]]> now() END), 0) overTime, ELSE t.change_limit_time <![CDATA[<]]> now() END), 0) overTime,
der.engineering_name der.engineering_name,
ic.deduct_score
from xz_security_quality_inspection_record t from xz_security_quality_inspection_record t
LEFT JOIN enterprise_info b ON t.enterprise_sn = b.enterprise_sn LEFT JOIN enterprise_info b ON t.enterprise_sn = b.enterprise_sn
LEFT JOIN xz_security_danger_type_record c ON t.danger_type_id = c.id LEFT JOIN xz_security_danger_type_record c ON t.danger_type_id = c.id
LEFT JOIN xz_security_danger_item_record ic ON t.danger_item_id = ic.id
LEFT JOIN system_user d ON t.change_id = d.user_id LEFT JOIN system_user d ON t.change_id = d.user_id
LEFT JOIN system_user e ON t.review_id = e.user_id LEFT JOIN system_user e ON t.review_id = e.user_id
LEFT JOIN system_user f ON t.verify_man_id = f.user_id LEFT JOIN system_user f ON t.verify_man_id = f.user_id
@ -271,6 +273,9 @@
LEFT JOIN (SELECT quality_id,MAX(rectify_time) as rectify_time FROM xz_security_quality_rectify_record GROUP BY LEFT JOIN (SELECT quality_id,MAX(rectify_time) as rectify_time FROM xz_security_quality_rectify_record GROUP BY
quality_id) r ON r.quality_id = t.id quality_id) r ON r.quality_id = t.id
WHERE t.project_sn = #{param.projectSn} WHERE t.project_sn = #{param.projectSn}
<if test="param.startMonth != null and param.startMonth != '' ">
and t.inspect_time >= #{param.startMonth}
</if>
<if test="param.recordStatus == '8'.toString() "> <if test="param.recordStatus == '8'.toString() ">
and t.status != 6 and t.status != 6
</if> </if>

View File

@ -69,4 +69,19 @@ public interface IXzSecurityDangerTypeRecordService extends IService<XzSecurityD
* @throws Exception * @throws Exception
*/ */
void importDangerTypeRecordExcelTemplate(MultipartFile excelFile, String sn) throws Exception; void importDangerTypeRecordExcelTemplate(MultipartFile excelFile, String sn) throws Exception;
/**
* 查询顶级的建筑施工安全检查标准类型
*
* @param topCodes
* @return
*/
List<XzSecurityDangerTypeRecord> getTopTypes(List<String> topCodes);
/**
* 获取分项检查评分表列表
* @param param
* @return
*/
List<XzSecurityDangerTypeRecord> getTypeRecordList(Map<String, Object> param);
} }

View File

@ -202,6 +202,8 @@ public class XzSecurityDangerTypeRecordServiceImpl extends ServiceImpl<XzSecurit
} }
String code = importInfo.get("编码").trim(); String code = importInfo.get("编码").trim();
String taskName = importInfo.get("检查任务"); String taskName = importInfo.get("检查任务");
String projectTypeName = importInfo.get("项目类型");
Integer projectType = getProjectType(projectTypeName);
Double deductScore = Convert.toDouble(importInfo.get("扣分")); Double deductScore = Convert.toDouble(importInfo.get("扣分"));
String newCode = CodeUtils.subCode(code); String newCode = CodeUtils.subCode(code);
if (StringUtils.isNotEmpty(taskName)) { if (StringUtils.isNotEmpty(taskName)) {
@ -210,21 +212,20 @@ public class XzSecurityDangerTypeRecordServiceImpl extends ServiceImpl<XzSecurit
.eq(XzSecurityDangerTypeRecord::getCode, code); .eq(XzSecurityDangerTypeRecord::getCode, code);
XzSecurityDangerTypeRecord library = xzSecurityDangerTypeRecordMapper.selectOne(queryWrapper); XzSecurityDangerTypeRecord library = xzSecurityDangerTypeRecordMapper.selectOne(queryWrapper);
if (library != null) { if (library != null) {
if (!library.getDangerName().equals(taskName)) { String oldFullName = library.getFullName();
String oldFullName = library.getFullName(); library.setDangerName(taskName);
library.setDangerName(taskName); if (library.getParentId() != 0) {
if (library.getParentId() != 0) { XzSecurityDangerTypeRecord parentHiddenDangerLibrary = xzSecurityDangerTypeRecordMapper.selectById(library.getParentId());
XzSecurityDangerTypeRecord parentHiddenDangerLibrary = xzSecurityDangerTypeRecordMapper.selectById(library.getParentId()); library.setFullName(parentHiddenDangerLibrary.getFullName() + "/" + library.getDangerName());
library.setFullName(parentHiddenDangerLibrary.getFullName() + "/" + library.getDangerName()); library.setLevel(2);
library.setLevel(2); } else {
} else { library.setFullName(taskName);
library.setFullName(taskName); library.setLevel(1);
library.setLevel(1);
}
xzSecurityDangerTypeRecordMapper.updateById(library);
//更新子级层级名称
xzSecurityDangerTypeRecordMapper.updateDangerTypeRecordFullName(oldFullName, library.getFullName(), library.getSn());
} }
library.setProjectType(projectType);
xzSecurityDangerTypeRecordMapper.updateById(library);
//更新子级层级名称
xzSecurityDangerTypeRecordMapper.updateDangerTypeRecordFullName(oldFullName, library.getFullName(), library.getSn());
libraryObj.put(library.getCode(), library); libraryObj.put(library.getCode(), library);
} else { } else {
XzSecurityDangerTypeRecord newHiddenDangerLibrary = new XzSecurityDangerTypeRecord(); XzSecurityDangerTypeRecord newHiddenDangerLibrary = new XzSecurityDangerTypeRecord();
@ -242,6 +243,7 @@ public class XzSecurityDangerTypeRecordServiceImpl extends ServiceImpl<XzSecurit
newHiddenDangerLibrary.setFullName(parentHiddenDangerLibrary.getFullName() + "/" + taskName); newHiddenDangerLibrary.setFullName(parentHiddenDangerLibrary.getFullName() + "/" + taskName);
newHiddenDangerLibrary.setLevel(2); newHiddenDangerLibrary.setLevel(2);
} }
newHiddenDangerLibrary.setProjectType(projectType);
xzSecurityDangerTypeRecordMapper.insert(newHiddenDangerLibrary); xzSecurityDangerTypeRecordMapper.insert(newHiddenDangerLibrary);
libraryObj.put(code, newHiddenDangerLibrary); libraryObj.put(code, newHiddenDangerLibrary);
} }
@ -268,6 +270,7 @@ public class XzSecurityDangerTypeRecordServiceImpl extends ServiceImpl<XzSecurit
itemRecord.setDangerTypeId(hiddenDangerLibrary.getId()); itemRecord.setDangerTypeId(hiddenDangerLibrary.getId());
itemRecord.setItemCode(code); itemRecord.setItemCode(code);
itemRecord.setDeductScore(deductScore); itemRecord.setDeductScore(deductScore);
itemRecord.setProjectType(projectType);
xzSecurityDangerItemRecordMapper.insert(itemRecord); xzSecurityDangerItemRecordMapper.insert(itemRecord);
} else { } else {
itemRecord.setContent(problemDescription); itemRecord.setContent(problemDescription);
@ -278,12 +281,32 @@ public class XzSecurityDangerTypeRecordServiceImpl extends ServiceImpl<XzSecurit
itemRecord.setItemCode(code); itemRecord.setItemCode(code);
itemRecord.setDangerTypeId(hiddenDangerLibrary.getId()); itemRecord.setDangerTypeId(hiddenDangerLibrary.getId());
itemRecord.setDeductScore(deductScore); itemRecord.setDeductScore(deductScore);
itemRecord.setProjectType(projectType);
xzSecurityDangerItemRecordMapper.updateById(itemRecord); xzSecurityDangerItemRecordMapper.updateById(itemRecord);
} }
} }
} }
} }
private Integer getProjectType(String projectTypeName) {
if (Objects.equals(projectTypeName, "保证项目")) {
return 1;
} else if (Objects.equals(projectTypeName, "一般项目")) {
return 2;
}
return null;
}
@Override
public List<XzSecurityDangerTypeRecord> getTopTypes(List<String> topCodes) {
return baseMapper.getTopTypes(topCodes);
}
@Override
public List<XzSecurityDangerTypeRecord> getTypeRecordList(Map<String, Object> param) {
return baseMapper.getTypeRecordList(param);
}
private Integer getLevel(String level) { private Integer getLevel(String level) {
if (level == null) { if (level == null) {
return null; return null;