Ver código fonte

计免提醒接口完善;支付接口只有集美街道有使用权限

zd_123 6 anos atrás
pai
commit
f2fcffec27

+ 154 - 10
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/imm/ChildFamilyImmuneService.java

@ -17,6 +17,7 @@ import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.third.guahao.ImmuneService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import io.searchbox.client.JestClient;
import org.apache.commons.lang.StringUtils;
@ -128,21 +129,56 @@ public class ChildFamilyImmuneService extends BaseService {
	/**
	 * 获取签约居民待接种疫苗列表
	 * @param doctorcode
	 * @param doctorcode,limitType 1要分页 0不用分页
	 * @return
	 */
	public List<Map<String,Object>> getImmVaccinList(String doctorcode,int pageNo,int pageSize) {
		String sql = "select t.*,m.family_name,m.child_name,m.birthday from wlyy_child_immune_vaccin t " +
	public List<Map<String,Object>> getImmVaccinList(String doctorcode,int pageNo,int pageSize,int limitType) {
		String sql = "select DISTINCT t.*,m.child_name,m.birthday,m.childCode from wlyy_child_immune_vaccin t " +
				" inner join ( " +
				" select a.*,b.name as family_name ,c.name as child_name,c.barcode as barcode ,c.birthday as birthday from  wlyy_child_family_immune a " +
				" select a.*,b.name as family_name ,c.name as child_name,c.barcode as barcode ,c.birthday as birthday,c.`code` AS childCode from  wlyy_child_family_immune a " +
				" inner join (select patient,name from wlyy_sign_family where type in (1,2) and `status` = 1 and expenses_status = 1 and doctor = '"+doctorcode+"') b " +
				" on a.family_code = b.patient " +
				" left join wlyy_child_info c on c.`code` = a.child_code " +
				") m on m.barcode = t.barcode ";
		int start = (pageNo-1)*pageSize;
		sql +=" limit "+start+","+pageSize;
		if (limitType==1){
			int start = (pageNo-1)*pageSize;
			sql +=" limit "+start+","+pageSize;
		}
		List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql);
		for (Map<String,Object> map : rs){
			String childCode = String.valueOf(map.get("childCode"));
			String familyName="";
			String familySql ="SELECT" +
					" a.*, b. NAME AS family_name," +
					" c. NAME AS child_name," +
					" c.barcode AS barcode," +
					" c.birthday AS birthday," +
					" c.`code` AS childCode" +
					" FROM" +
					" wlyy_child_family_immune a" +
					" INNER JOIN (" +
					" SELECT" +
					" patient," +
					" NAME" +
					" FROM" +
					" wlyy_sign_family" +
					" WHERE" +
					" type IN (1, 2)" +
					" AND `status` = 1" +
					" AND expenses_status = 1" +
					" AND doctor = '"+doctorcode+"'" +
					" ) b ON a.family_code = b.patient" +
					" LEFT JOIN wlyy_child_info c ON c.`code` = a.child_code where  a.child_code='"+childCode+"'";
			List<Map<String,Object>> familyList = jdbcTemplate.queryForList(familySql);
			for (Map<String,Object> map1 : familyList){
				familyName +=String.valueOf(map1.get("family_name"))+"、";
			}
			if (familyName.length()>1){
				familyName = familyName.substring(0,familyName.length()-1);
			}
			map.put("family_name",familyName);
		}
		return rs;
	}
@ -157,9 +193,10 @@ public class ChildFamilyImmuneService extends BaseService {
		return childImmuneVaccinDao.getChildImmuneVaccinByBarcode(barcode);
	}
	public boolean alertImmVacclinByChildInfoCodes(String alertDataJsonStr, String doctor)throws Exception{
	public int alertImmVacclinByChildInfoCodes(String alertDataJsonStr, String doctor)throws Exception{
		if (StringUtils.isEmpty(alertDataJsonStr)){
			return false;
			return -1;
		}
		Doctor doctorObj = doctorDao.findByCode(doctor);
		String doctorName = "";
@ -197,6 +234,9 @@ public class ChildFamilyImmuneService extends BaseService {
					" cfi.child_code = '"+childCode+"'" +
					" AND cfi.del = 0 and (p.openid is not null or p.openid !='')";
			List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
			if (list.size()==0){
				return -10000;
			}
			List<String> openIdList = new ArrayList<>();
			for (Map<String,Object> map : list){
				//如果父母亲都在就都发
@ -239,7 +279,93 @@ public class ChildFamilyImmuneService extends BaseService {
			}
		}
		//保存到es的提醒日志表中
		return esSavePatientRemindRecord(patientRemindRecordESDOList);
		esSavePatientRemindRecord(patientRemindRecordESDOList);
		return 200;
	}
	public int alertImmVacclinByChildInfoCode(String alertDataJsonStr, String doctor)throws Exception{
		if (StringUtils.isEmpty(alertDataJsonStr)){
			return -1;
		}
		Doctor doctorObj = doctorDao.findByCode(doctor);
		String doctorName = "";
		String doctorLevel = "";
		if (doctorObj!=null){
			doctorName = doctorObj.getName();
			if (doctorObj.getLevel()==1) {
				doctorLevel="专科";
			}
			if (doctorObj.getLevel()==2) {
				doctorLevel="全科";
			}
			if (doctorObj.getLevel()==3){
				doctorLevel="健管";
			}
		}
		List<PatientRemindRecordESDO> patientRemindRecordESDOList = new ArrayList<>();
		JSONObject jsonObject = new JSONObject(alertDataJsonStr);
		String childCode = jsonObject.getString("childCode");
		String childName = jsonObject.getString("childName");
		String vaccinName = jsonObject.getString("vaccinName");
		String vaccinCode = jsonObject.getString("vaccinCode");
		String sql ="SELECT" +
				" cfi.relation," +
				" p.`code`," +
				" p.`name`," +
				" p.openid" +
				" FROM" +
				" wlyy_child_family_immune cfi" +
				" LEFT JOIN wlyy_patient p ON cfi.family_code = p.`code`" +
				" WHERE" +
				" cfi.child_code = '"+childCode+"'" +
				" AND cfi.del = 0 and (p.openid is not null or p.openid !='')";
		List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
		if (list.size()==0){
			return -10000;
		}
		List<String> openIdList = new ArrayList<>();
		for (Map<String,Object> map : list){
			//如果父母亲都在就都发
			if (!openIdList.contains(String.valueOf(map.get("openid")))){
				if (("1".equals(String.valueOf(map.get("relation"))) || "2".equals(String.valueOf(map.get("relation")))) && StringUtils.isNotBlank(String.valueOf(map.get("openid")))){
					boolean flag =true;
					try {
						WechatTemplateConfig temp = templateConfigDao.findByScene("template_deal_with", "ymjztx");
						JSONObject json = new JSONObject();
						json.put("toUser",String.valueOf(map.get("code")));
						json.put("keyword1", temp.getKeyword1().replace("key1",DateUtil.dateToStr(new Date(), "yyyy-MM-dd")));
						json.put("keyword2", temp.getKeyword2().replace("key1", doctorName+"("+doctorLevel+")"));
						json.put("remark", temp.getRemark());
						json.put("first", temp.getFirst().replace("key1",String.valueOf(map.get("name"))).replace("key2", childName).replace("key3",vaccinName));
						logger.info("weiTempJOSN:"+json.toString());
						pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 24,String.valueOf(map.get("openid")) , String.valueOf(map.get("name")), json);
					}catch (Exception e){
						e.printStackTrace();
						flag = false;
					}
					//发送微信消息并且插入一条es提醒数据
					PatientRemindRecordESDO patientRemindRecordESDO =  new PatientRemindRecordESDO();
					patientRemindRecordESDO.setCode(getCode());
					patientRemindRecordESDO.setPatient(String.valueOf(map.get("code")));
					patientRemindRecordESDO.setPatientName(String.valueOf(map.get("name")));
					patientRemindRecordESDO.setDoctor(doctor);
					patientRemindRecordESDO.setDoctorName(doctorName);
					patientRemindRecordESDO.setCreateDate(new Date());
					patientRemindRecordESDO.setRemindType(1);
					if (flag) {
						patientRemindRecordESDO.setStatus(1);
						String update="UPDATE wlyy_child_immune_vaccin SET alert_tag=1,alert_time='"+DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD_HH_MM_SS)+"' where `code`='"+vaccinCode+"'";
						jdbcTemplate.update(update);
					}else {
						patientRemindRecordESDO.setStatus(0);
					}
					patientRemindRecordESDOList.add(patientRemindRecordESDO);
				}
			}
		}
		//保存到es的提醒日志表中
		esSavePatientRemindRecord(patientRemindRecordESDOList);
		return 200;
	}
@ -371,4 +497,22 @@ public class ChildFamilyImmuneService extends BaseService {
		}
		return result;
	}
	public int alertImmVacclinByDoctor(String doctor)throws Exception{
		List<Map<String, Object>> immVaccinList = getImmVaccinList(doctor,0,0,0);
		String alertJsonStr="";
		JSONArray jsonArray = new JSONArray();
		if (immVaccinList != null) {
			for (Map<String, Object> map : immVaccinList) {
				JSONObject jsonObject = new JSONObject();
				jsonObject.put("vaccinCode",map.get("code"));//待接种疫苗记录code
				jsonObject.put("childName", map.get("child_name"));//儿童姓名
				jsonObject.put("childCode", map.get("childCode"));//儿童code
				jsonObject.put("vaccinName", map.get("ymmc"));//疫苗名称
				jsonArray.put(jsonObject);
			}
		}
		alertJsonStr = jsonArray.toString();
		return alertImmVacclinByChildInfoCodes(alertJsonStr,doctor);
	}
}

+ 29 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/imm/DoctorImmController.java

@ -97,13 +97,15 @@ public class DoctorImmController extends BaseController {
				doctorCode = getUID();
			}
			
			List<Map<String, Object>> immrs = childFamilyImmuneService.getImmVaccinList(doctorCode,Integer.valueOf(pageNo),Integer.valueOf(pageSize));
			List<Map<String, Object>> immrs = childFamilyImmuneService.getImmVaccinList(doctorCode,Integer.valueOf(pageNo),Integer.valueOf(pageSize),1);
			JSONArray jsonArray = new JSONArray();
			if (immrs != null) {
				for (Map<String, Object> map : immrs) {
					JSONObject json = new JSONObject();
					json.put("vaccin_code",map.get("code"));
					json.put("family_name", map.get("family_name"));//关联居民
					json.put("child_name", map.get("child_name"));//儿童姓名
					json.put("child_code",map.get("childCode"));//儿童信息code
					json.put("birthday", map.get("birthday"));//儿童生日
					json.put("ymmc", map.get("ymmc"));//疫苗名称
					json.put("ymkc", map.get("ymkc"));//true:可约,false:不可约
@ -128,7 +130,13 @@ public class DoctorImmController extends BaseController {
	public String alertImmVacclinByDoctor(@ApiParam(name = "doctorcode", value = "医生CODE", defaultValue = "")
	                                      @RequestParam(value = "doctorcode", required = true) String doctorcode){
		try {
			// TODO: 2018/6/21
			int result = childFamilyImmuneService.alertImmVacclinByDoctor(doctorcode);
			if (result==-1){
				return error(-1, "参数错误!");
			}
			if (result==-10000){
				return error(-1, "该儿童父母数据为空,请联系管理员!");
			}
			return write(200, "请求成功");
		} catch (Exception e) {
			e.printStackTrace();
@ -161,6 +169,25 @@ public class DoctorImmController extends BaseController {
			return error(-1, "查询失败");
		}
	}
	@RequestMapping(value = "/alertImmVacclinByChildInfoCode", method = RequestMethod.POST)
	@ApiOperation(value = "医生提醒居民疫苗接种")
	public String alertImmVacclinByChildInfoCode(@ApiParam(name = "alertDataJsonStr", value = "{\"childCode\":\"123\",\"childName\":\"张三\",\"vaccinCode\":\"asd123\",\"vaccinName\":\"疫苗名称\"}", defaultValue = "")
												  @RequestParam(value = "alertDataJsonStr", required = true) String alertDataJsonStr){
		try {
			int result = childFamilyImmuneService.alertImmVacclinByChildInfoCode(alertDataJsonStr,getUID());
			if (result==-1){
				return error(-1, "参数错误!");
			}
			if (result==-10000){
				return error(-1, "该儿童父母数据为空,请联系管理员!");
			}
			return write(200, "请求成功");
		} catch (Exception e) {
			e.printStackTrace();
			return error(-1, "查询失败");
		}
	}
	
	@RequestMapping(value = "/getPatientImmVacclin", method = RequestMethod.GET)
	@ApiOperation(value = "根据儿童免疫条码获取待接种疫苗")

+ 14 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/message/GcOtherMessageController.java

@ -1,7 +1,9 @@
package com.yihu.wlyy.web.third.gateway.controller.message;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.util.NetworkUtil;
@ -45,11 +47,9 @@ public class GcOtherMessageController {
    @Autowired
    private WeiXinTempMsgSendUtils weiXinTempMsgSendUtils;
    @Autowired
    private PatientService patientService;
    @Autowired
    private SMSService smsService;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Value("${wechat.message.template_consult_notice}")
    private String templateId;
@ -78,6 +78,10 @@ public class GcOtherMessageController {
            System.out.println("param3-------"+type);
            System.out.println("param4-------"+url);
            Patient patient =  patientDao.findBySsc(cardNo);
            SignFamily signFamily = signFamilyDao.findByPatient(patient.getCode());
            if (signFamily==null){
                return new BaseResultModel(BaseResultModel.statusEm.opera_error.getCode(),BaseResultModel.statusEm.opera_error.getMessage()+"签约信息错误!");
            }
            String templateId = "";
            if ("1".equals(type)){
                templateId=template_to_be_pay;
@ -86,7 +90,12 @@ public class GcOtherMessageController {
            }
            System.out.println("接收者id----"+patient.getOpenid());
            System.out.println("消息模板id----"+templateId);
            weiXinTempMsgSendUtils.sendTemplateMessage(templateId, patient.getOpenid(), url, new JSONObject(templateJson));
            /*if ("oULM4xNdf4lqcjuq0-MGFRuhOcz8".equals(patient.getOpenid())){
                weiXinTempMsgSendUtils.sendTemplateMessage(templateId, patient.getOpenid(), url, new JSONObject(templateJson));
            }*/
            if ("3502110100".equals(signFamily.getHospital())){
                weiXinTempMsgSendUtils.sendTemplateMessage(templateId, patient.getOpenid(), url, new JSONObject(templateJson));
            }
            return new BaseResultModel(BaseResultModel.statusEm.success.getCode(),BaseResultModel.statusEm.success.getMessage());
        } catch (Exception e) {