Bladeren bron

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

chenweida 8 jaren geleden
bovenliggende
commit
f81a35fe9f

+ 2 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/template/DoctorGuidanceTempDao.java

@ -28,6 +28,6 @@ public interface DoctorGuidanceTempDao extends PagingAndSortingRepository<Doctor
    //    Page<List<DoctorGuidanceTemp>> findByOwnerAndSystem(String owner, Pageable pageRequest);
    //验证医生健康指导模板标题是否重复
    @Query("select t from DoctorGuidanceTemp t where t.owner != 'system' and t.modelName = ?1 ")
    List<DoctorGuidanceTemp> findByTitle(String title);
    @Query("select t from DoctorGuidanceTemp t where t.owner = ?1 and t.modelName = ?2 ")
    List<DoctorGuidanceTemp> findByTitle(String owner,String title);
}

+ 101 - 53
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/template/DoctorTeamGuidanceService.java

@ -120,29 +120,24 @@ public class DoctorTeamGuidanceService extends BaseService {
     * @param images
     * @throws Exception
     */
    public void modifyTeamGuidance(String doctor, String isLeader, int saveAsGuidance, String guidanceCode, String title,
                                   JSONArray teams, String content, String images) throws Exception {
    public void modifyTeamGuidance(String doctor, String isLeader,int saveAsGuidance,Boolean isRepeat , String guidanceCode, String title,
                                     JSONArray teams, String content, String images) throws Exception {
//        首先身份验证
        DoctorTeamGuidanceDetail guidanceDetail = doctorTeamGuidanceDetailDao.findGuidanceDetail(guidanceCode);
        String creater = guidanceDetail.getCreater();
        if ((!doctor.equals(creater)) && (!"1".equals(isLeader))) {
            throw new Exception("没有修改权限");
        }
//        图片地址需要处理
        String image = "";
        if (StringUtils.isNotEmpty(images)) {
            image = validateImages(images);
        }
        switch (saveAsGuidance) {
            case 1:
                //      保存为个人模板 去除个人模板标题重复
                //        验证模板名称唯一性
                List<DoctorGuidanceTemp> templates = guidanceTempDao.findByTitle(title);
                if (templates != null && templates.size() != 0) {
                    throw new Exception("个人模板标题重复");
                }
                DoctorGuidanceTemp doctorGuidanceTemp = new DoctorGuidanceTemp();
        if (saveAsGuidance == 1) {
            //      保存为个人模板 去除个人模板标题重复 个人模板重复和修改是分开的互不影响
            //        验证模板名称唯一性
            List<DoctorGuidanceTemp> templates = guidanceTempDao.findByTitle(doctor, title);
            DoctorGuidanceTemp doctorGuidanceTemp = new DoctorGuidanceTemp();
            if (!isRepeat) {
                doctorGuidanceTemp.setCode(getCode());
                doctorGuidanceTemp.setImagesUrl(image);
                doctorGuidanceTemp.setCreateTime(new Date());
@ -152,51 +147,104 @@ public class DoctorTeamGuidanceService extends BaseService {
                doctorGuidanceTemp.setLastTime(new Date());
                doctorGuidanceTemp.setSendTimes(1);
                doctorGuidanceTempDao.save(doctorGuidanceTemp);
            case 0:
                //                        数据库中拥有该模板的所有团队
                List<DoctorTeamGuidanceTemplate> teamIds = doctorTeamGuidanceTemplateDao.getTeamsByGuidance(guidanceCode);
                List teamList = new ArrayList();
                List tempTeams = new ArrayList();
                for (DoctorTeamGuidanceTemplate team : teamIds) {
                    teamList.add(team.getTeamId());
                }
                for (Object team : teams) {
                    JSONObject teamJson = new JSONObject(team.toString());
                    int teamId = teamJson.getInt("teamId");
                    tempTeams.add(teamId);
                    String teamName = teamJson.getString("teamName");
            }
            if ((!doctor.equals(creater)) && (!"1".equals(isLeader))) {
                throw new Exception("没有修改权限");
            }
            //                        数据库中拥有该模板的所有团队
            List<DoctorTeamGuidanceTemplate> teamIds = doctorTeamGuidanceTemplateDao.getTeamsByGuidance(guidanceCode);
            List teamList = new ArrayList();
            List tempTeams = new ArrayList();
            for (DoctorTeamGuidanceTemplate team : teamIds) {
                teamList.add(team.getTeamId());
            }
            for (Object team : teams) {
                JSONObject teamJson = new JSONObject(team.toString());
                int teamId = teamJson.getInt("teamId");
                tempTeams.add(teamId);
                String teamName = teamJson.getString("teamName");
//                    团队内模板标题要去重复(去掉自身)
                    List<DoctorTeamGuidanceTemplate> list = doctorTeamGuidanceTemplateDao.distinctByTeamTitle(title, teamId);
                    if (list.size() <= 1) {
                List<DoctorTeamGuidanceTemplate> list = doctorTeamGuidanceTemplateDao.distinctByTeamTitle(title, teamId);
                if (list.size() <= 1) {
//                        直接失效原有团队模板对应关系  在重新新增以前没有的团队关系 发送次数要归0
                        if (teamList.contains(teamId)) {
                    if (teamList.contains(teamId)) {
//                            数据库有
                            doctorTeamGuidanceTemplateDao.modifyTeamGuidance(teamId, guidanceCode, title);
                        }else if (!teamList.contains(teamId)){
                            //                        现在有,而数据库没有 要新增
                            DoctorTeamGuidanceTemplate doctorTeamGuidanceTemplate = new DoctorTeamGuidanceTemplate();
                            doctorTeamGuidanceTemplate.setCreater(doctor);
                            doctorTeamGuidanceTemplate.setCreateTime(new Date());
                            doctorTeamGuidanceTemplate.setDel(1);
                            doctorTeamGuidanceTemplate.setTeamId(teamId);
                            doctorTeamGuidanceTemplate.setTeamName(teamName);
                            doctorTeamGuidanceTemplate.setTitle(title);
                            doctorTeamGuidanceTemplate.setTeamTemplateCode(guidanceCode);
                            doctorTeamGuidanceTemplate.setUseTimes(0);
                            doctorTeamGuidanceTemplateDao.save(doctorTeamGuidanceTemplate);
                        }
                    } else {
                        throw new Exception(teamName + ":团队标题重复!");
                        doctorTeamGuidanceTemplateDao.modifyTeamGuidance(teamId, guidanceCode, title);
                    } else if (!teamList.contains(teamId)) {
                        //                        现在有,而数据库没有 要新增
                        DoctorTeamGuidanceTemplate doctorTeamGuidanceTemplate = new DoctorTeamGuidanceTemplate();
                        doctorTeamGuidanceTemplate.setCreater(doctor);
                        doctorTeamGuidanceTemplate.setCreateTime(new Date());
                        doctorTeamGuidanceTemplate.setDel(1);
                        doctorTeamGuidanceTemplate.setTeamId(teamId);
                        doctorTeamGuidanceTemplate.setTeamName(teamName);
                        doctorTeamGuidanceTemplate.setTitle(title);
                        doctorTeamGuidanceTemplate.setTeamTemplateCode(guidanceCode);
                        doctorTeamGuidanceTemplate.setUseTimes(0);
                        doctorTeamGuidanceTemplateDao.save(doctorTeamGuidanceTemplate);
                    }
                    //                直接修改团队模板后修改模板团队对应表
                    doctorTeamGuidanceDetailDao.modifyTeamGuidanceDetail(title, content, image, guidanceCode);
                } else {
                    throw new Exception(teamName + ":团队标题重复!");
                }
                //                直接修改团队模板后修改模板团队对应表
                doctorTeamGuidanceDetailDao.modifyTeamGuidanceDetail(title, content, image, guidanceCode);
            }
//                            数据库有,而现在没有
                teamList.removeAll(tempTeams);
                for (Object team:teamList) {
                    doctorTeamGuidanceTemplateDao.deleteTeamGuidance(Integer.parseInt(team.toString()), guidanceCode);
                }
            teamList.removeAll(tempTeams);
            for (Object team : teamList) {
                doctorTeamGuidanceTemplateDao.deleteTeamGuidance(Integer.parseInt(team.toString()), guidanceCode);
            }
        } else if (saveAsGuidance == 0) {
            if ((!doctor.equals(creater)) && (!"1".equals(isLeader))) {
                throw new Exception("没有修改权限");
            }
            //                        数据库中拥有该模板的所有团队
            List<DoctorTeamGuidanceTemplate> teamIds = doctorTeamGuidanceTemplateDao.getTeamsByGuidance(guidanceCode);
            List teamList = new ArrayList();
            List tempTeams = new ArrayList();
            for (DoctorTeamGuidanceTemplate team : teamIds) {
                teamList.add(team.getTeamId());
            }
            for (Object team : teams) {
                JSONObject teamJson = new JSONObject(team.toString());
                int teamId = teamJson.getInt("teamId");
                tempTeams.add(teamId);
                String teamName = teamJson.getString("teamName");
//                    团队内模板标题要去重复(去掉自身)
                List<DoctorTeamGuidanceTemplate> list = doctorTeamGuidanceTemplateDao.distinctByTeamTitle(title, teamId);
                if (list.size() <= 1) {
//                        直接失效原有团队模板对应关系  在重新新增以前没有的团队关系 发送次数要归0
                    if (teamList.contains(teamId)) {
//                            数据库有
                        doctorTeamGuidanceTemplateDao.modifyTeamGuidance(teamId, guidanceCode, title);
                    } else if (!teamList.contains(teamId)) {
                        //                        现在有,而数据库没有 要新增
                        DoctorTeamGuidanceTemplate doctorTeamGuidanceTemplate = new DoctorTeamGuidanceTemplate();
                        doctorTeamGuidanceTemplate.setCreater(doctor);
                        doctorTeamGuidanceTemplate.setCreateTime(new Date());
                        doctorTeamGuidanceTemplate.setDel(1);
                        doctorTeamGuidanceTemplate.setTeamId(teamId);
                        doctorTeamGuidanceTemplate.setTeamName(teamName);
                        doctorTeamGuidanceTemplate.setTitle(title);
                        doctorTeamGuidanceTemplate.setTeamTemplateCode(guidanceCode);
                        doctorTeamGuidanceTemplate.setUseTimes(0);
                        doctorTeamGuidanceTemplateDao.save(doctorTeamGuidanceTemplate);
                    }
                } else {
                    throw new Exception(teamName + ":团队标题重复!");
                }
                //                直接修改团队模板后修改模板团队对应表
                doctorTeamGuidanceDetailDao.modifyTeamGuidanceDetail(title, content, image, guidanceCode);
            }
//                            数据库有,而现在没有
            teamList.removeAll(tempTeams);
            for (Object team : teamList) {
                doctorTeamGuidanceTemplateDao.deleteTeamGuidance(Integer.parseInt(team.toString()), guidanceCode);
            }
        }
    }

+ 9 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/template/DoctorGuidanceTempController.java

@ -94,7 +94,7 @@ public class DoctorGuidanceTempController extends BaseController {
                return error(-1, "模板名称不能为空且在10字之内");
            }
            //        验证模板名称唯一性
            List<DoctorGuidanceTemp> templates = guidanceTempDao.findByTitle(modelName);
            List<DoctorGuidanceTemp> templates = guidanceTempDao.findByTitle(getUID(), modelName);
            if (templates != null && templates.size() != 0) {
                return error(-1, "模板名称与现有模板重复,请修改");
            }
@ -140,10 +140,14 @@ public class DoctorGuidanceTempController extends BaseController {
            if (StringUtils.isEmpty(modelName) || modelName.length() > 10) {
                return error(-1, "内容10个汉字之内且不能为空");
            }
//            验证模板名称唯一性 还要去除掉其本身
            List<DoctorGuidanceTemp> templates = guidanceTempDao.findByTitle(modelName);
            if (templates != null && templates.size() > 1) {
                return error(-1, "模板名称与现有模板重复,请修改");
//            验证模板名称唯一性 还要去除掉其本身  (判断查出来的和要修改的同名)
            List<DoctorGuidanceTemp> templates = guidanceTempDao.findByTitle(getUID(), modelName);
            for (DoctorGuidanceTemp teamplate : templates) {
                if (!code.equals(teamplate.getCode())) {
//                        不是修改同一个模板
                    return error(-1, "模板名称与现有模板重复,请修改");
                }
            }
            DoctorGuidanceTemp temp = guidanceTempService.modify(code, modelName, content, imagesUrl);

+ 14 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/template/DoctorTeamGuidanceController.java

@ -4,8 +4,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.patient.PatientHealthStandard;
import com.yihu.wlyy.entity.template.DoctorGuidanceTemp;
import com.yihu.wlyy.entity.template.DoctorTeamGuidanceDetail;
import com.yihu.wlyy.health.entity.DevicePatientHealthIndex;
import com.yihu.wlyy.repository.template.DoctorGuidanceTempDao;
import com.yihu.wlyy.service.app.health.PatientHealthIndexService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.service.template.DoctorTeamGuidanceService;
@ -44,6 +46,8 @@ public class DoctorTeamGuidanceController extends WeixinBaseController {
    private DoctorTeamGuidanceService doctorTeamGuidanceService;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    DoctorGuidanceTempDao guidanceTempDao;
    /**
     * 获取医生所属的所有团队
@ -178,10 +182,18 @@ public class DoctorTeamGuidanceController extends WeixinBaseController {
            @RequestParam(required = false) String images) {
        try {
//            新增修改权限,只有创建者和团队长才能修改
            String result = "";
            Boolean isRepeat = false;
            String doctor = getUID();
            List<DoctorGuidanceTemp> templates = guidanceTempDao.findByTitle(doctor, title);
            if (templates != null && templates.size() != 0) {
                isRepeat = true;
                result = "个人模板标题重复";
            }
            JSONArray teams = new JSONArray(teamInfo);
            doctorTeamGuidanceService.modifyTeamGuidance(doctor,isLeader, saveAsGuidance, guidanceCode, title, teams, content, images);
            return write(200, "修改团队模板成功!");
            doctorTeamGuidanceService.modifyTeamGuidance(doctor,isLeader, saveAsGuidance, isRepeat,guidanceCode, title, teams, content, images);
            String str = "";
            return write(200, "修改团队模板成功!","result",result);
        } catch (Exception e) {
            return invalidUserException(e, -1, e.getMessage());
        }