haungxing
7 months ago
26 changed files with 559 additions and 61 deletions
@ -0,0 +1,25 @@
|
||||
package com.hnac.hzims.safeproduct.dto; |
||||
|
||||
import com.hnac.hzims.safeproduct.entity.HygieneTemplateDetailEntity; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @date 2024-04-28 |
||||
*/ |
||||
@Data |
||||
@ApiModel(value = "卫生自查模板DTO类") |
||||
public class HygieneTemplateDTO { |
||||
|
||||
@ApiModelProperty("模板id") |
||||
private Long templateId; |
||||
|
||||
@ApiModelProperty("模板名称") |
||||
private String templateName; |
||||
|
||||
@ApiModelProperty("模板详情列表") |
||||
private List<HygieneTemplateDetailEntity> templateDetailList; |
||||
} |
@ -0,0 +1,30 @@
|
||||
package com.hnac.hzims.safeproduct.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.mp.base.BaseEntity; |
||||
|
||||
import javax.validation.constraints.Size; |
||||
|
||||
/** |
||||
* @date 2024-04-28 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@TableName("hzims_hygiene_template_detail") |
||||
@ApiModel(value = "卫生自查模板详情表") |
||||
public class HygieneTemplateDetailEntity extends BaseEntity { |
||||
|
||||
@ApiModelProperty("模板id") |
||||
private Long templateId; |
||||
|
||||
@Size(max = 50, message = "责任区字段长度不能超过50") |
||||
@ApiModelProperty("责任区") |
||||
private String zone; |
||||
|
||||
@ApiModelProperty("检查项") |
||||
private String checkItem; |
||||
} |
@ -0,0 +1,21 @@
|
||||
package com.hnac.hzims.safeproduct.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
import org.springblade.core.mp.base.BaseEntity; |
||||
|
||||
/** |
||||
* @date 2024-04-28 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@TableName("hzims_hygiene_template") |
||||
@ApiModel(value = "卫生自查模板表") |
||||
public class HygieneTemplateEntity extends BaseEntity { |
||||
|
||||
@ApiModelProperty("模板名称") |
||||
private String templateName; |
||||
} |
@ -0,0 +1,26 @@
|
||||
package com.hnac.hzims.safeproduct.vo; |
||||
|
||||
import com.hnac.hzims.safeproduct.entity.HygieneTemplateDetailEntity; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author liwen |
||||
* @date 2024-04-30 |
||||
*/ |
||||
@Data |
||||
@ApiModel(value = "卫生自查模板详情VO类") |
||||
public class HygieneTemplateDetailVO { |
||||
|
||||
@ApiModelProperty("模板id") |
||||
private Long id; |
||||
|
||||
@ApiModelProperty("模板名称") |
||||
private String templateName; |
||||
|
||||
@ApiModelProperty("模板详情列表") |
||||
private List<HygieneTemplateDetailEntity> templateDetailList; |
||||
} |
@ -0,0 +1,15 @@
|
||||
package com.hnac.hzims.safeproduct.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.hnac.hzims.safeproduct.entity.HygieneTemplateDetailEntity; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
/** |
||||
* 卫生自查模板详情Mapper类 |
||||
* |
||||
* @date 2024-04-29 |
||||
*/ |
||||
@Mapper |
||||
public interface HygieneTemplateDetailMapper extends BaseMapper<HygieneTemplateDetailEntity> { |
||||
|
||||
} |
@ -0,0 +1,4 @@
|
||||
<!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.HygieneTemplateDetailMapper"> |
||||
|
||||
</mapper> |
@ -0,0 +1,15 @@
|
||||
package com.hnac.hzims.safeproduct.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.hnac.hzims.safeproduct.entity.HygieneTemplateEntity; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
|
||||
/** |
||||
* 卫生自查模板Mapper类 |
||||
* |
||||
* @date 2024-04-29 |
||||
*/ |
||||
@Mapper |
||||
public interface HygieneTemplateMapper extends BaseMapper<HygieneTemplateEntity> { |
||||
|
||||
} |
@ -0,0 +1,4 @@
|
||||
<!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> |
@ -0,0 +1,21 @@
|
||||
package com.hnac.hzims.safeproduct.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
import com.hnac.hzims.safeproduct.entity.HygieneTemplateDetailEntity; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 卫生自查模板详情服务类 |
||||
* |
||||
* @date 2024-04-29 |
||||
*/ |
||||
public interface IHygieneTemplateDetailService extends IService<HygieneTemplateDetailEntity> { |
||||
|
||||
/** |
||||
* 根据模板id查找模板详情数据 |
||||
* @param templateId 模板id |
||||
* @return 模板详情列表 |
||||
*/ |
||||
List<HygieneTemplateDetailEntity> getListByTemplateId(Long templateId); |
||||
} |
@ -0,0 +1,42 @@
|
||||
package com.hnac.hzims.safeproduct.service; |
||||
|
||||
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; |
||||
|
||||
/** |
||||
* 卫生自查模板服务类 |
||||
* |
||||
* @date 2024-04-29 |
||||
*/ |
||||
public interface IHygieneTemplateService extends IService<HygieneTemplateEntity> { |
||||
|
||||
/** |
||||
* 新增卫生自查模板 |
||||
* @param hygieneTemplateDTO 卫生自查模板DTO类 |
||||
* @return true-成功,false-失败 |
||||
*/ |
||||
boolean saveHygieneTemplate(HygieneTemplateDTO hygieneTemplateDTO); |
||||
|
||||
/** |
||||
* 修改卫生自查模板 |
||||
* @param hygieneTemplateDTO 卫生自查模板DTO类 |
||||
* @return true-成功,false-失败 |
||||
*/ |
||||
boolean updateHygieneTemplate(HygieneTemplateDTO hygieneTemplateDTO); |
||||
|
||||
/** |
||||
* 删除卫生自查模板 |
||||
* @param id 卫生自查模板id |
||||
* @return true-成功,false-失败 |
||||
*/ |
||||
boolean removeHygieneTemplate(Long id); |
||||
|
||||
/** |
||||
* 卫生自查模板详情 |
||||
* @param id 卫生自查模板id |
||||
* @return 详情 |
||||
*/ |
||||
HygieneTemplateDetailVO getHygieneTemplateDetail(Long id); |
||||
} |
@ -0,0 +1,30 @@
|
||||
package com.hnac.hzims.safeproduct.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.hnac.hzims.safeproduct.entity.HygieneTemplateDetailEntity; |
||||
import com.hnac.hzims.safeproduct.mapper.HygieneTemplateDetailMapper; |
||||
import com.hnac.hzims.safeproduct.service.IHygieneTemplateDetailService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 卫生自查模板详情服务实现类 |
||||
* |
||||
* @date 2024-04-29 |
||||
*/ |
||||
@Service |
||||
public class HygieneTemplateDetailServiceImpl extends ServiceImpl<HygieneTemplateDetailMapper, HygieneTemplateDetailEntity> |
||||
implements IHygieneTemplateDetailService { |
||||
|
||||
/** |
||||
* 根据模板id查找模板详情数据 |
||||
*/ |
||||
@Override |
||||
public List<HygieneTemplateDetailEntity> getListByTemplateId(Long templateId) { |
||||
QueryWrapper<HygieneTemplateDetailEntity> queryWrapper = new QueryWrapper<>(); |
||||
queryWrapper.lambda().eq(HygieneTemplateDetailEntity::getTemplateId, templateId); |
||||
return this.list(queryWrapper); |
||||
} |
||||
} |
@ -0,0 +1,107 @@
|
||||
package com.hnac.hzims.safeproduct.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.hnac.hzims.safeproduct.dto.HygieneTemplateDTO; |
||||
import com.hnac.hzims.safeproduct.entity.HygieneTemplateDetailEntity; |
||||
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.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; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import java.util.List; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* 卫生自查模板服务实现类 |
||||
* |
||||
* @date 2024-04-29 |
||||
*/ |
||||
@Service |
||||
public class HygieneTemplateServiceImpl extends ServiceImpl<HygieneTemplateMapper, HygieneTemplateEntity> implements IHygieneTemplateService { |
||||
|
||||
@Autowired |
||||
IHygieneTemplateDetailService hygieneTemplateDetailService; |
||||
|
||||
/** |
||||
* 新增卫生自查模板 |
||||
*/ |
||||
@Transactional(rollbackFor = Exception.class) |
||||
@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)) { |
||||
throw new ServiceException("模板名不可重复"); |
||||
} |
||||
HygieneTemplateEntity hygieneTemplate = new HygieneTemplateEntity(); |
||||
hygieneTemplate.setTemplateName(templateName); |
||||
boolean saveTemplate = this.save(hygieneTemplate); |
||||
if (!saveTemplate) { |
||||
throw new ServiceException("卫生自查模板新增失败"); |
||||
} |
||||
return hygieneTemplateDetailService.saveBatch(hygieneTemplateDTO.getTemplateDetailList()); |
||||
} |
||||
|
||||
/** |
||||
* 修改卫生自查模板 |
||||
*/ |
||||
@Transactional(rollbackFor = Exception.class) |
||||
@Override |
||||
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)) { |
||||
throw new ServiceException("模板名不可重复"); |
||||
} |
||||
HygieneTemplateEntity hygieneTemplate = new HygieneTemplateEntity(); |
||||
hygieneTemplate.setId(templateId); |
||||
hygieneTemplate.setTemplateName(templateName); |
||||
boolean updateTemplate = this.updateById(hygieneTemplate); |
||||
if (!updateTemplate) { |
||||
throw new ServiceException("卫生自查模板修改失败"); |
||||
} |
||||
return hygieneTemplateDetailService.updateBatchById(hygieneTemplateDTO.getTemplateDetailList()); |
||||
} |
||||
|
||||
/** |
||||
* 删除卫生自查模板 |
||||
*/ |
||||
@Transactional(rollbackFor = Exception.class) |
||||
@Override |
||||
public boolean removeHygieneTemplate(Long id) { |
||||
boolean removeTemplate = this.removeById(id); |
||||
if (!removeTemplate) { |
||||
throw new ServiceException("卫生自查模板删除失败"); |
||||
} |
||||
List<HygieneTemplateDetailEntity> details = hygieneTemplateDetailService.getListByTemplateId(id); |
||||
List<Long> ids = details.stream().map(HygieneTemplateDetailEntity::getId).collect(Collectors.toList()); |
||||
return hygieneTemplateDetailService.removeByIds(ids); |
||||
} |
||||
|
||||
/** |
||||
* 卫生自查模板详情 |
||||
*/ |
||||
@Override |
||||
public HygieneTemplateDetailVO getHygieneTemplateDetail(Long id) { |
||||
HygieneTemplateDetailVO hygieneTemplateDetailVO = new HygieneTemplateDetailVO(); |
||||
HygieneTemplateEntity hygieneTemplate = this.getById(id); |
||||
BeanUtils.copyProperties(hygieneTemplate, hygieneTemplateDetailVO); |
||||
List<HygieneTemplateDetailEntity> details = hygieneTemplateDetailService.getListByTemplateId(id); |
||||
hygieneTemplateDetailVO.setTemplateDetailList(details); |
||||
return hygieneTemplateDetailVO; |
||||
} |
||||
} |
Loading…
Reference in new issue