Prechádzať zdrojové kódy

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

# Conflicts:
#	svr/svr-base/src/main/java/com/yihu/jw/base/dao/voluntary/VoluntaryRecruitmentPeopleDao.java
yeshijie 3 rokov pred
rodič
commit
46a6b48051

+ 10 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageSignRecordDO.java

@ -27,6 +27,7 @@ public class ServicePackageSignRecordDO extends UuidIdentityEntityWithCreateTime
    private Date startTime;//服务开始时间
    private Date endTime;//服务结束时间
    private Integer status;//状态 0新增,1生效,-1已过期
    private String teamCode;//服务团队id
    /**
     * 签约的服务包
@ -137,4 +138,13 @@ public class ServicePackageSignRecordDO extends UuidIdentityEntityWithCreateTime
    public void setPackageList(List<Map<String,Object>> packageList) {
        this.packageList = packageList;
    }
    @Column(name = "team_code")
    public String getTeamCode() {
        return teamCode;
    }
    public void setTeamCode(String teamCode) {
        this.teamCode = teamCode;
    }
}

+ 32 - 19
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java

@ -67,7 +67,7 @@ public class SignEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "findSignDoctor")
    @ApiOperation(value = "查找签约医生")
    public ListEnvelop findSignDoctor (
            @ApiParam(name = "patient", value = "医生code", required = true)
            @ApiParam(name = "patient", value = "居民code", required = true)
            @RequestParam(value = "patient",required = true) String patient,
            @ApiParam(name = "orgCode", value = "医院code", required = false)
            @RequestParam(value = "orgCode",required = false) String orgCode) throws Exception {
@ -192,6 +192,30 @@ public class SignEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "findPatientSignList")
    @ApiOperation(value = "获取签约服务包记录")
    public ListEnvelop findPatientSignList (
            @ApiParam(name = "patient", value = "patient", required = true)
            @RequestParam(value = "patient") String patient) throws Exception {
        try{
            return ListEnvelop.getSuccess("查询成功",servicePackageService.findPatientSignList(patient));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "signPackageDetail")
    @ApiOperation(value = "获取签约服务包记录详情")
    public ObjEnvelop signPackageDetail (
            @ApiParam(name = "id", value = "id", required = true)
            @RequestParam(value = "id") String id) throws Exception {
        try{
            return ObjEnvelop.getSuccess("查询成功",servicePackageService.signPackageDetail(id));
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @PostMapping(value = "servicePackageSign")
    @ApiOperation(value = "分配服务包-签约")
    @ObserverRequired
@ -200,14 +224,15 @@ public class SignEndpoint extends EnvelopRestEndpoint {
            @RequestParam String jsonData,
            @ApiParam(name = "patientId", value = "居民id", required = true)
            @RequestParam String patientId,
            @ApiParam(name = "signYear", value = "签约时长 0长期 1 1年 2 2年", required = true)
            @RequestParam String signYear,
            @ApiParam(name = "doctorId", value = "医生id", required = true)
            @RequestParam String doctorId) {
        try{
           JSONObject result  = servicePackageService.servicePackageSign(jsonData,doctorId,patientId);
           JSONObject result  = servicePackageService.servicePackageSign(jsonData,doctorId,patientId,signYear);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return Envelop.getError(result.getString(ResponseContant.resultMsg));
            }
            servicePackageService.setPatientServiceItems(result.getJSONObject("resultMsg").getString("patient"));
            return Envelop.getSuccess("分配成功");
        }catch (Exception e){
            if (e.getMessage().contains("重复签约服务项目")){
@ -220,12 +245,14 @@ public class SignEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "servicePackagePage")
    @ApiOperation(value = "获取服务包分页")
    public PageEnvelop<List<Map<String,Object>>> servicePackagePage (
            @ApiParam(name = "orgCode", value = "机构code", required = false)
            @RequestParam(value = "orgCode",required = false)  String orgCode,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        try{
            return servicePackageService.servicePackagePage(page, size);
            return servicePackageService.servicePackagePage(page, size,orgCode);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
@ -269,8 +296,6 @@ public class SignEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "status",required = false) Integer status,
            @ApiParam(name = "levelConclusion", value = "评估结果/等级结论", required = false)
            @RequestParam(value = "levelConclusion",required = false) Integer levelConclusion,
            @ApiParam(name = "servicePackageStatus", value = "服务包分配(0未分配,1已分配)", required = false)
            @RequestParam(value = "servicePackageStatus",required = false) Integer servicePackageStatus,
            @ApiParam(name = "type", value = "type 0当年 1全部", required = false)
            @RequestParam(value = "type",required = false,defaultValue = "0") Integer type,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
@ -278,7 +303,7 @@ public class SignEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        try{
            return capacityAssessmentRecordService.assessmentPage(doctorId,patientId, name, type,page, size, status, levelConclusion, servicePackageStatus);
            return capacityAssessmentRecordService.assessmentPage(doctorId,patientId, name, type,page, size, status, levelConclusion);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
@ -503,18 +528,6 @@ public class SignEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value="getServerDoctorByPackage")
    @ApiOperation(value = "根据服务包,服务项目获取对应的服务医生")
    public ListEnvelop getServerDoctorByPackage(@ApiParam(name="packageId",value = "服务包id",required = true)
                       @RequestParam(value = "packageId")String packageId,
                       @ApiParam(name="serverItem",value = "服务项目code",required = true)
                       @RequestParam(value = "serverItem")String serverItem){
        try {
            return ListEnvelop.getSuccess("查询成功",servicePackageService.getServerDoctorByPackage(packageId,serverItem));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value="getServerDoctorAll")
    @ApiOperation(value = "获取所有服务医生")

+ 2 - 11
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/consult/ConsultTeamService.java

@ -14,9 +14,7 @@ import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
import com.yihu.jw.entity.care.assistance.EmergencyAssistanceDO;
import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachOrderDO;
import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringOrderDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.im.dao.ConsultDao;
@ -24,23 +22,16 @@ import com.yihu.jw.im.dao.ConsultTeamDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.sms.service.TXYSmsService;
import com.yihu.jw.sms.service.ZBSmsService;
import com.yihu.jw.utils.EntityUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import static com.yihu.jw.rm.hospital.BaseHospitalRequestMapping.PatientIM.patientInfo;
/**
 * Created by yeshijie on 2020/12/23.
 */
@ -233,7 +224,7 @@ public class ConsultTeamService {
        }
        //加入团队医生
        List<Map<String,Object>> doctorList = servicePackageService.fingdDoctorByPaitenId(patient,"emergencyAssistance");
        List<Map<String,Object>> doctorList = servicePackageService.fingdDoctorByPaitenId(patient);
        for(Map<String,Object> map:doctorList){
            participants.put(String.valueOf(map.get("id")), 0);
        }
@ -440,7 +431,7 @@ public class ConsultTeamService {
        //加入团队医生
        List<Map<String,Object>> doctorList = servicePackageService.fingdDoctorByPaitenId(patient,"preventLost");
        List<Map<String,Object>> doctorList = servicePackageService.fingdDoctorByPaitenId(patient);
        for(Map<String,Object> map:doctorList){
            participants.put(String.valueOf(map.get("id")), 0);
        }

+ 1 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/CarePatientService.java

@ -214,10 +214,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg,"修改成功");
        if(jsonObject1!=null){
            result = servicePackageService.servicePackageSign(jsonObject1.toJSONString(),doctorId,patientBrief.getId());
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.success) {
                servicePackageService.setPatientServiceItems(patientBrief.getId());
            }
//            result = servicePackageService.servicePackageSign(jsonObject1.toJSONString(),doctorId,patientBrief.getId());
        }
        return result;
    }

+ 2 - 6
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/CapacityAssessmentRecordService.java

@ -143,8 +143,8 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
    }
    public PageEnvelop<List<Map<String,Object>>> assessmentPage(String doctorId,String patientId,String name,int type, int page, int size,
                    Integer status,Integer levelConclusion,Integer servicePackageStatus){
        String sql = "SELECT c.id,c.patient,c.assessment_time,c.service_package_status servicePackageStatus, " +
                    Integer status,Integer levelConclusion){
        String sql = "SELECT c.id,c.patient,c.assessment_time, " +
                "c.`status`,c.level_conclusion levelConclusion,c.org_code orgCode,c.org_name orgName,p.name,p.photo,p.mobile,p.sex,p.idcard  ";
        String countSql = "SELECT count(*) ";
@ -167,9 +167,6 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
        if(levelConclusion!=null){
            filters += " and c.level_conclusion = "+levelConclusion;
        }
        if(servicePackageStatus!=null){
            filters += " and c.service_package_status = "+servicePackageStatus;
        }
        if(!StringUtil.isEmpty(name)){
            filters += " and (c.name like '%"+name+"%' or c.idcard like '%"+name+"%') ";
        }
@ -183,7 +180,6 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
            map.put("assessmentTime", map.get("assessment_time").toString().substring(0,19));
            map.put("age", IdCardUtil.getAgeForIdcard(idcard));
            map.put("levelConclusionName",dictService.fingByNameAndCode(ConstantUtil.DICT_LEVEL_CONCLUSION,String.valueOf(map.get("levelConclusion"))));
            map.put("servicePackageStatusName",dictService.fingByNameAndCode(ConstantUtil.DICT_SERVICEPACKAGESTATUS,String.valueOf(map.get("servicePackageStatus"))));
            map.put("statusName",dictService.fingByNameAndCode(ConstantUtil.DICT_CAPACITY_AGREE_STATUS,String.valueOf(map.get("status"))));
        }
        Long count = jdbcTemplate.queryForObject(countSql+filters,Long.class);

+ 109 - 111
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java

@ -14,7 +14,6 @@ import com.yihu.jw.entity.base.servicePackage.ServicePackageRecordDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
import com.yihu.jw.entity.care.apply.PatientBedApplyDo;
import com.yihu.jw.entity.care.archive.ArchiveDO;
import com.yihu.jw.entity.care.sign.CapacityAssessmentRecordDO;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.service.BasePatientMedicardCardService;
@ -87,11 +86,11 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
                "FROM " +
                " base_service_package_sign_record sr, " +
                " base_service_package_record r, " +
                " base_service_package_item i, " +
                " base_service_package i, " +
                " base_org o " +
                "WHERE " +
                " sr.id = r.sign_id and sr.status=1 and sr.patient = '"+patient+"' " +
                "AND r.service_package_id = i.service_package_id " +
                "AND r.service_package_id = i.id " +
                "AND i.del = 1 " +
                "and i.org_code = o.code " +
                "AND sr.`status` = 1 ";
@ -120,12 +119,12 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
                "FROM " +
                " base_service_package_sign_record sr, " +
                " base_service_package_record r, " +
                " base_service_package_item i, " +
                " base_service_package i, " +
                " base_team_member m,base_doctor d  " +
                "WHERE " +
                " sr.id = r.sign_id and sr.status=1 and sr.patient = '"+patient+"'" +
                " AND r.service_package_id = i.service_package_id " +
                "AND i.del = 1 and m.team_code = i.team_code and m.doctor_code = d.id " +
                " AND r.service_package_id = i.id " +
                "AND i.del = 1 and m.team_code = sr.team_code and m.doctor_code = d.id " +
                "               and m.del = '1'";
        if(StringUtils.isNoneBlank(orgCode)){
            sql += " and i.org_code = '"+orgCode+"' " ;
@ -134,39 +133,6 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        return list;
    }
    /**
     * 获取居民签约的服务项
     * @param patientId
     * @return
     */
    public List<String> getPatientServiceItems(String patientId){
        String key = "serviceItem:"+patientId;
        List<String> res;
        if(redisTemplate.hasKey(key)){
            long size = redisTemplate.opsForList().size(key);
            res = redisTemplate.opsForList().range(key,0,size);
        }else{
            res = fingServiceItemsCodeByPatientId(patientId);
            redisTemplate.opsForList().leftPushAll(key,res);
        }
        return res;
    }
    /**
     * 每次修改服务项重新设置res的服务项值
     * @param patientId
     */
    public void setPatientServiceItems(String patientId){
        String key = "serviceItem:"+patientId;
        if(redisTemplate.hasKey(key)){
            redisTemplate.delete(key);
        }
        List<String> res = fingServiceItemsCodeByPatientId(patientId);
        if(res!=null&&res.size()>0){
            redisTemplate.opsForList().leftPushAll(key,res);
        }
    }
    /**
     * 查找居民的签约服务项
@ -216,10 +182,8 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
     * @param signId
     */
    public List<Map<String,Object>> fingdDoctorBySignId(String signId,Integer level){
        String sql = "SELECT DISTINCT d.id,d.name from base_service_package_sign_record sr,base_service_package_record r, " +
                "base_service_package_item i,base_team_member m,base_doctor d " +
                "WHERE sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id " +
                "and i.del = 1 and m.team_code = i.team_code and m.doctor_code = d.id " +
        String sql = "SELECT DISTINCT d.id,d.name from base_service_package_sign_record sr,base_team_member m,base_doctor d " +
                "WHERE sr.status=1 and m.team_code = sr.team_code and m.doctor_code = d.id " +
                "and m.del = '1' and d.doctor_level = " + level+
                " and sr.id = '"+signId+"' ";
        return jdbcTemplate.queryForList(sql);
@ -229,29 +193,13 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
     * 根据居民和服务项查找医生
     * @param patientId
     */
    public List<Map<String,Object>> fingdDoctorByPaitenId(String patientId,String serviceItem){
        String sql = "SELECT DISTINCT d.id,d.name from base_service_package_sign_record sr,base_service_package_record r,  " +
                "               base_service_package_item i,base_team_member m,base_doctor d  " +
                "               WHERE sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id  " +
                "               and i.del = 1 and m.team_code = i.team_code and m.doctor_code = d.id " +
                "               and m.del = '1' and sr.patient = '"+patientId+"' " +
                "and i.`code` = '"+serviceItem+"'";
    public List<Map<String,Object>> fingdDoctorByPaitenId(String patientId){
        String sql = "SELECT DISTINCT d.id,d.name from base_service_package_sign_record sr,base_team_member m,base_doctor d  " +
                "               WHERE sr.status=1  m.team_code = sr.team_code and m.doctor_code = d.id " +
                "               and m.del = '1' and sr.patient = '"+patientId+"' " ;
        return jdbcTemplate.queryForList(sql);
    }
    /**
     * 根据服务包id查找医生/助老员
     * @param packageId
     */
    public List<Map<String,Object>> fingdDoctorByPackageId(String packageId,Integer level){
        String sql = "SELECT DISTINCT d.id,d.name from base_service_package_record r, " +
                "base_service_package_item i,base_team_member m,base_doctor d " +
                "WHERE r.service_package_id = i.service_package_id " +
                "and i.del = 1 and m.team_code = i.team_code and m.doctor_code = d.id " +
                "and m.del = '1' and d.doctor_level = " + level+
                " and r.id = '"+packageId+"' ";
        return jdbcTemplate.queryForList(sql);
    }
    /**
     * 根据签约记录查找服务包
@ -277,11 +225,9 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        String sql = "SELECT DISTINCT sr.patient,sr.id,sr.start_time,p.name,p.sex,p.idcard,p.openid,p.photo ";
        String countSql = "SELECT count(DISTINCT sr.patient) ";
        String filters = " from base_service_package_sign_record sr,base_service_package_record r, " +
                "base_service_package_item i,base_team_member m,base_patient p " +
                "WHERE sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id " +
                "and i.del = 1 and m.team_code = i.team_code and p.id = sr.patient " +
                "and m.doctor_code = '"+doctorId+"' and m.del = '1' and sr.`status`=1 ";
        String filters = " from base_service_package_sign_record sr,base_team_member m,base_patient p " +
                "WHERE  sr.status=1 and m.team_code = sr.team_code and p.id = sr.patient " +
                "and m.doctor_code = '"+doctorId+"' and m.del = '1'  ";
        if(!StringUtil.isEmpty(name)){
            filters += " and sr.name like '%"+name+"%' ";
@ -309,11 +255,9 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
     * @return
     */
    public int getSignTotal(String doctorId){
        String sql = "SELECT COUNT(DISTINCT sr.patient) from base_service_package_sign_record sr,base_service_package_record r, " +
                "base_service_package_item i,base_team_member m " +
                "WHERE sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id " +
                "and i.del = 1 and m.team_code = i.team_code " +
                "and m.doctor_code = '"+doctorId+"' and m.del = '1' and sr.`status`=1 ";
        String sql = "SELECT COUNT(DISTINCT sr.patient) from base_service_package_sign_record sr,base_team_member m " +
                "WHERE sr.status=1 and m.team_code = sr.team_code " +
                "and m.doctor_code = '"+doctorId+"' and m.del = '1' ";
        return jdbcTemplate.queryForObject(sql,Integer.class);
    }
@ -324,7 +268,7 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
     * @param doctorId
     */
    @Transactional(rollbackFor = Exception.class)
    public JSONObject servicePackageSign(String jsonData,String doctorId,String patientId) throws Exception{
    public JSONObject servicePackageSign(String jsonData,String doctorId,String patientId,String signYear) throws Exception{
        BasePatientDO patientDO = patientDao.findById(patientId);
        JSONObject result = new JSONObject();
        ServicePackageSignRecordDO signRecordDO = objectMapper.readValue(jsonData, ServicePackageSignRecordDO.class);
@ -338,9 +282,15 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
                BaseDoctorDO doctorDO = doctorDao.findById(doctorId);
                //需要新增签约记录
                signRecordDO.setStatus(1);
                int year;
                if("0".equals(signYear)){
                    year = 100;
                }else{
                    year = Integer.valueOf(signYear);
                }
                signRecordDO.setStartTime(new Date());
                Calendar cal = Calendar.getInstance();
                cal.add(Calendar.YEAR,1);
                cal.add(Calendar.YEAR,year);
                signRecordDO.setEndTime(cal.getTime());
                signRecordDO.setSignDoctor(doctorId);
                signRecordDO.setSignDoctorName(doctorDO.getName());
@ -354,15 +304,24 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
                    archiveDao.save(archiveDO);
                }
            }else{
                ArchiveDO archiveDO = archiveDao.findByPatientAndDoctorCode(patientId,doctorId);
                if(archiveDO!=null){
                    archiveDO.setSignStatus(1);
                    archiveDao.save(archiveDO);
                }
                signId = signRecordDOs.get(0).getId();
                List<ServicePackageRecordDO> existList = servicePackageRecordDao.findBySignId(signId);
                idList = existList.stream().map(ServicePackageRecordDO::getServicePackageId).collect(Collectors.toList());
                //不能重复签约
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                result.put(ResponseContant.resultMsg,"请勿重复签约");
                return result;
//                ArchiveDO archiveDO = archiveDao.findByPatientAndDoctorCode(patientId,doctorId);
//                if(archiveDO!=null){
//                    archiveDO.setSignStatus(1);
//                    archiveDao.save(archiveDO);
//                }
//                signId = signRecordDOs.get(0).getId();
//                List<ServicePackageRecordDO> existList = servicePackageRecordDao.findBySignId(signId);
//                idList = existList.stream().map(ServicePackageRecordDO::getServicePackageId).collect(Collectors.toList());
            }
        }else{
            //不能重复签约
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"请勿重复签约");
            return result;
        }
        //服务项目 emergencyAssistance 只能签约一个
@ -393,9 +352,9 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
               throw new Exception(message);
           }
        }
        CapacityAssessmentRecordDO capacityAssessmentRecordDO = capacityAssessmentRecordService.findAssessmentByPatientId(patientId);
        capacityAssessmentRecordDO.setServicePackageStatus(1);
        capacityAssessmentRecordService.save(capacityAssessmentRecordDO);
//        CapacityAssessmentRecordDO capacityAssessmentRecordDO = capacityAssessmentRecordService.findAssessmentByPatientId(patientId);
//        capacityAssessmentRecordDO.setServicePackageStatus(1);
//        capacityAssessmentRecordService.save(capacityAssessmentRecordDO);
        servicePackageRecordDao.save(recordDOList);
        //修改床位生请状态为已完成
@ -412,13 +371,15 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
    public PageEnvelop<List<Map<String,Object>>> servicePackagePage(int page, int size){
    public PageEnvelop<List<Map<String,Object>>> servicePackagePage(int page, int size,String orgCode){
        String sql = "SELECT p.id,p.`name`,p.type,p.introduce,p.num  ";
        String countSql = "SELECT count(*) ";
        String filters = "from base_service_package p " +
                "WHERE p.del = 1 ";
        if(!StringUtil.isBlank(orgCode)){
            filters += " and p.org_code = '"+orgCode+"'";
        }
        String orderBy = " ORDER BY p.create_time DESC " +
                "LIMIT "+ (page - 1) * size + "," + size;
@ -428,10 +389,6 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
            String id = map.get("id").toString();
            List<ServicePackageItemDO> itemDOList = servicePackageItemDao.findByServicePackageId(id);
            map.put("detail",itemDOList);
            List<Map<String,Object>> doctorList = fingdDoctorByPackageId(id,1);
            List<Map<String,Object>> helperList = fingdDoctorByPackageId(id,2);
            map.put("doctorList",doctorList);
            map.put("helperList",helperList);
        }
        Long count = jdbcTemplate.queryForObject(countSql+filters,Long.class);
        return PageEnvelop.getSuccessListWithPage("success",list,page,size,count);
@ -501,8 +458,7 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
    public List<Map<String, Object>> servicePackageByTopicType(String patient, String topicType)
    {
        String sql="\n" +
                "select  DISTINCT item.code serverItem,item.name,pack.introduce,pack.type packageType,pack.`name` packageName \n" +
        String sql="select  DISTINCT item.code serverItem,item.name,pack.introduce,pack.type packageType,pack.`name` packageName \n" +
                "from base_service_package_record re, base_service_package_item item,base_service_package pack \n" +
                "where re.service_package_id = item.service_package_id and item.service_package_id = pack.id\n" +
                " and pack.del=1 and  item.topic_item='"+topicType+"' and re.sign_id in (\n" +
@ -511,24 +467,11 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        return result;
    }
    public List<Map<String,Object>> getServerDoctorByPackage(String packageId,String serverItem){
        String sql="select DISTINCT doc.id doctor,CONCAT(doc.`name`,\n" +
                "CASE WHEN doc.doctor_level=1 THEN '(社区医生)' ELSE '(助老员)' END) as name,doc.photo,doc.mobile\n" +
                "from base_service_package_item item ,base_service_package pack,base_team_member mem,base_doctor doc\n" +
                "where item.`code`='"+serverItem+"' and item.service_package_id='"+packageId+"' and item.service_package_id = pack.id " +
                "and item.team_code = mem.team_code and mem.doctor_code = doc.id and mem.del=1 and pack.del=1 ";
        List<Map<String,Object>>result = jdbcTemplate.queryForList(sql);
        return result;
    }
    public List<Map<String,Object>> getServerDoctorAll(String patient,String onlineFlag){
        String sql="select DISTINCT doc.id doctor,CONCAT(doc.`name`,CASE WHEN doc.doctor_level=1 THEN '(社区医生)' ELSE '(助老员)' END) as name,doc.photo,doc.mobile,0 as onLineFlag\n" +
                "from base_service_package_item item ,base_service_package pack,base_team_member mem,base_doctor doc\n" +
                "where item.service_package_id in (\n" +
                "SELECT spc.service_package_id FROM base_service_package_record spc ,base_service_package_sign_record spsr\n" +
                "WHERE spc.patient = '"+patient+"' AND spsr.status = 1 AND spsr.patient = spc.patient\n" +
                ") and item.service_package_id = pack.id\n" +
                "and item.team_code = mem.team_code and mem.doctor_code = doc.id and mem.del=1 and pack.del=1 and item.del = 1";
        String sql="select DISTINCT doc.id doctor,CONCAT(doc.`name`,CASE WHEN doc.doctor_level=1 THEN '(社区医生)' ELSE '(助老员)' END) as name,doc.photo,doc.mobile,0 as onLineFlag " +
                "from base_service_package_sign_record spsr,base_team_member mem,base_doctor doc " +
                "WHERE spsr.patient = '"+patient+"' AND spsr.status = 1  " +
                "and spsr.team_code = mem.team_code and mem.doctor_code = doc.id and mem.del=1 ";
        List<Map<String,Object>>result = jdbcTemplate.queryForList(sql);
        if ("1".equals(onlineFlag)){//展示是否在线
            String listStr = imUtil.getOnlineListByType("helper");
@ -582,4 +525,59 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        }
        return jdbcTemplate.queryForList(sql);
    }
    /**
     * 查找居民签约记录
     * @param patient
     */
    public List<Map<String,Object>> findPatientSignList(String patient){
        String sql = "SELECT r.id,sr.team_code teamCode,sr.id signId, DATE_FORMAT(sr.create_time,'%Y-%m-%d %H:%i:%S') createTime, " +
                " DATE_FORMAT(sr.start_time,'%Y-%m-%d %H:%i:%S')  startTime, " +
                " DATE_FORMAT(sr.end_time,'%Y-%m-%d %H:%i:%S') endTime,p.name,sr.`status`,p.org_code orgCode,p.org_name orgName " +
                "FROM " +
                " base_service_package_sign_record sr, " +
                " base_service_package_record r, " +
                " base_service_package p " +
                "WHERE " +
                " sr.id = r.sign_id and r.service_package_id = p.id " +
                "AND sr.patient = '"+patient+"' ORDER BY sr.create_time desc";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        String doctorSql = "SELECT d.name from base_team_member t,base_doctor d WHERE t.id = ? and t.doctor_code = d.id and d.del = 1 and t.del =1";
        for(Map<String,Object> map:list){
            List<String> doctorList = new ArrayList<>();
            if(map.get("teamCode")!=null){
                String teamCode = map.get("teamCode")+"";
                try {
                    doctorList = jdbcTemplate.queryForList(doctorSql,String.class, teamCode);
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
            map.put("doctorList",doctorList);
        }
        return list;
    }
    /**
     * 签约服务包详情
     * @param id
     */
    public Map<String,Object> signPackageDetail(String id){
        String orgSql = "SELECT o.id,o.code,o.name,o.address,o.photo FROM " +
                " base_org o, " +
                " base_service_package_record r, " +
                " base_service_package p " +
                "WHERE " +
                " p.org_code = o.id and r.service_package_id = p.id " +
                "AND r.id = '"+id+"' ";
        String doctorSql = "SELECT d.* from base_team_member t,base_doctor d,base_service_package_record r,base_service_package_sign_record sr" +
                " WHERE r.id = '"+id+"' and r.sign_id=sr.id and t.id = sr.team_code and t.doctor_code = d.id and d.del = 1 and t.del =1";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(orgSql);
        Map<String,Object> result = list.get(0);
        List<BaseDoctorDO> doctorDOList = jdbcTemplate.query(doctorSql, new BeanPropertyRowMapper<>(BaseDoctorDO.class));
        result.put("doctorDOList",doctorDOList);
        return result;
    }
}