Browse Source

update: 卫生自查更新

zhongwei
liwen 6 months ago
parent
commit
b601dd36e1
  1. 4
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneTemplateEntity.java
  2. 4
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java
  3. 10
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.java
  4. 13
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneTemplateMapper.xml
  5. 8
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java
  6. 12
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneTemplateService.java
  7. 29
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java
  8. 10
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java
  9. 31
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneTemplateServiceImpl.java

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

4
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.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; 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.Constants;
import com.hnac.hzims.safeproduct.dto.HygienePlanDTO; import com.hnac.hzims.safeproduct.dto.HygienePlanDTO;
import com.hnac.hzims.safeproduct.dto.HygieneRecordDTO; import com.hnac.hzims.safeproduct.dto.HygieneRecordDTO;
@ -228,8 +227,7 @@ public class HygieneController extends BladeController {
@ApiOperationSupport(order = 19) @ApiOperationSupport(order = 19)
@Operate(label = "卫生自查模板分页", type = BusinessType.QUERY, ignore = false) @Operate(label = "卫生自查模板分页", type = BusinessType.QUERY, ignore = false)
public R<IPage<HygieneTemplateEntity>> 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.getHygieneTemplatePage(param, query);
param, HygieneTemplateEntity.class));
return R.data(page); return R.data(page);
} }
} }

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

@ -1,9 +1,12 @@
package com.hnac.hzims.safeproduct.mapper; package com.hnac.hzims.safeproduct.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hnac.hzims.safeproduct.entity.HygieneTemplateEntity; import com.hnac.hzims.safeproduct.entity.HygieneTemplateEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.Map;
/** /**
* 卫生自查模板Mapper类 * 卫生自查模板Mapper类
* *
@ -12,4 +15,11 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface HygieneTemplateMapper extends BaseMapper<HygieneTemplateEntity> { 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"> <!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"> <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> </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 org.springblade.core.tool.api.R;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -62,4 +63,11 @@ public interface IHygieneRecordService extends IService<HygieneRecordEntity> {
* @param response 响应类 * @param response 响应类
*/ */
void exportHygieneRecordData(Long id, HttpServletResponse response); void exportHygieneRecordData(Long id, HttpServletResponse response);
/**
* 查询关联卫生自查记录
* @param planId 计划id
* @return 记录列表
*/
List<HygieneRecordEntity> getReferenceRecord(Long planId);
} }

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

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

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

@ -7,11 +7,13 @@ 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;
@ -39,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;
/** /**
* 卫生自查计划服务实现类 * 卫生自查计划服务实现类
@ -139,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) {
@ -157,7 +161,7 @@ public class HygienePlanServiceImpl extends ServiceImpl<HygienePlanMapper, Hygie
// 修改关联责任区数据 // 修改关联责任区数据
List<HygieneZoneEntity> zoneList = hygienePlanDTO.getZoneList(); List<HygieneZoneEntity> zoneList = hygienePlanDTO.getZoneList();
// 删除旧的责任区数据 // 删除旧的责任区数据
boolean removeZone = hygieneZoneService.removeReferenceZone(hygienePlanDTO.getId()); boolean removeZone = hygieneZoneService.removeReferenceZone(planId);
if (!removeZone) { if (!removeZone) {
throw new ServiceException("删除旧的责任区数据失败"); throw new ServiceException("删除旧的责任区数据失败");
} }
@ -170,7 +174,26 @@ public class HygienePlanServiceImpl extends ServiceImpl<HygienePlanMapper, Hygie
BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore()); BaseUtil.getSumScore(scores, hygienePlanDTO.getStandardScore());
} }
// 校验通过则批量修改责任区数据 // 校验通过则批量修改责任区数据
return R.status(hygieneZoneService.saveBatch(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(",");
}
}
recordList.forEach(record -> record.setHygieneZoneIds(zoneIds.toString()));
return R.status(hygieneRecordService.updateBatchById(recordList));
}
return R.status(Boolean.TRUE);
} }
/** /**

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

@ -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 当月 * @param currentMonth 当月
* @return 存在则返回上一编号否则返回null * @return 存在则返回上一编号否则返回null

31
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; package com.hnac.hzims.safeproduct.service.impl;
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.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.safeproduct.dto.HygieneTemplateDTO; import com.hnac.hzims.safeproduct.dto.HygieneTemplateDTO;
import com.hnac.hzims.safeproduct.entity.HygieneTemplateDetailEntity; import com.hnac.hzims.safeproduct.entity.HygieneTemplateDetailEntity;
@ -11,12 +13,17 @@ 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.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.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;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -30,6 +37,12 @@ public class HygieneTemplateServiceImpl extends ServiceImpl<HygieneTemplateMappe
@Autowired @Autowired
IHygieneTemplateDetailService hygieneTemplateDetailService; IHygieneTemplateDetailService hygieneTemplateDetailService;
@Resource
HygieneTemplateMapper hygieneTemplateMapper;
@Autowired
ISysClient sysClient;
/** /**
* 新增卫生自查模板 * 新增卫生自查模板
*/ */
@ -139,4 +152,22 @@ public class HygieneTemplateServiceImpl extends ServiceImpl<HygieneTemplateMappe
queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, name); queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, name);
return this.getOne(queryWrapper); 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;
}
} }

Loading…
Cancel
Save