|
|
|
@ -8,6 +8,7 @@ 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; |
|
|
|
@ -49,6 +50,15 @@ public class HygieneTemplateServiceImpl extends ServiceImpl<HygieneTemplateMappe
|
|
|
|
|
if (!saveTemplate) { |
|
|
|
|
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()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -72,9 +82,18 @@ public class HygieneTemplateServiceImpl extends ServiceImpl<HygieneTemplateMappe
|
|
|
|
|
hygieneTemplate.setTemplateName(templateName); |
|
|
|
|
boolean updateTemplate = this.updateById(hygieneTemplate); |
|
|
|
|
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); |
|
|
|
|
return hygieneTemplateDetailVO; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 根据模板名获取模板 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public HygieneTemplateEntity getHygieneTemplateByName(String name) { |
|
|
|
|
QueryWrapper<HygieneTemplateEntity> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
queryWrapper.lambda().eq(HygieneTemplateEntity::getTemplateName, name); |
|
|
|
|
return this.getOne(queryWrapper); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|