package com.yihu.rehabilitation.service; import com.alibaba.fastjson.JSON; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.yihu.fastdfs.FastDFSUtil; import com.yihu.jw.doctor.dao.BaseDoctorDao; import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao; import com.yihu.jw.entity.base.doctor.BaseDoctorDO; import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO; import com.yihu.jw.entity.base.patient.BasePatientDO; import com.yihu.jw.entity.base.team.BaseTeamMemberDO; import com.yihu.jw.entity.base.wx.WxWechatDO; import com.yihu.jw.entity.door.SignFamily; import com.yihu.jw.entity.hospital.doctor.Frequency; import com.yihu.jw.entity.patient.Message; import com.yihu.jw.entity.specialist.rehabilitation.PatientRehabilitationPlanDO; import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationDetailDO; import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationOperateRecordsDO; import com.yihu.jw.entity.util.TransforSqlUtl; import com.yihu.jw.file_upload.FileUploadService; import com.yihu.jw.org.dao.BaseOrgDao; import com.yihu.jw.patient.dao.BasePatientDao; import com.yihu.jw.rehabilitation.RehabilitationOperateRecordsDao; import com.yihu.jw.restmodel.iot.common.UploadVO; import com.yihu.jw.restmodel.web.Envelop; import com.yihu.jw.restmodel.web.MixEnvelop; import com.yihu.jw.restmodel.web.ObjEnvelop; import com.yihu.jw.rm.specialist.SpecialistMapping; import com.yihu.jw.sign.dao.MessagesDao; import com.yihu.jw.team.BaseDoctorTeamMemberDao; import com.yihu.jw.util.common.QrcodeUtil; import com.yihu.jw.util.date.DateUtil; import com.yihu.jw.utils.hibernate.HibenateUtils; import com.yihu.jw.wechat.dao.WechatDao; import com.yihu.mysql.query.BaseJpaService; import com.yihu.rehabilitation.dao.FrequencyDao; import com.yihu.rehabilitation.dao.PatientRehabilitationPlanDao; import com.yihu.rehabilitation.dao.RehabilitationDetailDao; import com.yihu.rehabilitation.dao.SignFamilyDao; import com.yihu.utils.network.HttpResponse; import com.yihu.utils.network.HttpUtils; import com.yihu.utils.security.MD5; import org.apache.commons.collections.map.HashedMap; import org.apache.commons.lang3.StringUtils; import org.json.JSONArray; import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.mock.web.MockMultipartFile; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.io.InputStream; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; /** * Created by humingfen on 2018/8/22. */ @Service @Transactional public class RehabilitationPlanService extends BaseJpaService { @Value("${specialist.url}") private String specialistUrl; @Autowired private SpecialistEvaluateSevice specialistEvaluateSevice; @Autowired private SignFamilyDao signFamilyDao; @Autowired private MessagesDao messageDao; @Autowired private BasePatientDao patientDao; @Autowired private JdbcTemplate jdbcTemplate; @Autowired private FrequencyDao frequencyDao; @Autowired private BaseDoctorDao doctorDao; @Autowired private PatientRehabilitationPlanDao patientRehabilitationPlanDao; @Autowired private ObjectMapper objectMapper; @Autowired private RehabilitationDetailDao rehabilitationDetailDao; @Value("${neiwang.enable}") private Boolean isneiwang; //如果不是内网项目要转到到内网wlyy在上传 @Autowired private FastDFSUtil fastDFSUtil; @Value("${fastDFS.fastdfs_file_url}") private String fastdfs_file_url; @Autowired FileUploadService fileUploadService; @Value("${testPattern.sign}") private String isClose; @Value("${testPattern.remote_inner_url}") private String remote_inner_url; @Autowired private WechatDao wechatDao; @Value("${wechat.id}") private String wxId; @Autowired private RehabilitationOperateRecordsDao rehabilitationOperateRecordsDao; @Autowired private BaseOrgDao baseOrgDao; @Autowired private BaseDoctorTeamMemberDao baseDoctorTeamMemberDao; @Autowired private BaseDoctorHospitalDao baseDoctorHospitalDao; @Autowired private HibenateUtils hibenateUtils; public Envelop updatePatientImgById(String planId, String patientImg) { if(patientRehabilitationPlanDao.updatePatientImgById(planId,patientImg) > 0){ return Envelop.getSuccess(SpecialistMapping.api_success); } return Envelop.getError("更新失败!"); } /*public JSONArray findTemplateInfo(String doctor, String patient) throws Exception { Map param = new HashedMap(); Long adminTeamId = null; AdminTeam team = teamService.findByLeaderCode(doctor); if(StringUtils.isBlank(patient)){ adminTeamId = team.getId(); param.put("adminTeamCode", adminTeamId); }else { param.put("doctor", doctor); param.put("patient", patient); } HttpResponse response = null; try { response = HttpUtils.doGet(specialistUrl + "svr-specialist/findRehabilitationPlanTemplate", param); } catch (Exception e) { e.printStackTrace(); } JSONObject rs = new JSONObject(response.getContent()); if ("success".equals(rs.getString("message"))) { return rs.getJSONArray("detailModelList"); } throw new Exception("请求获取模板列表失败!"); }*/ public List createRehabilitationDetail(List details, String planId,String createUser,String createUserName) { for(RehabilitationDetailDO detail : details) { /*List list = new ArrayList<>(); list.add(detail.getHospitalServiceItemId()); HospitalServiceItemDO hospitalServiceItemDO = hospitalServiceItemService.selectById(list).getDetailModelList().get(0); detail.setHospital(hospitalServiceItemDO.getHospital()); detail.setHospitalName(hospitalServiceItemDO.getHospitalName()); detail.setExpense(hospitalServiceItemDO.getExpense());*/ detail.setPlanId(planId); detail.setCreateTime(new Date()); detail.setStatus(0); detail.setUpdateTime(new Date()); detail.setCreateUser(createUser); detail.setCreateUserName(createUserName); } return (List)rehabilitationDetailDao.save(details); } //code,timeType,executeTimes public String createRehabilitationPlan(String json, BaseDoctorDO doctor) throws Exception { JSONObject object = new JSONObject(json); String patient = object.getString("patient"); BasePatientDO patientDo = null; if (!StringUtils.isNoneBlank(patient)){ BasePatientDO basePatientDO = new BasePatientDO(); basePatientDO.setName(object.getString("patientName")); basePatientDO.setIdcard(object.getString("idCard")); basePatientDO.setMobile(object.getString("mobile")); patientDo = saveUnSignPatient(basePatientDO); }else { patientDo = patientDao.findById(patient); } String patientName=""; if(patientDo!=null){ patientName = patientDo.getName(); } JSONArray array = object.getJSONArray("detail"); for (int z=0;z list = new ArrayList<>(); if (StringUtils.isNoneBlank(executeTimes)){ for (int i=0;i times = getFrequencyDate(frequency.getCode(),executeTime[i],frequency.getUnit(),frequency.getTime(),timeType); for (int j=0;j details = objectMapper.readValue(planDetails, new TypeReference>(){}); PatientRehabilitationPlanDO planDO = objectMapper.readValue(json.toString(), PatientRehabilitationPlanDO.class); planDO.setCreateUser(doctor.getId()); planDO.setCreateUserName(doctor.getName()); planDO = createPatientRehabilitationPlan(planDO); details = createRehabilitationDetail(details, planDO.getId(),doctor.getId(),doctor.getName()); //康复计划创建完给执行者发送消息 String planId = null; HashSet set = new HashSet(); for ( RehabilitationDetailDO rehabilitationDetailDO : details) { if (!set.contains(rehabilitationDetailDO.getDoctor())) { set.add(rehabilitationDetailDO.getDoctor()); planId = rehabilitationDetailDO.getPlanId(); Message message = new Message(); message.setSender(doctor.getId()); message.setType(19); message.setRelationCode(rehabilitationDetailDO.getPlanId()); message.setReceiver(rehabilitationDetailDO.getDoctor()); message.setReason(doctor.getName()); specialistEvaluateSevice.sendMessage(message, rehabilitationDetailDO.getHospital(), patient, null,null); //pushMsgTask.put(rehabilitationDetailDO.getDoctor(),"20", "康复计划创建消息", "您的居民"+patientName+"的康复计划已配置完成,点击查看", ""); } } SignFamily signFamily = signFamilyDao.findByPatient(patient); //推送消息到IM if (signFamily != null && !set.contains(signFamily.getDoctor())) { //pushMsgTask.put(signFamily.getDoctor(),"20", "康复计划创建消息", "您的居民"+patientName+"的康复计划已配置完成,点击查看", ""); } return planId; } public MixEnvelop createServiceQrCode(String planDetailId, String doctorCode) throws Exception{ //更新到康复计划居民关系表中 Map param = new HashedMap(); String fileUrl = ""; String sql ="SELECT service_qr_code FROM wlyy_specialist.wlyy_rehabilitation_plan_detail where id='"+planDetailId+"'"; List> list = jdbcTemplate.queryForList(sql); if(list!=null && list.size()>0){ fileUrl = String.valueOf(list.get(0).get("service_qr_code")); } if (StringUtils.isEmpty(fileUrl) || "null".equals(fileUrl)){ //生成二维码图片 WxWechatDO wxWechatDO = wechatDao.findById(wxId); String appId=""; String wechat_base_url=""; if (wxWechatDO!=null){ appId=wxWechatDO.getAppId(); wechat_base_url=wxWechatDO.getBaseUrl(); } String contentJsonStr="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appId+"&redirect_uri="+wechat_base_url+"/wx/html/kfgl/html/confirm-service.html"+"?paramStr="+planDetailId+","+doctorCode+"&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"; InputStream ipt = QrcodeUtil.createQrcode(contentJsonStr, 300, "png"); UploadVO uploadVO = new UploadVO(); String originalFilename ="plan_service_qrcode" + System.currentTimeMillis()+".png"; if (isClose.equalsIgnoreCase("1")){ Map map = fileUploadService.uploadImg(new MockMultipartFile(originalFilename,originalFilename,"", ipt)); uploadVO.setFullUri(map.get("accessory").toString()); }else if(isClose.equals("2")){ //内网上传 String rs = fileUploadService.request(remote_inner_url,new MockMultipartFile(originalFilename,originalFilename,"", ipt),null); com.alibaba.fastjson.JSONObject json = JSON.parseObject(rs); uploadVO = objectMapper.readValue(json.getJSONObject("obj").toJSONString(),UploadVO.class); }else { // 得到文件的完整名称 xxx.txt /*InputStream inputStream = ipt;*/ uploadVO = fileUploadService.uploadStream(ipt,originalFilename,fastdfs_file_url); } fileUrl = uploadVO.getFullUri(); } System.out.println("服务码-----------1"+fileUrl); String sqlUpdate = "update wlyy_rehabilitation_plan_detail set service_qr_code='" + fileUrl + "' where id='" + planDetailId + "'"; jdbcTemplate.update(sqlUpdate); return MixEnvelop.getSuccess("获取二维码成功!",fileUrl); } public Map checkAfterQrCode(String planDetailId,String patietCode)throws Exception{ Map map = new HashedMap(); int result = 0; String name= ""; String sql ="SELECT p.patient,p.name FROM `wlyy_rehabilitation_plan_detail` pd LEFT JOIN wlyy_patient_rehabilitation_plan p ON pd.plan_id = p.id WHERE pd.id='"+planDetailId+"'"; sql = TransforSqlUtl.wlyy_patient_rehabilitation_planName(sql); List> list = jdbcTemplate.queryForList(sql); if (list!=null && list.size()>0){ if (String.valueOf(list.get(0).get("patient")).equals(patietCode)){ result =200; }else { result = -1; name=String.valueOf(list.get(0).get("name")); } }else { result = -10000; } map.put("code",result); if (StringUtils.isNotBlank(name)){ map.put("name",name); } return map; } public PatientRehabilitationPlanDO createPatientRehabilitationPlan(PatientRehabilitationPlanDO planDO) { planDO.setCreateTime(new Date()); planDO.setStatus(1); planDO.setUpdateTime(new Date()); return patientRehabilitationPlanDao.save(planDO); } public List getFrequencyDate(String code,String date,String unit,String time,Long timeType) throws ParseException { List list = new ArrayList<>(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String nowDate = date+":00"; Date date6 = DateUtil.strToDateLong(nowDate); String date9 = sdf.format(date6)+" 09:00:00";//白天 String date21 = sdf.format(date6)+" 21:00:00";//白天 String date9s = DateUtil.getNextDay(date6,1)+" 09:00:00";//晚上 Calendar calendar = Calendar.getInstance(); if (unit.equalsIgnoreCase("D")&&!code.equalsIgnoreCase("qod")){ String[] str = time.split(","); for (int i=0;i param = new HashedMap(); param.put("id", templateId); HttpResponse response = null; try { response = HttpUtils.doPost(specialistUrl + "svr-specialist/deleteRehabilitationPlanTemplate", param); } catch (Exception e) { e.printStackTrace(); } JSONObject rs = new JSONObject(response.getContent()); return rs.getString("message"); } /** * 更新计划的状态 * @param planId * @param status * @throws Exception */ public void updatePlanStatusById(String planId, Integer status,String abortReason) throws Exception{ Map param = new HashedMap(); param.put("planId", planId); param.put("status", status); param.put("abortReason",abortReason); HttpResponse response = HttpUtils.doPost(specialistUrl + "svr-specialist/updatePlanStatusById", param); JSONObject result = new JSONObject(response.getContent()); if (result.getInt("status")==200 && status==0){ List messageList = new ArrayList<>(); Map recieveMap = new HashMap<>(); JSONObject jsonObject =result.getJSONObject("obj"); String patientCode = jsonObject.getString("patient"); String patientName = jsonObject.getString("name"); String diseaseName = jsonObject.getString("diseaseName"); String createDoctorCode = jsonObject.getString("createUser"); JSONArray detailModelList = result.getJSONArray("detailModelList"); for (Object obj : detailModelList) { JSONObject detail = (JSONObject) obj; String doctor = detail.getString("doctor"); if (!createDoctorCode.equals(doctor)){ if (!recieveMap.containsKey(doctor)){ recieveMap.put(doctor,detail.getString("doctorName")); } } } SignFamily signFamily = signFamilyDao.findByPatient(patientCode); if (signFamily!=null){ if (!recieveMap.containsKey(signFamily.getDoctor())){ recieveMap.put(signFamily.getDoctor(),signFamily.getDoctorName()); } } for (Map.Entry entry : recieveMap.entrySet()){ //推送消息到IM //pushMsgTask.put(entry.getKey(),"20", "康复计划中止消息", "您的居民"+patientName+",已中止"+diseaseName+"康复计划,点击查看原因", ""); Message message = initMessage(patientName,entry.getKey(),entry.getValue(),"system","system","康复计划-中止提醒","您的居民"+patientName+",已中止"+diseaseName+"康复计划,点击查看原因。",planId,29); messageList.add(message); } messageDao.save(messageList); /*Message message = new Message(); message.setCzrq(new Date()); message.setCreateTime(new Date()); message.setContent("您的"+patientName+"签约居民,已中止康复计划,点击查看原因。"); message.setRead(1);//设置未读 if (signFamily!=null){ message.setReceiver(signFamily.getDoctor());//设置接受医生的code message.setReceiverName(signFamily.getDoctorName()); } message.setSender("system");//设置发送的用户 message.setSenderName("system"); message.setCode(UUID.randomUUID().toString().replaceAll("-", "")); message.setSenderPhoto(""); message.setTitle("康复计划-中止提醒"); message.setType(29);//康复计划中止消息提醒 message.setReadonly(1);//是否只读消息 message.setRelationCode(planId); message.setOver("1");//未处理 message.setState(1); message.setData(""); message.setDel("1");*/ //推送消息到IM // pushMsgTask.put(signFamily.getDoctor(),"20", "康复计划中止消息", "您的"+patientName+"签约居民,已中止康复计划,点击查看原因", ""); } if(result.getInt("status")!=200){ throw new Exception("请求微服务失败!"); } } private Message initMessage(String patientName,String doctor,String doctorName,String sender,String senderName,String title,String content,String relatioenCode,int type){ Message message = new Message(); message.setCzrq(new Date()); message.setCreateTime(new Date()); message.setContent("您的服务居民"+patientName+",已中止康复计划,点击查看原因。"); message.setRead(1);//设置未读 message.setReceiver(doctor);//设置接受医生的code message.setReceiverName(doctorName); message.setSender(sender);//设置发送的用户 message.setSenderName(senderName); message.setCode(UUID.randomUUID().toString().replaceAll("-", "")); message.setSenderPhoto(""); message.setTitle(title); message.setType(type);//康复计划中止消息提醒 message.setReadonly(1);//是否只读消息 message.setRelationCode(relatioenCode); message.setOver("0");//未处理 message.setState(1); message.setData(""); message.setDel("1"); return message; } public JSONObject getServiceItemsAfterStop(String planId)throws Exception{ Map param = new HashedMap(); param.put("planId", planId); HttpResponse response = HttpUtils.doGet(specialistUrl + "svr-specialist/getServiceItemsAfterStop", param); JSONObject result = new JSONObject(response.getContent()); JSONObject jsonObject = new JSONObject(); if(result.getInt("status")!=200){ throw new Exception("请求微服务失败!"); } if (result.getInt("status")==200){ jsonObject = result.getJSONObject("obj"); JSONArray jsonArray = jsonObject.getJSONArray("serviceList"); if (jsonArray!=null && jsonArray.length()>0){ jsonObject.put("patientName",jsonArray.getJSONObject(0).get("name")); jsonObject.put("abortTime",jsonArray.getJSONObject(0).get("abort_time")); jsonObject.put("hospitalName",jsonArray.getJSONObject(0).get("hospital_name")); jsonObject.put("abortReason",jsonArray.getJSONObject(0).get("abort_reason")); String patientCode = String.valueOf(jsonArray.getJSONObject(0).get("patient")); jsonObject.put("patientCode", patientCode); jsonObject.put("disease_name", jsonArray.getJSONObject(0).get("disease_name")); jsonObject.put("create_time", jsonArray.getJSONObject(0).get("create_time")); jsonObject.put("patient_img", jsonArray.getJSONObject(0).get("patient_img")); BasePatientDO patient = patientDao.findById(patientCode); if (patient!=null){ jsonObject.put("openid", patient.getOpenid()); jsonObject.put("ssc",patient.getSsc()); jsonObject.put("mobile",patient.getMobile()); } } } return jsonObject; } /** * 更新居民签名照/证件照 * @param planId * @throws Exception *//* public void updatePatientImgById(String planId, String patientImg) throws Exception { Map param = new HashedMap(); param.put("planId", planId); param.put("patientImg", patientImg); HttpResponse response = HttpUtils.doPost(specialistUrl + "svr-specialist/updatePatientImgById", param); JSONObject result = new JSONObject(response.getContent()); if(result.getInt("status")!=200){ throw new Exception("请求微服务失败!"); } }*/ public void sendWxTemplate(String accessToken, String planId, String doctorCode, JSONObject jsonObject) { BaseDoctorDO d = doctorDao.findById(doctorCode); JSONObject json = new JSONObject(); String patient = jsonObject.getString("patientCode"); String patientName = jsonObject.get("patientName") + ""; json.put("first", patientName + "您好,您有一个康复计划已完成,请确认接收。"); json.put("toUser", patient); json.put("represented", patient);//被代理人 json.put("keyword1", jsonObject.get("disease_name") + "康复计划"); json.put("keyword2", d.getName()); json.put("keyword3", DateUtil.dateToStr(new Date ((Long) jsonObject.get("create_time")), "yyyy/MM/dd") + "-" + DateUtil.dateToStr(new Date(), "yyyy/MM/dd")); json.put("remark", "完成的康复项清单已发送给您,点击此消息可查看。"); json.put("planId", planId); if (!jsonObject.isNull("openid")) { //pushMsgTask.putWxMsg(accessToken, 27, jsonObject.get("openid") + "", patientName, json); }/*else { try { //发送代理人 JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openid); if (jsonArray != null && jsonArray.length() > 0) { Patient p = patientDao.findByCode(patient); for (int i = 0; i < jsonArray.length(); i++) { JSONObject j = jsonArray.getJSONObject(i); Patient member = (Patient) j.get("member"); JSONObject data = json; data.remove("toUser"); data.put("toUser", member.getCode()); data.remove("first"); json.put("first", weiXinOpenIdUtils.getTitleMes(p, (int) j.get("relation"), p.getName())); pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 27, member.getOpenid(), p.getName(), data); } } } catch (Exception e) { e.printStackTrace(); } }*/ } public BasePatientDO saveUnSignPatient(BasePatientDO basepatientDO){ basepatientDO.setDel("1"); basepatientDO.setLocked(0); basepatientDO.setEnabled(1); String salt = randomString(5); basepatientDO.setSalt(salt); basepatientDO.setPassword(MD5.md5Hex(basepatientDO.getIdcard().substring(12,18) + "{" + salt + "}")); basepatientDO=patientDao.save(basepatientDO); return basepatientDO; } public RehabilitationOperateRecordsDO saveRehabilitationRecord(RehabilitationOperateRecordsDO rehabilitationOperateRecordsDO){ RehabilitationDetailDO rehabilitationDetailDO = rehabilitationDetailDao.findById(rehabilitationOperateRecordsDO.getRehabilitationDetailId()); if (!StringUtils.isNoneBlank(rehabilitationOperateRecordsDO.getId())){ rehabilitationOperateRecordsDO.setId(getCode()); } if (rehabilitationDetailDO.getExecuteTime()!=null){ rehabilitationOperateRecordsDO.setReserveTime(rehabilitationDetailDO.getExecuteTime()); } rehabilitationOperateRecordsDO.setCompleteTime(new Date()); rehabilitationOperateRecordsDO.setCreateTime(new Date()); rehabilitationOperateRecordsDO.setUpdateTime(new Date()); rehabilitationOperateRecordsDO.setStatus(rehabilitationOperateRecordsDO.getStatus()); if (StringUtils.isEmpty(rehabilitationOperateRecordsDO.getPatientName())){ String sql ="select name from base_patient where id='"+rehabilitationOperateRecordsDO.getPatientCode()+"'"; List> list = jdbcTemplate.queryForList(sql); if (list!=null && list.size()>0){ rehabilitationOperateRecordsDO.setPatientName(String.valueOf(list.get(0).get("name"))); } } return rehabilitationOperateRecordsDao.save(rehabilitationOperateRecordsDO); } /** * 更新康复计划项目状态 * @param status * @param planId * @return */ public MixEnvelop updatePlanStatusById(Integer status, String planId) throws Exception{ if(status == 1) { if (patientRehabilitationPlanDao.updateStatusById(status, planId) > 0) { return MixEnvelop.getSuccess(SpecialistMapping.api_success, patientRehabilitationPlanDao.findById(planId)); } }else if(status == 2){ if (patientRehabilitationPlanDao.updateStatusAndTimeById(2,planId, new Date()) > 0) { return MixEnvelop.getSuccess(SpecialistMapping.api_success, patientRehabilitationPlanDao.findById(planId)); } } return MixEnvelop.getError("更新失败!"); } public MixEnvelop abortPlanById(String planId,String abortReason){ PatientRehabilitationPlanDO patientRehabilitationPlanDO=patientRehabilitationPlanDao.findById(planId); List detailDOList = rehabilitationDetailDao.findByPlanIdAndStatus(planId,0); if(null!=patientRehabilitationPlanDO){ patientRehabilitationPlanDO.setAbortReason(abortReason); patientRehabilitationPlanDO.setAbortTime(new Date()); patientRehabilitationPlanDO.setStatus(0); patientRehabilitationPlanDO.setUpdateTime(new Date()); patientRehabilitationPlanDao.save(patientRehabilitationPlanDO); return MixEnvelop.getSuccess(SpecialistMapping.api_success,patientRehabilitationPlanDO,detailDOList); } return MixEnvelop.getError("更新失败!"); } public ObjEnvelop findServiceItemByDoctor(String doctor){ String teamCode=""; String orgCode=""; List baseTeamMemberDO = baseDoctorTeamMemberDao.findUseDoctorCode(doctor); if (baseTeamMemberDO!=null&&baseTeamMemberDO.size()>0){ teamCode= baseTeamMemberDO.get(0).getTeamCode(); } List baseDoctorHospitalDO = baseDoctorHospitalDao.findByDoctorCode(doctor); if (baseDoctorHospitalDO!=null&&baseDoctorHospitalDO.size()>0){ orgCode= baseDoctorHospitalDO.get(0).getOrgCode(); } String packageSql = "select m.service_package_id as \"servicePackageId\"," + " n.name as \"name\"" + "from base_service_package_item m left join base_service_package_item n on" + " m.service_package_id = n.id where 1=1 and m.service_package_id !='system' "; if(StringUtils.isNoneBlank(teamCode)){ packageSql+= " and m.team_code ='"+teamCode+"'"; }else { return null; } if(StringUtils.isNoneBlank(orgCode)){ packageSql+= " and m.org_code ='"+orgCode+"'"; }else { return null; } packageSql+=" group by m.service_package_id,n.name "; List> listPackage = hibenateUtils.createSQLQuery(packageSql); for (Map map:listPackage){ if (map.get("servicePackageId")!=null){ String sql = "select t.id as \"id\"," + " t.code as \"code\"," + " t.name as \"name\"," + " t.service_package_id as \"servicePackageId\"," + " t.price as \"price\"," + " t.fee_type as \"feeType\"," + " t.org_code as \"orgCode\"," + " t.org_name as \"orgName\"," + " t.introduce as \"introduce\"," + " t.del as \"del\"," + " t.team_code as \"teamCode\"," + " t.team_name as \"teamName\"," + " t.create_time as \"createTime\"," + " t.dict_id as \"dictId\"" + " from base_service_package_item t where 1=1 and t.service_package_id !='system' "; if (StringUtils.isNoneBlank(teamCode)) { sql += " and t.team_code ='" + teamCode + "'"; } if (StringUtils.isNoneBlank(orgCode)) { sql += " and t.org_code ='" + orgCode + "'"; } sql+=" and t.service_package_id = '"+map.get("servicePackageId").toString()+"'"; List> list = hibenateUtils.createSQLQuery(sql); map.put("itemList",list); } } return ObjEnvelop.getSuccess("操作成功",listPackage); } public List> findServiceItemInBase(String code,String name,String teamCode){ String sql = "select t.id as \"id\"," + " t.code as \"code\"," + " t.name as \"name\"," + " t.service_package_id as \"servicePackageId\"," + " t.price as \"price\"," + " t.fee_type as \"feeType\"," + " t.org_code as \"orgCode\"," + " t.org_name as \"orgName\"," + " t.introduce as \"introduce\"," + " t.del as \"del\"," + " t.team_code as \"teamCode\"," + " t.team_name as \"teamName\"," + " t.create_time as \"createTime\"," + " t.dict_id as \"dictId\"" + " from base_service_package_item t where 1=1 and t.service_package_id ='system' and t.del ='1'"; if (StringUtils.isNoneBlank(teamCode)) { sql += " and t.team_code ='" + teamCode + "'"; } if (StringUtils.isNoneBlank(code)) { sql += " and t.code ='" + code + "'"; } if (StringUtils.isNoneBlank(name)) { sql += " and t.name ='" + name + "'"; } List> list = hibenateUtils.createSQLQuery(sql); return list; } }