Procházet zdrojové kódy

Merge branch 'dev' of wujunjie/patient-management into dev

trick9191 před 7 roky
rodič
revize
3b7ff0f57f

+ 7 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/template/DoctorTeamGuidanceTemplateDao.java

@ -22,6 +22,10 @@ public interface DoctorTeamGuidanceTemplateDao extends PagingAndSortingRepositor
    @Query("select t from DoctorTeamGuidanceTemplate t where t.del = 1 and t.teamId = ?1 ")
    List<DoctorTeamGuidanceTemplate> findGuidanceByTeamId(int teamId, Pageable request);
    //    由模板编码获取拥有该模板的团队信息
    @Query("select t from DoctorTeamGuidanceTemplate t where t.del = 1 and t.teamTemplateCode = ?1 ")
    List<DoctorTeamGuidanceTemplate> getTeamsByGuidance(String guidanceCode);
    //    根据团队ID及模板编码删除团队所属的团队模板
    @Modifying
    @Query("update DoctorTeamGuidanceTemplate t set t.del = 0 where t.teamId = ?1 and t.teamTemplateCode =?2 ")
@ -29,12 +33,12 @@ public interface DoctorTeamGuidanceTemplateDao extends PagingAndSortingRepositor
    //  根据模板编码更改团队模板对应表
    @Modifying
    @Query("update DoctorTeamGuidanceTemplate t set t.del = 0 where t.teamId = ?1 and t.teamTemplateCode =?2 ")
    int modifyTeamGuidance(int teamId, String title);
    @Query("update DoctorTeamGuidanceTemplate t set t.title = ?3 where t.del = 1 and t.teamId = ?1 and t.teamTemplateCode =?2 ")
    int modifyTeamGuidance(int teamId, String guidanceCode, String title);
    //  每给居民发送一次团队指导,使用数量加1
    @Modifying
    @Query("update DoctorTeamGuidanceTemplate t set t.useTimes = t.useTimes+1 where t.del = 1 and t.teamId = ?1 and t.teamTemplateCode =?2 ")
    int countSend(int teamId,String guidanceCode);
    int countSend(int teamId, String guidanceCode);
}

+ 54 - 15
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/template/DoctorTeamGuidanceService.java

@ -28,6 +28,7 @@ import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -68,10 +69,8 @@ public class DoctorTeamGuidanceService extends BaseService {
//            只限本地路径上传到FastDFS
            image = CommonUtil.copyTempImage(images);
            System.out.println("images =====>" + image);
        } else {
//            只有新增的时候才必须传地址
            throw new Exception("新增图片为空!");
        }
        for (Object team : teams) {
            JSONObject teamJson = new JSONObject(team.toString());
            int teamId = teamJson.getInt("teamId");
@ -140,16 +139,19 @@ public class DoctorTeamGuidanceService extends BaseService {
                doctorGuidanceTemp.setSendTimes(0);
                doctorGuidanceTempDao.save(doctorGuidanceTemp);
            case 0:
//                直接修改团队模板后修改模板团队对应表
                doctorTeamGuidanceDetailDao.modifyTeamGuidanceDetail(title, content, image, guidanceCode);
                for (Object team : teams) {
                    JSONObject teamJson = new JSONObject(team.toString());
                    int teamId = teamJson.getInt("teamId");
                    String teamName = teamJson.getString("teamName");
//                    团队内模板标题要去重复(去掉自身)
                    List<DoctorTeamGuidanceTemplate> list = doctorTeamGuidanceTemplateDao.distinctByTeamTitle(title, teamId);
                    if (list.size() == 0) {
                        doctorTeamGuidanceTemplateDao.modifyTeamGuidance(teamId, title);
                    if (list.size() <= 1) {
                        doctorTeamGuidanceTemplateDao.modifyTeamGuidance(teamId,guidanceCode, title);
                    } else {
                        throw new Exception(teamName + ":团队标题重复!");
                    }
                    //                直接修改团队模板后修改模板团队对应表
                    doctorTeamGuidanceDetailDao.modifyTeamGuidanceDetail(title, content, image, guidanceCode);
                }
                break;
        }
@ -191,9 +193,44 @@ public class DoctorTeamGuidanceService extends BaseService {
     * @return
     * @throws Exception
     */
    public DoctorTeamGuidanceDetail getTeamGuidanceDetail(String guidanceCode) throws Exception {
    public JSONObject getTeamGuidanceDetail(int teamId, String guidanceCode) throws Exception {
        JSONObject jsonObject = new JSONObject();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String createTime = "";
        String czrq = "";
        DoctorTeamGuidanceDetail guidanceDetail = doctorTeamGuidanceDetailDao.findGuidanceDetail(guidanceCode);
        return guidanceDetail;
        List<DoctorTeamGuidanceTemplate> doctorTeamGuidanceTemplate = doctorTeamGuidanceTemplateDao.getTeamsByGuidance(guidanceCode);
        List teamList = new ArrayList();
        for (DoctorTeamGuidanceTemplate teamGuidanceTemplate : doctorTeamGuidanceTemplate) {
            Map map = new HashMap();
            map.put("teamId", teamGuidanceTemplate.getTeamId());
            map.put("teamName", teamGuidanceTemplate.getTeamName());
            if (teamGuidanceTemplate.getTeamId() == teamId) {
                jsonObject.put("useTimes", teamGuidanceTemplate.getUseTimes());
            }
            teamList.add(map);
        }
        Date create = guidanceDetail.getCreateTime();
        Date cztime = guidanceDetail.getCzrq();
        if (create != null) {
            createTime = sdf.format(create);
        }
        if (cztime != null) {
            czrq = sdf.format(cztime);
        }
        jsonObject.put("id", guidanceDetail.getId() != null ? guidanceDetail.getId() : "");
        jsonObject.put("code", guidanceDetail.getCode() != null ? guidanceDetail.getCode() : "");
        jsonObject.put("creater", guidanceDetail.getCreater() != null ? guidanceDetail.getCreater() : "");
        jsonObject.put("title", guidanceDetail.getTitle() != null ? guidanceDetail.getTitle() : "");
        jsonObject.put("content", guidanceDetail.getContent() != null ? guidanceDetail.getContent() : "");
        jsonObject.put("imagesUrl", guidanceDetail.getImagesUrl() != null ? guidanceDetail.getImagesUrl() : "");
        jsonObject.put("createTime", createTime);
        jsonObject.put("czrq", czrq);
        jsonObject.put("teamList", teamList);
        return jsonObject;
    }
    /**
@ -203,14 +240,14 @@ public class DoctorTeamGuidanceService extends BaseService {
     * @param guidanceCode
     * @throws Exception
     */
    public void deleteTeamGuidance(String doctor,int deteleAll, Integer teamId, String guidanceCode) throws Exception {
    public void deleteTeamGuidance(String doctor, int deteleAll, Integer teamId, String guidanceCode) throws Exception {
        String str = "";
        if (deteleAll == 0) {
            doctorTeamGuidanceTemplateDao.deleteTeamGuidance(teamId, guidanceCode);
        } else {
//            删除该医生所有团队内该模板
            List<AdminTeam> teams =  memberDao.findDoctorTeams(doctor);
            for (AdminTeam team:teams) {
            List<AdminTeam> teams = memberDao.findDoctorTeams(doctor);
            for (AdminTeam team : teams) {
                int teamCode = team.getId().intValue();
                doctorTeamGuidanceTemplateDao.deleteTeamGuidance(teamCode, guidanceCode);
            }
@ -264,6 +301,7 @@ public class DoctorTeamGuidanceService extends BaseService {
     * @throws Exception
     */
    public static String validateImages(String images) throws Exception {
        String imagePath = "";
        String imageUrls = "";
        String imageRow = "";
        String[] imgs = images.split(",");
@ -277,10 +315,11 @@ public class DoctorTeamGuidanceService extends BaseService {
                    e.printStackTrace();
                }
            }
            images += imageUrls + imageRow;
        }
        images = images.substring(0, images.length() - 1);
        return images;
        imagePath += imageUrls + imageRow;
        imagePath = imagePath.substring(0, imagePath.length() - 1);
        return imagePath;
    }
}

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

@ -100,10 +100,12 @@ public class DoctorTeamGuidanceController extends WeixinBaseController {
    @ResponseBody
    @ApiOperation("获取单个模板详情")
    public String getTeamGuidanceDetail(
            @ApiParam(value = "团队编码")
            @RequestParam int teamId,
            @ApiParam(value = "团队模板编码")
            @RequestParam String teamTemplateCode) {
        try {
            DoctorTeamGuidanceDetail guidanceDetail = doctorTeamGuidanceService.getTeamGuidanceDetail(teamTemplateCode);
            JSONObject guidanceDetail = doctorTeamGuidanceService.getTeamGuidanceDetail(teamId,teamTemplateCode);
            return write(200, "获取模板详情成功!", "guidanceDetail", guidanceDetail);
        } catch (Exception e) {
            return invalidUserException(e, -1, e.getMessage());
@ -130,7 +132,7 @@ public class DoctorTeamGuidanceController extends WeixinBaseController {
            @ApiParam(value = "模板内容")
            @RequestParam String content,
            @ApiParam(value = "图片路径")
            @RequestParam String images
            @RequestParam(required = false) String images
    ) {
        try {
//            前端参数校验