Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

chenweida 8 years ago
parent
commit
87887f7250
18 changed files with 678 additions and 499 deletions
  1. 1 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/Prescription.java
  2. 34 116
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/yueren/YueRenController.java
  3. 14 1
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/PrescriptionController.java
  4. 7 10
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/zydict/ZyIvDeptDict.java
  5. 11 12
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/zydict/ZyIvPhysicDict.java
  6. 34 1
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionService.java
  7. 1 16
      patient-co-service/wlyy_service/src/main/resources/application.yml
  8. 378 294
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/ZyDictDataService.java
  9. 9 12
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java
  10. 28 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionDispensaryCodeService.java
  11. 2 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionExpressageService.java
  12. 36 10
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  13. 30 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java
  14. 20 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionCodeController.java
  15. 11 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java
  16. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java
  17. 21 17
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionController.java
  18. 40 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/ZyDictController.java

+ 1 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/Prescription.java

@ -638,6 +638,7 @@ public class Prescription extends IdEntity {
        this.prescribeReason = prescribeReason;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getPrescribeTime() {
        return prescribeTime;
    }

+ 34 - 116
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/yueren/YueRenController.java

@ -8,6 +8,7 @@ import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@ -47,44 +48,13 @@ public class YueRenController extends BaseController {
    /**
     * 新增客户咨询预约单,如果是新客人,同时新增客户信息
     * @param key
     * @param sl_date 预约时间
     * @param sl_state 咨询状态
     * @param u_tel
     * @param u_name
     * @param u_sex
     * @param sh_id 门店编号
     * @param u_idnum 身份证号码
     * @param u_native 籍贯
     * @param u_birthday
     * @param u_province
     * @param u_city
     * @param u_area
     * @param u_address
     * @param sl_pass 报告单是否审核通过
     * @param jsonString
     * @return
     */
    @RequestMapping(value = "insertslip", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String insertSlip(String key, String sl_date,String sl_state,String u_tel, String u_name, String u_sex,
                             String sh_id, String u_idnum, String u_native, String u_birthday, String u_province,
                             String u_city,String u_area,String u_address, String sl_pass) {
        JSONObject params = new JSONObject();
        params.put("key", key);
        params.put("sl_date", sl_date);
        params.put("sl_state", sl_state);
        params.put("u_tel", u_tel);
        params.put("u_name", u_name);
        params.put("u_sex", u_sex);
        params.put("sh_id", sh_id);
        params.put("u_idnum", u_idnum);
        params.put("u_native", u_native);
        params.put("u_birthday", u_birthday);
        params.put("u_province", u_province);
        params.put("u_city", u_city);
        params.put("u_area", u_area);
        params.put("u_address", u_address);
        params.put("sl_pass", sl_pass);
    public String insertSlip(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        String postStr = remoteCall("/yueren/insertslip", params);
        return postStr;
    }
@ -93,38 +63,26 @@ public class YueRenController extends BaseController {
    //--四诊模块 begin
    /**
     * 上传图片音频等附件
     * @param file 附件
     * @param jsonString 附件
     * @return
     */
    @RequestMapping(value = "/uploadattachment", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String uploadAttachment(String file, String e_no) {
    public String uploadAttachment(@RequestBody String jsonString) {
        JSONObject params = new JSONObject();
        params.put("file", file);
        String postStr = remoteCall("/yueren/uploadattachment", params);
        return postStr;
    }
    /**
     * 处理头像舌苔声音
     * @param key
     * @param at_id 文件id
     * @param answer 答案,格式固定为(”/attach/{{key}}/文件id/文件名称”)
     * @param answer_type 答案类型,备选数值(图片,录音,视频)
     * @param ct_id 预约编号
     * @param object_type 对象类型,备选数值(1,2,3)1脸型,2舌像,3录音
     * @param jsonString
     * @return
     */
    @RequestMapping(value = "dillphoneimgdata", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String inserTemp(String key, String at_id, String answer, String answer_type, String ct_id, String object_type) {
        JSONObject params = new JSONObject();
        params.put("key", key);
        params.put("at_id", at_id);
        params.put("answer", answer);
        params.put("answer_type", answer_type);
        params.put("ct_id", ct_id);
        params.put("object_type", object_type);
    public String inserTemp(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        String postStr = remoteCall("/yueren/dillphoneimgdata", params);
        return postStr;
    }
@ -133,94 +91,65 @@ public class YueRenController extends BaseController {
    //--答题模块 begin
    /**
     * 查找试卷
     * @param key
     * @param tp_type '问卷类型',//(备选值:1,2,4)1:初筛问卷,2:助理问卷,4:现场问卷,
     * @param sh_id 所属门店编号
     * @param jsonString
     * @return
     */
    @RequestMapping(value = "findtest", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String findTest(String key, String tp_type, String sh_id) {
        String key1 = request.getParameter("key");
        System.out.println(key1);
        JSONObject params = new JSONObject();
        params.put("key", key);
        params.put("tp_type", tp_type);
        params.put("sh_id", sh_id);
    public String findTest(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        String postStr = remoteCall("/yueren/findtest", params);
        return postStr;
    }
    /**
     * 查找试卷题目
     * @param key
     * @param ct_id 咨询编号
     * @param tp_id 试卷编号
     * @param pb_id 问题编号
     * @param jsonString
     * @return
     */
    @RequestMapping(value = "giveproblem", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String giveproblem(String key,String ct_id, String tp_id, String pb_id) {
        JSONObject params = new JSONObject();
        params.put("key", key);
        params.put("ct_id", ct_id);
        params.put("tp_id", tp_id);
        params.put("pb_id", pb_id);
    public String giveproblem(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        String postStr = remoteCall("/yueren/giveproblem", params);
        return postStr;
    }
    /**
     *
     * @param key
     * @param ct_id 咨询编号
     * @param tp_id 试卷编号
     * @param pb_id 问题编号
     * @param dc_answer 答案数组
     * 将用户提交的试卷题目的答案进行保存
     * @param jsonString
     * @return 将用户提交的试卷题目的答案进行保存
     */
    @RequestMapping(value = "handleproblem", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String handleproblem(String key, String ct_id, String tp_id,String pb_id, String[] dc_answer) {
        JSONObject params = new JSONObject();
        params.put("key", key);
        params.put("ct_id", ct_id);
        params.put("tp_id", tp_id);
        params.put("pb_id", pb_id);
        params.put("dc_answer", dc_answer);
    public String handleproblem(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        String postStr = remoteCall("/yueren/handleproblem", params);
        return postStr;
    }
    /**
     * 将用户提交的试卷题目的答案进行处理
     * @param key
     * @param ct_id 咨询编号
     * @param jsonString
     * @return
     */
    @RequestMapping(value = "centralizedproblem", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String centralizedproblem(String key, String ct_id) {
        JSONObject params = new JSONObject();
        params.put("key", key);
        params.put("ct_id", ct_id);
    public String centralizedproblem(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        String postStr = remoteCall("/yueren/centralizedproblem", params);
        return postStr;
    }
    /**
     * 在生成报告单之前,必须调用这个接口,将风险预警中的因素中的所有病处理到影响中
     * @param key
     * @param ct_id 咨询编号
     * @param jsonString
     * @return
     */
    @RequestMapping(value = "conclusionfactor", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String conclusionFactor(String key, String ct_id) {
        JSONObject params = new JSONObject();
        params.put("key", key);
        params.put("ct_id", ct_id);
    public String conclusionFactor(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        String postStr = remoteCall("/yueren/conclusionfactor", params);
        return postStr;
    }
@ -229,50 +158,39 @@ public class YueRenController extends BaseController {
    //--报告单模块 begin
    /**
     * 生成报告单
     * @param key
     * @param ct_id 咨询编号
     * @param jsonString
     * @return
     */
    @RequestMapping(value = "insertconconhealth", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String insertConsultConclusionHealth(String key, String ct_id) {
        JSONObject params = new JSONObject();
        params.put("key", key);
        params.put("ct_id", ct_id);
    public String insertConsultConclusionHealth(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        String postStr = remoteCall("/yueren/insertconconhealth", params);
        return postStr;
    }
    /**
     * 查找报告单结论
     * @param key
     * @param ct_id 咨询编号
     * @param reqtype 请求类型(备选数值1)
     * @param jsonString
     * @return
     */
    @RequestMapping(value = "findconconhealth", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String insertConsultConclusion(String key, String ct_id, String reqtype) {
        JSONObject params = new JSONObject();
        params.put("key", key);
        params.put("ct_id", ct_id);
        params.put("reqtype", reqtype);
    public String insertConsultConclusion(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        String postStr = remoteCall("/yueren/findconconhealth", params);
        return postStr;
    }
    /**
     * 查找状态要素结论积分图及个人信息
     * @param key
     * @param ct_id 咨询编号
     * @param jsonString
     * @return
     */
    @RequestMapping(value = "findintegral", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String findIntegral(String key, String ct_id) {
        JSONObject params = new JSONObject();
        params.put("key", key);
        params.put("ct_id", ct_id);
    public String findIntegral(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        String postStr = remoteCall("/yueren/findintegral", params);
        return postStr;
    }

+ 14 - 1
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/PrescriptionController.java

@ -42,7 +42,7 @@ public class PrescriptionController extends BaseController{
	}
	@RequestMapping(value = "prePayCompletion",method = RequestMethod.POST)
	@ApiOperation("接收预结算完成消息")
	@ApiOperation("接收预结算完成消息(废弃)")
	public Result prePayCompletion(@ApiParam(name="data",value="json串",defaultValue = "{\"CODE\":1,\"RECIPE_NO\":\"0\",\"ORDER_NO\":\"DB0537136\"}")
								   @RequestParam(value = "data",required = true) String data){
		try {
@ -230,6 +230,19 @@ public class PrescriptionController extends BaseController{
		}
	}
	@RequestMapping(value = "affirmCARecipe",method = RequestMethod.POST)
	@ApiOperation("CA认证通过接口")
	public Result affirmCARecipe(@ApiParam(name="code",value="续方code",defaultValue = "")
								 @RequestParam(value = "code",required = true) String code){
		try {
			String re = prescriptionService.affirmCARecipe(code);
			return Result.success("CA认证通过接口!",re);
		} catch (Exception ex) {
			ex.printStackTrace();
			return Result.error(ex.getMessage());
		}
	}
	/************************************ CA认证 ************************************************************/
	@RequestMapping(value = "RequestRealNameSoftCertAndSign",method = RequestMethod.POST)
	@ResponseBody

+ 7 - 10
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/zydict/ZyIvDeptDict.java

@ -20,7 +20,7 @@ public class ZyIvDeptDict extends IdEntity implements java.io.Serializable {
	private String orgCode;//机构编码
	private String deptCode;//科室代码
	private String deptName;//科室名称
	private String deptType;//科室类型  详见科室类型字典中定义
	private String deptClass;//科室类型  详见科室类型字典中定义
	private String upperDept;//上级科室
	// Constructors
@ -31,11 +31,10 @@ public class ZyIvDeptDict extends IdEntity implements java.io.Serializable {
	/** full constructor */
	public ZyIvDeptDict(String orgCode, String deptCode, String deptName,
			String deptType, String upperDept) {
						String deptType, String upperDept) {
		this.orgCode = orgCode;
		this.deptCode = deptCode;
		this.deptName = deptName;
		this.deptType = deptType;
		this.upperDept = upperDept;
	}
@ -66,14 +65,12 @@ public class ZyIvDeptDict extends IdEntity implements java.io.Serializable {
	public void setDeptName(String deptName) {
		this.deptName = deptName;
	}
	@Column(name = "dept_type", length = 50)
	public String getDeptType() {
		return this.deptType;
	@Column(name = "dept_class", length = 50)
	public String getDeptClass() {
		return deptClass;
	}
	public void setDeptType(String deptType) {
		this.deptType = deptType;
	public void setDeptClass(String deptClass) {
		this.deptClass = deptClass;
	}
	@Column(name = "upper_dept", length = 50)

+ 11 - 12
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/zydict/ZyIvPhysicDict.java

@ -27,7 +27,7 @@ public class ZyIvPhysicDict extends IdEntity implements java.io.Serializable {
	private Double minDose;//最小剂量
	private Double packSpec;
	private Double retailPrice;//零售价
	private String physicFrom;//药品剂型  药品剂型字典中定义
	private String physicForm;//药品剂型  药品剂型字典中定义
	private String toxicologyType;//毒理分类  药品毒理分类字典中定义
	private String basicFlag;//基本药物标志  0:否;1:是
	private String validFlag;//有效标志 0:无效;1:有效
@ -43,11 +43,11 @@ public class ZyIvPhysicDict extends IdEntity implements java.io.Serializable {
	/** full constructor */
	public ZyIvPhysicDict(String physicCode, String physicName,
			String physicSpec, String subjectClass, String doseUnit,
			String quantityUnit, String packUnit, Double minDose,
			Double packSpec, Double retailPrice, String physicFrom,
			String toxicologyType, String basicFlag, String validFlag,
			String spellCode, String wbzxCode, Integer sequence) {
						  String physicSpec, String subjectClass, String doseUnit,
						  String quantityUnit, String packUnit, Double minDose,
						  Double packSpec, Double retailPrice, String physicFrom,
						  String toxicologyType, String basicFlag, String validFlag,
						  String spellCode, String wbzxCode, Integer sequence) {
		this.physicCode = physicCode;
		this.physicName = physicName;
		this.physicSpec = physicSpec;
@ -58,7 +58,6 @@ public class ZyIvPhysicDict extends IdEntity implements java.io.Serializable {
		this.minDose = minDose;
		this.packSpec = packSpec;
		this.retailPrice = retailPrice;
		this.physicFrom = physicFrom;
		this.toxicologyType = toxicologyType;
		this.basicFlag = basicFlag;
		this.validFlag = validFlag;
@ -158,13 +157,13 @@ public class ZyIvPhysicDict extends IdEntity implements java.io.Serializable {
		this.retailPrice = retailPrice;
	}
	@Column(name = "physic_from", length = 50)
	public String getPhysicFrom() {
		return this.physicFrom;
	@Column(name = "physic_form", length = 50)
	public String getPhysicForm() {
		return physicForm;
	}
	public void setPhysicFrom(String physicFrom) {
		this.physicFrom = physicFrom;
	public void setPhysicForm(String physicForm) {
		this.physicForm = physicForm;
	}
	@Column(name = "toxicology_type", length = 250)

+ 34 - 1
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionService.java

@ -542,7 +542,7 @@ public class PrescriptionService extends ZysoftBaseService{
        if(prescriptionDiagnosisList.size()>1){
            json.put("DIAGNOSE_SUB_CODE",prescriptionDiagnosisList.get(1).getCode());//"DIAGNOSE_CODE": "次诊断编码",
        }
        if(prescription.getCaCertData()==null){
        if(prescription.getCaCertData()!=null){
            json.put("ORIGINAL_DATA",prescription.getStrOriginalData());//原文
            json.put("ORIGINAL_DATA_MD5",prescription.getOriginalDataAbstract());//原文的MD5摘要
            json.put("CA_SIGN_DATA",prescription.getCaMessage());//签名值
@ -743,6 +743,39 @@ public class PrescriptionService extends ZysoftBaseService{
        return response;
    }
    /**
     * CA认证通过接口
     * @param code
     * @return
     */
    public String affirmCARecipe(String code) throws Exception{
        Prescription prescription = prescriptionDao.findByCode(code);
        String[] hospitalMapping = getHospitalMapping(prescription.getHospital()); //获取机构映射
        String hospital = hospitalMapping[0];
        String licence = hospitalMapping[1];
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        //拼接开方参数
        JSONObject json = new JSONObject();
        json.put("recipeNo",prescription.getRecipeNo());// "recipeNo": "医嘱号",
        if(prescription.getCaCertData()!=null){
            json.put("ORIGINAL_DATA",prescription.getStrOriginalData());//原文
            json.put("ORIGINAL_DATA_MD5",prescription.getOriginalDataAbstract());//原文的MD5摘要
            json.put("CA_SIGN_DATA",prescription.getCaMessage());//签名值
            json.put("CA_CERTMAIN_DATA",prescription.getCaCertData());//签名证书主体数据
            json.put("CA_DIGITAL_SIGN_STREAM_NO_UUID",prescription.getDigitalSignNo());//CA数字签名唯一流水号
        }else {
            throw new Exception("未找到ca认证数据");
        }
        String response = postSecond("affirmCARecipe","CA认证通过接口",null,json,header,false,2);
        return response;
    }
    /*********************************************请求智业接口数据 end**************************************************/

+ 1 - 16
patient-co-service/wlyy_service/src/main/resources/application.yml

@ -57,7 +57,7 @@ redisChannel:
---
spring:
  profiles: dev1
  profiles: dev
  datasource:
    url: jdbc:mysql://172.19.103.77:3306/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
    username: root
@ -71,21 +71,6 @@ spring:
    port: 6379 # Redis server port.
#    password: jkzl_ehr
---
spring:
  profiles: dev
  datasource:
    url: jdbc:mysql://172.19.103.85:3306/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
    username: linzhou
    password: linzhou
    driverClassName: com.mysql.jdbc.Driver
    maxTotal: 500
    maxIdle: 30
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
#    password: jkzl_ehr
---
spring:
  profiles: test

+ 378 - 294
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/ZyDictDataService.java

@ -1,351 +1,391 @@
package com.yihu.wlyy.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.entity.zydict.*;
import com.yihu.wlyy.repository.zydict.*;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
 * Created by chenweida on 2017/8/10.
 * 每天1点同步 智业的字典数据
 * 智业的字典数据
 */
@Service
public class ZyDictDataService extends BaseService {
    private Logger logger = LoggerFactory.getLogger(ZyDictDataService.class);
    @Autowired
    private JwPrescriptionService jwPrescriptionService;
    @Autowired
    private HospitalDao hospitalDao;
    private ZyCommonDictDao zyCommonDictDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public void synchronizeZy_iv_subject_class_dict() {
        try{
            String re = jwPrescriptionService.getDictForI(IV_SUBJECT_CLASS_DICT);
            JSONObject jsonObject = JSONObject.parseObject(re);
            if(jsonObject.getInteger("status")==200){
                JSONObject data = jsonObject.getJSONObject("data");
                if("1".equals(data.getString("CODE"))){
                    JSONArray returnData = data.getJSONArray("returnData");
                    System.out.println("returnData="+returnData.toString());
                    if(returnData.size()==0){
                        return;
                    }
                    JSONArray dictArray = returnData.getJSONArray(0);
                    for(int i=0;i<dictArray.size();i++){
                        JSONObject dict = dictArray.getJSONObject(i);
                        StringBuffer sql = new StringBuffer("insert into ");
                        sql.append(TableName.zy_iv_subject_class_dict.getDict()).append(" (class_code,class_name,upper_class,spell_code,wbzx_code) " );
                        sql.append("values('").append(dict.getString("CLASS_CODE")).append("','");
                        sql.append(dict.getString("CLASS_NAME")).append("','");
                        sql.append(dict.getString("UPPER_CLASS")).append("','");
                        sql.append(dict.getString("SPELL_CODE")).append("','");
                        sql.append(dict.getString("WBZX_CODE")).append("')");
                        System.out.println("sql="+sql.toString());
                        jdbcTemplate.execute(sql.toString());
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
    private ZyIvDeptDictDao zyIvDeptDictDao;
    @Autowired
    private ZyIvDeptStaffAllotDictDao zyIvDeptStaffAllotDictDao;
    @Autowired
    private ZyIvDiagnoseClassDictDao zyIvDiagnoseClassDictDao;
    @Autowired
    private ZyIvDiagnoseDictDao zyIvDiagnoseDictDao;
    @Autowired
    private ZyIvOrgPhysicAllotDictDao zyIvOrgPhysicAllotDictDao;
    @Autowired
    private ZyIvPhysicDictDao zyIvPhysicDictDao;
    @Autowired
    private ZyIvStaffDictDao zyIvStaffDictDao;
    @Autowired
    private ZyIvStaffRegTypeAllotDictDao zyIvStaffRegTypeAllotDictDao;
    @Autowired
    private ZyIvSubjectClassDictDao zyIvSubjectClassDictDao;
    /**
     * 根据字典名称下载字典
     * @param dictName
     */
    public void dictByDictName(String dictName){
        switch (dictName){
            case IV_SUBJECT_CLASS_DICT:
                synchronizeZy_iv_subject_class_dict();
                break;
            case IV_STAFF_REG_TYPE_ALLOT_DICT:
                synchronizeZy_iv_staff_reg_type_allot_dict();
                break;
            case IV_STAFF_DICT:
                synchronizeZy_iv_staff_dict();
                break;
            case IV_PHYSIC_DICT:
                synchronizeZy_iv_physic_dict();
                break;
            case IV_ORG_PHYSIC_ALLOT_DICT:
                synchronizeZy_iv_org_physic_allot_dict();
                break;
            case IV_DIAGNOSE_CLASS_DICT:
                synchronizeZy_iv_diagnose_class_dict();
                break;
            case IV_DEPT_STAFF_ALLOT_DICT:
                synchronizeZy_iv_dept_staff_allot_dict();
                break;
            case "commonDict":
                synchronizeZyCommonDict();
                break;
            case IV_DEPT_DICT:
                synchronizeZy_iv_dept_dict();
                break;
            default:break;
        }
    }
    public void synchronizeZy_iv_staff_reg_type_allot_dict() {
        try{
            String re = jwPrescriptionService.getDictForI(IV_STAFF_REG_TYPE_ALLOT_DICT);
            JSONObject jsonObject = JSONObject.parseObject(re);
            if(jsonObject.getInteger("status")==200){
                JSONObject data = jsonObject.getJSONObject("data");
                if("1".equals(data.getString("CODE"))){
                    JSONArray returnData = data.getJSONArray("returnData");
                    System.out.println("returnData="+returnData.toString());
                    if(returnData.size()==0){
                        return;
                    }
                    JSONArray dictArray = returnData.getJSONArray(0);
                    for(int i=0;i<dictArray.size();i++){
                        JSONObject dict = dictArray.getJSONObject(i);
                        StringBuffer sql = new StringBuffer("insert into ");
                        sql.append(TableName.zy_iv_staff_reg_type_allot_dict.getDict()).append(" (org_code,staff_code,register_type,register_type_name,register_fee) " );
                        sql.append("values('").append(dict.getString("ORG_CODE")).append("','");
                        sql.append(dict.getString("STAFF_CODE")).append("','");
                        sql.append(dict.getString("REGISTER_TYPE")).append("','");
                        sql.append(dict.getString("REGISTER_TYPE_NAME")).append("','");
                        sql.append(dict.getString("REGISTER_FEE")).append("')");
                        System.out.println("sql="+sql.toString());
                        jdbcTemplate.execute(sql.toString());
                    }
                }
            }
        }catch (Exception e){
    public void allDict() {
        try {
            //同步 zy_common_dict
            synchronizeZyCommonDict();
            //同步 zy_iv_dept_dict
            synchronizeZy_iv_dept_dict();
            //同步 zy_iv_dept_staff_allot_dict
            synchronizeZy_iv_dept_staff_allot_dict();
            //同步 zy_iv_diagnose_dict
            synchronizeZy_iv_diagnose_dict();
            //同步 zy_iv_diagnose_class_dict
            synchronizeZy_iv_diagnose_class_dict();
            //同步 zy_iv_org_physic_allot_dict
            synchronizeZy_iv_org_physic_allot_dict();
            //同步 zy_iv_physic_dict
            synchronizeZy_iv_physic_dict();
            //同步 zy_iv_staff_dict
            synchronizeZy_iv_staff_dict();  //birthday    Date(529084800000+0800) 无法解析
            //同步 zy_iv_staff_reg_type_allot_dict
            synchronizeZy_iv_staff_reg_type_allot_dict();
            //同步 zy_iv_subject_class_dict
            synchronizeZy_iv_subject_class_dict();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public void synchronizeZ_iv_staff_dict() {
        try{
            String re = jwPrescriptionService.getDictForI(IV_STAFF_DICT);
            JSONObject jsonObject = JSONObject.parseObject(re);
            if(jsonObject.getInteger("status")==200){
                JSONObject data = jsonObject.getJSONObject("data");
                if("1".equals(data.getString("CODE"))){
                    JSONArray returnData = data.getJSONArray("returnData");
                    System.out.println("returnData="+returnData.toString());
                    if(returnData.size()==0){
                        return;
                    }
                    JSONArray dictArray = returnData.getJSONArray(0);
                    for(int i=0;i<dictArray.size();i++){
                        JSONObject dict = dictArray.getJSONObject(i);
                        StringBuffer sql = new StringBuffer("insert into ");
                        sql.append(TableName.zy_iv_staff_dict.getDict()).append(" (org_code,staff_code,staff_name,work_code,birthday,sex,spell_code,wbzx_code,identity_no,certificate_no) " );
                        sql.append("values('").append(dict.getString("ORG_CODE")).append("','");
                        sql.append(dict.getString("STAFF_CODE")).append("','");
                        sql.append(dict.getString("STAFF_NAME")).append("','");
                        sql.append(dict.getString("WORK_CODE")).append("','");
                        sql.append(dict.getString("BIRTHDAY")).append("','");
                        sql.append(dict.getString("SEX")).append("','");
                        sql.append(dict.getString("SPELL_CODE")).append("','");
                        sql.append(dict.getString("WBZX_CODE")).append("','");
                        sql.append(dict.getString("IDENTITY_NO")).append("','");
                        sql.append(dict.getString("CERTIFICATE_NO")).append("')");
                        System.out.println("sql="+sql.toString());
                        jdbcTemplate.execute(sql.toString());
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
    private void synchronizeZy_iv_diagnose_dict() {
        logger.info("synchronized zy_iv_diagnose_dict start");
        String dictName = this.IV_DIAGNOSE_DICT;
        List<ZyIvDiagnoseDict> zyIvDiagnoseDicts = new ArrayList<>();
        //得到list
        zyIvDiagnoseDicts = commonGetOneDict(ZyIvDiagnoseDict.class, dictName);
        if (zyIvDiagnoseDicts != null && zyIvDiagnoseDicts.size() > 0) {
            //清空表
            zyIvDiagnoseDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_diagnose_dict  ,size:" + zyIvDiagnoseDicts.size());
            zyIvDiagnoseDictDao.save(zyIvDiagnoseDicts);
        }
        logger.info("synchronized zy_iv_diagnose_dict end");
    }
    private String changDate(String date){
        String str=date.replace("/Date(","").replace(")/","");
        String time = str.substring(0,str.length()-5);
        Date data = new Date(Long.parseLong(time));
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return format.format(data);
    @Transactional
    private void synchronizeZy_iv_subject_class_dict() {
        logger.info("synchronized zy_iv_subject_class_dict start");
        String dictName = this.IV_SUBJECT_CLASS_DICT;
        List<ZyIvSubjectClassDict> zyIvSubjectClassDicts = new ArrayList<>();
        //得到list
        zyIvSubjectClassDicts = commonGetOneDict(ZyIvSubjectClassDict.class, dictName);
        if (zyIvSubjectClassDicts.size() > 0) {
            //清空表
            zyIvSubjectClassDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_subject_class_dict  ,size:" + zyIvSubjectClassDicts.size());
            zyIvSubjectClassDictDao.save(zyIvSubjectClassDicts);
            logger.info("synchronized zy_iv_subject_class_dict end");
        }
    }
    public void synchronizeZy_iv_physic_dict() {
        try{
            String re = jwPrescriptionService.getDictForI(IV_PHYSIC_DICT);
            JSONObject jsonObject = JSONObject.parseObject(re);
            if(jsonObject.getInteger("status")==200){
                JSONObject data = jsonObject.getJSONObject("data");
                if("1".equals(data.getString("CODE"))){
                    JSONArray returnData = data.getJSONArray("returnData");
                    System.out.println("returnData="+returnData.toString());
                    if(returnData.size()==0){
                        return;
                    }
                    JSONArray dictArray = returnData.getJSONArray(0);
                    for(int i=0;i<dictArray.size();i++){
                        JSONObject dict = dictArray.getJSONObject(i);
                        StringBuffer sql = new StringBuffer("insert into ");
                        sql.append(TableName.zy_iv_physic_dict.getDict()).append(" (physic_code,physic_name,physic_spec,subject_class,dose_unit,quantity_unit,pack_unit,min_dose,pack_spec, " );
                        sql.append("retail_price,physic_from,toxicology_type,basic_flag,valid_flag,spell_code,wbzx_code,sequence)");
                        sql.append("values('").append(dict.getString("PHYSIC_CODE")).append("','");//药品代码
                        sql.append(dict.getString("PHYSIC_NAME")).append("','");//'药品名称'
                        sql.append(dict.getString("PHYSIC_SPEC")).append("','");//'药品规格'
                        sql.append(dict.getString("SUBJECT_CLASS")).append("','");//'药品科目  科目类别字典中定义'
                        sql.append(dict.getString("DOSE_UNIT")).append("','");//'剂量单位 计量单位字典中定义'
                        sql.append(dict.getString("QUANTITY_UNIT")).append("','");///'数量单位  计量单位字典中定义'
                        sql.append(dict.getString("PACK_UNIT")).append("',");//'包装单位   计量单位字典中定义'
                        sql.append(dict.getDouble("MIN_DOSE")).append(",");//'最小剂量'
                        sql.append(dict.getDouble("PACK_SPEC")).append(",");//
                        sql.append(dict.getDouble("RETAIL_PRICE")).append(",'");//'零售价'
                        sql.append(dict.getString("PHYSIC_FROM")).append("','");//'药品剂型  药品剂型字典中定义'
                        sql.append(dict.getString("TOXICOLOGY_TYPE")).append("','");//'毒理分类  药品毒理分类字典中定义'
                        sql.append(dict.getString("BASIC_FLAG")).append("','");//'基本药物标志  0:否;1:是'
                        sql.append(dict.getString("VALID_FLAG")).append("','");//'有效标志 0:无效;1:有效'
                        sql.append(dict.getString("SPELL_CODE")).append("','");//'拼音首码'
                        sql.append(dict.getString("WBZX_CODE")).append("',");//'五笔首码'
                        if(dict.getInteger("SEQUENCE")==null){
                            sql.append(dict.getInteger("SEQUENCE")).append(")");//'排序号'
                        }else {
                            sql.append(dict.getString("SEQUENCE")).append(")");//'排序号'
                        }
                        System.out.println("sql="+sql.toString());
                        jdbcTemplate.execute(sql.toString());
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
    @Transactional
    private void synchronizeZy_iv_staff_reg_type_allot_dict() {
        logger.info("synchronized zy_iv_staff_reg_type_allot_dict start");
        String dictName = this.IV_STAFF_REG_TYPE_ALLOT_DICT;
        List<ZyIvStaffRegTypeAllotDict> zyIvStaffRegTypeAllotDicts = new ArrayList<>();
        //得到list
        zyIvStaffRegTypeAllotDicts = commonGetOneDict(ZyIvStaffRegTypeAllotDict.class, dictName);
        if (zyIvStaffRegTypeAllotDicts != null && zyIvStaffRegTypeAllotDicts.size() > 0) {
            //清空表
            zyIvStaffRegTypeAllotDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_staff_reg_type_allot_dict  ,size:" + zyIvStaffRegTypeAllotDicts.size());
            zyIvStaffRegTypeAllotDictDao.save(zyIvStaffRegTypeAllotDicts);
            logger.info("synchronized zy_iv_staff_reg_type_allot_dict end");
        }
    }
    public void synchronizeZy_iv_org_physic_allot_dict() {
        try{
            String re = jwPrescriptionService.getDictForI(IV_ORG_PHYSIC_ALLOT_DICT);
            JSONObject jsonObject = JSONObject.parseObject(re);
            if(jsonObject.getInteger("status")==200){
                JSONObject data = jsonObject.getJSONObject("data");
                if("1".equals(data.getString("CODE"))){
                    JSONArray returnData = data.getJSONArray("returnData");
                    System.out.println("returnData="+returnData.toString());
                    if(returnData.size()==0){
                        return;
                    }
                    JSONArray dictArray = returnData.getJSONArray(0);
                    for(int i=0;i<dictArray.size();i++){
                        JSONObject dict = dictArray.getJSONObject(i);
                        StringBuffer sql = new StringBuffer("insert into ");
                        sql.append(TableName.zy_iv_org_physic_allot_dict.getDict()).append(" (org_code,physic_code) " );
                        sql.append("values('").append(dict.getString("ORG_CODE")).append("','");//'机构编码'
                        sql.append(dict.getString("PHYSIC_CODE")).append("')");//'药品代码'
                        System.out.println("sql="+sql.toString());
                        jdbcTemplate.execute(sql.toString());
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
    @Transactional
    private void synchronizeZy_iv_staff_dict() {
        logger.info("synchronized zy_iv_staff_dict start");
        String dictName = this.IV_STAFF_DICT;
        List<ZyIvStaffDict> zyIvStaffDicts = new ArrayList<>();
        //得到list
        zyIvStaffDicts = commonGetOneDict(ZyIvStaffDict.class, dictName);
        //清空表
        if (zyIvStaffDicts != null && zyIvStaffDicts.size() > 0) {
            zyIvStaffDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_staff_dict  ,size:" + zyIvStaffDicts.size());
            zyIvStaffDictDao.save(zyIvStaffDicts);
            logger.info("synchronized zy_iv_staff_dict end");
        }
    }
    public void synchronizeZy_iv_diagnose_class_dict() {
        try{
            String re = jwPrescriptionService.getDictForI(IV_DIAGNOSE_CLASS_DICT);
            JSONObject jsonObject = JSONObject.parseObject(re);
            if(jsonObject.getInteger("status")==200){
                JSONObject data = jsonObject.getJSONObject("data");
                if("1".equals(data.getString("CODE"))){
                    JSONArray returnData = data.getJSONArray("returnData");
                    System.out.println("returnData="+returnData.toString());
                    if(returnData.size()==0){
                        return;
                    }
                    JSONArray dictArray = returnData.getJSONArray(0);
                    for(int i=0;i<dictArray.size();i++){
                        JSONObject dict = dictArray.getJSONObject(i);
                        StringBuffer sql = new StringBuffer("insert into ");
                        sql.append(TableName.zy_iv_diagnose_class_dict.getDict()).append(" (class_sub_no,class_code,class_name,upper_class,valid_flag,spell_code,wbzx_code) " );
                        sql.append("values('").append(dict.getString("CLASS_SUB_NO")).append("','");//''类别子序号''
                        sql.append(dict.getString("CLASS_CODE")).append("','");//'类别代码'
                        sql.append(dict.getString("CLASS_NAME")).append("','");//'类别名称'
                        sql.append(dict.getString("UPPER_CLASS")).append("','");//'上级类别'
                        sql.append(dict.getString("VALID_FLAG")).append("','");//'有效标志  0 :无效;1:有效'
                        sql.append(dict.getString("SPELL_CODE")).append("','");//'拼音首码'
                        sql.append(dict.getString("WBZX_CODE")).append("')");//''五笔首码''
                        System.out.println("sql="+sql.toString());
                        jdbcTemplate.execute(sql.toString());
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
    @Transactional
    private void synchronizeZy_iv_physic_dict() {
        logger.info("synchronized zy_iv_physic_dict start");
        String dictName = this.IV_PHYSIC_DICT;
        List<ZyIvPhysicDict> zyIvPhysicDicts = new ArrayList<>();
        //得到list
        zyIvPhysicDicts = commonGetOneDict(ZyIvPhysicDict.class, dictName);
        if (zyIvPhysicDicts != null && zyIvPhysicDicts.size() > 0) {
            //清空表
            zyIvPhysicDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_physic_dict  ,size:" + zyIvPhysicDicts.size());
            zyIvPhysicDictDao.save(zyIvPhysicDicts);
            logger.info("synchronized zy_iv_physic_dict end");
        }
    }
    public void synchronizeZy_iv_dept_staff_allot_dict() {
        try{
            String re = jwPrescriptionService.getDictForI(IV_DEPT_STAFF_ALLOT_DICT);
            JSONObject jsonObject = JSONObject.parseObject(re);
            if(jsonObject.getInteger("status")==200){
                JSONObject data = jsonObject.getJSONObject("data");
                if("1".equals(data.getString("CODE"))){
                    JSONArray returnData = data.getJSONArray("returnData");
                    System.out.println("returnData="+returnData.toString());
                    if(returnData.size()==0){
                        return;
                    }
                    JSONArray dictArray = returnData.getJSONArray(0);
                    for(int i=0;i<dictArray.size();i++){
                        JSONObject dict = dictArray.getJSONObject(i);
                        StringBuffer sql = new StringBuffer("insert into ");
                        sql.append(TableName.zy_iv_dept_staff_allot_dict.getDict()).append(" (org_code,dept_code,staff_code) " );
                        sql.append("values('").append(dict.getString("ORG_CODE")).append("','");//'''机构编码'''
                        sql.append(dict.getString("DEPT_CODE")).append("','");//''科室编码''
                        sql.append(dict.getString("STAFF_CODE")).append("')");//'''员工编码'''
                        System.out.println("sql="+sql.toString());
                        jdbcTemplate.execute(sql.toString());
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
    @Transactional
    private void synchronizeZy_iv_org_physic_allot_dict() {
        logger.info("synchronized zy_iv_org_physic_allot_dict start");
        String dictName = this.IV_ORG_PHYSIC_ALLOT_DICT;
        List<ZyIvOrgPhysicAllotDict> zyIvOrgPhysicAllotDicts = new ArrayList<>();
        //得到list
        zyIvOrgPhysicAllotDicts = commonGetOneDict(ZyIvOrgPhysicAllotDict.class, dictName);
        if (zyIvOrgPhysicAllotDicts != null && zyIvOrgPhysicAllotDicts.size() > 0) {
            //清空表
            zyIvOrgPhysicAllotDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_org_physic_allot_dict  ,size:" + zyIvOrgPhysicAllotDicts.size());
            zyIvOrgPhysicAllotDictDao.save(zyIvOrgPhysicAllotDicts);
        }
        logger.info("synchronized zy_iv_org_physic_allot_dict end");
    }
    @Transactional
    private void synchronizeZy_iv_diagnose_class_dict() {
        logger.info("synchronized zy_iv_diagnose_class_dict start");
        String dictName = this.IV_DIAGNOSE_CLASS_DICT;
        List<ZyIvDiagnoseClassDict> zIvDiagnoseClassDicts = new ArrayList<>();
        //得到list
        zIvDiagnoseClassDicts = commonGetOneDict(ZyIvDiagnoseClassDict.class, dictName);
        if (zIvDiagnoseClassDicts != null && zIvDiagnoseClassDicts.size() > 0) {
            //清空表
            zyIvDiagnoseClassDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_diagnose_class_dict  ,size:" + zIvDiagnoseClassDicts.size());
            zyIvDiagnoseClassDictDao.save(zIvDiagnoseClassDicts);
        }
        logger.info("synchronized zy_iv_diagnose_class_dict end");
    }
    @Transactional
    private void synchronizeZy_iv_dept_staff_allot_dict() {
        logger.info("synchronized zy_iv_dept_staff_allot_dict start");
        String dictName = this.IV_DEPT_STAFF_ALLOT_DICT;
        List<ZyIvDeptStaffAllotDict> syIvDeptStaffAllotDictz = new ArrayList<>();
        //得到list
        syIvDeptStaffAllotDictz = commonGetOneDict(ZyIvDeptStaffAllotDict.class, dictName);
        if (syIvDeptStaffAllotDictz != null && syIvDeptStaffAllotDictz.size() > 0) {
            //清空表
            zyIvDeptStaffAllotDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_dept_staff_allot_dict  ,size:" + syIvDeptStaffAllotDictz.size());
            zyIvDeptStaffAllotDictDao.save(syIvDeptStaffAllotDictz);
        }
        logger.info("synchronized zy_iv_dept_staff_allot_dict end");
    }
    public void synchronizeZyCommonDict() {
    @Transactional
    private void synchronizeZyCommonDict() {
        logger.info("synchronized zy_common_dict start");
        String[] dictNames = new String[]{
                this.IV_PHYSIC_FORM_DICT, this.IV_PHYSIC_INJECT_PLACE_DICT, this.IV_PHYSIC_SKIN_TEST_DICT,
                this.IV_RATE_TYPE_DICT, this.IV_RECIPE_FREQUENCY_DICT, this.IV_RECIPE_USAGE_DICT,
                this.IV_SEX_DICT, this.IV_PHYSIC_TOXICOLOGY_TYPE_DICT, this.IV_MEASURE_UNIT_DICT,
                this.IV_DEPT_TYPE_DICT};
        try{
            for (String dictName : dictNames) {
                String re = jwPrescriptionService.getDictForI(dictName);
                JSONObject jsonObject = JSONObject.parseObject(re);
                if(jsonObject.getInteger("status")==200){
                    JSONObject data = jsonObject.getJSONObject("data");
                    if("1".equals(data.getString("CODE"))){
                        JSONArray returnData = data.getJSONArray("returnData");
                        System.out.println("returnData="+returnData.toString());
                        if(returnData.size()==0){
                            continue;
                        }
                        JSONArray dictArray = returnData.getJSONArray(0);
                        for(int i=0;i<dictArray.size();i++){
                            JSONObject dict = dictArray.getJSONObject(i);
                            StringBuffer sql = new StringBuffer("insert into ");
                            sql.append(TableName.zy_common_dict.getDict()).append(" (dict_name,code,name) " );
                            sql.append("values('").append(dict.getString("DICT_NAME")).append("','");
                            sql.append(dict.getString("CODE")).append("','");
                            sql.append(dict.getString("NAME")).append("')");
                            System.out.println("sql="+sql.toString());
                            jdbcTemplate.execute(sql.toString());
                        }
        List<ZyCommonDict> zyCommonDictz = new ArrayList<>();
        Boolean isFlush = true;
        for (String dictName : dictNames) {
            String json = null;
            try {
                //调用智业的接口得到字典
                json = jwPrescriptionService.getDictForI(dictName);
                JSONObject returnJson = JSONObject.fromObject(json);
                if (returnJson.getInt("status") != 200) {
                    throw new Exception("zy dict error status not 200");
                }
                if (returnJson.containsKey("data")) {
                    String dataString = returnJson.getString("data");
                    JSONArray dataJSONArray = JSONObject.fromObject(dataString).getJSONArray("returnData");
                    if (dataJSONArray.size() == 0) {
                        logger.info("zy dict data size " + dataJSONArray.size() + ",dictname:" + dictName);
                        continue;
                    }
                    //下划线转驼峰
                    JSONArray newJA = new JSONArray();
                    JSONArray jsonArrayTemp = dataJSONArray.getJSONArray(0);
                    logger.info("zy dict data size " + jsonArrayTemp.size() + ",dictname:" + dictName);
                    for (int i = 0; i < jsonArrayTemp.size(); i++) {
                        JSONObject jo = jsonArrayTemp.getJSONObject(i);
                        JSONObject newJO = new JSONObject();
                        jo.keySet().stream().forEach(key -> {
                            Object value = jo.get(key);
                            String newKey = Tool.lineToHump(key.toString());
                            newJO.put(newKey, value);
                        });
                        newJA.add(newJO);
                    }
                    ZyCommonDict[] zyCommonDictArrays = (ZyCommonDict[]) JSONArray.toArray(newJA, ZyCommonDict.class);
                    zyCommonDictz.addAll(Arrays.asList(zyCommonDictArrays));
                } else {
                    throw new Exception("zy dict error no contain data");
                }
            } catch (Exception e) {
                e.printStackTrace();
                isFlush = false; //设置状态不能更新
                logger.error("dictName:" + dictName);
                logger.error("returnJson:" + json);
                logger.error(e.getMessage());
            }
        }
        //判断是否可以更新
        if (isFlush) {
            // 判断返回的数据是否大于0
            if (zyCommonDictz.size() > 0) {
                //清空表
                zyCommonDictDao.deleteAll();
                //新增数据
                logger.info("save table zy_common_dict  ,size:" + zyCommonDictz.size());
                zyCommonDictDao.save(zyCommonDictz);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        logger.info("synchronized zy_common_dict end");
    }
    public void synchronizeZy_iv_dept_dict() {
        try{
            String re = jwPrescriptionService.getDictForI(IV_DEPT_DICT);
            JSONObject jsonObject = JSONObject.parseObject(re);
            if(jsonObject.getInteger("status")==200){
                JSONObject data = jsonObject.getJSONObject("data");
                if("1".equals(data.getString("CODE"))){
                    JSONArray returnData = data.getJSONArray("returnData");
                    System.out.println("returnData="+returnData.toString());
                    if(returnData.size()==0){
                        return;
                    }
                    JSONArray dictArray = returnData.getJSONArray(0);
                    for(int i=0;i<dictArray.size();i++){
                        JSONObject dict = dictArray.getJSONObject(i);
                        StringBuffer sql = new StringBuffer("insert into ");
                        sql.append(TableName.zy_iv_dept_dict.getDict()).append(" (org_code,dept_code,dept_name,dept_type,upper_dept) " );
                        sql.append("values('").append(dict.getString("ORG_CODE")).append("','");//机构编码
                        sql.append(dict.getString("DEPT_CODE")).append("','");//'科室编码
                        sql.append(dict.getString("DEPT_NAME")).append("','");//'科室名称
                        sql.append(dict.getString("DEPT_TYPE")).append("','");//'科室类型  详见科室类型字典中定义
                        sql.append(dict.getString("UPPER_DEPT")).append("')");//'上级科室
                        System.out.println("sql="+sql.toString());
                        jdbcTemplate.execute(sql.toString());
                    }
    @Transactional
    private void synchronizeZy_iv_dept_dict() {
        logger.info("synchronized zy_iv_dept_dict start");
        String dictName = this.IV_DEPT_DICT;
        List<ZyIvDeptDict> zyIvDeptDicts = new ArrayList<>();
        //得到list
        zyIvDeptDicts = commonGetOneDict(ZyIvDeptDict.class, dictName);
        if (zyIvDeptDicts != null && zyIvDeptDicts.size() > 0) {
            //清空表
            zyIvDeptDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_dept_dict  ,size:" + zyIvDeptDicts.size());
            zyIvDeptDictDao.save(zyIvDeptDicts);
        }
        logger.info("synchronized zy_iv_dept_dict end");
    }
    /**
     * 得到单个字典
     *
     * @param clazz    class
     * @param dictName 字典名称
     */
    private List commonGetOneDict(Class clazz, String dictName) {
        String json = null;
        try {
            //调用智业的接口得到字典
            json = jwPrescriptionService.getDictForI(dictName);
            JSONObject returnJson = JSONObject.fromObject(json);
            if (returnJson.getInt("status") != 200) {
                throw new Exception("zy dict error status not 200");
            }
            if (returnJson.containsKey("data")) {
                String dataJSONStr = returnJson.getString("data");
                JSONObject joTemp = JSONObject.fromObject(dataJSONStr);
                JSONArray dataJSONArray = joTemp.getJSONArray("returnData");
                if (dataJSONArray.size() == 0) {
                    logger.info("zy dict data size " + dataJSONArray.size() + ",dictname:" + dictName);
                    return null;
                } else {
                    dataJSONArray = dataJSONArray.getJSONArray(0);
                }
                logger.info("zy dict data size " + dataJSONArray.size() + ",dictname:" + dictName);
                //下划线转驼峰
                JSONArray newJA = new JSONArray();
                for (int i = 0; i < dataJSONArray.size(); i++) {
                    JSONObject jo = dataJSONArray.getJSONObject(i);
                    JSONObject newJO = new JSONObject();
                    jo.keySet().stream().forEach(key -> {
                        Object value = jo.get(key);
                        String newKey = Tool.lineToHump(key.toString());
                        newJO.put(newKey, value);
                    });
                    newJA.add(newJO);
                }
                return (List) JSONArray.toCollection(newJA, clazz);
            } else {
                throw new Exception("zy dict error no contain data");
            }
        }catch (Exception e){
            e.printStackTrace();
        } catch (Exception e) {
            logger.error("dictName:" + dictName);
            logger.error("returnJson:" + json);
            logger.error(e.getMessage());
        }
        return null;
    }
    /**
@ -371,7 +411,9 @@ public class ZyDictDataService extends BaseService {
    public static final String IV_STAFF_REG_TYPE_ALLOT_DICT = "IV_STAFF_REG_TYPE_ALLOT_DICT";//("员工挂号类型配置字典", "IV_STAFF_REG_TYPE_ALLOT_DICT"),
    public static final String IV_DEPT_STAFF_ALLOT_DICT = "IV_DEPT_STAFF_ALLOT_DICT";//("科室员工配置字典", "IV_DEPT_STAFF_ALLOT_DICT");
    /**
     * 字典表的枚举类
     */
    public enum TableName {
        zy_common_dict("通用字典", "zy_common_dict"),
@ -408,6 +450,7 @@ public class ZyDictDataService extends BaseService {
        public void setDict(String dict) {
            this.dict = dict;
        }
    }
    /**
@ -479,4 +522,45 @@ public class ZyDictDataService extends BaseService {
        }
        return "";
    }
    public static class Tool {
        private static Pattern linePattern = Pattern.compile("_(\\w)");
        /**
         * 下划线转驼峰
         */
        public static String lineToHump(String str) {
            str = str.toLowerCase();
            Matcher matcher = linePattern.matcher(str);
            StringBuffer sb = new StringBuffer();
            while (matcher.find()) {
                matcher.appendReplacement(sb, matcher.group(1).toUpperCase());
            }
            matcher.appendTail(sb);
            return sb.toString();
        }
        /**
         * 驼峰转下划线(简单写法,效率低于{@link #humpToLine2(String)})
         */
        public static String humpToLine(String str) {
            return str.replaceAll("[A-Z]", "_$0").toLowerCase();
        }
        private static Pattern humpPattern = Pattern.compile("[A-Z]");
        /**
         * 驼峰转下划线,效率比上面高
         */
        public static String humpToLine2(String str) {
            Matcher matcher = humpPattern.matcher(str);
            StringBuffer sb = new StringBuffer();
            while (matcher.find()) {
                matcher.appendReplacement(sb, "_" + matcher.group(0).toLowerCase());
            }
            matcher.appendTail(sb);
            return sb.toString();
        }
    }
}

+ 9 - 12
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java

@ -12,10 +12,7 @@ import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressage;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionPay;
import com.yihu.wlyy.entity.patient.prescription.*;
import com.yihu.wlyy.repository.charge.ChargeDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.message.MessageDao;
@ -419,7 +416,7 @@ public class PatientPrescriptionPayService extends BaseService {
                //支付成功返回续方code给前端
                resultMap.put("prescriptionCode",prescriptionCode);
                prescriptionPay.setTradeStatus("1");//交易状态 成功1 失败0
                prescription.setStatus(30);//续费状态 30支付成功 21支付失败
                prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.pay_success.getValue());//续费状态 枚举 支付成功
                expressage.setDel(1);//快递信息状态 1可用 0删除
                expressageDao.save(expressage);
                prescriptionDao.save(prescription);
@ -445,7 +442,7 @@ public class PatientPrescriptionPayService extends BaseService {
            } else if ("1".equals(tradeStatus)) {
                prescriptionPay.setTradeStatus("0");//交易状态 成功1 失败0
                prescription.setStatus(21);////续费状态 30支付成功 21支付失败
                prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.pay_error.getValue());////续费状态 支付失败
                expressage.setDel(0);//快递信息状态 1可用 0删除
                expressageDao.save(expressage);
                prescriptionDao.save(prescription);
@ -457,8 +454,8 @@ public class PatientPrescriptionPayService extends BaseService {
        }
        //                记录log日志到数据库
        logService.saveHttpLog(isSuccess, config.getRecipeReturnUrl(), "长处方支付页面跳转", "POST", null, "", responses, error, logService.onepayType);
        //记录支付log日志到数据库
        payLogService.addLog(prescription, 2, flag, 1);
        //记录支付log日志到数据库  支付
        payLogService.addLog(prescription, PrescriptionLog.PrescriptionLogType.pay.getValue(), flag, 1);
        return resultMap;
    }
@ -589,7 +586,7 @@ public class PatientPrescriptionPayService extends BaseService {
                    PrescriptionExpressage expressage = expressageDao.findByPrescriptionPay(prescriptionCode);
                    if ("0".equals(tradeStatus)) {
                        prescriptionPay.setTradeStatus("1");//交易状态 成功1 失败0
                        prescription.setStatus(30);//续费状态 30支付成功 21支付失败
                        prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.pay_success.getValue());//续费状态 30支付成功 21支付失败
                        expressage.setDel(1);//快递信息状态 1可用 0删除
                        expressageDao.save(expressage);
                        prescriptionDao.save(prescription);
@ -610,7 +607,7 @@ public class PatientPrescriptionPayService extends BaseService {
                        jwPrescriptionService.executeSickSettle(prescriptionCode);
                    } else if ("1".equals(tradeStatus)) {
                        prescriptionPay.setTradeStatus("0");//交易状态 成功1 失败0
                        prescription.setStatus(21);////续费状态 30支付成功 21支付失败
                        prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.pay_error.getValue());////续费状态 30支付成功 21支付失败
                        expressage.setDel(0);//快递信息状态 1可用 0删除
                        expressageDao.save(expressage);
                        prescriptionDao.save(prescription);
@ -628,7 +625,7 @@ public class PatientPrescriptionPayService extends BaseService {
        //                记录log日志到数据库
        logService.saveHttpLog(isSuccess, config.getReceiveNotify(), "异步支付通知", "POST", null, params, responses, error, logService.onepayType);
        //记录支付log日志到数据库
        payLogService.addLog(prescription, 2, flag, 1);
        payLogService.addLog(prescription, PrescriptionLog.PrescriptionLogType.pay.getValue(), flag, 1);
    }
@ -958,7 +955,7 @@ public class PatientPrescriptionPayService extends BaseService {
        //保存http日志
        logService.saveHttpLog(isSuccess, config.getRecipeChargeType(), "长处方结算", "POST", null, msgBody, response, error, logService.onepayType);
        //保存长处方日志  type=2易联众对接 flag =1成功 flag=0 0失败 userType 1 患者 2医生
        payLogService.addLog(prescription, 2, flag, 1);
        payLogService.addLog(prescription, PrescriptionLog.PrescriptionLogType.pay.getValue(), flag, 1);
        if (!isSuccess) {
            throw new Exception(error);
        }

+ 28 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionDispensaryCodeService.java

@ -2,9 +2,11 @@ package com.yihu.wlyy.service.app.prescription;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionDispensaryCode;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDispensaryCodeDao;
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
import com.yihu.wlyy.service.BaseService;
@ -51,6 +53,8 @@ public class PrescriptionDispensaryCodeService extends BaseService {
    private PrescriptionInfoDao prescriptionInfoDao;
    @Autowired
    private HttpUtil httpUtil;
    @Autowired
    private PrescriptionDao prescriptionDao;
    private static Object obj = new Object();
    private static Object obj2 = new Object();
@ -116,6 +120,30 @@ public class PrescriptionDispensaryCodeService extends BaseService {
        return false;
    }
    public boolean saveQRCode(String token,String prescriptionCode) throws Exception {
        Prescription prescription = prescriptionDao.findByCode(prescriptionCode);
        //取药类型:1 自取 2快递配送 3健管师配送
        Integer type = prescription.getDispensaryType();
        PrescriptionDispensaryCode prescriptionDispensaryCode = savePatientQRCode(token,prescriptionCode);
        if(type==3){
            if(prescriptionDispensaryCode!=null){
                prescriptionDispensaryCode = saveQRCode(prescriptionDispensaryCode.getCode(),token,prescriptionCode,2);
                if(prescriptionDispensaryCode!=null){
                    prescriptionDispensaryCode = saveQRCode(prescriptionDispensaryCode.getCode(),token,prescriptionCode,3);
                    if(prescriptionDispensaryCode==null){
                        return false;
                    }
                }else{
                    return false;
                }
            }else{
                return false;
            }
        }
        return true;
    }
    //生成居民端取药码
    @Transactional
    public PrescriptionDispensaryCode savePatientQRCode(String token,String prescriptionCode) throws Exception {

+ 2 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionExpressageService.java

@ -8,12 +8,14 @@ import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.prescription.*;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.SystemConf;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ExecutionException;

+ 36 - 10
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java

@ -366,16 +366,27 @@ public class PrescriptionInfoService extends BaseService {
            if(st==200&&"1".equals(code)&&data.getJSONArray("returnData").size()>0){
                //开方成功返回遗嘱号
                com.alibaba.fastjson.JSONArray returnDatas = data.getJSONArray("returnData");
                com.alibaba.fastjson.JSONObject returnData = (com.alibaba.fastjson.JSONObject)returnDatas.get(0);
                com.alibaba.fastjson.JSONArray reData = (com.alibaba.fastjson.JSONArray)returnDatas.get(0);
                com.alibaba.fastjson.JSONObject returnData = (com.alibaba.fastjson.JSONObject)reData.get(0);
                p.setVisitNo(returnData.getString("VISIT_NO"));
                p.setRecipeNo(returnData.getString("RECIPE_NO"));
                //设置状态为待支付
                p.setStatus(PrescriptionLog.PrescriptionLogStatus.wait_pay.getValue());
                //设置审核通过
                reviewed.setStatus(1);
                reviewed.setReviewedTime(new Date());
                prescriptionDao.save(p);
                //审核通过模板消息
                sendRMess(code,1);
                return 1;
            }else{
                p.setStatus(PrescriptionLog.PrescriptionLogStatus.add_error.getValue());
                p.setPrescribeReason(byRefParaData.getJSONObject(0).getString("errorMsg"));
                p.setPrescribeTime(new Date());
                prescriptionDao.save(p);
                //审核不通过模板消息
                sendRMess(code,0);
                return 0;
            }
        }
@ -763,16 +774,25 @@ public class PrescriptionInfoService extends BaseService {
            JSONObject json = new JSONObject(mes);
            Integer state = json.getInt("state");
            String code = json.getString("prescription");
            return sendRMess(code ,state);
        }catch (Exception e){
            logger.error("报文解析失败!",e);
        }
        return 0;
    }
    public int  sendRMess(String code ,Integer state){
        try {
            Prescription prescription = prescriptionDao.findByCode(code);
            Patient p = patientDao.findByCode(prescription.getPatient());
            if(state!=null&&state==1){
                prescriptionNoticesService.sendMessages(prescription.getPatient(),prescription.getDoctorName(),null,1,1,"prescription/html/re-prescription_info.html?openid=" + p.getOpenid() + "&toUser=" + p.getCode()+ "&toName=" + p.getName() +"&code="+prescription.getCode());
            }else{
                prescriptionNoticesService.sendMessages(prescription.getPatient(),prescription.getDoctorName(),null,1,2,"prescription/html/re-prescription_info.html?openid=" + p.getOpenid() + "&toUser=" + p.getCode()+ "&toName=" + p.getName() +"&code="+prescription.getCode());
            if (state != null && state == 1) {
                prescriptionNoticesService.sendMessages(prescription.getPatient(), prescription.getDoctorName(), null, 1, 1, "prescription/html/re-prescription_info.html?openid=" + p.getOpenid() + "&toUser=" + p.getCode() + "&toName=" + p.getName() + "&code=" + prescription.getCode());
            } else {
                prescriptionNoticesService.sendMessages(prescription.getPatient(), prescription.getDoctorName(), null, 1, 2, "prescription/html/re-prescription_info.html?openid=" + p.getOpenid() + "&toUser=" + p.getCode() + "&toName=" + p.getName() + "&code=" + prescription.getCode());
            }
            return 1;
        }catch (Exception e){
            logger.error("续方消息发送失败!",e);
        } catch (Exception e) {
            logger.error("续方消息发送失败!", e);
        }
        return 0;
    }
@ -901,7 +921,7 @@ public class PrescriptionInfoService extends BaseService {
        if(StringUtils.isNotBlank(AllocationType)){
            //1为未分配建管师列表
            if("1".equals(AllocationType)){
                pre_sql.append(" AND pr.expressage_code IS NULL ");
                pre_sql.append(" AND e.expressage_code IS NULL ");
            }
        }
@ -1031,7 +1051,7 @@ public class PrescriptionInfoService extends BaseService {
     * @return 0 审核中,1为处理完成
     */
    public String presCheckState(String code){
        StringBuffer sql = new StringBuffer(" SELECT pr.code FROM wlyy_prescription pr JOIN wlyy_prescription_reviewed r ON pr.code = r.prescription_code WHERE pr.parent_code = ? AND r.status = 0");
        StringBuffer sql = new StringBuffer(" SELECT pr.code FROM wlyy_prescription pr JOIN wlyy_prescription_reviewed r ON pr.code = r.prescription_code WHERE pr.parent_code = ? AND pr.status >= "+PrescriptionLog.PrescriptionLogStatus.revieweding+" AND pr.status < "+PrescriptionLog.PrescriptionLogStatus.wait_pay);
        List<Map<String,Object>> mp = jdbcTemplate.queryForList(sql.toString(),code);
        if(mp!=null&&mp.size()>0){
            return "0";
@ -1041,7 +1061,7 @@ public class PrescriptionInfoService extends BaseService {
    }
    public String presCheckStateObj(String code){
        StringBuffer sql = new StringBuffer(" SELECT pr.code FROM wlyy_prescription pr JOIN wlyy_prescription_reviewed r ON pr.code = r.prescription_code WHERE pr.parent_code = ? AND r.status = 0");
        StringBuffer sql = new StringBuffer(" SELECT pr.code FROM wlyy_prescription pr JOIN wlyy_prescription_reviewed r ON pr.code = r.prescription_code WHERE pr.parent_code = ? AND pr.status >= "+PrescriptionLog.PrescriptionLogStatus.revieweding+" AND pr.status < "+PrescriptionLog.PrescriptionLogStatus.wait_pay);
        List<Map<String,Object>> mp = jdbcTemplate.queryForList(sql.toString(),code);
        if(mp!=null&&mp.size()>0){
            return (String)((mp.get(0)).get("code"));
@ -1108,4 +1128,10 @@ public class PrescriptionInfoService extends BaseService {
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql.toString(),new Object[]{jwHospital,jwDoctorCode});
        return new JSONArray(rs);
    }
    public JSONArray getUsageDict(){
        StringBuffer sql = new StringBuffer("SELECT t.code,t.`name` FROM zy_common_dict t WHERE t.dict_name='IV_RECIPE_USAGE_DICT'");
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql.toString());
        return new JSONArray(rs);
    }
}

+ 30 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java

@ -1,9 +1,13 @@
package com.yihu.wlyy.service.third.jw;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.util.HttpClientUtil;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
@ -20,6 +24,7 @@ import java.util.Map;
@Service
public class JwPrescriptionService {
    private static final Logger logger = LoggerFactory.getLogger(JwPrescriptionService.class);
    //基卫服务地址
    @Value("${sign.check_upload}")
    private String jwUrl;
@ -27,6 +32,8 @@ public class JwPrescriptionService {
    private HttpClientUtil httpClientUtil;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PrescriptionDao prescriptionDao;
    /**
     * 获取字典列表
@ -115,6 +122,11 @@ public class JwPrescriptionService {
     * @throws Exception
     */
    public String saveRecipe(String prescriptionCode) throws Exception{
        try {
        }catch (Exception e){
        }
        String url = jwUrl + "/third/prescription/saveRecipe";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("prescriptionCode", prescriptionCode));
@ -164,15 +176,29 @@ public class JwPrescriptionService {
     * @return
     * @throws Exception
     */
    public String fadeRecipe(String visitNo,String fadeDept,String fadeOperator)throws Exception{
    public String fadeRecipe(String prescriptionCode)throws Exception{
        Prescription prescription = prescriptionDao.findByCode(prescriptionCode);
        String url = jwUrl + "/third/prescription/fadeRecipe";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("visitNo", visitNo));//挂号号
        params.add(new BasicNameValuePair("fadeDept", fadeDept));//作废科室编码
        params.add(new BasicNameValuePair("fadeOperator", fadeOperator));//作废人员编码
        params.add(new BasicNameValuePair("visitNo", prescription.getVisitNo()));//挂号号
        params.add(new BasicNameValuePair("fadeDept", prescription.getJwDeptCode()));//作废科室编码
        params.add(new BasicNameValuePair("fadeOperator", prescription.getJwDoctorCode()));//作废人员编码
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
    /**
     * ca认证接口
     * @param code 续方code
     * @return
     */
    public String affirmCARecipe(String code){
        String url = jwUrl + "/third/prescription/affirmCARecipe";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("code", code));//续方code
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
}

+ 20 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionCodeController.java

@ -1,6 +1,7 @@
package com.yihu.wlyy.web.doctor.prescription;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionDispensaryCode;
import com.yihu.wlyy.service.app.prescription.PrescriptionDispensaryCodeService;
import com.yihu.wlyy.service.app.prescription.PrescriptionExpressageService;
import com.yihu.wlyy.service.app.prescription.PrescriptionInfoService;
@ -154,4 +155,23 @@ public class PrescriptionCodeController extends BaseController{
        }
    }
    /**
     * 扫码
     * @param code
     * @return
     */
    @RequestMapping(value = "/dispensaryCode/scanQrcode",method = RequestMethod.GET)
    @ObserverRequired
    @ResponseBody
    public String scanQrcode(
            @RequestParam(value = "code",required = true) String code){
        try {
            PrescriptionDispensaryCode prescriptionDispensaryCode = prescriptionDispensaryCodeService.scanQrcode(code);
            return write(200, "扫码成功!", "data", prescriptionDispensaryCode);
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
}

+ 11 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java

@ -428,4 +428,15 @@ public class PrescriptionInfoController extends BaseController{
        }
    }
    @RequestMapping(value = "/getUsageDict" ,method = RequestMethod.GET)
    @ApiOperation(value = "获取药品用法列表")
    public String getUsageDict(){
        try {
            return write(200, "查询成功!", "data", prescriptionInfoService.getUsageDict());
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java

@ -993,7 +993,7 @@ public class ConsultController extends WeixinBaseController {
            consult.setType(8);//续方咨询
            consult.setAdminTeamId(adminTeamId);
            // 保存到数据库
//            int res = consultTeamService.addPrescriptionConsult(jwCode, "37c0657335f94ed38eeced22dbed8011","37c0657335f94ed38eeced22dbed8011",doctor,consult,reason,type);
//            int res = consultTeamService.addPrescriptionConsult(jwCode, "b02f132bfbfc45d287bcde18ad342522","b02f132bfbfc45d287bcde18ad342522",doctor,consult,reason,type);
            int res = consultTeamService.addPrescriptionConsult(jwCode, getRepUID(),getUID(),doctor,consult,reason,type);
            if (res == -1) {
                return error(-1, "该处方存在未审核的续方,无法进行续方咨询!");

+ 21 - 17
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionController.java

@ -43,7 +43,27 @@ public class PatientPrescriptionController extends WeixinBaseController {
    @Autowired
    private PrescriptionExpressageService prescriptionExpressageService;
    /**
     * 生成取药码
     */
    @RequestMapping(value = "/dispensaryCode/saveQRCode",method = RequestMethod.POST)
    @ResponseBody
    @ObserverRequired
    public String saveQRCode2(
            @ApiParam(required = true ,name = "prescriptionCode",value = "处方code")@RequestParam(value = "prescriptionCode",required = true) String prescriptionCode){
        try {
           boolean b = prescriptionDispensaryCodeService.saveQRCode(getAccessToken(),prescriptionCode);
           if(b){
               return write(200, "生成二维码成功!");
           }else{
               return error(-1, "生成二维码失败!");
           }
        }catch (Exception e) {
            error(e);
            return error(-1, "生成二维码失败!");
        }
    }
    /**
     *生成居民取药码
@ -166,23 +186,7 @@ public class PatientPrescriptionController extends WeixinBaseController {
        }
    }
    /**
     * 扫码
     * @param code
     * @return
     */
    @RequestMapping(value = "/dispensaryCode/scanQrcode",method = RequestMethod.GET)
    @ResponseBody
    public String scanQrcode(
            @RequestParam(value = "code",required = true) String code){
        try {
            PrescriptionDispensaryCode prescriptionDispensaryCode = prescriptionDispensaryCodeService.scanQrcode(code);
            return write(200, "扫码成功!", "data", prescriptionDispensaryCode);
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    /**
     * 判断该居民是否有待取的药的接口

+ 40 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/ZyDictController.java

@ -1,6 +1,6 @@
package com.yihu.wlyy.web.third;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.service.ZyDictDataService;
import com.yihu.wlyy.service.third.jw.ZyDictService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.ApiOperation;
@ -8,9 +8,6 @@ import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2017/8/10.
 * 智业字典同步接口
@ -20,11 +17,12 @@ import java.util.Map;
public class ZyDictController extends BaseController {
    @Autowired
    private ZyDictService zyDictService;
    @Autowired
    private ZyDictDataService zyDictDataService;
    @ApiOperation("同步智业字典")
    @RequestMapping(value = "/synchronousDict", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String synchronousDict(
            @ApiParam(name = "dictName", value = "字典名称", defaultValue = "")
            @RequestParam(value = "dictName", required = true) String dictName) {
@ -36,4 +34,41 @@ public class ZyDictController extends BaseController {
        }
    }
    @ApiOperation("下载智业所有字典")
    @RequestMapping(value = "/downLoadAllDict", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    public String downLoadAllDict(){
        try {
            zyDictDataService.allDict();
            return write(200, "下载智业所有字典!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "下载智业所有字典");
        }
    }
    /**
     * IV_SUBJECT_CLASS_DICT
     * IV_STAFF_REG_TYPE_ALLOT_DICT
     * IV_STAFF_DICT
     * IV_PHYSIC_DICT
     * IV_ORG_PHYSIC_ALLOT_DICT
     * IV_DIAGNOSE_CLASS_DICT
     * IV_DEPT_STAFF_ALLOT_DICT
     * "commonDict"
     * IV_DEPT_DICT
     * @param dictName
     * @return
     */
    @ApiOperation("下载智业字典")
    @RequestMapping(value = "/downLoadDict", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    public String downLoadDict(@ApiParam(name = "dictName", value = "字典名称", defaultValue = "commonDict")
                               @RequestParam(value = "dictName", required = true) String dictName){
        try {
            zyDictDataService.dictByDictName(dictName);
            return write(200, "下载智业所有字典!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "下载智业所有字典");
        }
    }
}