|
|
@ -7,17 +7,20 @@ import com.alibaba.excel.write.metadata.WriteSheet; |
|
|
|
import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy; |
|
|
|
import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.hnac.hzims.common.utils.Condition; |
|
|
|
import com.hnac.hzims.common.utils.Condition; |
|
|
|
import com.hnac.hzims.safeproduct.dto.HygienePlanDTO; |
|
|
|
import com.hnac.hzims.safeproduct.dto.HygienePlanDTO; |
|
|
|
import com.hnac.hzims.safeproduct.entity.HygienePlanEntity; |
|
|
|
import com.hnac.hzims.safeproduct.entity.HygienePlanEntity; |
|
|
|
|
|
|
|
import com.hnac.hzims.safeproduct.entity.HygieneRecordEntity; |
|
|
|
import com.hnac.hzims.safeproduct.entity.HygieneZoneEntity; |
|
|
|
import com.hnac.hzims.safeproduct.entity.HygieneZoneEntity; |
|
|
|
import com.hnac.hzims.safeproduct.enums.HygieneStatusEnum; |
|
|
|
import com.hnac.hzims.safeproduct.enums.HygieneStatusEnum; |
|
|
|
import com.hnac.hzims.safeproduct.mapper.HygienePlanMapper; |
|
|
|
import com.hnac.hzims.safeproduct.mapper.HygienePlanMapper; |
|
|
|
import com.hnac.hzims.safeproduct.service.IHygienePlanService; |
|
|
|
import com.hnac.hzims.safeproduct.service.IHygienePlanService; |
|
|
|
import com.hnac.hzims.safeproduct.service.IHygieneRecordService; |
|
|
|
import com.hnac.hzims.safeproduct.service.IHygieneRecordService; |
|
|
|
import com.hnac.hzims.safeproduct.service.IHygieneZoneService; |
|
|
|
import com.hnac.hzims.safeproduct.service.IHygieneZoneService; |
|
|
|
|
|
|
|
import com.hnac.hzims.safeproduct.utils.BaseUtil; |
|
|
|
import com.hnac.hzims.safeproduct.vo.HygienePlanDetailVO; |
|
|
|
import com.hnac.hzims.safeproduct.vo.HygienePlanDetailVO; |
|
|
|
import com.hnac.hzims.safeproduct.vo.HygieneMonthVO; |
|
|
|
import com.hnac.hzims.safeproduct.vo.HygieneMonthVO; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
@ -38,6 +41,7 @@ import java.net.URLEncoder; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.Optional; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 卫生自查计划服务实现类 |
|
|
|
* 卫生自查计划服务实现类 |
|
|
@ -62,16 +66,17 @@ public class HygienePlanServiceImpl extends ServiceImpl<HygienePlanMapper, Hygie |
|
|
|
public boolean removePlan(Long id) { |
|
|
|
public boolean removePlan(Long id) { |
|
|
|
// 删除计划数据
|
|
|
|
// 删除计划数据
|
|
|
|
boolean remove = this.removeById(id); |
|
|
|
boolean remove = this.removeById(id); |
|
|
|
if (remove) { |
|
|
|
if (!remove) { |
|
|
|
|
|
|
|
throw new ServiceException("删除卫生自查计划失败"); |
|
|
|
|
|
|
|
} |
|
|
|
// 删除记录数据
|
|
|
|
// 删除记录数据
|
|
|
|
boolean removeRecord = hygieneRecordService.removeReferenceRecord(id); |
|
|
|
boolean removeRecord = hygieneRecordService.removeReferenceRecord(id); |
|
|
|
if (removeRecord) { |
|
|
|
if (!removeRecord) { |
|
|
|
|
|
|
|
throw new ServiceException("删除卫生自查记录失败"); |
|
|
|
|
|
|
|
} |
|
|
|
// 删除责任区数据
|
|
|
|
// 删除责任区数据
|
|
|
|
return hygieneZoneService.removeReferenceZone(id); |
|
|
|
return hygieneZoneService.removeReferenceZone(id); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 卫生自查计划分页 |
|
|
|
* 卫生自查计划分页 |
|
|
@ -115,24 +120,21 @@ public class HygienePlanServiceImpl extends ServiceImpl<HygienePlanMapper, Hygie |
|
|
|
BeanUtils.copyProperties(hygienePlanDTO, hygienePlanEntity); |
|
|
|
BeanUtils.copyProperties(hygienePlanDTO, hygienePlanEntity); |
|
|
|
hygienePlanDTO.setStandardScore(100); |
|
|
|
hygienePlanDTO.setStandardScore(100); |
|
|
|
boolean savePlan = this.save(hygienePlanEntity); |
|
|
|
boolean savePlan = this.save(hygienePlanEntity); |
|
|
|
|
|
|
|
if (!savePlan) { |
|
|
|
|
|
|
|
throw new ServiceException("卫生自查计划新增失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 新增关联责任区数据
|
|
|
|
List<HygieneZoneEntity> zoneList = hygienePlanDTO.getZoneList(); |
|
|
|
List<HygieneZoneEntity> zoneList = hygienePlanDTO.getZoneList(); |
|
|
|
// 若计划新增成功,新增关联责任区数据
|
|
|
|
|
|
|
|
if (savePlan) { |
|
|
|
|
|
|
|
hygienePlan = getPlanByName(hygienePlanDTO.getName()); |
|
|
|
hygienePlan = getPlanByName(hygienePlanDTO.getName()); |
|
|
|
for (HygieneZoneEntity zone : zoneList) { |
|
|
|
for (HygieneZoneEntity zone : zoneList) { |
|
|
|
// 传计划id
|
|
|
|
|
|
|
|
if (hygienePlan != null) { |
|
|
|
|
|
|
|
zone.setHygienePlanId(hygienePlan.getId()); |
|
|
|
zone.setHygienePlanId(hygienePlan.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
String[] scores = zone.getCheckItemScore().split(",|,"); |
|
|
|
String[] scores = zone.getCheckItemScore().split(",|,"); |
|
|
|
// 校验检查项总成绩是否为标准总成绩
|
|
|
|
// 校验检查项总成绩是否为标准总成绩
|
|
|
|
getSumScore(scores, hygienePlanDTO.getStandardScore()); |
|
|
|
BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore()); |
|
|
|
} |
|
|
|
} |
|
|
|
// 校验通过则批量新增责任区数据
|
|
|
|
// 校验通过则批量新增责任区数据
|
|
|
|
return R.status(hygieneZoneService.saveBatch(zoneList)); |
|
|
|
return R.status(hygieneZoneService.saveBatch(zoneList)); |
|
|
|
} |
|
|
|
} |
|
|
|
return R.status(Boolean.FALSE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 修改卫生自查计划 |
|
|
|
* 修改卫生自查计划 |
|
|
@ -140,9 +142,10 @@ public class HygienePlanServiceImpl extends ServiceImpl<HygienePlanMapper, Hygie |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public R updatePlan(HygienePlanDTO hygienePlanDTO) { |
|
|
|
public R updatePlan(HygienePlanDTO hygienePlanDTO) { |
|
|
|
|
|
|
|
Long planId = hygienePlanDTO.getId(); |
|
|
|
// 重名校验
|
|
|
|
// 重名校验
|
|
|
|
QueryWrapper<HygienePlanEntity> queryWrapper = new QueryWrapper<>(); |
|
|
|
QueryWrapper<HygienePlanEntity> queryWrapper = new QueryWrapper<>(); |
|
|
|
queryWrapper.lambda().ne(HygienePlanEntity::getId, hygienePlanDTO.getId()); |
|
|
|
queryWrapper.lambda().ne(HygienePlanEntity::getId, planId); |
|
|
|
queryWrapper.lambda().eq(HygienePlanEntity::getName, hygienePlanDTO.getName()); |
|
|
|
queryWrapper.lambda().eq(HygienePlanEntity::getName, hygienePlanDTO.getName()); |
|
|
|
HygienePlanEntity hygienePlan = this.getOne(queryWrapper); |
|
|
|
HygienePlanEntity hygienePlan = this.getOne(queryWrapper); |
|
|
|
if (hygienePlan != null) { |
|
|
|
if (hygienePlan != null) { |
|
|
@ -152,18 +155,45 @@ public class HygienePlanServiceImpl extends ServiceImpl<HygienePlanMapper, Hygie |
|
|
|
HygienePlanEntity hygienePlanEntity = new HygienePlanEntity(); |
|
|
|
HygienePlanEntity hygienePlanEntity = new HygienePlanEntity(); |
|
|
|
BeanUtils.copyProperties(hygienePlanDTO, hygienePlanEntity); |
|
|
|
BeanUtils.copyProperties(hygienePlanDTO, hygienePlanEntity); |
|
|
|
boolean updatePlan = this.updateById(hygienePlanEntity); |
|
|
|
boolean updatePlan = this.updateById(hygienePlanEntity); |
|
|
|
|
|
|
|
if (!updatePlan) { |
|
|
|
|
|
|
|
throw new ServiceException("卫生自查计划修改失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 修改关联责任区数据
|
|
|
|
List<HygieneZoneEntity> zoneList = hygienePlanDTO.getZoneList(); |
|
|
|
List<HygieneZoneEntity> zoneList = hygienePlanDTO.getZoneList(); |
|
|
|
// 若计划修改成功,修改关联责任区数据
|
|
|
|
// 删除旧的责任区数据
|
|
|
|
if (updatePlan) { |
|
|
|
boolean removeZone = hygieneZoneService.removeReferenceZone(planId); |
|
|
|
|
|
|
|
if (!removeZone) { |
|
|
|
|
|
|
|
throw new ServiceException("删除旧的责任区数据失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 新增新的责任区数据
|
|
|
|
|
|
|
|
hygienePlan = getPlanByName(hygienePlanDTO.getName()); |
|
|
|
for (HygieneZoneEntity zone : zoneList) { |
|
|
|
for (HygieneZoneEntity zone : zoneList) { |
|
|
|
|
|
|
|
zone.setHygienePlanId(hygienePlan.getId()); |
|
|
|
String[] scores = zone.getCheckItemScore().split(",|,"); |
|
|
|
String[] scores = zone.getCheckItemScore().split(",|,"); |
|
|
|
// 校验检查项总成绩是否为标准总成绩
|
|
|
|
// 校验检查项总成绩是否为标准总成绩
|
|
|
|
getSumScore(scores, hygienePlanDTO.getStandardScore()); |
|
|
|
BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore()); |
|
|
|
} |
|
|
|
} |
|
|
|
// 校验通过则批量修改责任区数据
|
|
|
|
// 校验通过则批量修改责任区数据
|
|
|
|
return R.status(hygieneZoneService.updateBatchById(zoneList)); |
|
|
|
boolean saveZone = hygieneZoneService.saveBatch(zoneList); |
|
|
|
|
|
|
|
if (!saveZone) { |
|
|
|
|
|
|
|
throw new ServiceException("新增新的责任区数据失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 修改卫生自查记录的责任区id
|
|
|
|
|
|
|
|
List<HygieneRecordEntity> recordList = hygieneRecordService.getReferenceRecord(planId); |
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(recordList)) { |
|
|
|
|
|
|
|
List<HygieneZoneEntity> zones = hygieneZoneService.getReferenceZone(planId); |
|
|
|
|
|
|
|
List<Long> ids = zones.stream().map(HygieneZoneEntity::getId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
StringBuilder zoneIds = new StringBuilder(); |
|
|
|
|
|
|
|
for (int i = 0; i < ids.size(); i++) { |
|
|
|
|
|
|
|
zoneIds.append(ids.get(i)); |
|
|
|
|
|
|
|
if (i != ids.size() - 1) { |
|
|
|
|
|
|
|
zoneIds.append(","); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return R.status(Boolean.FALSE); |
|
|
|
recordList.forEach(record -> record.setHygieneZoneIds(zoneIds.toString())); |
|
|
|
|
|
|
|
return R.status(hygieneRecordService.updateBatchById(recordList)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return R.status(Boolean.TRUE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -210,24 +240,6 @@ public class HygienePlanServiceImpl extends ServiceImpl<HygienePlanMapper, Hygie |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 计算累计分值 |
|
|
|
|
|
|
|
* @param scores 各项分值 |
|
|
|
|
|
|
|
* @param standardScore 标准总分值 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void getSumScore(String[] scores, Integer standardScore) { |
|
|
|
|
|
|
|
int sum = 0; |
|
|
|
|
|
|
|
for (String score : scores) { |
|
|
|
|
|
|
|
sum += Integer.parseInt(score); |
|
|
|
|
|
|
|
if (sum > standardScore) { |
|
|
|
|
|
|
|
throw new ServiceException("累计分值超过标准总分值"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (sum < standardScore) { |
|
|
|
|
|
|
|
throw new ServiceException("标准总分值未全部分配"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 根据编码查询卫生自查计划 |
|
|
|
* 根据编码查询卫生自查计划 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|