Selaa lähdekoodia

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

huangwenjie 7 vuotta sitten
vanhempi
commit
887246e018
25 muutettua tiedostoa jossa 593 lisäystä ja 62 poistoa
  1. 17 13
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/Prescription.java
  2. 1 1
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionLog.java
  3. 15 1
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/PrescriptionController.java
  4. 7 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java
  5. 11 1
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/PrescriptionPayOverdueJob.java
  6. 42 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/redis/RedisThread.java
  7. 19 7
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java
  8. 5 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionExpressageDao.java
  9. 228 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionNoticesService.java
  10. 170 7
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java
  11. 5 1
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/util/MessageType.java
  12. 23 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/GateWayInterceptor.java
  13. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/gateway/GcTokenDao.java
  14. 1 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionExpressageService.java
  15. 4 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  16. 1 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java
  17. 3 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java
  18. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  19. 6 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/CommonUtil.java
  20. 11 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java
  21. 4 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionLogController.java
  22. 13 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/AdminTeamController.java
  23. 2 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/vo/base/BaseResultModel.java
  24. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionController.java
  25. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionLogController.java

+ 17 - 13
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/Prescription.java

@ -38,10 +38,10 @@ public class Prescription extends IdEntity {
    private String ssc;//社保卡号
    private Integer type;                    //1 处方 2 续方
    private Integer status;                  //(-3 支付过期 -2 患者自己取消 )续方取消,-1 审核不通过 ,
                                                // (0 待审核, 2调整中,3调整成功, 4调整失败 ,10 医生审核(CA)通过)审核中,
                                                // 20药师审核中,21.药师审核失败,30 开方中/药师审核成功,31.开方失败/预结算失败,
                                                // (40开方完成/待支付 ,41 支付失败 )待支付,  50 支付成功/待配药,(60配药成功/待配送)等待领药,
                                                // (61配送失败62分配健管师 65配送中,69配送到服务站)配送中,(100配送到患者手中/已完成)已完成',
    // (0 待审核, 2调整中,3调整成功, 4调整失败 ,10 医生审核(CA)通过)审核中,
    // 20药师审核中,21.药师审核失败,30 开方中/药师审核成功,31.开方失败/预结算失败,
    // (40开方完成/待支付 ,41 支付失败 )待支付,  50 支付成功/待配药,(60配药成功/待配送)等待领药,
    // (61配送失败62分配健管师 65配送中,69配送到服务站)配送中,(100配送到患者手中/已完成)已完成',
    private String doctor;                   //开处方的医生code 关联 wlyy_doctor
    private String doctorName;               //医生名称
    private Long adminTeamId;             //患者签约的行政团队
@ -89,7 +89,7 @@ public class Prescription extends IdEntity {
    private String jwRegisterFee; //基卫-诊金
    private String prescribeReason; //开方失败/成功原因
    private Date prescribeTime ;//开方失败、成功时间
    private Date prescribeTime;//开方失败、成功时间
    private String dispensaryTypeName; //类型翻译
@ -367,7 +367,7 @@ public class Prescription extends IdEntity {
    }
    public void setStatusName(String statusName) {
        this.statusName = getStatusName(status,null);
        this.statusName = getStatusName(status, null, null);
    }
    public Date getExpressageTime() {
@ -379,7 +379,7 @@ public class Prescription extends IdEntity {
    }
    @Transient
    public static String getStatusName(Integer status, String hospitalName) {
    public static String getStatusName(Integer status, String hospitalName, String userName) {
        /**
         *  no_reviewed("审核不通过", -1),
@ -443,10 +443,10 @@ public class Prescription extends IdEntity {
                return "支付失败";
            }
            case 50: {
                return " 支付成功/待配药";
                return " 订单已支付";
            }
            case 60: {
                return "配药成功/待配送";
                return "配药完成";
            }
            case 61: {
                return "配送失败";
@ -458,15 +458,19 @@ public class Prescription extends IdEntity {
                return "配送中 ";
            }
            case 69: {
                if (StringUtils.isEmpty(hospitalName)) {
                if (StringUtils.isEmpty(hospitalName) || StringUtils.isEmpty(userName)) {
                    return "配送到服务站";
                }
                {
                    return "配送到" + hospitalName;
                    return "配送到" + hospitalName + ",接收人:" + userName;
                }
            }
            case 100: {
                return "续方完成";
                if (StringUtils.isEmpty(userName)) {
                    return "续方完成";
                } else {
                    return "续方完成,确认人:" + userName;
                }
            }
        }
        return "未知";
@ -620,7 +624,7 @@ public class Prescription extends IdEntity {
    @Transient
    public String getDispensaryTypeName() {
        if(dispensaryType!=null){
        if (dispensaryType != null) {
            switch (this.dispensaryType) {
                case 1: {
                    return "自取";

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

@ -250,7 +250,7 @@ public class PrescriptionLog extends IdEntity {
    @Transient
    public String getStatusName() {
        return Prescription.getStatusName(this.status,hospitalName);
        return Prescription.getStatusName(this.status,hospitalName,userName);
    }
}

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

@ -6,6 +6,9 @@ import com.yihu.wlyy.service.service.prescription.PrescriptionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@ -20,6 +23,8 @@ import org.springframework.web.bind.annotation.*;
@Api(description = "长处方接口")
public class PrescriptionController extends BaseController{
	private static Logger logger = LoggerFactory.getLogger(PrescriptionController.class);
	@Autowired
	PrescriptionCAService caService;
@ -183,7 +188,16 @@ public class PrescriptionController extends BaseController{
			return Result.success("挂号开处方接口!",re);
		} catch (Exception ex) {
			ex.printStackTrace();
			return Result.error(ex.getMessage());
			logger.info("智业接口请求失败");
			//异常处理
			String message = ex.getMessage();
			if(StringUtils.isNotBlank(message)){
				if(message.contains("System.Exception:")){
					message = message.substring(message.indexOf("System.Exception:")+18,message.indexOf("\\n"));
					return Result.error(message);
				}
			}
			return Result.error("请求失败");
		}
	}

+ 7 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java

@ -2,6 +2,7 @@ package com.yihu.wlyy.event;
import com.yihu.wlyy.job.*;
import com.yihu.wlyy.job.consult.EvaluateScoreJob;
import com.yihu.wlyy.redis.RedisThread;
import com.yihu.wlyy.util.SystemConf;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -21,6 +22,8 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
    private Logger logger = LoggerFactory.getLogger(ApplicationEvent.class);
    @Autowired
    QuartzHelper quartzHelper;
    @Autowired
    private RedisThread redisThread;
    @Override
    public void onApplicationEvent(ContextRefreshedEvent ContextRefreshedEvent) {
@ -95,6 +98,10 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
                logger.info("zy_execute_sick_settle_job reorder job job exist");
            }
            // 启动redis 消息队列线程
            logger.info("redis message start");
            new Thread(redisThread).start();
            logger.info("redis message end");
        } catch (Exception e) {
            logger.info("sign end job start failed");

+ 11 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/PrescriptionPayOverdueJob.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.job;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
@ -23,7 +24,16 @@ public class PrescriptionPayOverdueJob implements Job {
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        try {
            logger.info("Prescription_Pay_Overdue_Job_start");
            StringBuffer sql = new StringBuffer("UPDATE wlyy_prescription SET status = -3 WHERE TIMESTAMPDIFF(second,create_time,NOW())>=172800");
            StringBuffer sql = new StringBuffer("UPDATE wlyy_prescription " +
                    " JOIN wlyy_prescription_reviewed ON wlyy_prescription_reviewed.prescription_code = wlyy_prescription. CODE " +
                    " SET wlyy_prescription.`status` = -3 " +
                    " WHERE " +
                    " wlyy_prescription.`status` = " + PrescriptionLog.PrescriptionLogStatus.wait_pay.getValue() +
                    " AND TIMESTAMPDIFF( " +
                    " SECOND, " +
                    " wlyy_prescription_reviewed.reviewed_time, " +
                    " NOW() " +
                    " ) >= 86400");
            jdbcTemplate.execute(sql.toString());
            logger.info("Prescription_Pay_Overdue_Job_end");
        }catch (Exception e){

+ 42 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/redis/RedisThread.java

@ -0,0 +1,42 @@
package com.yihu.wlyy.redis;
import com.yihu.wlyy.service.app.prescription.PrescriptionService;
import com.yihu.wlyy.util.SystemConf;
import org.apache.commons.lang3.StringUtils;
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.Component;
/**
 * Created by Trick on 2017/8/7.
 */
@Component
public class RedisThread implements Runnable {
    @Value("${spring.redis.host}")
    private String url;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private PrescriptionService prescriptionService;
    @Override
    public void run() {
        String key = SystemConf.getInstance().getSystemProperties().getProperty("redis_prescription_title");
        while (true){
            redisTemplate.watch(key);
            String message = redisTemplate.opsForList().rightPop(key);
            redisTemplate.unwatch();
            if(StringUtils.isEmpty(message)){
                try{
                    Thread.sleep(1000L);//如果没有读取到记录,等待1秒
                }catch (Exception e){
                    e.printStackTrace();
                }
            }else {
                prescriptionService.redisMessage(message);
            }
        }
    }
}

+ 19 - 7
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java

@ -55,26 +55,38 @@ public interface MessageDao extends PagingAndSortingRepository<Message, Long>, J
    @Query("select a from Message a where a.read= 1 and a.receiver = ?1 and a.type not in (1,2,6) order by a.czrq desc")
    List<Message> getSystemMessageUnread(String doctor);
    @Query("select a from Message a where a.receiver = ?1 and a.read=?2 and a.type=?3 order by a.createTime desc")
    List<Message> getSysTemMessageByTypeAndRead(String doctor, Integer read, Integer type);
    @Query("select a from Message a where a.receiver = ?1 and a.prescriptionStatus=?2 and a.type in (6,7) order by a.createTime desc")
    List<Message> getSysTemMessageByPrescription(String doctor, String prescriptionStatus);
    @Query("select a from Message a where a.receiver = ?1 and a.type not in (1,2,6)")
    @Query("select a from Message a where a.receiver = ?1 and a.type not in (1,2,6,7)")
    List<Message> getSystemMessage(String doctor,Pageable pageRequest);
    @Query("select a from Message a where a.receiver = ?1 and a.type=?2 and a.prescriptionStatus='0' ")
    List<Message> getPrescriptionMessage(String doctor,Integer type,Pageable pageRequest);
    @Query("select count(a) from Message a where a.read = 0 and a.over ='0'  and a.receiver=?1 and a.type=?2 ")
    int findMessageNum(String doctor, Integer type);
    @Modifying
    @Query("update Message a set a.prescriptionStatus=?2 where a.relationCode = ?1 and a.type=?3 ")
    int updatePreScriptionMessage(String relateCode,String prescriptionStatus,Integer type);
    @Query("update Message a set a.read = 0,a.over = '0' where a.receiver = ?1 and a.type = ?2")
    @Modifying
    int setMessageReaded(String doctor,Integer type);
    int setMessageReaded(String doctor, Integer type);
    @Query("update Message a set a.read = 0,a.over = '0' where a.receiver = ?1 and a.type not in (1,2,6)")
    @Query("update Message a set a.read = 0,a.over = '0' where a.receiver = ?1 and a.type not in (1,2,6,7)")
    @Modifying
    int setSysMessageReaded(String doctor);
    @Query("from Message a where a.receiver = ?1 and relationCode = ?2 and a.type=?3 ")
    List<Message> findByReceiverAndRelationCode(String receiver,String relationCode,Integer type);
    //查询患者最近7天的体征异常记录
    @Query(value = "SELECT COUNT(1) FROM wlyy_message WHERE type = '2' and sender = ?1 and create_time>=date_add(now(),interval -7 day) ",nativeQuery = true)
    @Query(value = "SELECT COUNT(1) FROM wlyy_message WHERE type = '2' and sender = ?1 and create_time>=date_add(now(),interval -7 day) ", nativeQuery = true)
    int findTzMessage(String patient);
    //根据续方关联code查询团队长分配健管师消息
    @Query("from Message a where a.type = 8 and a.state=0 and a.del='1' and a.over='0' and relationCode = ?1  ")
    Message findByRelationCode(String relationCode);
}

+ 5 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionExpressageDao.java

@ -18,4 +18,9 @@ public interface PrescriptionExpressageDao extends PagingAndSortingRepository<Pr
    @Query(value = "select p.* FROM wlyy_prescription_expressage p LEFT JOIN wlyy_prescription a on a.code = p.prescription_code where a.status = 30 and p.mobile is null",nativeQuery = true)
    List<PrescriptionExpressage> findByPrescriptionPaidExpressOrderFail();
    @Query("from PrescriptionExpressage p where p.mailno=?1")
    PrescriptionExpressage findByPrescriptionExpressMailno(String mailno);
    @Query(" from PrescriptionExpressage p where p.prescriptionCode=?1 and p.del=1")
    PrescriptionExpressage findByPrescriptionCode(String prescriptionCode);
}

+ 228 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionNoticesService.java

@ -0,0 +1,228 @@
package com.yihu.wlyy.service.app.prescription;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
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.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
 * Created by Reece on 2017/8/3.
 */
@Service
public class PrescriptionNoticesService extends BaseService {
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private WeiXinOpenIdUtils weiXinOpenIdUtils;
    private static final Logger LOGGER = LoggerFactory.getLogger(PrescriptionNoticesService.class);
    /**
     * 发送续方相关模板消息(增加代理模式)
     *
     * @param patient   要发送对象居民code
     * @param doctName  相关医生姓名(type=1审核医生、type=2 null、type=3配送健管师、type=4审核医生)
     * @param ordenTime 订单完成时间(type=1 null、type=2 null、type=3 null、type=4 订单完成时间)
     * @param type      1:续方审核通知 2:取药代办通知 3:配送中信息变更 4:已完成服务结果
     * @param status    续方通知状态 0不通过 1通过 2调整处方  其余状态均为0
     * @param url       带参数的模板跳转链接
     */
    public void sendMessages(String patient, String doctName, String ordenTime, int type, int status, String url) throws Exception {
        LOGGER.info("=======================> sendMessages start!!");
        LOGGER.debug("patient "+patient);
        LOGGER.debug("doctName "+doctName);
        LOGGER.debug("ordenTime "+ordenTime);
        LOGGER.debug("type "+type);
        LOGGER.debug("status "+status);
        LOGGER.debug("url "+ url);
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        JSONArray jsonArray = null;
        Patient people = patientDao.findByCode(patient);
        String openId = people.getOpenid();
        String name = people.getName();
        JSONObject sendJson = new JSONObject();
        String first = "";
        String remark = "";
        if (type == 1) {
            switch (status) {
                case 0:
                    first = name + "您好,你的续方申请医生已审核。";
                    remark = "您可点击消息查看详情,修改续方信息后重新提交。";
                    sendJson.put("keyword1", "审核不通过");
                    sendJson.put("keyword2", doctName);
                    sendJson.put("first", first);
                    sendJson.put("remark", remark);
                    sendJson.put("url", url);//带参数的模板跳转链接
                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 19, openId, name, sendJson);
                    //发送代理人
                    jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
                    if (jsonArray != null && jsonArray.length() > 0) {
                        for (int i = 0; i < jsonArray.length(); i++) {
                            JSONObject j = jsonArray.getJSONObject(i);
                            Patient member = (Patient) j.get("member");
                            int start = url.indexOf("&toUser=");
                            int end = url.indexOf("&", start + 1);
                            String touser = url.substring(start, end);
                            url = url.replace(touser, "&toUser=" + member.getCode());
                            //name患者姓名
                            sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
                            sendJson.put("url", url);
                            pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 19, member.getOpenid(), name, sendJson);
                        }
                    }
                    break;
                case 1:
                    first = name + "您好,你的续方申请医生已审核。";
                    remark = "您可点击消息查看详情并完成支付。";
                    sendJson.put("keyword1", "审核通过");
                    sendJson.put("keyword2", doctName);
                    sendJson.put("first", first);
                    sendJson.put("remark", remark);
                    sendJson.put("url", url);//带参数的模板跳转链接
                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 19, openId, name, sendJson);
                    //发送代理人
                    jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
                    if (jsonArray != null && jsonArray.length() > 0) {
                        for (int i = 0; i < jsonArray.length(); i++) {
                            JSONObject j = jsonArray.getJSONObject(i);
                            Patient member = (Patient) j.get("member");
                            int start = url.indexOf("&toUser=");
                            int end = url.indexOf("&", start + 1);
                            String touser = url.substring(start, end);
                            url = url.replace(touser, "&toUser=" + member.getCode());
                            //name患者姓名
                            sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
                            sendJson.put("url", url);
                            pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 19, member.getOpenid(), name, sendJson);
                        }
                    }
                    break;
                case 2:
                    first = name + "您好,您的续方申请医生已修改处方清单并审核。";
                    remark = "您可点击消息查看详情并完成支付。";
                    sendJson.put("keyword1", "审核通过");
                    sendJson.put("keyword2", doctName);
                    sendJson.put("first", first);
                    sendJson.put("remark", remark);
                    sendJson.put("url", url);//带参数的模板跳转链接
                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 19, openId, name, sendJson);
                    //发送代理人
                    jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
                    if (jsonArray != null && jsonArray.length() > 0) {
                        for (int i = 0; i < jsonArray.length(); i++) {
                            JSONObject j = jsonArray.getJSONObject(i);
                            Patient member = (Patient) j.get("member");
                            int start = url.indexOf("&toUser=");
                            int end = url.indexOf("&", start + 1);
                            String touser = url.substring(start, end);
                            url = url.replace(touser, "&toUser=" + member.getCode());
                            //name患者姓名
                            sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
                            sendJson.put("url", url);
                            pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 19, member.getOpenid(), name, sendJson);
                        }
                    }
                    break;
            }
        } else if (type == 2) {
            first = name + "您好,您的续方订单已完成配药,请尽快致社区医院取药。";
            remark = "";
            sendJson.put("keyword1", "续方订单取药");
            sendJson.put("keyword2", dateFormat.format(new Date()));
            sendJson.put("first", first);
            sendJson.put("remark", remark);
            sendJson.put("url", url);//带参数的模板跳转链接
            pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 11, openId, name, sendJson);
            //发送代理人
            jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
            if (jsonArray != null && jsonArray.length() > 0) {
                for (int i = 0; i < jsonArray.length(); i++) {
                    JSONObject j = jsonArray.getJSONObject(i);
                    Patient member = (Patient) j.get("member");
                    int start = url.indexOf("&toUser=");
                    int end = url.indexOf("&", start + 1);
                    String touser = url.substring(start, end);
                    url = url.replace(touser, "&toUser=" + member.getCode());
                    //name患者姓名
                    sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
                    sendJson.put("url", url);
                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 11, member.getOpenid(), name, sendJson);
                }
            }
        }
        if (type == 3) {
            first = name + "您好,您的续方订单配送员" + doctName + "已顺利取药,续方状态变更为配送中。";
            remark = "您可点击消息查看详情。";
            sendJson.put("keyword1", doctName);
            sendJson.put("keyword2", dateFormat.format(new Date()));
            sendJson.put("keyword3", "续方状态");
            sendJson.put("first", first);
            sendJson.put("remark", remark);
            sendJson.put("url", url);//带参数的模板跳转链接
            pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 10, openId, name, sendJson);
            //发送代理人
            jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
            if (jsonArray != null && jsonArray.length() > 0) {
                for (int i = 0; i < jsonArray.length(); i++) {
                    JSONObject j = jsonArray.getJSONObject(i);
                    Patient member = (Patient) j.get("member");
                    int start = url.indexOf("&toUser=");
                    int end = url.indexOf("&", start + 1);
                    String touser = url.substring(start, end);
                    url = url.replace(touser, "&toUser=" + member.getCode());
                    //name患者姓名
                    sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
                    sendJson.put("url", url);
                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 10, member.getOpenid(), name, sendJson);
                }
            }
        }
        if (type == 4) {
            first = name + ",您好!您的续方订单已成功配送。";
            remark = "感谢您的使用。";
            sendJson.put("keyword1", "续方申请");
            sendJson.put("keyword2", doctName);//审核医生姓名 开处方的医生(团队长?)
            sendJson.put("keyword3", ordenTime);//订单完成时间
            sendJson.put("first", first);
            sendJson.put("remark", remark);
            sendJson.put("url", url);//带参数的模板跳转链接
            pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 20, openId, name, sendJson);
            //发送代理人
            jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
            if (jsonArray != null && jsonArray.length() > 0) {
                for (int i = 0; i < jsonArray.length(); i++) {
                    JSONObject j = jsonArray.getJSONObject(i);
                    Patient member = (Patient) j.get("member");
                    int start = url.indexOf("&toUser=");
                    int end = url.indexOf("&", start + 1);
                    String touser = url.substring(start, end);
                    url = url.replace(touser, "&toUser=" + member.getCode());
                    //name患者姓名
                    sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
                    sendJson.put("url", url);
                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 20, member.getOpenid(), name, sendJson);
                }
            }
        }
    }
}

+ 170 - 7
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java

@ -1,21 +1,72 @@
package com.yihu.wlyy.service.app.prescription;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeam;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressage;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.repository.doctor.DoctorTeamDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.repository.prescription.PrescriptionPayDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDiagnosisDao;
import com.yihu.wlyy.repository.prescription.PrescriptionExpressageDao;
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.MessageType;
import org.apache.commons.lang3.StringUtils;
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.orm.jpa.JpaTransactionManager;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
 * Created by huangwenjie on 2017/8/12.
 * Created by chenweida on 2017/7/27.
 */
@Service
public class PrescriptionService extends BaseService {
    private static Logger logger = LoggerFactory.getLogger(PrescriptionService.class);
    @Value("${wechat.wechat_base_url}")
    private String wechat_base_url;
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private MessageDao messageDao;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
    private PrescriptionNoticesService prescriptionNoticesService;
    @Autowired
    private PatientDao patientDao;
    @Autowired
    private JwPrescriptionService jwPrescriptionService;
    @Autowired
    private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
    @Autowired
    private DoctorTeamDao doctorTeamDao;
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    @Autowired
    private JpaTransactionManager transactionManager;
    @Autowired
    private com.yihu.wlyy.util.CommonUtil commonUtil;
    /**
     *  获取处方信息
@ -27,12 +78,124 @@ public class PrescriptionService extends BaseService {
    }
    /**
     * 获取支付完成,院内结算失败的 处方CODE 集合
     *@author huangwenjie
     *@date 2017/8/17 19:27
     * redis 消息队列
     * @param message
     */
    public void redisMessage(String message){
        logger.info("redis_onMessage...:"+message);
        //this.unsubscribe();
        try{
            JSONObject json = JSONObject.parseObject(message);
            String title =  json.getString("title");
            if("dispensingComplete".equals(title)){//配药完成
                //药品配送完成,提醒取药
                String prescriptionCode = json.getString("prescription");
                dispensingComplete(prescriptionCode);
            }
        }catch (Exception e){
            logger.error("redis_error...",e);
        }
    }
    /**
     * 配药完成
     * @param code
     */
    public List<String> findCodesByPayStautsAndExecuteSickStatus() {
        return prescriptionDao.findCodesByPayStautsAndExecuteSickStatus();
    public void dispensingComplete(String code){
        logger.info("配药完成,提示居民或健管师取药:"+code);
        Prescription prescription = prescriptionDao.findByCode(code);
        if(prescription.getStatus().equals(PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue())){//等待领药
            if(prescription.getDispensaryType()==1){
                //自取
                Patient patient = patientDao.findByCode(prescription.getPatient());
                try {
//                    String dispensaryCode = prescriptionDispensaryCodeDao.getCodeByPrescriptionCodeAndType(code,1);
                    StringBuffer url = new StringBuffer();
                    url.append("/wx/prescription/html/code-detail.html?prescriptionCode=").append(code);
                    url.append("&openid=").append(patient.getOpenid());
                    url.append("&toUser=").append(patient.getCode());
                    url.append("&toName=").append(patient.getName());
                    url.append("&represented=").append(patient.getCode());
                    prescriptionNoticesService.sendMessages(prescription.getPatient(), null, null, 2, 0, url.toString());
                }catch (Exception e){
                    logger.info("微信模板发送失败,续方code"+code);
                }
            }else if(prescription.getDispensaryType()==3){
                //健管师配送
                PrescriptionExpressage expressage = prescriptionExpressageDao.findByPrescriptionCode(code);
                if(StringUtils.isNotBlank(expressage.getExpressageCode())){
                    String content = "您有一条新的续方订单待取药!";
                    Message message = new Message();
                    message.setCzrq(new Date());
                    message.setCreateTime(new Date());
                    message.setRead(1);//设置未读
                    message.setOver("1");
                    message.setReceiver(expressage.getExpressageCode());
                    message.setSender("system");
                    message.setCode(getCode());
                    message.setSenderName("系统");
                    message.setTitle("居民"+prescription.getPatientName()+"的续方订单待取药");
                    message.setContent("您有一条新的续方订单待取药!");
                    message.setType(7);//续方订单待取药
                    message.setReadonly(1);//是否只读消息
                    message.setDel("1");
                    message.setRelationCode(prescription.getCode());
                    message.setPrescriptionStatus("0");//待取药
                    message.setData(prescription.getAdminTeamId()+"");
                    messageDao.save(message);
                    pushMsgTask.put(expressage.getExpressageCode(), MessageType.MESSAGE_TYPE_PRESCRIPTION_WAIT_TAKE_DRUG.D_P_WRD.name(), MessageType.MESSAGE_TYPE_PRESCRIPTION_WAIT_TAKE_DRUG.续方消息.name(), content, prescription.getCode());
                }
            }
        }
        logger.info("配药完成,提示居民或健管师取药:"+code+",status="+prescription.getStatus());
    }
    /**
     * 提醒健管师待取药
     * @param code
     * @param healthDoctor
     */
    public void waitExpressageMessage(String code,String healthDoctor){
        try{
            Prescription prescription = prescriptionDao.findByCode(code);
            if(PrescriptionLog.PrescriptionLogStatus.wait_expressage.getValue()==prescription.getStatus()){
                //配药完成之后才分配健管师,分配健管师后,提示健管师待取药
                List<Message> list = messageDao.findByReceiverAndRelationCode(healthDoctor,code,7);
                if(list.size()==0){
                    PrescriptionExpressage expressage = prescriptionExpressageDao.findByPrescriptionCode(code);
                    if(StringUtils.isNotBlank(expressage.getExpressageCode())){
                        String content = "您有一条新的续方订单待取药!";
                        Message message = new Message();
                        message.setCzrq(new Date());
                        message.setCreateTime(new Date());
                        message.setRead(1);//设置未读
                        message.setOver("1");
                        message.setReceiver(expressage.getExpressageCode());
                        message.setSender("system");
                        message.setCode(getCode());
                        message.setSenderName("系统");
                        message.setTitle("居民"+prescription.getPatientName()+"的续方订单待取药");
                        message.setContent("您有一条新的续方订单待取药!");
                        message.setType(7);//续方订单待取药
                        message.setReadonly(1);//是否只读消息
                        message.setDel("1");
                        message.setRelationCode(prescription.getCode());
                        message.setPrescriptionStatus("0");//待取药
                        //获取居民团队code
                        DoctorTeam dt = doctorTeamDao.findByParientCode(prescription.getPatient());
                        message.setData(dt.getCode());
                        messageDao.save(message);
                        pushMsgTask.put(expressage.getExpressageCode(), MessageType.MESSAGE_TYPE_PRESCRIPTION_WAIT_TAKE_DRUG.D_P_WRD.name(), MessageType.MESSAGE_TYPE_PRESCRIPTION_WAIT_TAKE_DRUG.续方消息.name(), content, prescription.getCode());
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
            logger.info("提醒健管师待取药,消息新增失败");
        }
    }
}

+ 5 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/util/MessageType.java

@ -168,9 +168,13 @@ public class MessageType {
	public static enum MESSAGE_TYPE_DOCTOR_FOLLOW_UP_RECORD_FINISH {
		D_FU_04, 随访计划, 患者已提交随访内容
	};
	
	public static enum MESSAGE_TYPE_DOCTOR_HEALTH_INDEX {
		D_HI_01, 体征指标
	};
	public static enum MESSAGE_TYPE_PRESCRIPTION_WAIT_TAKE_DRUG{
		D_P_WRD, 续方消息, 待取药
	}
}

+ 23 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/GateWayInterceptor.java

@ -20,12 +20,16 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.web.context.HttpRequestResponseHolder;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -37,7 +41,7 @@ import java.util.Map;
 * 对外的请求拦截
 */
@Component
public class GateWayInterceptor extends BaseInterceptor {
public class GateWayInterceptor implements HandlerInterceptor {
    private Logger logger = LoggerFactory.getLogger(GateWayInterceptor.class);
    @Autowired
@ -58,10 +62,16 @@ public class GateWayInterceptor extends BaseInterceptor {
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        boolean flag = true;
        String accesstoken = request.getParameter("accesstoken");
        String accesstoken = request.getHeader("accesstoken");
        String ip = NetworkUtil.getIpAddress(request);
        //********************************判断accesstoken********************************
        try {
            if (org.springframework.util.StringUtils.isEmpty(accesstoken)) {
                saveHttpLog(ip, JSONObject.fromObject(request.getParameterMap()).toString(), null, accesstoken, request.getRequestURI(), GcHttpLog.flagEm.error.getCode(), BaseResultModel.codeEm.token_null.getMessage());
                //没权限
                BaseResultModel baseResultModel = new BaseResultModel(BaseResultModel.codeEm.token_null.getCode(), BaseResultModel.codeEm.token_null.getMessage());
                response.getOutputStream().write(JSONObject.fromObject(baseResultModel).toString().getBytes());
            }
            GcToken gcToken = gcTokenDaoDao.findByToken(accesstoken);
            if (gcToken == null) {
                saveHttpLog(ip, JSONObject.fromObject(request.getParameterMap()).toString(), null, accesstoken, request.getRequestURI(), GcHttpLog.flagEm.error.getCode(), BaseResultModel.codeEm.token_no_power.getMessage());
@ -101,12 +111,19 @@ public class GateWayInterceptor extends BaseInterceptor {
     */
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        //保存成功之后的日志
        String token = request.getParameter("token");
        String output = "";
        if (modelAndView != null) {
            output = JSONObject.fromObject(modelAndView.getModelMap()).toString();
        }
        HandlerMethod handlerMethod= (HandlerMethod) handler;
//        response.getOutputStream()
        String token = request.getHeader("accesstoken");
        String ip = NetworkUtil.getIpAddress(request);
        saveHttpLog(ip,
                JSONObject.fromObject(request.getParameterMap()).toString(),
                JSONObject.fromObject(modelAndView.getModelMap()).toString(),
                output,
                token,
                request.getRequestURI(),
                GcHttpLog.flagEm.success.getCode(),
@ -127,7 +144,6 @@ public class GateWayInterceptor extends BaseInterceptor {
    }
    @Transactional
    public void saveHttpLog(String ip, String input, String output, String token, String method, Integer flag, String message) {
        GcHttpLog gcHttpLog = new GcHttpLog();
        gcHttpLog.setCreateTime(new Date());
@ -137,6 +153,7 @@ public class GateWayInterceptor extends BaseInterceptor {
        gcHttpLog.setToken(token);
        gcHttpLog.setMethod(method);
        gcHttpLog.setFlag(flag);
        gcHttpLog.setMessage(message);
        httpLogDao.save(gcHttpLog);
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/gateway/GcTokenDao.java

@ -16,6 +16,6 @@ public interface GcTokenDao extends PagingAndSortingRepository<GcToken, Long>, J
    @Modifying
    void updateDel(String appid);
    @Query("from GcToken where token=?1")
    @Query("from GcToken where accesstoken=?1")
    GcToken findByToken(String token);
}

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

@ -119,6 +119,7 @@ public class PrescriptionExpressageService {
            case 3: {
                //判断是3 配送员(健管师)配送码
                // returnStatus = dispensaryCode_3(userCode, prescriptionDispensaryCode);
                returnStatus=0;
                break;
            }
            default: {

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

@ -317,7 +317,7 @@ public class PrescriptionInfoService extends BaseService {
        if (prescription!=null&&reviewed != null && prescription.getStatus() == PrescriptionLog.PrescriptionLogStatus.wait_pay.getValue()&&reviewed.getReviewedTime()!=null) {
            Long s = (new Date().getTime()-reviewed.getReviewedTime().getTime()) / 1000;
            //rs.put("time",s);
            if (s > 172800) {
            if (s > 86400) {
                prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.pay_outtime.getValue());
                prescriptionDao.save(prescription);
            }
@ -814,7 +814,7 @@ public class PrescriptionInfoService extends BaseService {
            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());
                prescriptionNoticesService.sendMessages(prescription.getPatient(), prescription.getDoctorName(), null, 1, 0, "prescription/html/re-prescription_info.html?openid=" + p.getOpenid() + "&toUser=" + p.getCode() + "&toName=" + p.getName() + "&code=" + prescription.getCode());
            }
            return 1;
        } catch (Exception e) {
@ -896,7 +896,8 @@ public class PrescriptionInfoService extends BaseService {
                " LEFT(pr.create_time,19) AS createTime, " +
                " pr.doctor, " +
                " pr.dispensary_type AS dispensaryType," +
                " e.expressage_code AS expressageCode " +
                " e.expressage_code AS expressageCode, " +
                " e.expressage_name AS expressageName " +
                " FROM " +
                " wlyy_prescription pr " +
                " LEFT JOIN wlyy_patient p ON pr.patient = p.`code` " +

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

@ -142,9 +142,7 @@ public class PrescriptionService extends BaseService {
                    message.setDel("1");
                    message.setRelationCode(prescription.getCode());
                    message.setPrescriptionStatus("0");//待取药
                    //获取居民团队code
                    DoctorTeam dt = doctorTeamDao.findByParientCode(prescription.getPatient());
                    message.setData(dt.getCode());
                    message.setData(prescription.getAdminTeamId()+"");
                    messageDao.save(message);
                    pushMsgTask.put(expressage.getExpressageCode(), MessageType.MESSAGE_TYPE_PRESCRIPTION_WAIT_TAKE_DRUG.D_P_WRD.name(), MessageType.MESSAGE_TYPE_PRESCRIPTION_WAIT_TAKE_DRUG.续方消息.name(), content, prescription.getCode());

+ 3 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java

@ -1873,7 +1873,7 @@ public class StatisticsService extends BaseService {
        //1.统计签约数据
        //查找团队签约
        String sign_sql = "SELECT COUNT(1) signCount FROM wlyy_sign_family t WHERE t.admin_team_code =" + id + " AND t.czrq >='" + startDate + "' AND t.czrq<='" + endDate + "' AND t.status >0 AND t.expenses_status ='1'";
        String sign_sql = "SELECT COUNT(1) signCount FROM wlyy_sign_family t WHERE t.admin_team_code =" + id + " AND t.czrq >='" + startDate + "' AND t.czrq<='" + endDate + "' AND t.status >0 AND  t.expenses_status ='1'";
        //查找续签表未转移的记录
        String renew_sql = "SELECT COUNT(1) renewCount FROM wlyy_sign_family_renew t WHERE t.admin_team_code =" + id + " AND t.czrq >='" + startDate + "' AND t.czrq<='" + endDate + "' AND t.status =1 AND t.expenses_status ='1' AND t.is_valid =0";
@ -2044,6 +2044,7 @@ public class StatisticsService extends BaseService {
                "  d.id = p.participant_id " +
                " AND c.consult = t.id " +
                " AND c.patient = s.id " +
                " AND c.type = 2 " +
                " AND p.session_id = t.session_id " +
                " AND c.admin_team_code =" + id +
                " AND t.create_time >= '" + startDate + "' " +
@ -2066,6 +2067,7 @@ public class StatisticsService extends BaseService {
                "  d.id = p.participant_id " +
                " AND c.consult = t.id " +
                " AND c.patient = s.id " +
                " AND c.type = 2 " +
                " AND t. STATUS <> 10 " +
                " AND t.`reply` = 0 " +
                " AND p.session_id = t.session_id " +

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java

@ -66,7 +66,7 @@ public class PatientService extends TokenService {
    private Clock clock = Clock.DEFAULT;
    //可续签月份
    private int[] canRenewMonth = {4, 5, 6, 7};
    private int[] canRenewMonth = {1,2,3,4,5,6,7,8,9,10,11,12};
    public void setClock(Clock clock) {
        this.clock = clock;

+ 6 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/CommonUtil.java

@ -119,7 +119,8 @@ public class CommonUtil {
    }
    /**
     * double*100转int
     * double转字符串,在转int
     * double*100转int 有bug 34.3会会变成3429
     * @param d
     * @return
     */
@ -135,9 +136,10 @@ public class CommonUtil {
            amLong = Integer.valueOf(currency+"00");
        }else if(length - index >= 3){
            amLong = Integer.valueOf((currency.substring(0, index+3)).replace(".", ""));
            Integer i = Integer.valueOf(currency.substring(index+3,index+4));
            if(i>=5){
                amLong++;
            if(length-index>3){
                if(Integer.valueOf(currency.substring(index+3,index+4))>=5){
                    amLong++;
                }
            }
        }else if(length - index == 2){
            amLong = Integer.valueOf((currency.substring(0, index+2)).replace(".", "")+0);

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

@ -3,6 +3,7 @@ package com.yihu.wlyy.web.doctor.prescription;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.adapter.PresModeAdapter;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressage;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
@ -11,6 +12,7 @@ import com.yihu.wlyy.service.app.prescription.PrescriptionExpressageService;
import com.yihu.wlyy.service.app.prescription.PrescriptionInfoService;
import com.yihu.wlyy.service.app.prescription.PrescriptionPayService;
import com.yihu.wlyy.service.app.prescription.PrescriptionService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.service.third.jw.ZyDictService;
import com.yihu.wlyy.web.BaseController;
@ -44,6 +46,8 @@ public class PrescriptionInfoController extends BaseController {
    private PresModeAdapter adapter;
    @Autowired
    private ZyDictService zyDictService;
    @Autowired
    private AdminTeamService adminTeamService;
    @RequestMapping(value = "/getPrescriptionFilter", method = RequestMethod.GET)
@ -171,9 +175,11 @@ public class PrescriptionInfoController extends BaseController {
    public String prescriptionFollow(
            @RequestParam(required = true) @ApiParam(value = "处方code", name = "prescriptionCode") String prescriptionCode) {
        try {
           JSONObject jo = new JSONObject();
            JSONObject jo = new JSONObject();
            //获取处方信息
            Prescription prescription = prescriptionService.findByCode(prescriptionCode);
            AdminTeam adminTeam = adminTeamService.getTeam(prescription.getAdminTeamId());
            //获取处方药品信息
            List<PrescriptionInfo> prescriptionInfos = prescriptionInfoService.getPrescriptionInfo(prescriptionCode);
            //获取付款信息
@ -183,12 +189,13 @@ public class PrescriptionInfoController extends BaseController {
            jo.put("prescriptionInfos", prescriptionInfos);
            jo.put("prescriptionPay", prescriptionPay);
            jo.put("prescriptionExpressage", prescriptionExpressage);
            jo.put("leadCode", adminTeam.getLeaderCode());//团队长code
            if (prescription != null) {
                jo.put("prescriptionHospital", prescription.getHospitalName());//出药机构
                jo.put("dispensaryDispensaryType", prescription.getDispensaryType());//处方配送方式
                jo.put("dispensaryDispensaryTypeName", prescription.getDispensaryTypeName());//处方配送方式
                jo.put("prescriptionStatus", prescription.getStatus());//处方状态
                jo.put("prescriptionStatusName", prescription.getStatusName(prescription.getStatus(), ""));//处方状态名称
                jo.put("prescriptionStatusName", prescription.getStatusName(prescription.getStatus(), "",""));//处方状态名称
            }
            return write(200, "查询成功", "data", jo);
        } catch (Exception e) {
@ -331,7 +338,7 @@ public class PrescriptionInfoController extends BaseController {
             @RequestParam(required = true) @ApiParam(value = "健康管理师Code", name = "healthDoctor") String
                     healthDoctor) {
        try {
            return write(200, "操作成功!", "data", prescriptionInfoService.distributionHealthDoctor(codes, healthDoctor,getUID()));
            return write(200, "操作成功!", "data", prescriptionInfoService.distributionHealthDoctor(codes, healthDoctor, getUID()));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -453,6 +460,7 @@ public class PrescriptionInfoController extends BaseController {
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/getPhysicMinDose", method = RequestMethod.GET)
    @ApiOperation(value = "获取药品最小用量")
    public String getPhysicMinDose(String code) {

+ 4 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionLogController.java

@ -100,8 +100,8 @@ public class PrescriptionLogController extends BaseController {
                prescriptionLog.setCreateTime(prescriptionExpressageLog.getCreateTime());
                prescriptionLog.setHospital(prescriptionExpressageLog.getAcceptHospital());
                prescriptionLog.setHospitalName(prescriptionExpressageLog.getAcceptHospitalName());
                prescriptionLog.setUserCode(prescriptionExpressageLog.getExpressageUserCode());
                prescriptionLog.setUserName(prescriptionExpressageLog.getExpressageUserName());
                prescriptionLog.setUserCode(prescriptionExpressageLog.getAcceptUser());
                prescriptionLog.setUserName(prescriptionExpressageLog.getAcceptUserName());
                prescriptionLogs.add(prescriptionLog);
            }
            //排序
@ -111,9 +111,9 @@ public class PrescriptionLogController extends BaseController {
                long map2value = o2.getCreateTime().getTime();
                if (map1value - map2value > 0) {
                    return 1;
                } else if (map1value - map2value < 0) {
                    return -1;
                } else if (map1value - map2value < 0) {
                    return 1;
                } else {
                    return 0;
                }

+ 13 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/AdminTeamController.java

@ -366,7 +366,7 @@ public class AdminTeamController extends BaseController {
    @RequestMapping(value = "/teams/{hospital}", method = RequestMethod.GET)
    @ApiOperation(value = "查询机构下的团队")
    @ApiOperation(value = "查询机构下的团队(翻译名称)")
    public String getHospitalTeams(@PathVariable  String hospital){
        try{
            List<AdminTeam> teams =  teamService.findHospitalTeams(hospital);
@ -378,4 +378,16 @@ public class AdminTeamController extends BaseController {
            return error(-1,"查询失败");
        }
    }
    @RequestMapping(value = "/teams/{hospital}/noTranslateAdminTeamLeaderName", method = RequestMethod.GET)
    @ApiOperation(value = "查询机构下的团队(不翻译名称)")
    public String getHospitalTeamsNoTranslateAdminTeamLeaderName(@PathVariable  String hospital){
        try{
            List<AdminTeam> teams =  teamService.findHospitalTeams(hospital);
            return write(200,"查询成功","data",teams);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
}

+ 2 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/gateway/vo/base/BaseResultModel.java

@ -35,7 +35,8 @@ public class BaseResultModel {
        error_AppSecret(-9001, "AppSecret不存在"),//AppSecret不存在
        token_out_effect(-9002, "无效的token"),//token无效
        token_no_power(-9003, "用户没权限"),// 没权限 包括未授权 或者uri错误
        token_out_time(-9004, "oken已过期"),//token无效
        token_out_time(-9004, "accesstoken已过期"),//token无效
        token_null(-9005, "accesstoken为空"),// 没权限 包括未授权 或者uri错误
        error_params(-10000, "请求失败 参数错误"),//请求失败 参数错误
        error_no_ip(-10010, "请求失败,获取IP失败"),//请求失败,获取IP失败

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

@ -244,7 +244,7 @@ public class PatientPrescriptionController extends WeixinBaseController {
                jo.put("dispensaryDispensaryType", prescription.getDispensaryType());//处方配送方式
                jo.put("dispensaryDispensaryTypeName", prescription.getDispensaryTypeName());//处方配送方式
                jo.put("prescriptionStatus", prescription.getStatus());//处方状态
                jo.put("prescriptionStatusName", prescription.getStatusName(prescription.getStatus(), ""));//处方状态名称
                jo.put("prescriptionStatusName", prescription.getStatusName(prescription.getStatus(), "",""));//处方状态名称
            }
            return write(200, "查询成功", "data", jo);
        } catch (Exception e) {

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionLogController.java

@ -76,9 +76,9 @@ public class PatientPrescriptionLogController extends BaseController {
                long map2value = o2.getCreateTime().getTime();
                if (map1value - map2value > 0) {
                    return 1;
                } else if (map1value - map2value < 0) {
                    return -1;
                } else if (map1value - map2value < 0) {
                    return 1;
                } else {
                    return 0;
                }