Browse Source

智业接口,续方详情修改

yeshijie 7 years ago
parent
commit
daf36d5ba9

+ 14 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/common/util/DateUtil.java

@ -64,6 +64,20 @@ public class DateUtil {
        return formatter.format(dateDate);
    }
    /**
     * 将短时间格式时间转换为字符串 yyyy-MM-dd
     *
     * @param dateDate
     * @return
     */
    public static String dateToStr(java.util.Date dateDate, String format) {
        if (dateDate == null) {
            return "";
        }
        SimpleDateFormat formatter = new SimpleDateFormat(format);
        return formatter.format(dateDate);
    }
    /**
     * 获取当前时间 yyyy-MM-dd HH:mm:ss
     * @return

+ 411 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/BaseController.java

@ -0,0 +1,411 @@
package com.yihu.wlyy.service.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.service.common.model.IdEntity;
import com.yihu.wlyy.service.common.util.DateUtil;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.util.ReflectionUtils;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Field;
import java.util.*;
public class BaseController {
    private static Logger logger = LoggerFactory.getLogger(BaseController.class);
    @Autowired
    protected HttpServletRequest request;
    public void error(Exception e) {
        logger.error(DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss")+":"+getClass().getName() + ":", e.getMessage());
        e.printStackTrace();
    }
    public void warn(Exception e) {
        logger.warn(getClass().getName() + ":", e.getMessage());
        e.printStackTrace();
    }
    public void infoMessage(String message) {
        logger.info(message);
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @return
     */
    public String error(int code, String msg) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return null;
        }
    }
    /**
     * 接口处理成功
     *
     * @param msg
     * @return
     */
    public String success(String msg) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", 200);
            map.put("msg", msg);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return null;
        }
    }
    public String write(int code, String msg) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return null;
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @return
     */
    public String write(int code, String msg, String key, List<?> list) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, list);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, JSONObject value) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            json.put(key, value);
            return json.toString();
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, JSONArray value) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            json.put(key, value);
            return json.toString();
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param total 总数
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, int total, String key, JSONArray value) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            json.put("total", total);
            json.put(key, value);
            return json.toString();
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, Object value) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, value);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @return
     */
    public String write(int code, String msg, String key, Page<?> list) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            // 是否为第一页
            map.put("isFirst", list.isFirst());
            // 是否为最后一页
            map.put("isLast", list.isLast());
            // 总条数
            map.put("total", list.getTotalElements());
            // 总页数
            map.put("totalPages", list.getTotalPages());
            map.put(key, list.getContent());
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @return
     */
    public String write(int code, String msg, String key, Page<?> page, JSONArray array) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            // 是否为第一页
            json.put("isFirst", page == null ? false : page.isFirst());
            // 是否为最后一页
            json.put("isLast", page == null ? true : page.isLast());
            // 总条数
            json.put("total", page == null ? 0 : page.getTotalElements());
            // 总页数
            json.put("totalPages", page == null ? 0 : page.getTotalPages());
            json.put(key, array);
            return json.toString();
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, Map<?, ?> value) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, value);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, String value) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, value);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @return
     */
    public String write(int code, String msg, String key, IdEntity entity) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("status", code);
            map.put("msg", msg);
            map.put(key, entity);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @return
     */
    public String write(int code, String msg, boolean isFirst, boolean isLast, long total, int totalPages, String key, Object values) {
        try {
            JSONObject json = new JSONObject();
            json.put("status", code);
            json.put("msg", msg);
            // 是否为第一页
            json.put("isFirst", isFirst);
            // 是否为最后一页
            json.put("isLast", isLast);
            // 总条数
            json.put("total", total);
            // 总页数
            json.put("totalPages", totalPages);
            json.put(key, values);
            return json.toString();
        } catch (Exception e) {
            logger.error("BaseController:", e.getMessage());
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    public String trimEnd(String param, String trimChars) {
        if (param.endsWith(trimChars)) {
            param = param.substring(0, param.length() - trimChars.length());
        }
        return param;
    }
    /**
     * 无效用户消息返回
     *
     * @param e
     * @param defaultCode
     * @param defaultMsg
     * @return
     */
    public String invalidUserException(Exception e, int defaultCode, String defaultMsg) {
        try {
            // if (e instanceof UndeclaredThrowableException) {
            // UndeclaredThrowableException ute = (UndeclaredThrowableException) e;
            // InvalidUserException iue = (InvalidUserException) ute.getUndeclaredThrowable();
            // if (iue != null) {
            // return error(iue.getCode(), iue.getMsg());
            // }
            // }
            return error(defaultCode, defaultMsg);
        } catch (Exception e2) {
            return null;
        }
    }
    public List<Map<String, Object>> copyBeans(Collection<? extends Object> beans, String... propertyNames) {
        List<Map<String, Object>> result = new ArrayList<>();
        for (Object bean : beans) {
            result.add(copyBeanProperties(bean, propertyNames));
        }
        return result;
    }
    /**
     * 复制特定属性。
     *
     * @param bean
     * @param propertyNames
     * @return
     */
    public Map<String, Object> copyBeanProperties(Object bean, String... propertyNames) {
        Map<String, Object> simplifiedBean = new HashMap<>();
        for (String propertyName : propertyNames) {
            Field field = ReflectionUtils.findField(bean.getClass(), propertyName);
            if (field != null) {
                field.setAccessible(true);
                Object value = ReflectionUtils.getField(field, bean);
                simplifiedBean.put(propertyName, value == null ? "" : value);
            } else {
                simplifiedBean.put(propertyName, "");
            }
        }
        return simplifiedBean;
    }
}

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

@ -6,7 +6,6 @@ import com.yihu.wlyy.service.service.prescription.PrescriptionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@ -15,14 +14,13 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
/**
 * 长处方接口
 * */
@Controller
@RequestMapping(value = "/third/prescription/")
@Api(description = "长处方接口")
public class PrescriptionController {
public class PrescriptionController extends BaseController{
	@Autowired
	PrescriptionCAService caService;
@ -89,21 +87,18 @@ public class PrescriptionController {
		}
	}
	@RequestMapping(value = "pharmacistPrescriptionCompletion",method = RequestMethod.POST)
	@RequestMapping(value = "readNewsOnline",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("提供在线问诊消息调阅")
	public String readNewsOnline(@ApiParam(name="data",value="json串",defaultValue = "{}")
								 @RequestParam(value = "data",required = true) String data){
		JSONObject jsonObject = new JSONObject();
		try {
			jsonObject.put("status",200);
			jsonObject.put("msg","success");
			jsonObject.put("url","http://www.yihu.com/");
			return write(200,"success","url","http://www.yihu.com/");
		}catch (Exception e){
			e.printStackTrace();
			jsonObject.put("msg",e.getMessage());
			return error(-1,e.getMessage());
		}
		return jsonObject.toString();
	}

+ 2 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prescription/PrescriptionDao.java

@ -21,4 +21,6 @@ public interface PrescriptionDao extends PagingAndSortingRepository<Prescription
    @Query("select p from Prescription p where p.jwCode=?1 and p.status=?2 ")
    List<Prescription> fingdByJwCodeAndStatus(String jwcode, Integer status);
}

+ 3 - 3
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/PrescriptionLog.java

@ -58,21 +58,21 @@ public class PrescriptionLog extends IdEntity {
        // 审核不通过
        no_reviewed("审核不通过", -1),
        revieweding("待审核", 0),
        //审核中
        revieweding("待审核", 0),
        changeing("调整中", 2),
        change_success("调整成功",3),
        change_error("调整失败",4),
        Pharmacist_examination_error("药师审核失败",5),
        add_error("开方失败",6),
        reviewed_success(" 医生审核(CA)通过", 10),
        //药师审核中
        Pharmacist_examination("药师审核中",20),
        Pharmacist_examination_error("药师审核失败",21),
        //开方中/药师审核成功
        adding("开方中/药师审核成功",30),
        add_error("开方失败",31),
        //待支付
        wait_pay("开方完成/待支付", 40),

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

@ -14,7 +14,6 @@ import net.sf.json.JSONObject;
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.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -42,8 +41,7 @@ public class PrescriptionService extends ZysoftBaseService{
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    @Value("${redis.channelTopic}")
    private String channelTopic;
    private String channelTopic = "redisPrescription";
    /**
     * 新增续方日志
@ -83,9 +81,9 @@ public class PrescriptionService extends ZysoftBaseService{
            JSONObject pre = json.getJSONObject("Data");
            String prescriptionCode = pre.getString("PRESCRIPTION_CODE");
            Prescription prescription = prescriptionDao.findByCode(prescriptionCode);
            if(prescription.getStatus()==2||prescription.getStatus()==4){
            if(prescription.getStatus()==PrescriptionLog.PrescriptionLogStatus.changeing.getValue()||prescription.getStatus()==PrescriptionLog.PrescriptionLogStatus.change_error.getValue()){
                if(CODE==1){
                    prescription.setStatus(3);
                    prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.change_success.getValue());
                    prescriptionDao.save(prescription);
                    //调整续方的药品信息
@ -126,8 +124,13 @@ public class PrescriptionService extends ZysoftBaseService{
                        prescriptionInfoDao.save(prescriptionInfo);
                    }
                    // redis 的发布
                    redisTemplate.convertAndSend(channelTopic,JSONObject.fromObject(prescription).toString());
                    // redis 的发布 {tilte:redisAddPrescription   state: 1 ,//1:成功,2.失败 mes:'开方成功' prescription : "0001" //续方CODE  }
                    JSONObject message = new JSONObject();
                    message.put("title","adjustPrescription");
                    message.put("state",1);
                    message.put("prescription",prescriptionCode);
                    message.put("mes","调整处方完成");
                    redisTemplate.convertAndSend(channelTopic,message.toString());
                }else {
                    //调整失败
                    prescription.setStatus(4);
@ -166,6 +169,22 @@ public class PrescriptionService extends ZysoftBaseService{
            if(code==1){
                String orderNo = json.getString("ORDER_NO");//挂号编号
                String recipeNo = json.getString("RECIPE_NO");//处方编号
                //修改续方表状态
//                Prescription prescription = prescriptionDao.f
                //修改续方审核表状态
                // redis 的发布 {tilte:redisAddPrescription   state: 1 ,//1:成功,2.失败 mes:'开方成功' prescription : "0001" //续方CODE  }
                JSONObject message = new JSONObject();
                message.put("title","redisAddPrescription");
                message.put("state",1);
                message.put("prescription","fd3b137cd907456dbcc5b11ecd701741");
//                message.put("mes","预结算完成完成");
                message.put("mes","success");
                redisTemplate.convertAndSend(channelTopic,message.toString());
            }
        }catch (JSONException ex){
@ -195,6 +214,15 @@ public class PrescriptionService extends ZysoftBaseService{
            if(code==1){
                String orderNo = json.getString("ORDER_NO");//挂号编号
                String recipeNo = json.getString("RECIPE_NO");//处方编号
                //判断健管师配送要添加续方消息,提示健管师有续方代配送
                JSONObject message = new JSONObject();
                message.put("title","dispensingComplete");
                message.put("state",1);
                message.put("prescription","fd3b137cd907456dbcc5b11ecd701741");
//                message.put("mes","预结算完成完成");
                message.put("mes","success");
                redisTemplate.convertAndSend(channelTopic,message.toString());
            }
        }catch (JSONException ex){

+ 8 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/redis/RedisMsgPubSubListener.java

@ -1,8 +1,7 @@
package com.yihu.wlyy.redis;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
import com.yihu.wlyy.service.app.prescription.PrescriptionInfoService;
import com.yihu.wlyy.service.app.prescription.PrescriptionService;
import com.yihu.wlyy.util.HttpUtil;
import org.json.JSONObject;
import org.slf4j.Logger;
@ -19,6 +18,8 @@ public class RedisMsgPubSubListener extends JedisPubSub {
    @Autowired
    private PrescriptionInfoService prescriptionInfoService;
    @Autowired
    private PrescriptionService prescriptionService;
    private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
@ -63,6 +64,11 @@ public class RedisMsgPubSubListener extends JedisPubSub {
                logger.info(json.toString());
                //审核消息发送
                prescriptionInfoService.onMesSquareState(message);
            }else if("dispensingComplete".equals(title)){//配药完成
                //提醒健管师待取药
                String prescriptionCode = json.getString("prescription");
            }
        }catch (Exception e){
            logger.error("redis_error...",e);

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

@ -24,6 +24,18 @@ public class PrescriptionService extends BaseService {
     */
    public Prescription findByCode(String prescriptionCode) {
        return prescriptionDao.findByCode(prescriptionCode);
    }
    /**
     * 配药完成
     * @param code
     */
    public void dispensingComplete(String code){
        Prescription prescription = prescriptionDao.findByCode(code);
    }
    /**

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

@ -1094,8 +1094,9 @@ public class ConsultController extends WeixinBaseController {
            json.put("prescriptionInfo",prescriptionDiagnosisService.getPrescriptionInfo(prescriptionCode));//续方药品信息
            json.put("symptoms",consult1.getSymptoms());//咨询类型--- 1高血压,2糖尿病
            json.put("jwCode",prescription.getJwCode());//基位处方code
            json.put("code",prescription.getCode());//续方code
            return write(200, "查询成功!", "list", json);
            return write(200, "查询成功!", "data", json);
        }catch (Exception e){
            error(e);
            return error(-1, "查询失败!");