Browse Source

update: 卫生自查模板

zhongwei
liwen 6 months ago
parent
commit
bee5de26b8
  1. 8
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateDetailEntity.java
  2. 4
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java
  3. 7
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateDetailService.java
  4. 7
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java
  5. 35
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java
  6. 13
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateDetailServiceImpl.java
  7. 33
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java
  8. 18
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java
  9. 4
      hzims-service/safeproduct/src/main/resources/db/2.0.1.sql

8
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateDetailEntity.java

@ -25,6 +25,14 @@ public class HygieneTemplateDetailEntity extends BaseEntity {
@ApiModelProperty("责任区") @ApiModelProperty("责任区")
private String zone; private String zone;
@Size(max = 20, message = "责任人字段长度不能超过20")
@ApiModelProperty("责任人")
private String principal;
@ApiModelProperty("检查项") @ApiModelProperty("检查项")
private String checkItem; private String checkItem;
@Size(max = 255, message = "检查项分值字段长度不能超过255")
@ApiModelProperty("检查项分值")
private String checkItemScore;
} }

4
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java

@ -218,7 +218,7 @@ public class HygieneController extends BladeController {
@ApiOperation(value = "卫生自查模板详情") @ApiOperation(value = "卫生自查模板详情")
@ApiOperationSupport(order = 18) @ApiOperationSupport(order = 18)
@Operate(label = "卫生自查模板详情", type = BusinessType.QUERY, ignore = false) @Operate(label = "卫生自查模板详情", type = BusinessType.QUERY, ignore = false)
public R hygieneTemplateDetail(@RequestParam Long id) { public R<HygieneTemplateDetailVO> hygieneTemplateDetail(@RequestParam Long id) {
HygieneTemplateDetailVO detail = hygieneTemplateService.getHygieneTemplateDetail(id); HygieneTemplateDetailVO detail = hygieneTemplateService.getHygieneTemplateDetail(id);
return R.data(detail); return R.data(detail);
} }
@ -227,7 +227,7 @@ public class HygieneController extends BladeController {
@ApiOperation(value = "卫生自查模板分页") @ApiOperation(value = "卫生自查模板分页")
@ApiOperationSupport(order = 19) @ApiOperationSupport(order = 19)
@Operate(label = "卫生自查模板分页", type = BusinessType.QUERY, ignore = false) @Operate(label = "卫生自查模板分页", type = BusinessType.QUERY, ignore = false)
public R hygieneTemplatePage(@ApiIgnore @RequestParam Map<String, Object> param, Query query) { public R<IPage<HygieneTemplateEntity>> hygieneTemplatePage(@ApiIgnore @RequestParam Map<String, Object> param, Query query) {
IPage<HygieneTemplateEntity> page = hygieneTemplateService.page(Condition.getPage(query), Condition.getQueryWrapper( IPage<HygieneTemplateEntity> page = hygieneTemplateService.page(Condition.getPage(query), Condition.getQueryWrapper(
param, HygieneTemplateEntity.class)); param, HygieneTemplateEntity.class));
return R.data(page); return R.data(page);

7
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateDetailService.java

@ -18,4 +18,11 @@ public interface IHygieneTemplateDetailService extends IService<HygieneTemplateD
* @return 模板详情列表 * @return 模板详情列表
*/ */
List<HygieneTemplateDetailEntity> getListByTemplateId(Long templateId); List<HygieneTemplateDetailEntity> getListByTemplateId(Long templateId);
/**
* 删除关联模板详情数据
* @param templateId 模板id
* @return true-成功false-失败
*/
boolean removeReferenceDetail(Long templateId);
} }

7
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java

@ -39,4 +39,11 @@ public interface IHygieneTemplateService extends IService<HygieneTemplateEntity>
* @return 详情 * @return 详情
*/ */
HygieneTemplateDetailVO getHygieneTemplateDetail(Long id); HygieneTemplateDetailVO getHygieneTemplateDetail(Long id);
/**
* 根据模板名获取模板
* @param name 模板名
* @return 模板实体类
*/
HygieneTemplateEntity getHygieneTemplateByName(String name);
} }

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

@ -18,6 +18,7 @@ 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;
@ -126,7 +127,7 @@ public class HygienePlanServiceImpl extends ServiceImpl<HygienePlanMapper, Hygie
} }
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));
@ -155,13 +156,23 @@ public class HygienePlanServiceImpl extends ServiceImpl<HygienePlanMapper, Hygie
List<HygieneZoneEntity> zoneList = hygienePlanDTO.getZoneList(); List<HygieneZoneEntity> zoneList = hygienePlanDTO.getZoneList();
// 若计划修改成功,修改关联责任区数据 // 若计划修改成功,修改关联责任区数据
if (updatePlan) { if (updatePlan) {
// 删除旧数据
boolean removeZone = hygieneZoneService.removeReferenceZone(hygienePlanDTO.getId());
if (removeZone) {
hygienePlan = getPlanByName(hygienePlanDTO.getName());
// 增加新数据
for (HygieneZoneEntity zone : zoneList) { for (HygieneZoneEntity zone : zoneList) {
// 传计划id
if (hygienePlan != null) {
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)); return R.status(hygieneZoneService.saveBatch(zoneList));
}
} }
return R.status(Boolean.FALSE); return R.status(Boolean.FALSE);
} }
@ -210,24 +221,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

13
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateDetailServiceImpl.java

@ -8,6 +8,7 @@ import com.hnac.hzims.safeproduct.service.IHygieneTemplateDetailService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 卫生自查模板详情服务实现类 * 卫生自查模板详情服务实现类
@ -27,4 +28,16 @@ public class HygieneTemplateDetailServiceImpl extends ServiceImpl<HygieneTemplat
queryWrapper.lambda().eq(HygieneTemplateDetailEntity::getTemplateId, templateId); queryWrapper.lambda().eq(HygieneTemplateDetailEntity::getTemplateId, templateId);
return this.list(queryWrapper); return this.list(queryWrapper);
} }
/**
* 删除关联模板详情数据
*/
@Override
public boolean removeReferenceDetail(Long templateId) {
QueryWrapper<HygieneTemplateDetailEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(HygieneTemplateDetailEntity::getTemplateId, templateId);
List<HygieneTemplateDetailEntity> list = this.list(queryWrapper);
List<Long> ids = list.stream().map(HygieneTemplateDetailEntity::getId).collect(Collectors.toList());
return this.removeByIds(ids);
}
} }

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

@ -8,6 +8,7 @@ import com.hnac.hzims.safeproduct.entity.HygieneTemplateEntity;
import com.hnac.hzims.safeproduct.mapper.HygieneTemplateMapper; import com.hnac.hzims.safeproduct.mapper.HygieneTemplateMapper;
import com.hnac.hzims.safeproduct.service.IHygieneTemplateDetailService; import com.hnac.hzims.safeproduct.service.IHygieneTemplateDetailService;
import com.hnac.hzims.safeproduct.service.IHygieneTemplateService; import com.hnac.hzims.safeproduct.service.IHygieneTemplateService;
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.springblade.core.tool.utils.CollectionUtil;
@ -49,6 +50,15 @@ public class HygieneTemplateServiceImpl extends ServiceImpl<HygieneTemplateMappe
if (!saveTemplate) { if (!saveTemplate) {
throw new ServiceException("卫生自查模板新增失败"); throw new ServiceException("卫生自查模板新增失败");
} }
// 传模板id
HygieneTemplateEntity hygieneTemplateEntity = getHygieneTemplateByName(templateName);
List<HygieneTemplateDetailEntity> detailList = hygieneTemplateDTO.getTemplateDetailList();
detailList.forEach(detail -> {
detail.setTemplateId(hygieneTemplateEntity.getId());
String[] scores = detail.getCheckItemScore().split(",|,");
// 校验检查项总成绩是否为标准总成绩
BaseUtil.getSumScore(scores, 100);
});
return hygieneTemplateDetailService.saveBatch(hygieneTemplateDTO.getTemplateDetailList()); return hygieneTemplateDetailService.saveBatch(hygieneTemplateDTO.getTemplateDetailList());
} }
@ -72,9 +82,18 @@ public class HygieneTemplateServiceImpl extends ServiceImpl<HygieneTemplateMappe
hygieneTemplate.setTemplateName(templateName); hygieneTemplate.setTemplateName(templateName);
boolean updateTemplate = this.updateById(hygieneTemplate); boolean updateTemplate = this.updateById(hygieneTemplate);
if (!updateTemplate) { if (!updateTemplate) {
throw new ServiceException("卫生自查模板修改失败"); throw new ServiceException("卫生自查模板更新失败");
} }
return hygieneTemplateDetailService.updateBatchById(hygieneTemplateDTO.getTemplateDetailList()); boolean removeDetail = hygieneTemplateDetailService.removeReferenceDetail(templateId);
if (!removeDetail) {
throw new ServiceException("卫生自查模板详情数据删除失败");
}
List<HygieneTemplateDetailEntity> detailList = hygieneTemplateDTO.getTemplateDetailList();
for (HygieneTemplateDetailEntity detail : detailList) {
String[] scores = detail.getCheckItemScore().split(",|,");
BaseUtil.getSumScore(scores, 100);
}
return hygieneTemplateDetailService.saveBatch(detailList);
} }
/** /**
@ -104,4 +123,14 @@ public class HygieneTemplateServiceImpl extends ServiceImpl<HygieneTemplateMappe
hygieneTemplateDetailVO.setTemplateDetailList(details); hygieneTemplateDetailVO.setTemplateDetailList(details);
return hygieneTemplateDetailVO; return hygieneTemplateDetailVO;
} }
/**
* 根据模板名获取模板
*/
@Override
public HygieneTemplateEntity getHygieneTemplateByName(String name) {
QueryWrapper<HygieneTemplateEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, name);
return this.getOne(queryWrapper);
}
} }

18
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java

@ -395,4 +395,22 @@ public class BaseUtil {
} }
return fileName; return fileName;
} }
/**
* 计算累计分值
* @param scores 各项分值
* @param standardScore 标准总分值
*/
public static 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("标准总分值未全部分配");
}
}
} }

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

@ -31,7 +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 '责任区',
`check_item` mediumtext NOT NULL COMMENT '检查项', `PRINCIPAL` 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_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