From c94f3c34d1c2c5a1d5e7010ab1e3cd0aded3cfac Mon Sep 17 00:00:00 2001
From: 郑永安 <zyazyz250@sina.com>
Date: 星期二, 15 八月 2023 09:40:37 +0800
Subject: [PATCH] Merge branch 'zya'
---
src/main/java/com/gk/hotwork/Service/ServiceImpl/SafetySelfInspectionImpl.java | 245 +++++++++++++++++++++---------------------------
1 files changed, 106 insertions(+), 139 deletions(-)
diff --git a/src/main/java/com/gk/hotwork/Service/ServiceImpl/SafetySelfInspectionImpl.java b/src/main/java/com/gk/hotwork/Service/ServiceImpl/SafetySelfInspectionImpl.java
index b8e40f0..c8548a1 100644
--- a/src/main/java/com/gk/hotwork/Service/ServiceImpl/SafetySelfInspectionImpl.java
+++ b/src/main/java/com/gk/hotwork/Service/ServiceImpl/SafetySelfInspectionImpl.java
@@ -53,9 +53,11 @@
private InspectionExpertService expertService;
@Autowired
private InspectionHiddenDangerService dangerService;
+ @Autowired
+ private AttachmentInfoService attachmentInfoService;
/**
- * @Description: 分页
+ * @Description: 自查分页
*/
@Override
public IPage<SafetySelfInspection> selectPage(Page<SafetySelfInspection> page, Map<String, Object> filter, UserInfo user) {
@@ -72,7 +74,7 @@
filter.put("city",user.getCity());
filter.put("area",user.getCounty());
}
- filter.put("flag",0);
+ filter.put("flag",(byte)2);
IPage<SafetySelfInspection> res = safetySelfInspectionMapper.selectPages(page, filter);
List<SafetySelfInspection> records = res.getRecords();
@@ -97,7 +99,7 @@
}
/**
- * @Description: 分页
+ * @Description: 监管检查分页
*/
@Override
public IPage<SafetySelfInspection> selectSupervisePage(Page<SafetySelfInspection> page, Map<String, Object> filter, UserInfo user) {
@@ -114,7 +116,7 @@
filter.put("city",user.getCity());
filter.put("area",user.getCounty());
}
- filter.put("flag",1);
+ filter.put("flag",(byte)1);
IPage<SafetySelfInspection> res = safetySelfInspectionMapper.selectPages(page, filter);
List<SafetySelfInspection> records = res.getRecords();
@@ -137,119 +139,7 @@
}
return res;
}
- /* @Override
- public IPage<SafetySelfInspection> selectPage(Page<SafetySelfInspection> page, Map<String, Object> filter, UserInfo user) {
- Integer type = user.getType();
- //普通用户
- if (type.equals(3)) {
- Long companyid = user.getCompanyid();
- filter.put("companyid",companyid);
- }
- //监管用户
- if (type.equals(2)) {
- Long companyid = user.getCompanyid();
- //获取企业信息
- CompanyInfo companyInfo = companyService.getById(companyid);
- filter.put("province",companyInfo.getProvince());
- filter.put("city",companyInfo.getCity());
- filter.put("area",companyInfo.getArea());
- }
- IPage<SafetySelfInspection> res = safetySelfInspectionMapper.selectPages(page, filter);
- List<SafetySelfInspection> records = res.getRecords();
- if (CollectionUtils.isNotEmpty(records)){
- DecimalFormat df = new DecimalFormat("0.00%");
- records = records.stream().map((safetySelfInspection) -> {
- //总分
- Integer totalScore = 0;
- //扣分
- Integer delScore =0;
-
- Long id = safetySelfInspection.getId();
- SafetySelfInspectionItemQualifiedCountDO countDO = safetySelfInspectionItemMapper.countQualifiedDataById(id);
- safetySelfInspection.setUnqualifiedItem(countDO.getItemSum() - countDO.getQualifiedItem());
- if (countDO != null && countDO.getItemSum() != 0 && countDO.getItemSum() != null) {
- BigDecimal rate = new BigDecimal(countDO.getQualifiedItem())
- .divide(new BigDecimal(countDO.getItemSum()), 4, BigDecimal.ROUND_HALF_UP);
- String qualifiedRate = df.format(rate);
- safetySelfInspection.setQualifiedRate(qualifiedRate);
- safetySelfInspection.setItemSum(countDO.getItemSum());
- }
- //计算总分以及得分
- //获取要素
- List<SafetyInspectionElementA> inspectionElementAList = safetyInspectionElementAService.getBySafetySelfInspectionId(id);
- //获取检查项
- List<SafetySelfInspectionItem> safetySelfInspectionItemList = safetySelfInspectionItemMapper.getBySafetySelfInspectionId2(id);
- //循环要素
- for(SafetyInspectionElementA elementA : inspectionElementAList){
- //获取该要素的树
- List<ElementTree> elementTree = elementManagementService.getElementTreeByParentId(elementA.getElementA());
- //二级要素
- if (CollectionUtils.isNotEmpty(elementTree)) {
- List<ElementTree> elementBList = elementTree.get(0).getChildren();
- for(ElementTree stree : elementBList){
- //三级要素为空
- if(CollectionUtils.isEmpty(stree.getChildren())){
- //总分累计
- totalScore += stree.getPoint();
- //无三级要素过滤出二级要素检查内容
- List<SafetySelfInspectionItem> sItemList = safetySelfInspectionItemList
- .stream()
- .filter(item -> item.getElementC() == null && item.getElementB().equals(stree.getValue()))
- .collect(Collectors.toList());
- //判断是否有否决项
- List<SafetySelfInspectionItem> rejectList = sItemList
- .stream()
- .filter(item -> item.getSafetyInspectionItemResult().equals(0))
- .collect(Collectors.toList());
-
- if(rejectList.size() > 0){
- delScore += stree.getPoint();
- }else {
- //计算出不合格扣分
- delScore += unqualifiedItemDelScore(sItemList);
- }
-
- } else {
- List<ElementTree> elementCList = stree.getChildren();
- for(ElementTree ttree : elementCList){
- //计算总分
- totalScore += ttree.getPoint();
- //过滤该三级要素检查项目
- List<SafetySelfInspectionItem> tItemList = safetySelfInspectionItemList
- .stream()
- .filter(item -> item.getElementC() != null && item.getElementC().equals(ttree.getValue()))
- .collect(Collectors.toList());
- //判断是否有被否决
- List<SafetySelfInspectionItem> rejectList = tItemList
- .stream()
- .filter(item -> item.getSafetyInspectionItemResult().equals(0))
- .collect(Collectors.toList());
- if(rejectList.size() > 0){
- delScore += ttree.getPoint();
- }else {
- //计算出不合格扣分
- totalScore += unqualifiedItemDelScore(tItemList);
- }
- }
-
- }
- }
-
- }
-
-
- }
- //得分
- Integer score = totalScore - delScore;
- safetySelfInspection.setTotalScore(totalScore.toString());
- safetySelfInspection.setScore(score.toString());
- return safetySelfInspection;
- }).collect(Collectors.toList());
- res.setRecords(records);
- }
- return res;
- }*/
//累计过出不合格扣分
private Integer unqualifiedItemDelScore(List<SafetySelfInspectionItem> itemList){
int delScore = 0;
@@ -283,7 +173,7 @@
Date date = new Date();
String username = user.getRealname();
param.setValidFlag(Boolean.TRUE);
- param.setFlag((byte) 0);
+ param.setFlag((byte) 2);
param.setUpdateBy(username);
param.setCreateBy(username);
param.setUpdateTime(date);
@@ -521,25 +411,26 @@
BeanUtils.copyProperties(safetySelfInspection,safetySelfInspectionRespDTO);
//获取所有检查项
List<SafetySelfInspectionItem> itemList= safetySelfInspectionItemMapper.getDetailBySafetySelfInspectionId(id,unqualified);
- //获取关联要素
- List<SafetyInspectionElementA> inspectionElementAList = safetyInspectionElementAService.getBySafetySelfInspectionId(id);
+ //获取要素树
+ List<ElementTree> elementTreeList = elementManagementService.getMenuType1Tree();
+ //获取附件
+ List<AttachmentInfo> byBusinessId = attachmentInfoService.findByBusinessId(id);
+ safetySelfInspectionRespDTO.setAttachmentList(byBusinessId);
List<SafetySelfInspectionElementRespDTO> arespDTOList = new ArrayList<>();
- if (CollectionUtils.isNotEmpty(inspectionElementAList)) {
- for (SafetyInspectionElementA elementA : inspectionElementAList) {
- //获取该要素的树
- List<ElementTree> elementTree = elementManagementService.getElementTreeByParentId(elementA.getElementA());
- if (CollectionUtils.isNotEmpty(elementTree)) {
- //一级要素
- ElementTree otree = elementTree.get(0);
+ if (CollectionUtils.isNotEmpty(elementTreeList)) {
+ for (ElementTree elementA : elementTreeList) {
+
+ List<SafetySelfInspectionItem> selectElementList = itemList.stream().filter(item -> item.getElementA().equals(elementA.getValue())).collect(Collectors.toList());
+ if (CollectionUtils.isNotEmpty(selectElementList)) {
SafetySelfInspectionElementRespDTO elementARespDTO = new SafetySelfInspectionElementRespDTO();
- elementARespDTO.setElementId(otree.getValue());
- elementARespDTO.setElementName(otree.getLabel());
- elementARespDTO.setType(otree.getType());
+ elementARespDTO.setElementId(elementA.getValue());
+ elementARespDTO.setElementName(elementA.getLabel());
+ elementARespDTO.setType(elementA.getType());
List<SafetySelfInspectionElementRespDTO> brespDTOList = new ArrayList<>();
//二级要素
- List<ElementTree> elementBList = otree.getChildren();
+ List<ElementTree> elementBList = elementA.getChildren();
if(CollectionUtils.isNotEmpty(elementBList)){
for (ElementTree stree : elementBList) {
SafetySelfInspectionElementRespDTO elementBRespDTO = new SafetySelfInspectionElementRespDTO();
@@ -669,6 +560,7 @@
SafetySelfInspectionItem safetySelfInspectionItem = safetySelfInspectionItemMapper.getDetailById(id);
List<SafetySelfInspectionItemDeduction> selfDeductionList = safetySelfInspectionItemDeductionMapper.getBySafetySelfInspectionItemId(safetySelfInspectionItem.getId());
List<InspectionHiddenDanger> inspectionHiddenDangerList = dangerService.getBySafetySelfInspectionItemId(id);
+ List<AttachmentInfo> byBusinessId = attachmentInfoService.findByBusinessId(id);
if (CollectionUtils.isNotEmpty(selfDeductionList)){
safetySelfInspectionItem.setSelfDeductionList(selfDeductionList);
@@ -689,6 +581,20 @@
safetySelfInspectionItem.setSelfDeductionList(new ArrayList<>());
}
}
+ for (InspectionHiddenDanger inspectionHiddenDanger : inspectionHiddenDangerList) {
+ if(StringUtils.isNotBlank(inspectionHiddenDanger.getUrl())){
+ List<Long> attachmentIds = new ArrayList<>();
+ String[] split = inspectionHiddenDanger.getUrl().split(",");
+ for (String s : split) {
+ attachmentIds.add(Long.valueOf(s));
+ }
+
+ List<AttachmentInfo> dangerAttachList = attachmentInfoService.findByIds(attachmentIds);
+ inspectionHiddenDanger.setAttachmentList(dangerAttachList);
+ }
+
+ }
+ safetySelfInspectionItem.setAttachmentList(byBusinessId);
safetySelfInspectionItem.setDangerList(inspectionHiddenDangerList);
return safetySelfInspectionItem;
}
@@ -705,11 +611,22 @@
param.setUpdateTime(date);
param.setUpdateBy(username);
safetySelfInspectionItemMapper.updateById(param);
+ //附件
+ List<AttachmentInfo> attachmentInfoList = new ArrayList<>();
+ if(CollectionUtils.isNotEmpty(param.getAttachmentList())){
+ for (AttachmentInfo attachmentInfo : param.getAttachmentList()) {
+ attachmentInfo.setBusinessId(param.getId());
+ attachmentInfoList.add(attachmentInfo);
+ }
+ }
+
if (param.getSafetyInspectionItemResult()==0 || param.getSafetyInspectionItemResult() == 2){
//否决 合格--删除扣分记录
safetySelfInspectionItemDeductionMapper.delBySafetySelfInspectionItemId(param.getId(),username,date);
//删除隐患
dangerService.delByInspectionItemId(param.getSafetyInspectionItemId(),user);
+ //删除附件
+ attachmentInfoService.deleteByBusinessId(param.getId());
}else{
//扣分
List<SafetySelfInspectionItemDeduction> list = safetySelfInspectionItemDeductionMapper.getBySafetySelfInspectionItemId(param.getId());
@@ -747,23 +664,53 @@
dangerService.delByIds(idList);
}
for (InspectionHiddenDanger inspectionHiddenDanger : param.getDangerList()) {
+ StringBuffer stringBuffer = new StringBuffer();
+ //附件
+ if(CollectionUtils.isNotEmpty(inspectionHiddenDanger.getAttachmentList())){
+ for (AttachmentInfo attachmentInfo : inspectionHiddenDanger.getAttachmentList()) {
+ stringBuffer.append(attachmentInfo.getId().toString()).append(",");
+ }
+ stringBuffer = stringBuffer.deleteCharAt(stringBuffer.length()-1);
+ }
+
if(inspectionHiddenDanger.getId() == null){
inspectionHiddenDanger.setCreateBy(user.getRealname());
inspectionHiddenDanger.setCreateTime(new Date());
inspectionHiddenDanger.setUpdateBy(user.getRealname());
inspectionHiddenDanger.setUpdateTime(new Date());
- inspectionHiddenDanger.setStatus((byte)0);
+ inspectionHiddenDanger.setStatus((byte)-1);
inspectionHiddenDanger.setValidFlag(true);
inspectionHiddenDanger.setSelfInspectionId(param.getSafetySelfInspectionId());
inspectionHiddenDanger.setSelfInspectionItemId(param.getId());
+ inspectionHiddenDanger.setUrl(stringBuffer.toString());
dangerService.save(inspectionHiddenDanger);
+ //附件
+ if(StringUtils.isNotBlank(inspectionHiddenDanger.getUrl())){
+ for (AttachmentInfo attachmentInfo : inspectionHiddenDanger.getAttachmentList()) {
+ attachmentInfo.setBusinessId(inspectionHiddenDanger.getId());
+ attachmentInfoList.add(attachmentInfo);
+ }
+ }
}else {
inspectionHiddenDanger.setUpdateBy(user.getRealname());
inspectionHiddenDanger.setUpdateTime(new Date());
+ inspectionHiddenDanger.setUrl(stringBuffer.toString());
dangerService.updateById(inspectionHiddenDanger);
+ //附件
+ if(CollectionUtils.isNotEmpty(inspectionHiddenDanger.getAttachmentList())){
+ for (AttachmentInfo attachmentInfo : inspectionHiddenDanger.getAttachmentList()) {
+ attachmentInfo.setBusinessId(inspectionHiddenDanger.getId());
+ attachmentInfoList.add(attachmentInfo);
+ }
+ }
}
}
}
+
+ }
+ //附件信息更新
+ if(CollectionUtils.isNotEmpty(attachmentInfoList)){
+ attachmentInfoService.updateBusinessIdBatch(attachmentInfoList);
}
}
@@ -787,6 +734,32 @@
item.setUpdateTime(new Date());
});
safetySelfInspectionItemMapper.updateBatch(itemList);
+ }
+
+ @Override
+ public void addCheckAttachment(List<AttachmentInfo> attachmentList, UserInfo user) {
+ requiredAttachmentVerification(attachmentList);
+ for (AttachmentInfo attachmentInfo : attachmentList) {
+ attachmentInfo.setUpdateTime(new Date());
+ attachmentInfo.setUpdateUid(user.getId());
+ attachmentInfo.setUpdateUname(user.getRealname());
+ }
+ attachmentInfoService.updateBusinessIdBatch(attachmentList);
+ }
+
+ private void requiredAttachmentVerification(List<AttachmentInfo> attachmentList) {
+ if(CollectionUtils.isEmpty(attachmentList)){
+ throw new BusinessException("附件信息为空");
+ }
+ for (AttachmentInfo attachmentInfo : attachmentList) {
+ if(attachmentInfo.getId() == null){
+ throw new BusinessException("附件主键信息不能为空");
+ }
+ if(attachmentInfo.getBusinessId() == null){
+ throw new BusinessException("附件信息关联业务id不能为空");
+ }
+ }
+
}
/**
@@ -844,13 +817,7 @@
if (param.getCheckedCompanyId() == null){
throw new BusinessException("请选择被检查公司");
}
- if(CollectionUtils.isEmpty(param.getElementAList())){
- throw new BusinessException("请选择A检查要素");
- }
- for(SafetyInspectionElementA elementA : param.getElementAList()){
- if(elementA.getElementA() == null){
- throw new BusinessException("请选择A检查要素");
- }
- }
}
+
+
}
--
Gitblit v1.9.2