Browse Source

update: 卫生自查模块

zhongwei
liwen 6 months ago
parent
commit
9d5461c38f
  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.mapper.UserDataScopeBaseMapper;
/**
* 卫生自查计划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) {
// 删除计划数据
boolean remove = this.removeById(id);
if (remove) {
// 删除记录数据
boolean removeRecord = hygieneRecordService.removeReferenceRecord(id);
if (removeRecord) {
// 删除责任区数据
return hygieneZoneService.removeReferenceZone(id);
}
if (!remove) {
throw new ServiceException("删除卫生自查计划失败");
}
// 删除记录数据
boolean removeRecord = hygieneRecordService.removeReferenceRecord(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);
hygienePlanDTO.setStandardScore(100);
boolean savePlan = this.save(hygienePlanEntity);
if (!savePlan) {
throw new ServiceException("卫生自查计划新增失败");
}
// 新增关联责任区数据
List<HygieneZoneEntity> zoneList = hygienePlanDTO.getZoneList();
// 若计划新增成功,新增关联责任区数据
if (savePlan) {
hygienePlan = getPlanByName(hygienePlanDTO.getName());
for (HygieneZoneEntity zone : zoneList) {
// 传计划id
if (hygienePlan != null) {
zone.setHygienePlanId(hygienePlan.getId());
}
String[] scores = zone.getCheckItemScore().split(",|,");
// 校验检查项总成绩是否为标准总成绩
BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore());
}
// 校验通过则批量新增责任区数据
return R.status(hygieneZoneService.saveBatch(zoneList));
hygienePlan = getPlanByName(hygienePlanDTO.getName());
for (HygieneZoneEntity zone : zoneList) {
zone.setHygienePlanId(hygienePlan.getId());
String[] scores = zone.getCheckItemScore().split(",|,");
// 校验检查项总成绩是否为标准总成绩
BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore());
}
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();
BeanUtils.copyProperties(hygienePlanDTO, hygienePlanEntity);
boolean updatePlan = this.updateById(hygienePlanEntity);
if (!updatePlan) {
throw new ServiceException("卫生自查计划修改失败");
}
// 修改关联责任区数据
List<HygieneZoneEntity> zoneList = hygienePlanDTO.getZoneList();
// 若计划修改成功,修改关联责任区数据
if (updatePlan) {
// 删除旧数据
boolean removeZone = hygieneZoneService.removeReferenceZone(hygienePlanDTO.getId());
if (removeZone) {
hygienePlan = getPlanByName(hygienePlanDTO.getName());
// 增加新数据
for (HygieneZoneEntity zone : zoneList) {
// 传计划id
if (hygienePlan != null) {
zone.setHygienePlanId(hygienePlan.getId());
}
String[] scores = zone.getCheckItemScore().split(",|,");
// 校验检查项总成绩是否为标准总成绩
BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore());
}
// 校验通过则批量修改责任区数据
return R.status(hygieneZoneService.saveBatch(zoneList));
}
// 删除旧的责任区数据
boolean removeZone = hygieneZoneService.removeReferenceZone(hygienePlanDTO.getId());
if (!removeZone) {
throw new ServiceException("删除旧的责任区数据失败");
}
// 新增新的责任区数据
hygienePlan = getPlanByName(hygienePlanDTO.getName());
for (HygieneZoneEntity zone : zoneList) {
zone.setHygienePlanId(hygienePlan.getId());
String[] scores = zone.getCheckItemScore().split(",|,");
// 校验检查项总成绩是否为标准总成绩
BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore());
}
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 currentSimpleMonth = DatePattern.SIMPLE_MONTH_FORMAT.format(new Date());
// 查询是否存在同月编号
// 查询同月的最新编号
String lastCode = getLastCode(currentNormMonth);
// 若不存在,新增编号
// 生成编号
String code = BaseUtil.getUniqueCode("WSZC", lastCode, currentSimpleMonth);
hygieneRecordEntity.setCode(code);
// 周数计算
@ -102,12 +102,12 @@ public class HygieneRecordServiceImpl extends ServiceImpl<HygieneRecordMapper, H
}
}
boolean save = this.save(hygieneRecordEntity);
// 若自查记录新增成功,修改自查计划状态为已完成
if (save) {
hygienePlanEntity.setHygienePlanStatus(RehearsalStatusEnum.FINISHED.getValue());
return R.status(hygienePlanMapper.updateById(hygienePlanEntity) == SafeProductConstant.SUCCESS);
if (!save) {
throw new ServiceException("卫生自查记录新增失败");
}
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.vo.HygieneTemplateDetailVO;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -38,28 +37,28 @@ public class HygieneTemplateServiceImpl extends ServiceImpl<HygieneTemplateMappe
@Override
public boolean saveHygieneTemplate(HygieneTemplateDTO hygieneTemplateDTO) {
String templateName = hygieneTemplateDTO.getTemplateName();
QueryWrapper<HygieneTemplateEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, templateName);
List<HygieneTemplateEntity> list = this.list(queryWrapper);
if (CollectionUtil.isNotEmpty(list)) {
// 重名校验
HygieneTemplateEntity hygieneTemplate = getHygieneTemplateByName(templateName);
if (hygieneTemplate != null) {
throw new ServiceException("模板名不可重复");
}
HygieneTemplateEntity hygieneTemplate = new HygieneTemplateEntity();
hygieneTemplate.setTemplateName(templateName);
boolean saveTemplate = this.save(hygieneTemplate);
// 新增模板
HygieneTemplateEntity hygieneTemplateEntity = new HygieneTemplateEntity();
hygieneTemplateEntity.setTemplateName(templateName);
boolean saveTemplate = this.save(hygieneTemplateEntity);
if (!saveTemplate) {
throw new ServiceException("卫生自查模板新增失败");
}
// 传模板id
HygieneTemplateEntity hygieneTemplateEntity = getHygieneTemplateByName(templateName);
// 新增模板详情
hygieneTemplate = getHygieneTemplateByName(templateName);
List<HygieneTemplateDetailEntity> detailList = hygieneTemplateDTO.getTemplateDetailList();
detailList.forEach(detail -> {
detail.setTemplateId(hygieneTemplateEntity.getId());
for (HygieneTemplateDetailEntity detail : detailList) {
detail.setTemplateId(hygieneTemplate.getId());
String[] scores = detail.getCheckItemScore().split(",|,");
// 校验检查项总成绩是否为标准总成绩
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) {
String templateName = hygieneTemplateDTO.getTemplateName();
Long templateId = hygieneTemplateDTO.getTemplateId();
// 重名校验
QueryWrapper<HygieneTemplateEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, templateName);
queryWrapper.lambda().ne(HygieneTemplateEntity::getId, templateId);
List<HygieneTemplateEntity> list = this.list(queryWrapper);
if (CollectionUtil.isNotEmpty(list)) {
HygieneTemplateEntity hygieneTemplate = this.getOne(queryWrapper);
if (hygieneTemplate != null) {
throw new ServiceException("模板名不可重复");
}
HygieneTemplateEntity hygieneTemplate = new HygieneTemplateEntity();
hygieneTemplate.setId(templateId);
hygieneTemplate.setTemplateName(templateName);
boolean updateTemplate = this.updateById(hygieneTemplate);
// 更新模板
HygieneTemplateEntity hygieneTemplateEntity = new HygieneTemplateEntity();
hygieneTemplateEntity.setId(templateId);
hygieneTemplateEntity.setTemplateName(templateName);
boolean updateTemplate = this.updateById(hygieneTemplateEntity);
if (!updateTemplate) {
throw new ServiceException("卫生自查模板更新失败");
}
// 更新模板详情
// 删除旧的模板详情数据
boolean removeDetail = hygieneTemplateDetailService.removeReferenceDetail(templateId);
if (!removeDetail) {
throw new ServiceException("卫生自查模板详情数据删除失败");
}
// 新增新的模板详情数据
hygieneTemplate = getHygieneTemplateByName(templateName);
List<HygieneTemplateDetailEntity> detailList = hygieneTemplateDTO.getTemplateDetailList();
for (HygieneTemplateDetailEntity detail : detailList) {
detail.setTemplateId(hygieneTemplate.getId());
String[] scores = detail.getCheckItemScore().split(",|,");
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',
`template_id` bigint(20) NOT NULL COMMENT '模板id',
`zone` varchar(50) NOT NULL COMMENT '责任区',
`PRINCIPAL` VARCHAR(20) NOT NULL COMMENT '责任人',
`CHECK_ITEM` MEDIUMTEXT NOT NULL COMMENT '检查项',
`CHECK_ITEM_SCORE` VARCHAR(255) NOT NULL COMMENT '检查项分值',
`prinicipal` varchar(20) NOT NULL COMMENT '责任人',
`check_item` mediumtext NOT NULL COMMENT '检查项',
`check_item_score` varchar(255) NOT NULL COMMENT '检查项分值',
`create_user` 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 '创建时间',

Loading…
Cancel
Save