Browse Source

update: 卫生自查模块

zhongwei
liwen 8 months ago
parent
commit
bcc6592d35
  1. 1
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.java
  2. 82
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java
  3. 14
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java
  4. 46
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java
  5. 6
      hzims-service/safeproduct/src/main/resources/db/2.0.1.sql

1
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.java

@ -7,7 +7,6 @@ import org.apache.ibatis.annotations.Mapper;
import org.springblade.core.datascope.annotation.UserDataAuth; import org.springblade.core.datascope.annotation.UserDataAuth;
import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper;
/** /**
* 卫生自查计划Mapper类 * 卫生自查计划Mapper类
* *

82
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java

@ -63,15 +63,16 @@ 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); }
if (removeRecord) { // 删除记录数据
// 删除责任区数据 boolean removeRecord = hygieneRecordService.removeReferenceRecord(id);
return hygieneZoneService.removeReferenceZone(id); if (!removeRecord) {
} throw new ServiceException("删除卫生自查记录失败");
} }
return false; // 删除责任区数据
return hygieneZoneService.removeReferenceZone(id);
} }
/** /**
@ -116,23 +117,20 @@ 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();
// 若计划新增成功,新增关联责任区数据 hygienePlan = getPlanByName(hygienePlanDTO.getName());
if (savePlan) { for (HygieneZoneEntity zone : zoneList) {
hygienePlan = getPlanByName(hygienePlanDTO.getName()); zone.setHygienePlanId(hygienePlan.getId());
for (HygieneZoneEntity zone : zoneList) { String[] scores = zone.getCheckItemScore().split(",|,");
// 传计划id // 校验检查项总成绩是否为标准总成绩
if (hygienePlan != null) { BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore());
zone.setHygienePlanId(hygienePlan.getId());
}
String[] scores = zone.getCheckItemScore().split(",|,");
// 校验检查项总成绩是否为标准总成绩
BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore());
}
// 校验通过则批量新增责任区数据
return R.status(hygieneZoneService.saveBatch(zoneList));
} }
return R.status(Boolean.FALSE); // 校验通过则批量新增责任区数据
return R.status(hygieneZoneService.saveBatch(zoneList));
} }
/** /**
@ -153,28 +151,26 @@ 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(hygienePlanDTO.getId());
// 删除旧数据 if (!removeZone) {
boolean removeZone = hygieneZoneService.removeReferenceZone(hygienePlanDTO.getId()); throw new ServiceException("删除旧的责任区数据失败");
if (removeZone) { }
hygienePlan = getPlanByName(hygienePlanDTO.getName()); // 新增新的责任区数据
// 增加新数据 hygienePlan = getPlanByName(hygienePlanDTO.getName());
for (HygieneZoneEntity zone : zoneList) { for (HygieneZoneEntity zone : zoneList) {
// 传计划id zone.setHygienePlanId(hygienePlan.getId());
if (hygienePlan != null) { String[] scores = zone.getCheckItemScore().split(",|,");
zone.setHygienePlanId(hygienePlan.getId()); // 校验检查项总成绩是否为标准总成绩
} BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore());
String[] scores = zone.getCheckItemScore().split(",|,");
// 校验检查项总成绩是否为标准总成绩
BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore());
}
// 校验通过则批量修改责任区数据
return R.status(hygieneZoneService.saveBatch(zoneList));
}
} }
return R.status(Boolean.FALSE); // 校验通过则批量修改责任区数据
return R.status(hygieneZoneService.saveBatch(zoneList));
} }
/** /**

14
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java

@ -84,9 +84,9 @@ public class HygieneRecordServiceImpl extends ServiceImpl<HygieneRecordMapper, H
// 获取当月时间 // 获取当月时间
String currentNormMonth = DatePattern.NORM_MONTH_FORMAT.format(new Date()); String currentNormMonth = DatePattern.NORM_MONTH_FORMAT.format(new Date());
String currentSimpleMonth = DatePattern.SIMPLE_MONTH_FORMAT.format(new Date()); String currentSimpleMonth = DatePattern.SIMPLE_MONTH_FORMAT.format(new Date());
// 查询是否存在同月编号 // 查询同月的最新编号
String lastCode = getLastCode(currentNormMonth); String lastCode = getLastCode(currentNormMonth);
// 若不存在,新增编号 // 生成编号
String code = BaseUtil.getUniqueCode("WSZC", lastCode, currentSimpleMonth); String code = BaseUtil.getUniqueCode("WSZC", lastCode, currentSimpleMonth);
hygieneRecordEntity.setCode(code); hygieneRecordEntity.setCode(code);
// 周数计算 // 周数计算
@ -102,12 +102,12 @@ public class HygieneRecordServiceImpl extends ServiceImpl<HygieneRecordMapper, H
} }
} }
boolean save = this.save(hygieneRecordEntity); boolean save = this.save(hygieneRecordEntity);
// 若自查记录新增成功,修改自查计划状态为已完成 if (!save) {
if (save) { throw new ServiceException("卫生自查记录新增失败");
hygienePlanEntity.setHygienePlanStatus(RehearsalStatusEnum.FINISHED.getValue());
return R.status(hygienePlanMapper.updateById(hygienePlanEntity) == SafeProductConstant.SUCCESS);
} }
return R.fail("新增失败"); // 修改自查计划状态为已完成
hygienePlanEntity.setHygienePlanStatus(RehearsalStatusEnum.FINISHED.getValue());
return R.status(hygienePlanMapper.updateById(hygienePlanEntity) == SafeProductConstant.SUCCESS);
} }
/** /**

46
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java

@ -11,7 +11,6 @@ import com.hnac.hzims.safeproduct.service.IHygieneTemplateService;
import com.hnac.hzims.safeproduct.utils.BaseUtil; import com.hnac.hzims.safeproduct.utils.BaseUtil;
import com.hnac.hzims.safeproduct.vo.HygieneTemplateDetailVO; import com.hnac.hzims.safeproduct.vo.HygieneTemplateDetailVO;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -38,28 +37,28 @@ public class HygieneTemplateServiceImpl extends ServiceImpl<HygieneTemplateMappe
@Override @Override
public boolean saveHygieneTemplate(HygieneTemplateDTO hygieneTemplateDTO) { public boolean saveHygieneTemplate(HygieneTemplateDTO hygieneTemplateDTO) {
String templateName = hygieneTemplateDTO.getTemplateName(); String templateName = hygieneTemplateDTO.getTemplateName();
QueryWrapper<HygieneTemplateEntity> queryWrapper = new QueryWrapper<>(); // 重名校验
queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, templateName); HygieneTemplateEntity hygieneTemplate = getHygieneTemplateByName(templateName);
List<HygieneTemplateEntity> list = this.list(queryWrapper); if (hygieneTemplate != null) {
if (CollectionUtil.isNotEmpty(list)) {
throw new ServiceException("模板名不可重复"); throw new ServiceException("模板名不可重复");
} }
HygieneTemplateEntity hygieneTemplate = new HygieneTemplateEntity(); // 新增模板
hygieneTemplate.setTemplateName(templateName); HygieneTemplateEntity hygieneTemplateEntity = new HygieneTemplateEntity();
boolean saveTemplate = this.save(hygieneTemplate); hygieneTemplateEntity.setTemplateName(templateName);
boolean saveTemplate = this.save(hygieneTemplateEntity);
if (!saveTemplate) { if (!saveTemplate) {
throw new ServiceException("卫生自查模板新增失败"); throw new ServiceException("卫生自查模板新增失败");
} }
// 传模板id // 新增模板详情
HygieneTemplateEntity hygieneTemplateEntity = getHygieneTemplateByName(templateName); hygieneTemplate = getHygieneTemplateByName(templateName);
List<HygieneTemplateDetailEntity> detailList = hygieneTemplateDTO.getTemplateDetailList(); List<HygieneTemplateDetailEntity> detailList = hygieneTemplateDTO.getTemplateDetailList();
detailList.forEach(detail -> { for (HygieneTemplateDetailEntity detail : detailList) {
detail.setTemplateId(hygieneTemplateEntity.getId()); detail.setTemplateId(hygieneTemplate.getId());
String[] scores = detail.getCheckItemScore().split(",|,"); String[] scores = detail.getCheckItemScore().split(",|,");
// 校验检查项总成绩是否为标准总成绩 // 校验检查项总成绩是否为标准总成绩
BaseUtil.getSumScore(scores, 100); BaseUtil.getSumScore(scores, 100);
}); }
return hygieneTemplateDetailService.saveBatch(hygieneTemplateDTO.getTemplateDetailList()); return hygieneTemplateDetailService.saveBatch(detailList);
} }
/** /**
@ -70,26 +69,33 @@ public class HygieneTemplateServiceImpl extends ServiceImpl<HygieneTemplateMappe
public boolean updateHygieneTemplate(HygieneTemplateDTO hygieneTemplateDTO) { public boolean updateHygieneTemplate(HygieneTemplateDTO hygieneTemplateDTO) {
String templateName = hygieneTemplateDTO.getTemplateName(); String templateName = hygieneTemplateDTO.getTemplateName();
Long templateId = hygieneTemplateDTO.getTemplateId(); Long templateId = hygieneTemplateDTO.getTemplateId();
// 重名校验
QueryWrapper<HygieneTemplateEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<HygieneTemplateEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, templateName); queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, templateName);
queryWrapper.lambda().ne(HygieneTemplateEntity::getId, templateId); queryWrapper.lambda().ne(HygieneTemplateEntity::getId, templateId);
List<HygieneTemplateEntity> list = this.list(queryWrapper); HygieneTemplateEntity hygieneTemplate = this.getOne(queryWrapper);
if (CollectionUtil.isNotEmpty(list)) { if (hygieneTemplate != null) {
throw new ServiceException("模板名不可重复"); throw new ServiceException("模板名不可重复");
} }
HygieneTemplateEntity hygieneTemplate = new HygieneTemplateEntity(); // 更新模板
hygieneTemplate.setId(templateId); HygieneTemplateEntity hygieneTemplateEntity = new HygieneTemplateEntity();
hygieneTemplate.setTemplateName(templateName); hygieneTemplateEntity.setId(templateId);
boolean updateTemplate = this.updateById(hygieneTemplate); hygieneTemplateEntity.setTemplateName(templateName);
boolean updateTemplate = this.updateById(hygieneTemplateEntity);
if (!updateTemplate) { if (!updateTemplate) {
throw new ServiceException("卫生自查模板更新失败"); throw new ServiceException("卫生自查模板更新失败");
} }
// 更新模板详情
// 删除旧的模板详情数据
boolean removeDetail = hygieneTemplateDetailService.removeReferenceDetail(templateId); boolean removeDetail = hygieneTemplateDetailService.removeReferenceDetail(templateId);
if (!removeDetail) { if (!removeDetail) {
throw new ServiceException("卫生自查模板详情数据删除失败"); throw new ServiceException("卫生自查模板详情数据删除失败");
} }
// 新增新的模板详情数据
hygieneTemplate = getHygieneTemplateByName(templateName);
List<HygieneTemplateDetailEntity> detailList = hygieneTemplateDTO.getTemplateDetailList(); List<HygieneTemplateDetailEntity> detailList = hygieneTemplateDTO.getTemplateDetailList();
for (HygieneTemplateDetailEntity detail : detailList) { for (HygieneTemplateDetailEntity detail : detailList) {
detail.setTemplateId(hygieneTemplate.getId());
String[] scores = detail.getCheckItemScore().split(",|,"); String[] scores = detail.getCheckItemScore().split(",|,");
BaseUtil.getSumScore(scores, 100); BaseUtil.getSumScore(scores, 100);
} }

6
hzims-service/safeproduct/src/main/resources/db/2.0.1.sql

@ -31,9 +31,9 @@ CREATE TABLE IF NOT EXISTS `hzims_hygiene_template_detail` (
`id` bigint(20) NOT NULL COMMENT '主键ID', `id` bigint(20) NOT NULL COMMENT '主键ID',
`template_id` bigint(20) NOT NULL COMMENT '模板id', `template_id` bigint(20) NOT NULL COMMENT '模板id',
`zone` varchar(50) NOT NULL COMMENT '责任区', `zone` varchar(50) NOT NULL COMMENT '责任区',
`PRINCIPAL` VARCHAR(20) NOT NULL COMMENT '责任人', `prinicipal` varchar(20) NOT NULL COMMENT '责任人',
`CHECK_ITEM` MEDIUMTEXT NOT NULL COMMENT '检查项', `check_item` mediumtext NOT NULL COMMENT '检查项',
`CHECK_ITEM_SCORE` VARCHAR(255) NOT NULL COMMENT '检查项分值', `check_item_score` varchar(255) NOT NULL COMMENT '检查项分值',
`create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人',
`create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门', `create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',

Loading…
Cancel
Save