|
@@ -0,0 +1,120 @@
|
|
|
+package com.diagbot.facade;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.diagbot.client.TranServiceClient;
|
|
|
+import com.diagbot.entity.FolderMapping;
|
|
|
+import com.diagbot.entity.TemplateFolder;
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
+import com.diagbot.exception.CommonException;
|
|
|
+import com.diagbot.service.impl.TemplateFolderServiceImpl;
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
+import com.diagbot.util.DateUtil;
|
|
|
+import com.diagbot.vo.HospitalCodeSetVO;
|
|
|
+import com.diagbot.vo.TemplateFolderDelVO;
|
|
|
+import com.diagbot.vo.TemplateFolderListVO;
|
|
|
+import com.diagbot.vo.TemplateFolderVO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author zhoutg
|
|
|
+ * @Description: 病历模板文件夹管理员
|
|
|
+ * @date 2018年11月16日 上午11:24:36
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class TemplateFolderAdminFacade extends TemplateFolderServiceImpl {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ AdminCheckFacade adminCheckFacade;
|
|
|
+ @Autowired
|
|
|
+ FolderMappingFacade folderMappingFacade;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 文件夹新增或更新
|
|
|
+ *
|
|
|
+ * @param templateFolderVO
|
|
|
+ */
|
|
|
+ public void saveOrUpdate(TemplateFolderVO templateFolderVO) {
|
|
|
+ HospitalCodeSetVO hospitalCodeSetVO = new HospitalCodeSetVO();
|
|
|
+ hospitalCodeSetVO.setDoctorId(templateFolderVO.getDoctorId());
|
|
|
+ hospitalCodeSetVO.setHospitalId(templateFolderVO.getHospitalId());
|
|
|
+ boolean res = adminCheckFacade.getadminCheck(hospitalCodeSetVO);
|
|
|
+ if (!res) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "暂无修改权限");
|
|
|
+ }
|
|
|
+ boolean add = true;
|
|
|
+ if (templateFolderVO.getId() != null) {
|
|
|
+ add = false;
|
|
|
+ }
|
|
|
+ int count = this.count(new QueryWrapper<TemplateFolder>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("name", templateFolderVO.getName())
|
|
|
+ .eq("hospital_id", templateFolderVO.getHospitalId())
|
|
|
+ // .eq("doctor_id", templateFolderVO.getDoctorId())
|
|
|
+ .ne(!add, "id", templateFolderVO.getId())
|
|
|
+ );
|
|
|
+ if (count > 0) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该文件夹已存在");
|
|
|
+ }
|
|
|
+ TemplateFolder templateFolder = new TemplateFolder();
|
|
|
+ BeanUtil.copyProperties(templateFolderVO, templateFolder);
|
|
|
+ Date date = DateUtil.now();
|
|
|
+ if (add) {
|
|
|
+ templateFolder.setGmtCreate(date);
|
|
|
+ templateFolder.setCreator(templateFolderVO.getDoctorId().toString());
|
|
|
+ }
|
|
|
+ templateFolder.setGmtModified(date);
|
|
|
+ templateFolder.setModifier(templateFolderVO.getDoctorId().toString());
|
|
|
+ this.saveOrUpdate(templateFolder);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 文件夹删除
|
|
|
+ *
|
|
|
+ * @param templateFolderDelVO
|
|
|
+ */
|
|
|
+ public void delete(TemplateFolderDelVO templateFolderDelVO) {
|
|
|
+ // 校验权限
|
|
|
+ HospitalCodeSetVO hospitalCodeSetVO = new HospitalCodeSetVO();
|
|
|
+ hospitalCodeSetVO.setDoctorId(templateFolderDelVO.getDoctorId());
|
|
|
+ hospitalCodeSetVO.setHospitalId(templateFolderDelVO.getHospitalId());
|
|
|
+ boolean res = adminCheckFacade.getadminCheck(hospitalCodeSetVO);
|
|
|
+ if (!res) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "暂无删除权限");
|
|
|
+ }
|
|
|
+ int count = folderMappingFacade.count(new QueryWrapper<FolderMapping>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("folder_id", templateFolderDelVO.getFolderId())
|
|
|
+ );
|
|
|
+ if (count > 0) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "请先删除当前文件夹下的模板");
|
|
|
+ }
|
|
|
+ // 删除
|
|
|
+ this.update(new UpdateWrapper<TemplateFolder>()
|
|
|
+ .eq("id", templateFolderDelVO.getFolderId())
|
|
|
+ .set("is_deleted", IsDeleteEnum.Y.getKey())
|
|
|
+ .set("gmt_modified", DateUtil.now())
|
|
|
+ .set("modifier", templateFolderDelVO.getDoctorId())
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 文件夹列表
|
|
|
+ *
|
|
|
+ * @param templateFolderListVO
|
|
|
+ */
|
|
|
+ public List<TemplateFolder> list(TemplateFolderListVO templateFolderListVO) {
|
|
|
+ return this.list(new QueryWrapper<TemplateFolder>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ //.eq("doctor_id", templateFolderListVO.getDoctorId())
|
|
|
+ .eq("hospital_id", templateFolderListVO.getHospitalId())
|
|
|
+ .orderByDesc("gmt_modified")
|
|
|
+ );
|
|
|
+ }
|
|
|
+}
|