Browse Source

Merge remote-tracking branch 'origin/prod-20240506' into prod-20240506

zhongwei
ty 6 months ago
parent
commit
aee95af2b6
  1. 8
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateDetailEntity.java
  2. 4
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateEntity.java
  3. 10
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java
  4. 53
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java
  5. 8
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java
  6. 1
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.java
  7. 10
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.java
  8. 13
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.xml
  9. 8
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java
  10. 7
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateDetailService.java
  11. 19
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java
  12. 114
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java
  13. 24
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java
  14. 13
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateDetailServiceImpl.java
  15. 100
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java
  16. 4
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java
  17. 18
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java
  18. 2
      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("责任区")
private String zone;
@Size(max = 20, message = "责任人字段长度不能超过20")
@ApiModelProperty("责任人")
private String principal;
@ApiModelProperty("检查项")
private String checkItem;
@Size(max = 255, message = "检查项分值字段长度不能超过255")
@ApiModelProperty("检查项分值")
private String checkItemScore;
}

4
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateEntity.java

@ -1,5 +1,6 @@
package com.hnac.hzims.safeproduct.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -18,4 +19,7 @@ public class HygieneTemplateEntity extends BaseEntity {
@ApiModelProperty("模板名称")
private String templateName;
@TableField(exist = false)
private String createDeptName;
}

10
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java

@ -60,11 +60,11 @@ public class TestEntity extends BaseEntity {
@ApiModelProperty("考试结束时间")
private Date testEndTime;
// @NotNull
// @Min(value = 0, message = "及格分必须大于等于0")
// @Max(value = 100, message = "及格分必须小于等于100")
// @ApiModelProperty("及格分")
// private Integer passingScore;
@NotNull
@Min(value = 0, message = "及格分必须大于等于0")
@Max(value = 100, message = "及格分必须小于等于100")
@ApiModelProperty("及格分")
private Integer passingScore;
@NotNull
@Size(max = 255, message = "考试地点字段长度不能超过255")

53
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java

@ -110,19 +110,30 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont
}
RunDataShowVo data = new RunDataShowVo();
BeanUtil.copyProperties(entity,data);
List<RunDataVo> run = JSONObject.parseObject(entity.getRunData(),new TypeReference<List<RunDataVo>>(){});
if(CollectionUtil.isEmpty(run)){
List<RunDataVo> runs = JSONObject.parseObject(entity.getRunData(),new TypeReference<List<RunDataVo>>(){});
if(CollectionUtil.isEmpty(runs)){
return data;
}
double monSumGenerate = run.stream().mapToDouble(RunDataVo::getGenerate).sum();
double monSumPlan = run.stream().mapToDouble(RunDataVo::getPlan).sum();
// 保留两位小数
data.setRunData(JSONObject.toJSONString(runs.stream().map(run->{
// 月发电量
run.setGenerate(BigDecimal.valueOf(run.getGenerate()).setScale(2, RoundingMode.HALF_UP).doubleValue());
// 年发电量
run.setGenerateYear(BigDecimal.valueOf(run.getGenerateYear()).setScale(2, RoundingMode.HALF_UP).doubleValue());
return run;
}).collect(Collectors.toList())));
// 月发电量完成率
double monSumGenerate = runs.stream().mapToDouble(RunDataVo::getGenerate).sum();
double monSumPlan = runs.stream().mapToDouble(RunDataVo::getPlan).sum();
data.setMonSumGenerate(monSumGenerate);
data.setMonSumPlan(monSumPlan);
if(Math.abs(monSumGenerate) > 0 && Math.abs(monSumPlan) > 0){
data.setMonRate(BigDecimal.valueOf(monSumGenerate / monSumPlan * 100L).setScale(2, RoundingMode.HALF_UP).doubleValue());
}
double yearSumGenerate = run.stream().mapToDouble(RunDataVo::getGenerateYear).sum();
double yearSumPlan = run.stream().mapToDouble(RunDataVo::getPlanYear).sum();
// 年发电量完成率
double yearSumGenerate = runs.stream().mapToDouble(RunDataVo::getGenerateYear).sum();
double yearSumPlan = runs.stream().mapToDouble(RunDataVo::getPlanYear).sum();
data.setYearSumGenerate(yearSumGenerate);
data.setYearSumPlan(yearSumPlan);
if(Math.abs(yearSumGenerate) > 0 && Math.abs(yearSumPlan) > 0){
@ -131,7 +142,6 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont
return data;
}
/**
* 导出站点月报文件
* @param mon
@ -149,6 +159,17 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont
if(ObjectUtil.isEmpty(data)){
throw new ServiceException("站点" + mon + "月份未生成运行月报数据!");
}
List<RunDataVo> runs = JSONObject.parseObject(data.getRunData(),new TypeReference<List<RunDataVo>>(){});
if(CollectionUtil.isNotEmpty(runs)){
// 保留两位小数
data.setRunData(JSONObject.toJSONString(runs.stream().map(run->{
// 月发电量
run.setGenerate(BigDecimal.valueOf(run.getGenerate()).setScale(2, RoundingMode.HALF_UP).doubleValue());
// 年发电量
run.setGenerateYear(BigDecimal.valueOf(run.getGenerateYear()).setScale(2, RoundingMode.HALF_UP).doubleValue());
return run;
}).collect(Collectors.toList())));
}
// 创建Excel文件
// 表头、sheet页、文件名
String headerName = data.getStationName() + "运行月报(" + mon + ")";
@ -211,7 +232,15 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont
String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME);
// 告警数据
run.setAlarmData(this.alarmData(station.getCode(),start,end));
CountDownLatch countDownLatch = new CountDownLatch(devices.size());
List<RunDataVo> runDatas = new ArrayList<>();
List<CurveEchartVo> curveEcharts = new ArrayList<>();
for (RideDeviceVo device : devices){
// 运行数据
runDatas.add(this.runData(station.getCode(),device,plans,start,end));
// 月度运行曲线
curveEcharts.add(this.curveData(device,start,end));
}
/*CountDownLatch countDownLatch = new CountDownLatch(devices.size());
List<RunDataVo> runDatas = new CopyOnWriteArrayList<>();
List<CurveEchartVo> curveEcharts = new CopyOnWriteArrayList<>();
for (RideDeviceVo device : devices){
@ -220,8 +249,8 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont
runDatas.add(this.runData(station.getCode(),device,plans,start,end));
// 月度运行曲线
curveEcharts.add(this.curveData(device,start,end));
countDownLatch.countDown();
});
countDownLatch.countDown();
}
//所有模板数据获取完成后释放锁
try {
@ -229,11 +258,11 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}
if(CollectionUtil.isEmpty(runDatas)){
}*/
if(!CollectionUtil.isEmpty(runDatas)){
run.setRunData(JSONObject.toJSONString(runDatas));
}
if(CollectionUtil.isEmpty(curveEcharts)){
if(!CollectionUtil.isEmpty(curveEcharts)){
run.setCurveData(JSONObject.toJSONString(curveEcharts));
}
// TODO 运行数据分析

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

@ -2,7 +2,6 @@ package com.hnac.hzims.safeproduct.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.common.utils.Condition;
import com.hnac.hzims.safeproduct.Constants;
import com.hnac.hzims.safeproduct.dto.HygienePlanDTO;
import com.hnac.hzims.safeproduct.dto.HygieneRecordDTO;
@ -218,7 +217,7 @@ public class HygieneController extends BladeController {
@ApiOperation(value = "卫生自查模板详情")
@ApiOperationSupport(order = 18)
@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);
return R.data(detail);
}
@ -227,9 +226,8 @@ public class HygieneController extends BladeController {
@ApiOperation(value = "卫生自查模板分页")
@ApiOperationSupport(order = 19)
@Operate(label = "卫生自查模板分页", type = BusinessType.QUERY, ignore = false)
public R hygieneTemplatePage(@ApiIgnore @RequestParam Map<String, Object> param, Query query) {
IPage<HygieneTemplateEntity> page = hygieneTemplateService.page(Condition.getPage(query), Condition.getQueryWrapper(
param, HygieneTemplateEntity.class));
public R<IPage<HygieneTemplateEntity>> hygieneTemplatePage(@ApiIgnore @RequestParam Map<String, Object> param, Query query) {
IPage<HygieneTemplateEntity> page = hygieneTemplateService.getHygieneTemplatePage(param, query);
return R.data(page);
}
}

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类
*

10
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.java

@ -1,9 +1,12 @@
package com.hnac.hzims.safeproduct.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.safeproduct.entity.HygieneTemplateEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.Map;
/**
* 卫生自查模板Mapper类
*
@ -12,4 +15,11 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface HygieneTemplateMapper extends BaseMapper<HygieneTemplateEntity> {
/**
* 卫生自查页面
* @param param 参数
* @param page 分页类
* @return 页面
*/
IPage<HygieneTemplateEntity> getHygieneTemplatePage(IPage<HygieneTemplateEntity> page, Map<String, Object> param);
}

13
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.xml

@ -1,4 +1,17 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.safeproduct.mapper.HygieneTemplateMapper">
<select id="getHygieneTemplatePage" resultType="com.hnac.hzims.safeproduct.entity.HygieneTemplateEntity">
SELECT
*
FROM
hzims_hygiene_template
WHERE
is_deleted = 0
<if test="param.templateName != null and param.templateName != ''">
AND template_name like concate('%', #{param.templateName}, '%')
</if>
ORDER BY
create_time DESC
</select>
</mapper>

8
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java

@ -10,6 +10,7 @@ import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
@ -62,4 +63,11 @@ public interface IHygieneRecordService extends IService<HygieneRecordEntity> {
* @param response 响应类
*/
void exportHygieneRecordData(Long id, HttpServletResponse response);
/**
* 查询关联卫生自查记录
* @param planId 计划id
* @return 记录列表
*/
List<HygieneRecordEntity> getReferenceRecord(Long planId);
}

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 模板详情列表
*/
List<HygieneTemplateDetailEntity> getListByTemplateId(Long templateId);
/**
* 删除关联模板详情数据
* @param templateId 模板id
* @return true-成功false-失败
*/
boolean removeReferenceDetail(Long templateId);
}

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

@ -1,9 +1,13 @@
package com.hnac.hzims.safeproduct.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.safeproduct.dto.HygieneTemplateDTO;
import com.hnac.hzims.safeproduct.entity.HygieneTemplateEntity;
import com.hnac.hzims.safeproduct.vo.HygieneTemplateDetailVO;
import org.springblade.core.mp.support.Query;
import java.util.Map;
/**
* 卫生自查模板服务类
@ -39,4 +43,19 @@ public interface IHygieneTemplateService extends IService<HygieneTemplateEntity>
* @return 详情
*/
HygieneTemplateDetailVO getHygieneTemplateDetail(Long id);
/**
* 根据模板名获取模板
* @param name 模板名
* @return 模板实体类
*/
HygieneTemplateEntity getHygieneTemplateByName(String name);
/**
* 卫生自查页面
* @param param 参数
* @param query 分页类
* @return 页面
*/
IPage<HygieneTemplateEntity> getHygieneTemplatePage(Map<String, Object> param, Query query);
}

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

@ -7,17 +7,20 @@ import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.service.impl.ServiceImpl;
import com.hnac.hzims.common.utils.Condition;
import com.hnac.hzims.safeproduct.dto.HygienePlanDTO;
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.enums.HygieneStatusEnum;
import com.hnac.hzims.safeproduct.mapper.HygienePlanMapper;
import com.hnac.hzims.safeproduct.service.IHygienePlanService;
import com.hnac.hzims.safeproduct.service.IHygieneRecordService;
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.HygieneMonthVO;
import org.springblade.core.log.exception.ServiceException;
@ -38,6 +41,7 @@ import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* 卫生自查计划服务实现类
@ -62,15 +66,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);
}
/**
@ -115,23 +120,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(",|,");
// 校验检查项总成绩是否为标准总成绩
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));
}
/**
@ -140,9 +142,10 @@ public class HygienePlanServiceImpl extends ServiceImpl<HygienePlanMapper, Hygie
@Transactional(rollbackFor = Exception.class)
@Override
public R updatePlan(HygienePlanDTO hygienePlanDTO) {
Long planId = hygienePlanDTO.getId();
// 重名校验
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());
HygienePlanEntity hygienePlan = this.getOne(queryWrapper);
if (hygienePlan != null) {
@ -152,18 +155,45 @@ 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) {
for (HygieneZoneEntity zone : zoneList) {
String[] scores = zone.getCheckItemScore().split(",|,");
// 校验检查项总成绩是否为标准总成绩
getSumScore(scores, hygienePlanDTO.getStandardScore());
// 删除旧的责任区数据
boolean removeZone = hygieneZoneService.removeReferenceZone(planId);
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());
}
// 校验通过则批量修改责任区数据
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(hygieneZoneService.updateBatchById(zoneList));
recordList.forEach(record -> record.setHygieneZoneIds(zoneIds.toString()));
return R.status(hygieneRecordService.updateBatchById(recordList));
}
return R.status(Boolean.FALSE);
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

24
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);
}
/**
@ -200,6 +200,16 @@ public class HygieneRecordServiceImpl extends ServiceImpl<HygieneRecordMapper, H
}
/**
* 查询关联卫生自查记录
*/
@Override
public List<HygieneRecordEntity> getReferenceRecord(Long planId) {
QueryWrapper<HygieneRecordEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(HygieneRecordEntity::getHygienePlanId, planId);
return this.list(queryWrapper);
}
/**
* 查询是否存在同月编号
* @param currentMonth 当月
* @return 存在则返回上一编号否则返回null

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 java.util.List;
import java.util.stream.Collectors;
/**
* 卫生自查模板详情服务实现类
@ -27,4 +28,16 @@ public class HygieneTemplateDetailServiceImpl extends ServiceImpl<HygieneTemplat
queryWrapper.lambda().eq(HygieneTemplateDetailEntity::getTemplateId, templateId);
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);
}
}

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

@ -1,6 +1,8 @@
package com.hnac.hzims.safeproduct.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.safeproduct.dto.HygieneTemplateDTO;
import com.hnac.hzims.safeproduct.entity.HygieneTemplateDetailEntity;
@ -8,15 +10,20 @@ import com.hnac.hzims.safeproduct.entity.HygieneTemplateEntity;
import com.hnac.hzims.safeproduct.mapper.HygieneTemplateMapper;
import com.hnac.hzims.safeproduct.service.IHygieneTemplateDetailService;
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.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.system.feign.ISysClient;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
@ -30,6 +37,12 @@ public class HygieneTemplateServiceImpl extends ServiceImpl<HygieneTemplateMappe
@Autowired
IHygieneTemplateDetailService hygieneTemplateDetailService;
@Resource
HygieneTemplateMapper hygieneTemplateMapper;
@Autowired
ISysClient sysClient;
/**
* 新增卫生自查模板
*/
@ -37,19 +50,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("卫生自查模板新增失败");
}
return hygieneTemplateDetailService.saveBatch(hygieneTemplateDTO.getTemplateDetailList());
// 新增模板详情
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);
}
return hygieneTemplateDetailService.saveBatch(detailList);
}
/**
@ -60,21 +82,37 @@ 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("卫生自查模板修改失败");
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);
}
return hygieneTemplateDetailService.updateBatchById(hygieneTemplateDTO.getTemplateDetailList());
return hygieneTemplateDetailService.saveBatch(detailList);
}
/**
@ -104,4 +142,32 @@ public class HygieneTemplateServiceImpl extends ServiceImpl<HygieneTemplateMappe
hygieneTemplateDetailVO.setTemplateDetailList(details);
return hygieneTemplateDetailVO;
}
/**
* 根据模板名获取模板
*/
@Override
public HygieneTemplateEntity getHygieneTemplateByName(String name) {
QueryWrapper<HygieneTemplateEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, name);
return this.getOne(queryWrapper);
}
/**
* 卫生自查页面
*/
@Override
public IPage<HygieneTemplateEntity> getHygieneTemplatePage(Map<String, Object> param, Query query) {
IPage<HygieneTemplateEntity> page = new Page<>(query.getCurrent(), query.getSize());
IPage<HygieneTemplateEntity> templatePage = hygieneTemplateMapper.getHygieneTemplatePage(page, param);
List<HygieneTemplateEntity> templateList = templatePage.getRecords();
templateList.forEach(template -> {
R<String> deptName = sysClient.getDeptName(template.getCreateDept());
if (deptName.isSuccess()) {
template.setCreateDeptName(deptName.getData());
}
});
templatePage.setRecords(templateList);
return templatePage;
}
}

4
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java

@ -126,7 +126,7 @@ public class TestScoreServiceImpl extends ServiceImpl<TestScoreMapper, TestScore
public TestScoreSumVO testScoreSum(Long testId, String name) {
TestScoreSumVO testScoreSumVO = new TestScoreSumVO();
TestEntity testEntity = testMapper.selectById(testId);
// testScoreSumVO.setPassingScore(testEntity.getPassingScore());
testScoreSumVO.setPassingScore(testEntity.getPassingScore());
String peopleName = testEntity.getPeopleName();
if (StringUtils.isNotBlank(peopleName)) {
String[] split = peopleName.split(",");
@ -138,7 +138,7 @@ public class TestScoreServiceImpl extends ServiceImpl<TestScoreMapper, TestScore
list= list.stream().filter(s -> s.getScore() != null).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(list)) {
testScoreSumVO.setActualPeopleNum(list.size());
List<TestScoreEntity> passCollect = list.stream().filter(s -> s.getScore() > 60).collect(Collectors.toList());
List<TestScoreEntity> passCollect = list.stream().filter(s -> s.getScore() > testEntity.getPassingScore()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(list)&&CollectionUtils.isNotEmpty(passCollect)) {
double result = BigDecimal.valueOf(passCollect.size()).divide(BigDecimal.valueOf(list.size()),2, RoundingMode.UP).doubleValue();
testScoreSumVO.setPercentage(result);

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

@ -395,4 +395,22 @@ public class BaseUtil {
}
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("标准总分值未全部分配");
}
}
}

2
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',
`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 '检查项分值',
`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