|  | @ -1,603 +0,0 @@
 | 
	
		
			
				|  |  | package com.yihu.wlyy.web.common.util;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.yihu.wlyy.web.BaseController;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | //@Controller
 | 
	
		
			
				|  |  | //@RequestMapping(value = "/util/data")
 | 
	
		
			
				|  |  | public class ImportDataController extends BaseController {
 | 
	
		
			
				|  |  | //
 | 
	
		
			
				|  |  | //	@Autowired
 | 
	
		
			
				|  |  | //	private PatientService patientService;
 | 
	
		
			
				|  |  | //	@Autowired
 | 
	
		
			
				|  |  | //	private ImportDataService importDataService;
 | 
	
		
			
				|  |  | //	// @Autowired
 | 
	
		
			
				|  |  | //	// private DoctorService doctorService;
 | 
	
		
			
				|  |  | //
 | 
	
		
			
				|  |  | //	/**
 | 
	
		
			
				|  |  | //	 *
 | 
	
		
			
				|  |  | //	 * @param data
 | 
	
		
			
				|  |  | //	 * @param type 1高,2糖
 | 
	
		
			
				|  |  | //	 * @return
 | 
	
		
			
				|  |  | //	 */
 | 
	
		
			
				|  |  | //	@RequestMapping(value = "id")
 | 
	
		
			
				|  |  | //	@ResponseBody
 | 
	
		
			
				|  |  | //	public String importData(String data, int type) {
 | 
	
		
			
				|  |  | //		try {
 | 
	
		
			
				|  |  | //			String[] datas = data.split(";");
 | 
	
		
			
				|  |  | //			List<Patient> patients = new ArrayList<Patient>();
 | 
	
		
			
				|  |  | //			List<Family> scs = new ArrayList<SignContract>();
 | 
	
		
			
				|  |  | //			for (String temp : datas) {
 | 
	
		
			
				|  |  | //				String[] temps = temp.split(",");
 | 
	
		
			
				|  |  | //				String name = temps[0];
 | 
	
		
			
				|  |  | //				String ssc = temps[1];
 | 
	
		
			
				|  |  | //				String idcard = temps[2];
 | 
	
		
			
				|  |  | //				String phone = temps[3];
 | 
	
		
			
				|  |  | //				String province = temps[4];
 | 
	
		
			
				|  |  | //				String city = temps[5];
 | 
	
		
			
				|  |  | //				String town = temps[6];
 | 
	
		
			
				|  |  | //				String address = temps[7];
 | 
	
		
			
				|  |  | //				String zk = temps[9];
 | 
	
		
			
				|  |  | //				String qk = temps[10];
 | 
	
		
			
				|  |  | //				String jk = temps[11];
 | 
	
		
			
				|  |  | //				String qyrq = temps[12].replace("/", "-");
 | 
	
		
			
				|  |  | //
 | 
	
		
			
				|  |  | //				IdcardInfoExtractor ie = new IdcardInfoExtractor(idcard);
 | 
	
		
			
				|  |  | //
 | 
	
		
			
				|  |  | //				Patient patient = new Patient();
 | 
	
		
			
				|  |  | //				patient.setAddress(address);
 | 
	
		
			
				|  |  | //				patient.setBirthday(ie.getBirthday());
 | 
	
		
			
				|  |  | //				patient.setCityName(city);
 | 
	
		
			
				|  |  | //				patient.setCode(patientService.getCode());
 | 
	
		
			
				|  |  | //				patient.setCzrq(new Date());
 | 
	
		
			
				|  |  | //				patient.setDisease(type);
 | 
	
		
			
				|  |  | //				patient.setIdcard(idcard);
 | 
	
		
			
				|  |  | //				patient.setName(name);
 | 
	
		
			
				|  |  | //				patient.setPhone(phone);
 | 
	
		
			
				|  |  | //				patient.setProvinceName(province);
 | 
	
		
			
				|  |  | //				patient.setSex(ie.getGender());
 | 
	
		
			
				|  |  | //				patient.setSsc(ssc);
 | 
	
		
			
				|  |  | //				patient.setTownName(town);
 | 
	
		
			
				|  |  | //				patients.add(patient);
 | 
	
		
			
				|  |  | //
 | 
	
		
			
				|  |  | //				SignContract sc = new SignContract();
 | 
	
		
			
				|  |  | //				sc.setBegin(DateUtil.strToDateShort(qyrq));
 | 
	
		
			
				|  |  | //				sc.setCode(patientService.getCode());
 | 
	
		
			
				|  |  | //				sc.setEnd(DateUtil.strToDateShort(DateUtil.getNextYear(sc.getBegin(), 1)));
 | 
	
		
			
				|  |  | //				sc.setMonths(12);
 | 
	
		
			
				|  |  | //				sc.setTeam("-1");
 | 
	
		
			
				|  |  | //				sc.setUname(name);
 | 
	
		
			
				|  |  | //				sc.setUser(patient.getCode());
 | 
	
		
			
				|  |  | //				sc.setGp(qk);
 | 
	
		
			
				|  |  | //				sc.setSpec(zk);
 | 
	
		
			
				|  |  | //				sc.setHealthManager(jk);
 | 
	
		
			
				|  |  | //				sc.setStatus(200);
 | 
	
		
			
				|  |  | //				scs.add(sc);
 | 
	
		
			
				|  |  | //			}
 | 
	
		
			
				|  |  | //			importDataService.importData(patients, scs);
 | 
	
		
			
				|  |  | //			return success("导入成功!");
 | 
	
		
			
				|  |  | //		} catch (Exception e) {
 | 
	
		
			
				|  |  | //			error(e);
 | 
	
		
			
				|  |  | //			return error(-1, "导入失败!");
 | 
	
		
			
				|  |  | //		}
 | 
	
		
			
				|  |  | //	}
 | 
	
		
			
				|  |  | //
 | 
	
		
			
				|  |  | //	/**
 | 
	
		
			
				|  |  | //	 * 创建医生分组数据
 | 
	
		
			
				|  |  | //	 * @return
 | 
	
		
			
				|  |  | //	 */
 | 
	
		
			
				|  |  | //	@RequestMapping(value = "cd")
 | 
	
		
			
				|  |  | //	@ResponseBody
 | 
	
		
			
				|  |  | //	public String createDPGData() {
 | 
	
		
			
				|  |  | //		try {
 | 
	
		
			
				|  |  | //			importDataService.createDPGData();
 | 
	
		
			
				|  |  | //			return success("创建成功!");
 | 
	
		
			
				|  |  | //		} catch (Exception e) {
 | 
	
		
			
				|  |  | //			error(e);
 | 
	
		
			
				|  |  | //			return error(-1, "创建失败!");
 | 
	
		
			
				|  |  | //		}
 | 
	
		
			
				|  |  | //	}
 | 
	
		
			
				|  |  | //
 | 
	
		
			
				|  |  | //	@RequestMapping(value = "excel")
 | 
	
		
			
				|  |  | //	@ResponseBody
 | 
	
		
			
				|  |  | //	public String loadExcel() {
 | 
	
		
			
				|  |  | //		try {
 | 
	
		
			
				|  |  | //			List<String> sqls = new ArrayList<String>();
 | 
	
		
			
				|  |  | //
 | 
	
		
			
				|  |  | //			JSONObject hosMaps = new JSONObject();
 | 
	
		
			
				|  |  | //			hosMaps.put("厦门市同安区新民卫生院", "新民卫生院");
 | 
	
		
			
				|  |  | //			hosMaps.put("厦门市集美区侨英街道社区卫生服务中心", "侨英街道社区卫生服务中心");
 | 
	
		
			
				|  |  | //			hosMaps.put("厦门市同安区莲花卫生院", "莲花卫生院");
 | 
	
		
			
				|  |  | //			hosMaps.put("厦门市同安区西柯中心卫生院", "同安区西柯中心卫生院");
 | 
	
		
			
				|  |  | //			hosMaps.put("鹭江社区卫生服务中心", "鹭江社区医疗服务中心");
 | 
	
		
			
				|  |  | //			hosMaps.put("厦门市湖里区金山街道社区卫生服务中心", "金山社区医疗服务中心");
 | 
	
		
			
				|  |  | //			hosMaps.put("厦门市思明区梧村街道社区卫生服务中心", "梧村社区医疗服务中心");
 | 
	
		
			
				|  |  | //			hosMaps.put("后溪镇卫生院", "集美区后溪卫生院");
 | 
	
		
			
				|  |  | //			hosMaps.put("禾山街道社区卫生服务中心", "禾山社区医疗服务中心");
 | 
	
		
			
				|  |  | //			hosMaps.put("厦门市同安区洪塘卫生院", "洪塘卫生院");
 | 
	
		
			
				|  |  | //			hosMaps.put("同安区大同街道社区卫生服务中心", "大同街道社区卫生服务中心");
 | 
	
		
			
				|  |  | //			hosMaps.put("厦门市思明区筼筜街道社区卫生服务中心", "筼筜街道社区卫生服务中心");
 | 
	
		
			
				|  |  | //			hosMaps.put("厦门市同安区祥平街道社区卫生服务中心", "祥平街道社区卫生服务中心");
 | 
	
		
			
				|  |  | //			hosMaps.put("集美区杏滨街道社区卫生服务中心", "杏滨街道社区卫生服务中心");
 | 
	
		
			
				|  |  | //			hosMaps.put("厦门市同安区五显卫生院", "五显卫生院");
 | 
	
		
			
				|  |  | //			hosMaps.put("厦门市集美区集美街道社区卫生服务中心", "集美街道社区卫生服务中心");
 | 
	
		
			
				|  |  | //			hosMaps.put("厦门市集美区灌口镇中心卫生院", "集美区灌口医院");
 | 
	
		
			
				|  |  | //			hosMaps.put("莲前街道社区卫生服务中心", "莲前第一社区医疗服务中心");
 | 
	
		
			
				|  |  | //			hosMaps.put("思明区鹭江街道社区卫生服务中心", "鹭江社区医疗服务中心");
 | 
	
		
			
				|  |  | //			hosMaps.put("厦门市思明区滨海街道社区卫生服务中心", "滨海社区医疗服务中心");
 | 
	
		
			
				|  |  | //			hosMaps.put("嘉莲街道社区卫生服务中心", "嘉莲社区医疗服务中心");
 | 
	
		
			
				|  |  | //			hosMaps.put("同安区汀溪卫生院", "汀溪卫生院");
 | 
	
		
			
				|  |  | //			hosMaps.put("厦门市思明区开元街道社区卫生服务中心", "开元社区医疗服务中心");
 | 
	
		
			
				|  |  | //			hosMaps.put("嘉莲社区卫生服务中心", "嘉莲社区医疗服务中心");
 | 
	
		
			
				|  |  | //			hosMaps.put("厦门市思明区鹭江街道社区卫生服务中心", "鹭江社区医疗服务中心");
 | 
	
		
			
				|  |  | //			hosMaps.put("厦门市湖里区湖里街道社区卫生服务中心", "湖里社区医疗服务中心");
 | 
	
		
			
				|  |  | //			hosMaps.put("江头街道社区卫生服务中心", "江头社区医疗服务中心");
 | 
	
		
			
				|  |  | //			hosMaps.put("厦门市思明区嘉莲街道社区卫生服务中心", "嘉莲社区医疗服务中心");
 | 
	
		
			
				|  |  | //			hosMaps.put("湖里区殿前街道社区卫生服务中心", "殿前社区医疗服务中心");
 | 
	
		
			
				|  |  | //			hosMaps.put("厦门市集美区杏林街道社区卫生服务中心", "杏林街道社区卫生服务中心");
 | 
	
		
			
				|  |  | //
 | 
	
		
			
				|  |  | //			Map<String, String> hospitals = new HashMap<String, String>();
 | 
	
		
			
				|  |  | //			File file = new File("D:\\doctors");
 | 
	
		
			
				|  |  | //			if (file.exists()) {
 | 
	
		
			
				|  |  | //				File[] files = file.listFiles();
 | 
	
		
			
				|  |  | //				for (File temp : files) {
 | 
	
		
			
				|  |  | //					InputStream is = null;
 | 
	
		
			
				|  |  | //					HSSFWorkbook hssfWorkbook = null;
 | 
	
		
			
				|  |  | //					try {
 | 
	
		
			
				|  |  | //						// System.out.println(temp.getAbsolutePath());
 | 
	
		
			
				|  |  | //						is = new FileInputStream(temp);
 | 
	
		
			
				|  |  | //						hssfWorkbook = new HSSFWorkbook(is);
 | 
	
		
			
				|  |  | //						// 获取第一个sheet
 | 
	
		
			
				|  |  | //						HSSFSheet hssfSheet = hssfWorkbook.getSheetAt(0);
 | 
	
		
			
				|  |  | //						if (hssfSheet == null) {
 | 
	
		
			
				|  |  | //							continue;
 | 
	
		
			
				|  |  | //						}
 | 
	
		
			
				|  |  | //						for (int row = 1; row < hssfSheet.getLastRowNum() + 1; row++) {
 | 
	
		
			
				|  |  | //							HSSFRow hssfRow = hssfSheet.getRow(row);
 | 
	
		
			
				|  |  | //							// 姓名
 | 
	
		
			
				|  |  | //							String name = getStringValue(hssfRow.getCell(0));
 | 
	
		
			
				|  |  | //							// 性别
 | 
	
		
			
				|  |  | //							String sex = getStringValue(hssfRow.getCell(1));
 | 
	
		
			
				|  |  | //							// 人员类型
 | 
	
		
			
				|  |  | //							// String userType = getStringValue(hssfRow.getCell(2));
 | 
	
		
			
				|  |  | //							// 临床职称
 | 
	
		
			
				|  |  | //							String job = getStringValue(hssfRow.getCell(4));
 | 
	
		
			
				|  |  | //							// //教学职称
 | 
	
		
			
				|  |  | //							// String name = getStringValue(hssfRow.getCell(5));
 | 
	
		
			
				|  |  | //							// //行政职称
 | 
	
		
			
				|  |  | //							// String name = getStringValue(hssfRow.getCell(6));
 | 
	
		
			
				|  |  | //							// 人员专长
 | 
	
		
			
				|  |  | //							String expertise = getStringValue(hssfRow.getCell(7));
 | 
	
		
			
				|  |  | //							// //机构所在省
 | 
	
		
			
				|  |  | //							// String province = getStringValue(hssfRow.getCell(8));
 | 
	
		
			
				|  |  | //							// //机构所在市
 | 
	
		
			
				|  |  | //							// String city = getStringValue(hssfRow.getCell(9));
 | 
	
		
			
				|  |  | //							// //机构详细地址
 | 
	
		
			
				|  |  | //							// String address = getStringValue(hssfRow.getCell(10));
 | 
	
		
			
				|  |  | //							// 机构名称
 | 
	
		
			
				|  |  | //							String hospitalName = getStringValue(hssfRow.getCell(11));
 | 
	
		
			
				|  |  | //							if (StringUtils.isNotEmpty(hospitalName)) {
 | 
	
		
			
				|  |  | //								if (hosMaps.has(hospitalName)) {
 | 
	
		
			
				|  |  | //									hospitalName = hosMaps.getString(hospitalName);
 | 
	
		
			
				|  |  | //								} else {
 | 
	
		
			
				|  |  | //									hospitalName = "===" + hospitalName + "===";
 | 
	
		
			
				|  |  | //									continue;
 | 
	
		
			
				|  |  | //								}
 | 
	
		
			
				|  |  | //							}
 | 
	
		
			
				|  |  | //							// 科室
 | 
	
		
			
				|  |  | //							String dept = getStringValue(hssfRow.getCell(12));
 | 
	
		
			
				|  |  | //							// 医生简介
 | 
	
		
			
				|  |  | //							String intro = getStringValue(hssfRow.getCell(13));
 | 
	
		
			
				|  |  | //							// 三师类型
 | 
	
		
			
				|  |  | //							String doctorType = getStringValue(hssfRow.getCell(14));
 | 
	
		
			
				|  |  | //							// 手机号码
 | 
	
		
			
				|  |  | //							String mobile = getStringValue(hssfRow.getCell(15));
 | 
	
		
			
				|  |  | //							// 邮箱
 | 
	
		
			
				|  |  | //							// String email = getStringValue(hssfRow.getCell(16));
 | 
	
		
			
				|  |  | //							// 医生荣誉
 | 
	
		
			
				|  |  | //							// String ysry = getStringValue(hssfRow.getCell(17));
 | 
	
		
			
				|  |  | //
 | 
	
		
			
				|  |  | //							// System.out.println(name);
 | 
	
		
			
				|  |  | //							// System.out.println(sex);
 | 
	
		
			
				|  |  | //							// System.out.println(job);
 | 
	
		
			
				|  |  | //							// System.out.println(expertise);
 | 
	
		
			
				|  |  | //							// System.out.println(hospitalName);
 | 
	
		
			
				|  |  | //							// System.out.println(dept);
 | 
	
		
			
				|  |  | //							// System.out.println(intro);
 | 
	
		
			
				|  |  | //							// System.out.println(doctorType);
 | 
	
		
			
				|  |  | //							// System.out.println(mobile);
 | 
	
		
			
				|  |  | //							if (StringUtils.isEmpty(hospitalName)) {
 | 
	
		
			
				|  |  | //								// System.out.println(temp.getAbsolutePath() + " 第" + (row + 1) + "行,机构名称不允许为空!");
 | 
	
		
			
				|  |  | //								continue;
 | 
	
		
			
				|  |  | //							} else if (StringUtils.isEmpty(mobile) || mobile.length() != 11) {
 | 
	
		
			
				|  |  | //								// System.out.println(temp.getAbsolutePath() + " 第" + (row + 1) + "行,手机号码为允许为空且必须为11位!");
 | 
	
		
			
				|  |  | //								continue;
 | 
	
		
			
				|  |  | //							} else if (StringUtils.isEmpty(doctorType)) {
 | 
	
		
			
				|  |  | //								// System.out.println(temp.getAbsolutePath() + " 第" + (row + 1) + "行,三师类型不允许为空!");
 | 
	
		
			
				|  |  | //								continue;
 | 
	
		
			
				|  |  | //							} else if (StringUtils.isEmpty(name)) {
 | 
	
		
			
				|  |  | //								// System.out.println(temp.getAbsolutePath() + " 第" + (row + 1) + "行,姓名不允许为空!");
 | 
	
		
			
				|  |  | //								continue;
 | 
	
		
			
				|  |  | //							} else if (StringUtils.isEmpty(sex)) {
 | 
	
		
			
				|  |  | //								// System.out.println(temp.getAbsolutePath() + " 第" + (row + 1) + "行,性别不允许为空!");
 | 
	
		
			
				|  |  | //								continue;
 | 
	
		
			
				|  |  | //							}
 | 
	
		
			
				|  |  | //							// else if (StringUtils.isEmpty(job)) {
 | 
	
		
			
				|  |  | //							// System.out.println(temp.getAbsolutePath() + " 第" + (row+1) + "行,临床职称不允许为空!");
 | 
	
		
			
				|  |  | //							// }
 | 
	
		
			
				|  |  | //							else if (StringUtils.isEmpty(dept)) {
 | 
	
		
			
				|  |  | //								// System.out.println(temp.getAbsolutePath() + " 第" + (row + 1) + "行,科室不允许为空!");
 | 
	
		
			
				|  |  | //								continue;
 | 
	
		
			
				|  |  | //							}
 | 
	
		
			
				|  |  | //							if (hospitalName != null) {
 | 
	
		
			
				|  |  | //								hospitals.put(hospitalName, hospitalName);
 | 
	
		
			
				|  |  | //							}
 | 
	
		
			
				|  |  | //							String photo = "";
 | 
	
		
			
				|  |  | //							// 类型:1专科医生,2全科医生,3健康管理师
 | 
	
		
			
				|  |  | //							int level = 0;
 | 
	
		
			
				|  |  | //							if (doctorType.contains("专")) {
 | 
	
		
			
				|  |  | //								level = 1;
 | 
	
		
			
				|  |  | //							} else if (doctorType.contains("全")) {
 | 
	
		
			
				|  |  | //								level = 2;
 | 
	
		
			
				|  |  | //							} else if (doctorType.contains("健")) {
 | 
	
		
			
				|  |  | //								level = 3;
 | 
	
		
			
				|  |  | //							}
 | 
	
		
			
				|  |  | //							if (sex.contains("男")) {
 | 
	
		
			
				|  |  | //								sex = "1";
 | 
	
		
			
				|  |  | //							} else if (sex.contains("女")) {
 | 
	
		
			
				|  |  | //								sex = "2";
 | 
	
		
			
				|  |  | //							} else {
 | 
	
		
			
				|  |  | //								sex = "0";
 | 
	
		
			
				|  |  | //							}
 | 
	
		
			
				|  |  | //							StringBuffer sql = new StringBuffer();
 | 
	
		
			
				|  |  | //							sql.append("INSERT INTO `wlyy_doctor` (`code`,`name`,`sex`,`photo`,`mobile`,`status`,`province`,`city`,`hospital`,`dept`,`job`,`expertise`,`introduce`,`level`,`czrq`,`province_name`,`city_name`,`hospital_name`,`dept_name`,`job_name`) VALUES (");
 | 
	
		
			
				|  |  | //							sql.append("REPLACE(UUID(), '-', ''),'" + name + "','" + sex + "','" + photo + "','" + mobile + "','1','350000','350200','','','','" + expertise + "','" + intro + "','" + level + "','now()','福建省','厦门市','" + hospitalName + "','" + dept + "','" + job + "');");
 | 
	
		
			
				|  |  | //							sqls.add(sql.toString());
 | 
	
		
			
				|  |  | //						}
 | 
	
		
			
				|  |  | //					} catch (Exception e) {
 | 
	
		
			
				|  |  | //						e.printStackTrace();
 | 
	
		
			
				|  |  | //					} finally {
 | 
	
		
			
				|  |  | //						if (is != null) {
 | 
	
		
			
				|  |  | //							is.close();
 | 
	
		
			
				|  |  | //						}
 | 
	
		
			
				|  |  | //						if (hssfWorkbook != null) {
 | 
	
		
			
				|  |  | //							hssfWorkbook.close();
 | 
	
		
			
				|  |  | //						}
 | 
	
		
			
				|  |  | //					}
 | 
	
		
			
				|  |  | //				}
 | 
	
		
			
				|  |  | //			}
 | 
	
		
			
				|  |  | //			System.out.println("===========================");
 | 
	
		
			
				|  |  | //			Iterator<String> temps = hospitals.keySet().iterator();
 | 
	
		
			
				|  |  | //			while (temps.hasNext()) {
 | 
	
		
			
				|  |  | //				System.out.println(temps.next());
 | 
	
		
			
				|  |  | //			}
 | 
	
		
			
				|  |  | //			// System.out.println("===========================");
 | 
	
		
			
				|  |  | //			// for(String sql : sqls){
 | 
	
		
			
				|  |  | //			// System.out.println(sql);
 | 
	
		
			
				|  |  | //			// }
 | 
	
		
			
				|  |  | //			writeFile("D:\\tmp\\doctors.txt", sqls);
 | 
	
		
			
				|  |  | //			return success("导入成功!");
 | 
	
		
			
				|  |  | //		} catch (Exception e) {
 | 
	
		
			
				|  |  | //			error(e);
 | 
	
		
			
				|  |  | //			return error(-1, "导入失败!");
 | 
	
		
			
				|  |  | //		}
 | 
	
		
			
				|  |  | //	}
 | 
	
		
			
				|  |  | //
 | 
	
		
			
				|  |  | //	private static String getStringValue(HSSFCell cell) {
 | 
	
		
			
				|  |  | //		if (cell == null) {
 | 
	
		
			
				|  |  | //			return "";
 | 
	
		
			
				|  |  | //		}
 | 
	
		
			
				|  |  | //		String value = null;
 | 
	
		
			
				|  |  | //		switch (cell.getCellType()) {
 | 
	
		
			
				|  |  | //		case Cell.CELL_TYPE_BOOLEAN:
 | 
	
		
			
				|  |  | //			value = cell.getBooleanCellValue() ? "true" : "false";
 | 
	
		
			
				|  |  | //			break;
 | 
	
		
			
				|  |  | //		case Cell.CELL_TYPE_FORMULA:
 | 
	
		
			
				|  |  | //			value = cell.getCellFormula();
 | 
	
		
			
				|  |  | //			break;
 | 
	
		
			
				|  |  | //		case Cell.CELL_TYPE_NUMERIC:
 | 
	
		
			
				|  |  | //			cell.setCellType(Cell.CELL_TYPE_STRING);
 | 
	
		
			
				|  |  | //			value = cell.getStringCellValue();
 | 
	
		
			
				|  |  | //			break;
 | 
	
		
			
				|  |  | //		case Cell.CELL_TYPE_STRING:
 | 
	
		
			
				|  |  | //			value = cell.getStringCellValue();
 | 
	
		
			
				|  |  | //			break;
 | 
	
		
			
				|  |  | //		}
 | 
	
		
			
				|  |  | //		if (StringUtils.isNotEmpty(value)) {
 | 
	
		
			
				|  |  | //			value = value.replace("无", "");
 | 
	
		
			
				|  |  | //			value = value.replace("-", "");
 | 
	
		
			
				|  |  | //			value = value.replace("——", "");
 | 
	
		
			
				|  |  | //		}
 | 
	
		
			
				|  |  | //		return value;
 | 
	
		
			
				|  |  | //	}
 | 
	
		
			
				|  |  | //
 | 
	
		
			
				|  |  | //	private static void writeFile(String targetFile, List<String> list) throws IOException {
 | 
	
		
			
				|  |  | //		FileWriter fw = null;
 | 
	
		
			
				|  |  | //		try {
 | 
	
		
			
				|  |  | //			fw = new FileWriter(targetFile);
 | 
	
		
			
				|  |  | //			for (String temp : list) {
 | 
	
		
			
				|  |  | //				fw.write(temp);
 | 
	
		
			
				|  |  | //				fw.write("\n");
 | 
	
		
			
				|  |  | //			}
 | 
	
		
			
				|  |  | //		} catch (Exception e) {
 | 
	
		
			
				|  |  | //			e.printStackTrace();
 | 
	
		
			
				|  |  | //		} finally {
 | 
	
		
			
				|  |  | //			if (fw != null) {
 | 
	
		
			
				|  |  | //				fw.close();
 | 
	
		
			
				|  |  | //			}
 | 
	
		
			
				|  |  | //		}
 | 
	
		
			
				|  |  | //	}
 | 
	
		
			
				|  |  | //
 | 
	
		
			
				|  |  | //	@RequestMapping(value = "sign")
 | 
	
		
			
				|  |  | //	@ResponseBody
 | 
	
		
			
				|  |  | //	public String importSignData() throws IOException {
 | 
	
		
			
				|  |  | //
 | 
	
		
			
				|  |  | ////		Map<String, String> teams = new HashMap<String, String>();
 | 
	
		
			
				|  |  | ////		List<String> idcards = new ArrayList<String>();
 | 
	
		
			
				|  |  | ////
 | 
	
		
			
				|  |  | ////		List<String> errors = new ArrayList<String>();
 | 
	
		
			
				|  |  | ////
 | 
	
		
			
				|  |  | ////		List<Patient> patients = new ArrayList<Patient>();
 | 
	
		
			
				|  |  | ////		List<SignContract> scs = new ArrayList<SignContract>();
 | 
	
		
			
				|  |  | ////		List<DoctorTeam> dts = new ArrayList<DoctorTeam>();
 | 
	
		
			
				|  |  | ////		List<DoctorTeamInfo> dtis = new ArrayList<DoctorTeamInfo>();
 | 
	
		
			
				|  |  | ////		List<DoctorPatientGroupInfo> dptis = new ArrayList<DoctorPatientGroupInfo>();
 | 
	
		
			
				|  |  | ////		InputStream is = null;
 | 
	
		
			
				|  |  | ////		HSSFWorkbook hssfWorkbook = null;
 | 
	
		
			
				|  |  | ////		try {
 | 
	
		
			
				|  |  | ////			is = new FileInputStream(new File("D:\\tmp\\sign_data.xls"));
 | 
	
		
			
				|  |  | ////			hssfWorkbook = new HSSFWorkbook(is);
 | 
	
		
			
				|  |  | ////			// 获取第一个sheet
 | 
	
		
			
				|  |  | ////			HSSFSheet hssfSheet = hssfWorkbook.getSheetAt(0);
 | 
	
		
			
				|  |  | ////			for (int row = 1; row < hssfSheet.getLastRowNum() + 1; row++) {
 | 
	
		
			
				|  |  | ////				HSSFRow hssfRow = hssfSheet.getRow(row);
 | 
	
		
			
				|  |  | ////				// 患者姓名
 | 
	
		
			
				|  |  | ////				String name = getStringValue(hssfRow.getCell(0));
 | 
	
		
			
				|  |  | ////				// 身份证号
 | 
	
		
			
				|  |  | ////				String idcard = getStringValue(hssfRow.getCell(1));
 | 
	
		
			
				|  |  | ////				// 社保卡号
 | 
	
		
			
				|  |  | ////				String ssc = getStringValue(hssfRow.getCell(2));
 | 
	
		
			
				|  |  | ////				// 手机号
 | 
	
		
			
				|  |  | ////				String mobile = getStringValue(hssfRow.getCell(3));
 | 
	
		
			
				|  |  | ////				// 性别
 | 
	
		
			
				|  |  | ////				String sex = getStringValue(hssfRow.getCell(4));
 | 
	
		
			
				|  |  | ////				// 生日
 | 
	
		
			
				|  |  | ////				String birthday = getStringValue(hssfRow.getCell(5));
 | 
	
		
			
				|  |  | ////				// 省
 | 
	
		
			
				|  |  | ////				String province = getStringValue(hssfRow.getCell(6));
 | 
	
		
			
				|  |  | ////				// 市
 | 
	
		
			
				|  |  | ////				String city = getStringValue(hssfRow.getCell(7));
 | 
	
		
			
				|  |  | ////				// 区县
 | 
	
		
			
				|  |  | ////				String town = getStringValue(hssfRow.getCell(8));
 | 
	
		
			
				|  |  | ////				// 家庭地址
 | 
	
		
			
				|  |  | ////				String address = getStringValue(hssfRow.getCell(9));
 | 
	
		
			
				|  |  | ////				// 疾病类型:1高血压,2糖尿病
 | 
	
		
			
				|  |  | ////				String disease = getStringValue(hssfRow.getCell(10));
 | 
	
		
			
				|  |  | ////				// 签约机构
 | 
	
		
			
				|  |  | ////				// String organization = getStringValue(hssfRow.getCell(11));
 | 
	
		
			
				|  |  | ////				// 签约开始时间
 | 
	
		
			
				|  |  | ////				String begin = getStringValue(hssfRow.getCell(12));
 | 
	
		
			
				|  |  | ////				// 签约到期时间
 | 
	
		
			
				|  |  | ////				String end = getStringValue(hssfRow.getCell(13));
 | 
	
		
			
				|  |  | ////				// 专科医生
 | 
	
		
			
				|  |  | ////				String doctor_1 = getStringValue(hssfRow.getCell(14));
 | 
	
		
			
				|  |  | ////				// 专科医生手机
 | 
	
		
			
				|  |  | ////				String d_mobile_1 = getStringValue(hssfRow.getCell(16));
 | 
	
		
			
				|  |  | ////				// 专科医生所在医院
 | 
	
		
			
				|  |  | ////				// String d_org_1 = getStringValue(hssfRow.getCell(17));
 | 
	
		
			
				|  |  | ////				// 全科医生
 | 
	
		
			
				|  |  | ////				String doctor_2 = getStringValue(hssfRow.getCell(18));
 | 
	
		
			
				|  |  | ////				// 全科医生手机
 | 
	
		
			
				|  |  | ////				String d_mobile_2 = getStringValue(hssfRow.getCell(19));
 | 
	
		
			
				|  |  | ////				// 全科医生所在医院
 | 
	
		
			
				|  |  | ////				// String d_org_2 = getStringValue(hssfRow.getCell(20));
 | 
	
		
			
				|  |  | ////				// 健康管理师
 | 
	
		
			
				|  |  | ////				String doctor_3 = getStringValue(hssfRow.getCell(21));
 | 
	
		
			
				|  |  | ////				// 健康管理师手机
 | 
	
		
			
				|  |  | ////				String d_mobile_3 = getStringValue(hssfRow.getCell(22));
 | 
	
		
			
				|  |  | ////				// 健康管理师所在医院
 | 
	
		
			
				|  |  | ////				// String d_org_3 = getStringValue(hssfRow.getCell(23));
 | 
	
		
			
				|  |  | ////				if (StringUtils.isEmpty(idcard)) {
 | 
	
		
			
				|  |  | ////					errors.add("无效身份证号:" + name);
 | 
	
		
			
				|  |  | ////					continue;
 | 
	
		
			
				|  |  | ////				}
 | 
	
		
			
				|  |  | ////				if (idcards.contains(idcard)) {
 | 
	
		
			
				|  |  | ////					errors.add("重复的身份证号:" + idcard + "  姓名:" + name);
 | 
	
		
			
				|  |  | ////					continue;
 | 
	
		
			
				|  |  | ////				}
 | 
	
		
			
				|  |  | ////				if (StringUtils.isEmpty(ssc)) {
 | 
	
		
			
				|  |  | ////					errors.add("无效的社保卡号:" + ssc);
 | 
	
		
			
				|  |  | ////					continue;
 | 
	
		
			
				|  |  | ////				}
 | 
	
		
			
				|  |  | ////				idcards.add(idcard);
 | 
	
		
			
				|  |  | ////				if (StringUtils.isEmpty(mobile)) {
 | 
	
		
			
				|  |  | ////					errors.add("无效手机号:" + idcard);
 | 
	
		
			
				|  |  | ////					continue;
 | 
	
		
			
				|  |  | ////				}
 | 
	
		
			
				|  |  | ////				if (mobile.length() != 11) {
 | 
	
		
			
				|  |  | ////					errors.add("错误手机号:" + mobile);
 | 
	
		
			
				|  |  | ////					continue;
 | 
	
		
			
				|  |  | ////				}
 | 
	
		
			
				|  |  | ////				if (d_mobile_1 == null || d_mobile_1.length() != 11) {
 | 
	
		
			
				|  |  | ////					errors.add("专科医生手机号码为空:" + mobile);
 | 
	
		
			
				|  |  | ////					continue;
 | 
	
		
			
				|  |  | ////				}
 | 
	
		
			
				|  |  | ////				if (d_mobile_2 == null || d_mobile_2.length() != 11) {
 | 
	
		
			
				|  |  | ////					errors.add("全科医生手机号码为空:" + mobile);
 | 
	
		
			
				|  |  | ////					continue;
 | 
	
		
			
				|  |  | ////				}
 | 
	
		
			
				|  |  | ////				if (d_mobile_3 == null || d_mobile_3.length() != 11) {
 | 
	
		
			
				|  |  | ////					errors.add("健康管理师手机号码为空:" + mobile);
 | 
	
		
			
				|  |  | ////					continue;
 | 
	
		
			
				|  |  | ////				}
 | 
	
		
			
				|  |  | ////				IdcardInfoExtractor ie = new IdcardInfoExtractor(idcard);
 | 
	
		
			
				|  |  | ////				if (ie == null || ie.getGender() == 0) {
 | 
	
		
			
				|  |  | ////					errors.add("错误的身份证号:" + idcard);
 | 
	
		
			
				|  |  | ////					continue;
 | 
	
		
			
				|  |  | ////				}
 | 
	
		
			
				|  |  | ////
 | 
	
		
			
				|  |  | ////				Patient patient = new Patient();
 | 
	
		
			
				|  |  | ////				patient.setAddress(address);
 | 
	
		
			
				|  |  | ////				patient.setBirthday(DateUtil.strToDateShort(birthday));
 | 
	
		
			
				|  |  | ////				patient.setCityName(city);
 | 
	
		
			
				|  |  | ////				patient.setCode(patientService.getCode());
 | 
	
		
			
				|  |  | ////				patient.setCzrq(new Date());
 | 
	
		
			
				|  |  | ////				patient.setDisease(NumberUtils.toInt(disease, 0));
 | 
	
		
			
				|  |  | ////				patient.setDiseaseCondition(0);
 | 
	
		
			
				|  |  | ////				patient.setIdcard(idcard);
 | 
	
		
			
				|  |  | ////				patient.setName(name);
 | 
	
		
			
				|  |  | ////				patient.setMobile(mobile);
 | 
	
		
			
				|  |  | ////				patient.setProvinceName(province);
 | 
	
		
			
				|  |  | ////				patient.setSex(NumberUtils.toInt(sex));
 | 
	
		
			
				|  |  | ////				patient.setSsc(ssc);
 | 
	
		
			
				|  |  | ////				patient.setTownName(town);
 | 
	
		
			
				|  |  | ////				patient.setStatus(1);
 | 
	
		
			
				|  |  | ////				patients.add(patient);
 | 
	
		
			
				|  |  | ////
 | 
	
		
			
				|  |  | ////				String team = teams.get(d_mobile_1 + "," + d_mobile_2 + "," + d_mobile_2);
 | 
	
		
			
				|  |  | ////
 | 
	
		
			
				|  |  | ////				if (StringUtils.isEmpty(team)) {
 | 
	
		
			
				|  |  | ////					DoctorTeam dt = new DoctorTeam();
 | 
	
		
			
				|  |  | ////					dt.setCode(patientService.getCode());
 | 
	
		
			
				|  |  | ////					dt.setCzrq(new Date());
 | 
	
		
			
				|  |  | ////					dt.setStatus(1);
 | 
	
		
			
				|  |  | ////					dt.setDoctor(d_mobile_2);
 | 
	
		
			
				|  |  | ////					dt.setDoctorName(doctor_2);
 | 
	
		
			
				|  |  | ////					dt.setDoctors(d_mobile_1 + "," + d_mobile_2 + "," + d_mobile_2);
 | 
	
		
			
				|  |  | ////					dt.setMembers("3");
 | 
	
		
			
				|  |  | ////					dt.setName(name);
 | 
	
		
			
				|  |  | ////					dts.add(dt);
 | 
	
		
			
				|  |  | ////
 | 
	
		
			
				|  |  | ////					DoctorTeamInfo dti1 = new DoctorTeamInfo();
 | 
	
		
			
				|  |  | ////					dti1.setCzrq(new Date());
 | 
	
		
			
				|  |  | ////					dti1.setDoctor(d_mobile_1);
 | 
	
		
			
				|  |  | ////					dti1.setName(doctor_1);
 | 
	
		
			
				|  |  | ////					dti1.setTeam(dt.getCode());
 | 
	
		
			
				|  |  | ////					dti1.setType(1);
 | 
	
		
			
				|  |  | ////					dtis.add(dti1);
 | 
	
		
			
				|  |  | ////
 | 
	
		
			
				|  |  | ////					DoctorTeamInfo dti2 = new DoctorTeamInfo();
 | 
	
		
			
				|  |  | ////					dti2.setCzrq(new Date());
 | 
	
		
			
				|  |  | ////					dti2.setDoctor(d_mobile_2);
 | 
	
		
			
				|  |  | ////					dti2.setName(doctor_2);
 | 
	
		
			
				|  |  | ////					dti2.setTeam(dt.getCode());
 | 
	
		
			
				|  |  | ////					dti2.setType(2);
 | 
	
		
			
				|  |  | ////					dtis.add(dti2);
 | 
	
		
			
				|  |  | ////
 | 
	
		
			
				|  |  | ////					DoctorTeamInfo dti3 = new DoctorTeamInfo();
 | 
	
		
			
				|  |  | ////					dti3.setCzrq(new Date());
 | 
	
		
			
				|  |  | ////					dti3.setDoctor(d_mobile_3);
 | 
	
		
			
				|  |  | ////					dti3.setName(doctor_3);
 | 
	
		
			
				|  |  | ////					dti3.setTeam(dt.getCode());
 | 
	
		
			
				|  |  | ////					dti3.setType(3);
 | 
	
		
			
				|  |  | ////					dtis.add(dti3);
 | 
	
		
			
				|  |  | ////
 | 
	
		
			
				|  |  | ////					team = dt.getCode();
 | 
	
		
			
				|  |  | ////					teams.put(d_mobile_1 + "," + d_mobile_2 + "," + d_mobile_2, dt.getCode());
 | 
	
		
			
				|  |  | ////				}
 | 
	
		
			
				|  |  | ////				System.out.println(begin + "=====" + end);
 | 
	
		
			
				|  |  | ////				System.out.println();
 | 
	
		
			
				|  |  | ////				SignContract sc = new SignContract();
 | 
	
		
			
				|  |  | ////				sc.setBegin(DateUtil.strToDateShort(begin));
 | 
	
		
			
				|  |  | ////				sc.setCode(patientService.getCode());
 | 
	
		
			
				|  |  | ////				sc.setEnd(DateUtil.strToDateShort(end));
 | 
	
		
			
				|  |  | ////				sc.setIdcard(idcard);
 | 
	
		
			
				|  |  | ////				sc.setSsc(ssc);
 | 
	
		
			
				|  |  | ////				sc.setMobile(mobile);
 | 
	
		
			
				|  |  | ////				sc.setBirthday(patient.getBirthday());
 | 
	
		
			
				|  |  | ////				sc.setSex(patient.getSex());
 | 
	
		
			
				|  |  | ////				sc.setDisease(patient.getDisease());
 | 
	
		
			
				|  |  | ////				sc.setDiseaseCondition(patient.getDiseaseCondition());
 | 
	
		
			
				|  |  | ////				sc.setMonths(12);
 | 
	
		
			
				|  |  | ////				sc.setTeam(team);
 | 
	
		
			
				|  |  | ////				sc.setUname(name);
 | 
	
		
			
				|  |  | ////				sc.setUser(patient.getCode());
 | 
	
		
			
				|  |  | ////				sc.setGp(d_mobile_2);
 | 
	
		
			
				|  |  | ////				sc.setSpec(d_mobile_1);
 | 
	
		
			
				|  |  | ////				sc.setHealthManager(d_mobile_3);
 | 
	
		
			
				|  |  | ////				sc.setStatus(1);
 | 
	
		
			
				|  |  | ////				scs.add(sc);
 | 
	
		
			
				|  |  | ////
 | 
	
		
			
				|  |  | ////				DoctorPatientGroupInfo dpgi1 = new DoctorPatientGroupInfo();
 | 
	
		
			
				|  |  | ////				dpgi1.setCzrq(new Date());
 | 
	
		
			
				|  |  | ////				dpgi1.setDoctor(d_mobile_1);
 | 
	
		
			
				|  |  | ////				dpgi1.setDqrq(sc.getEnd());
 | 
	
		
			
				|  |  | ////				if (patient.getDisease() == 1) {
 | 
	
		
			
				|  |  | ////					// 高友
 | 
	
		
			
				|  |  | ////					dpgi1.setGroup("1");
 | 
	
		
			
				|  |  | ////				} else if (patient.getDisease() == 2) {
 | 
	
		
			
				|  |  | ////					// 糖友
 | 
	
		
			
				|  |  | ////					dpgi1.setGroup("2");
 | 
	
		
			
				|  |  | ////				} else {
 | 
	
		
			
				|  |  | ////					// 我的患者
 | 
	
		
			
				|  |  | ////					dpgi1.setGroup("3");
 | 
	
		
			
				|  |  | ////				}
 | 
	
		
			
				|  |  | ////				dpgi1.setPartAmount(0);
 | 
	
		
			
				|  |  | ////				dpgi1.setPatient(patient.getCode());
 | 
	
		
			
				|  |  | ////				dpgi1.setPname(patient.getName());
 | 
	
		
			
				|  |  | ////				dpgi1.setQyrq(sc.getBegin());
 | 
	
		
			
				|  |  | ////				dpgi1.setSignType("1");
 | 
	
		
			
				|  |  | ////				dpgi1.setStatus(1);
 | 
	
		
			
				|  |  | ////				dptis.add(dpgi1);
 | 
	
		
			
				|  |  | ////
 | 
	
		
			
				|  |  | ////				DoctorPatientGroupInfo dpgi2 = new DoctorPatientGroupInfo();
 | 
	
		
			
				|  |  | ////				dpgi2.setCzrq(new Date());
 | 
	
		
			
				|  |  | ////				dpgi2.setDoctor(d_mobile_2);
 | 
	
		
			
				|  |  | ////				dpgi2.setDqrq(sc.getEnd());
 | 
	
		
			
				|  |  | ////				if (patient.getDisease() == 1) {
 | 
	
		
			
				|  |  | ////					// 高友
 | 
	
		
			
				|  |  | ////					dpgi2.setGroup("1");
 | 
	
		
			
				|  |  | ////				} else if (patient.getDisease() == 2) {
 | 
	
		
			
				|  |  | ////					// 糖友
 | 
	
		
			
				|  |  | ////					dpgi2.setGroup("2");
 | 
	
		
			
				|  |  | ////				} else {
 | 
	
		
			
				|  |  | ////					// 我的患者
 | 
	
		
			
				|  |  | ////					dpgi2.setGroup("3");
 | 
	
		
			
				|  |  | ////				}
 | 
	
		
			
				|  |  | ////				dpgi2.setPartAmount(0);
 | 
	
		
			
				|  |  | ////				dpgi2.setPatient(patient.getCode());
 | 
	
		
			
				|  |  | ////				dpgi2.setPname(patient.getName());
 | 
	
		
			
				|  |  | ////				dpgi2.setQyrq(sc.getBegin());
 | 
	
		
			
				|  |  | ////				dpgi2.setSignType("1");
 | 
	
		
			
				|  |  | ////				dpgi2.setStatus(1);
 | 
	
		
			
				|  |  | ////				dptis.add(dpgi2);
 | 
	
		
			
				|  |  | ////
 | 
	
		
			
				|  |  | ////				DoctorPatientGroupInfo dpgi3 = new DoctorPatientGroupInfo();
 | 
	
		
			
				|  |  | ////				dpgi3.setCzrq(new Date());
 | 
	
		
			
				|  |  | ////				dpgi3.setDoctor(d_mobile_3);
 | 
	
		
			
				|  |  | ////				dpgi3.setDqrq(sc.getEnd());
 | 
	
		
			
				|  |  | ////				if (patient.getDisease() == 1) {
 | 
	
		
			
				|  |  | ////					// 高友
 | 
	
		
			
				|  |  | ////					dpgi3.setGroup("1");
 | 
	
		
			
				|  |  | ////				} else if (patient.getDisease() == 2) {
 | 
	
		
			
				|  |  | ////					// 糖友
 | 
	
		
			
				|  |  | ////					dpgi3.setGroup("2");
 | 
	
		
			
				|  |  | ////				} else {
 | 
	
		
			
				|  |  | ////					// 我的患者
 | 
	
		
			
				|  |  | ////					dpgi3.setGroup("3");
 | 
	
		
			
				|  |  | ////				}
 | 
	
		
			
				|  |  | ////				dpgi3.setPartAmount(0);
 | 
	
		
			
				|  |  | ////				dpgi3.setPatient(patient.getCode());
 | 
	
		
			
				|  |  | ////				dpgi3.setPname(patient.getName());
 | 
	
		
			
				|  |  | ////				dpgi3.setQyrq(sc.getBegin());
 | 
	
		
			
				|  |  | ////				dpgi3.setSignType("1");
 | 
	
		
			
				|  |  | ////				dpgi3.setStatus(1);
 | 
	
		
			
				|  |  | ////				dptis.add(dpgi3);
 | 
	
		
			
				|  |  | ////			}
 | 
	
		
			
				|  |  | ////			importDataService.importSignData(patients, scs, dts, dtis, dptis);
 | 
	
		
			
				|  |  | ////			writeFile("D:\\tmp\\error.txt", errors);
 | 
	
		
			
				|  |  | ////			return success("导入成功!");
 | 
	
		
			
				|  |  | ////		} catch (Exception e) {
 | 
	
		
			
				|  |  | ////			error(e);
 | 
	
		
			
				|  |  | ////			return error(-1, "导入失败!");
 | 
	
		
			
				|  |  | ////		} finally {
 | 
	
		
			
				|  |  | ////			if (is != null) {
 | 
	
		
			
				|  |  | ////				is.close();
 | 
	
		
			
				|  |  | ////			}
 | 
	
		
			
				|  |  | ////			if (hssfWorkbook != null) {
 | 
	
		
			
				|  |  | ////				hssfWorkbook.close();
 | 
	
		
			
				|  |  | ////			}
 | 
	
		
			
				|  |  | ////		}
 | 
	
		
			
				|  |  | //		return null;
 | 
	
		
			
				|  |  | //	}
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | }
 |