|  | @ -9,12 +9,12 @@ import com.yihu.wlyy.service.manager.sign.FamilyContractService;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.util.CommonUtil;
 | 
	
		
			
				|  |  | import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  | import org.json.JSONArray;
 | 
	
		
			
				|  |  | import org.json.JSONObject;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.jdbc.core.JdbcTemplate;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import javax.annotation.PostConstruct;
 | 
	
		
			
				|  |  | import java.util.ArrayList;
 | 
	
		
			
				|  |  | import java.util.HashMap;
 | 
	
		
			
				|  |  | import java.util.List;
 | 
	
		
			
				|  |  | import java.util.Map;
 | 
	
	
		
			
				|  | @ -54,15 +54,14 @@ public class FamilyMemberService extends BaseService {
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取所有家庭成员,包括自己
 | 
	
		
			
				|  |  |      * @param patient
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public JSONArray getAllFamilyMembers(String patient){
 | 
	
		
			
				|  |  |         JSONArray resultArray = new JSONArray();
 | 
	
		
			
				|  |  |         resultArray.put(getPatient(patient));
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> getAllFamilyMembers(String patient){
 | 
	
		
			
				|  |  |         List<Map<String,Object>> list = new ArrayList<>();
 | 
	
		
			
				|  |  |         list.add(getPatient(patient));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String sql = "select * " +
 | 
	
		
			
				|  |  |                 " from " +
 | 
	
	
		
			
				|  | @ -78,105 +77,82 @@ public class FamilyMemberService extends BaseService {
 | 
	
		
			
				|  |  |         if (result != null && result.size() > 0) {
 | 
	
		
			
				|  |  |             JSONArray tem = new JSONArray();//存储其他
 | 
	
		
			
				|  |  |             for (Map<String, Object> map : result) {
 | 
	
		
			
				|  |  |                 JSONObject obj = new JSONObject();
 | 
	
		
			
				|  |  |                 Map<String,Object> map1 = new HashMap();
 | 
	
		
			
				|  |  |                 SignFamily sign = contractService.findSignByPatient(map.get("code").toString());
 | 
	
		
			
				|  |  |                 boolean ssSign = false;
 | 
	
		
			
				|  |  |                 boolean jtSign = false;
 | 
	
		
			
				|  |  |                 map.put("statusName","未签约");
 | 
	
		
			
				|  |  |                 if(sign!=null){
 | 
	
		
			
				|  |  |                     if (sign.getType() == 1 ) {
 | 
	
		
			
				|  |  |                         ssSign = true;
 | 
	
		
			
				|  |  |                     } else if (sign.getType() == 2 ) {
 | 
	
		
			
				|  |  |                         jtSign = true;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     obj.put("doctor",sign.getDoctor());
 | 
	
		
			
				|  |  |                     obj.put("doctorName",sign.getDoctorName());
 | 
	
		
			
				|  |  |                     map1.put("statusName","已签约");
 | 
	
		
			
				|  |  |                     map1.put("doctor",sign.getDoctor());
 | 
	
		
			
				|  |  |                     map1.put("doctorName",sign.getDoctorName());
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 Integer family_relation = Integer.valueOf(map.get("family_relation").toString());
 | 
	
		
			
				|  |  |                 obj.put("code", map.get("code"));
 | 
	
		
			
				|  |  |                 obj.put("name", map.get("name"));
 | 
	
		
			
				|  |  |                 obj.put("sex", map.get("sex"));
 | 
	
		
			
				|  |  |                 obj.put("isAuthorize", map.get("is_authorize"));//0:未授权,1:已授权
 | 
	
		
			
				|  |  |                 obj.put("birthday", map.get("birthday"));
 | 
	
		
			
				|  |  |                 obj.put("idcard", StringUtils.isEmpty(String.valueOf(map.get("idcard"))) ? "" : map.get("idcard").toString());
 | 
	
		
			
				|  |  |                 obj.put("photo", map.get("photo"));
 | 
	
		
			
				|  |  |                 obj.put("mobile", map.get("mobile"));
 | 
	
		
			
				|  |  |                 obj.put("address", StringUtils.isEmpty(String.valueOf(map.get("address"))) ? "" : map.get("address"));
 | 
	
		
			
				|  |  |                 obj.put("familyRelation", family_relation);
 | 
	
		
			
				|  |  |                 obj.put("familyRelationName", relations.get(map.get("family_relation")));
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 if (ssSign && jtSign) {
 | 
	
		
			
				|  |  |                     obj.put("signType", 3);
 | 
	
		
			
				|  |  |                 } else if (!ssSign && jtSign) {
 | 
	
		
			
				|  |  |                     obj.put("signType", 2);
 | 
	
		
			
				|  |  |                 } else if (ssSign && !jtSign) {
 | 
	
		
			
				|  |  |                     obj.put("signType", 1);
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     obj.put("signType", 0);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 map1.put("code", map.get("code"));
 | 
	
		
			
				|  |  |                 map1.put("name", map.get("name"));
 | 
	
		
			
				|  |  |                 map1.put("sex", map.get("sex"));
 | 
	
		
			
				|  |  |                 map1.put("isAuthorize", map.get("is_authorize"));//0:未授权,1:已授权
 | 
	
		
			
				|  |  |                 map1.put("birthday", map.get("birthday"));
 | 
	
		
			
				|  |  |                 map1.put("idcard", StringUtils.isEmpty(String.valueOf(map.get("idcard"))) ? "" : map.get("idcard").toString());
 | 
	
		
			
				|  |  |                 map1.put("photo", map.get("photo"));
 | 
	
		
			
				|  |  |                 map1.put("mobile", map.get("mobile"));
 | 
	
		
			
				|  |  |                 map1.put("address", StringUtils.isEmpty(String.valueOf(map.get("address"))) ? "" : map.get("address"));
 | 
	
		
			
				|  |  |                 map1.put("familyRelation", family_relation);
 | 
	
		
			
				|  |  |                 map1.put("familyRelationName", relations.get(map.get("family_relation")));
 | 
	
		
			
				|  |  |                 if(family_relation==0){
 | 
	
		
			
				|  |  |                     tem.put(obj);
 | 
	
		
			
				|  |  |                     tem.put(map1);
 | 
	
		
			
				|  |  |                 }else {
 | 
	
		
			
				|  |  |                     resultArray.put(obj);
 | 
	
		
			
				|  |  |                     list.add(map1);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             if(tem.length()>0){
 | 
	
		
			
				|  |  |                 for(int i =0;i<tem.length();i++){
 | 
	
		
			
				|  |  |                     resultArray.put(tem.get(i));
 | 
	
		
			
				|  |  |                 if(family_relation==0){
 | 
	
		
			
				|  |  |                     tem.put(map1);
 | 
	
		
			
				|  |  |                 }else {
 | 
	
		
			
				|  |  |                     list.add(map1);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return resultArray;
 | 
	
		
			
				|  |  |         return list;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public JSONObject getPatient(String patient){
 | 
	
		
			
				|  |  |     public Map getPatient(String patient){
 | 
	
		
			
				|  |  |         Patient p = patientDao.findByCode(patient);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //查询签约信息
 | 
	
		
			
				|  |  |         JSONObject obj = new JSONObject();
 | 
	
		
			
				|  |  |         Map map = new HashMap<String,Object>();
 | 
	
		
			
				|  |  |         SignFamily sign = contractService.findSignByPatient(p.getCode());
 | 
	
		
			
				|  |  |         boolean ssSign = false;
 | 
	
		
			
				|  |  |         boolean jtSign = false;
 | 
	
		
			
				|  |  |         String doctor = null;
 | 
	
		
			
				|  |  |         String doctorName = null;
 | 
	
		
			
				|  |  |         map.put("statusName","未签约");
 | 
	
		
			
				|  |  |         if (sign != null) {
 | 
	
		
			
				|  |  |             if (sign.getType() == 1 ) {
 | 
	
		
			
				|  |  |                 ssSign = true;
 | 
	
		
			
				|  |  |             } else if (sign.getType() == 2 ) {
 | 
	
		
			
				|  |  |                 jtSign = true;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             doctor = sign.getDoctor();
 | 
	
		
			
				|  |  |             doctorName = sign.getDoctorName();
 | 
	
		
			
				|  |  |             map.put("statusName","已签约");
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         obj.put("doctor",doctor);
 | 
	
		
			
				|  |  |         obj.put("doctorName",doctorName);
 | 
	
		
			
				|  |  |         obj.put("code", p.getCode());
 | 
	
		
			
				|  |  |         obj.put("name", p.getName());
 | 
	
		
			
				|  |  |         obj.put("sex", p.getSex());
 | 
	
		
			
				|  |  |         obj.put("birthday", p.getBirthday());
 | 
	
		
			
				|  |  |         obj.put("isAuthorize", 1);
 | 
	
		
			
				|  |  |         map.put("doctor",doctor);
 | 
	
		
			
				|  |  |         map.put("doctorName",doctorName);
 | 
	
		
			
				|  |  |         map.put("code", p.getCode());
 | 
	
		
			
				|  |  |         map.put("name", p.getName());
 | 
	
		
			
				|  |  |         map.put("sex", p.getSex());
 | 
	
		
			
				|  |  |         map.put("birthday", p.getBirthday());
 | 
	
		
			
				|  |  |         map.put("isAuthorize", 1);
 | 
	
		
			
				|  |  |         String idCard = StringUtils.isEmpty(p.getIdcard()) ? "" : p.getIdcard();
 | 
	
		
			
				|  |  |         obj.put("idcard", CommonUtil.getIdcardEncode(idCard));
 | 
	
		
			
				|  |  |         obj.put("idcardAll", idCard);
 | 
	
		
			
				|  |  |         obj.put("ssc", p.getSsc());
 | 
	
		
			
				|  |  |         obj.put("photo", StringUtils.isEmpty(p.getPhoto()) ? "" : p.getPhoto());
 | 
	
		
			
				|  |  |         obj.put("mobile", StringUtils.isEmpty(p.getMobile()) ? "" : p.getMobile());
 | 
	
		
			
				|  |  |         obj.put("address", StringUtils.isEmpty(p.getAddress()) ? "" : p.getAddress());
 | 
	
		
			
				|  |  |         obj.put("familyRelation", -1);
 | 
	
		
			
				|  |  |         obj.put("familyRelationName", "自己");
 | 
	
		
			
				|  |  |         obj.put("isAuthorize", 1);//0:未授权,1:已授权
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         if (ssSign && jtSign) {
 | 
	
		
			
				|  |  |             obj.put("signType", 3);
 | 
	
		
			
				|  |  |         } else if (!ssSign && jtSign) {
 | 
	
		
			
				|  |  |             obj.put("signType", 2);
 | 
	
		
			
				|  |  |         } else if (ssSign && !jtSign) {
 | 
	
		
			
				|  |  |             obj.put("signType", 1);
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             obj.put("signType", 0);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return obj;
 | 
	
		
			
				|  |  |         map.put("idcard", CommonUtil.getIdcardEncode(idCard));
 | 
	
		
			
				|  |  |         map.put("idcardAll", idCard);
 | 
	
		
			
				|  |  |         map.put("ssc", p.getSsc());
 | 
	
		
			
				|  |  |         map.put("photo", StringUtils.isEmpty(p.getPhoto()) ? "" : p.getPhoto());
 | 
	
		
			
				|  |  |         map.put("mobile", StringUtils.isEmpty(p.getMobile()) ? "" : p.getMobile());
 | 
	
		
			
				|  |  |         map.put("address", StringUtils.isEmpty(p.getAddress()) ? "" : p.getAddress());
 | 
	
		
			
				|  |  |         map.put("familyRelation", -1);
 | 
	
		
			
				|  |  |         map.put("familyRelationName", "自己");
 | 
	
		
			
				|  |  |         map.put("isAuthorize", 1);//0:未授权,1:已授权
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         return map;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |