Browse Source

Merge branch 'medicare' of liubing/wlyy2.0 into medicare

liubing 2 years ago
parent
commit
9334b59670

+ 18 - 12
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/a4endpoint/MedicineDeviceEndpoint.java

@ -821,18 +821,6 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
        return success(deviceService.getPrescriptionStatics(level,area, day));
    }
    @GetMapping(value = "getPrescriptionStaticsRank")
    @ApiOperation(value = "总览-处方订单情况统计", notes = "总览-处方订单情况统计")
    public Envelop getPrescriptionStaticsRank(
            @ApiParam(name = "area", value = "对应级别code", required = true)
            @RequestParam(value = "area", required = true) String area,
            @ApiParam(name = "day", value = "天数", required = false)
            @RequestParam(value = "day", required = false) Integer day,
            @ApiParam(name = "level", value = "1、市级、2、区级、3、社区", required = true)
            @RequestParam(value = "level", required = true) Integer level) throws Exception {
        return success(deviceService.getPrescriptionStaticsRank(level,area, day));
    }
    @PostMapping(value = BaseRequestMapping.BaseDevice.setWarrayRule)
    @ApiOperation(value = "设置设备药品库存报警规则")
    public Envelop setWarrayRule(
@ -1007,6 +995,24 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
        return success(deviceService.getPrescriptionStaticsByUserId(userId, day,startTime,endTime,level,area));
    }
    @GetMapping(value = "getPrescriptionStaticsRank")
    @ApiOperation(value = "总览-处方订单情况统计", notes = "总览-处方订单情况统计")
    public Envelop getPrescriptionStaticsRank(
            @ApiParam(name = "day", value = "天数", required = false)
            @RequestParam(value = "day", required = false) Integer day,
            @ApiParam(name = "startTime", value = "开始时间", required = false)
            @RequestParam(value = "startTime", required = false) String startTime,
            @ApiParam(name = "endTime", value = "结束时间", required = false)
            @RequestParam(value = "endTime", required = false) String endTime,
            @ApiParam(name = "userId", value = "1、市级、2、区级、3、社区", required = true)
            @RequestParam(value = "userId") String userId,
            @ApiParam(name = "level", value = "1、市级、2、区级、3、社区", required = false)
            @RequestParam(value = "level",required = false) Integer level,
            @ApiParam(name = "area", value = "1、市级、2、区级、3、社区", required = false)
            @RequestParam(value = "area",required = false) String area) throws Exception {
        return success(deviceService.getPrescriptionStaticsRank(userId, day,startTime,endTime,level,area));
    }
    @GetMapping("/open/setDeviceAttribute")
    @ApiOperation(value = "设置窗口结算属性", notes = "预缴金充值结果查询")
    public Envelop setDeviceAttribute(

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/JwService.java

@ -220,7 +220,7 @@ public class JwService {
                    insurResultTmp.put("dise_msgid",ylzMedicalIcdDOList.get(0).getDiseMsgid()); //就诊信息上传发送方报文ID
                    insurResultTmp.put("chrg_bchno",medicalMxDO.getChrgBchno());   //收费批次号
                    insurResultTmp.put("insuplc_admdvs",ylzMedicalRelationDO.getRegionCode()); //参保地医保区划【窗口冲销有用】
                    insurResultTmp.put("card_sn",ylzMedicalRelationDO.getCardSn()); //卡识别码
                    insurResultTmp.put("card_sn",null==ylzMedicalRelationDO.getCardSn()?"":ylzMedicalRelationDO.getCardSn()); //卡识别码
                    insurResultTmp.put("mdtrt_cert_no",ylzMedicalRelationDO.getCardNo()); //就诊凭证编号
                    JSONObject setlinfoEexpContent = JSONObject.parseObject(setlinfo.getString("exp_content"));

+ 0 - 46
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicineOrderService.java

@ -1553,52 +1553,6 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
    }
    /**
     * 根据处方号获取处方状态
     * @param realOrder
     * @return
     */
    public String getDataStatus(String realOrder){
        OauthWlyyConfigDO oauthWlyyConfigDO = oauthWlyyConfigDao.findOne("getDataStatus");
        //token获取accesstoken
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("appid", oauthWlyyConfigDO.getAppId()));
        params.add(new BasicNameValuePair("appSecret",oauthWlyyConfigDO.getAppSecret()));
        String res = httpClientUtil.post(oauthWlyyConfigDO.getTokenUrl(),params,"UTF-8");
        String token = null;
        JSONObject rsjson = JSONObject.parseObject(res);
        logger.info("checkWlyyDoctor token :"+rsjson.toString());
        Integer status = rsjson.getInteger("status");
        if(status==10000){
            //设置入参
            List<NameValuePair> p = new ArrayList<>();
            p.add(new BasicNameValuePair("jwCode", realOrder));
            //设置头部
            token = rsjson.getJSONObject("result").getString("accesstoken");
            Map<String,Object> headerMap = new HashedMap();
            headerMap.put("accesstoken",token);
            String rs = httpClientUtil.headerPost(oauthWlyyConfigDO.getUrl(),p,"UTF-8",headerMap);
            WlyyHttpLogDO wlyyHttpLogDO = new WlyyHttpLogDO();
            wlyyHttpLogDO.setCode("getDataStatus");
            wlyyHttpLogDO.setRequest(p.toString());
            wlyyHttpLogDO.setResponse(rs);
            wlyyHttpLogDO.setName("根据处方号获取i健康处方状态");
            wlyyHttpLogDO.setStatus("1");
            wlyyHttpLogDO.setCreateTime(new Date());
            httpLogDao.save(wlyyHttpLogDO);
            logger.info("getDataStatus:"+rs);
            return rs;
        }else {
            return null;
        }
    }
    /**
     * 取货预警发送模板消息

+ 105 - 14
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicinedeviceService.java

@ -5724,26 +5724,109 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
     * @param day
     * @return
     */
    public List<Map<String,Object>> getPrescriptionStaticsRank(int level,String area,int day){
    public List<Map<String,Object>> getPrescriptionStaticsRank(String userId,Integer day,String startTime,String endTime,Integer level,String area){
        JSONObject object = new JSONObject();
        String condition = "";
        if (level==1){
            condition = "";
        }else if (level==2){
            condition = " o.belong_community IN (select h.code from dm_hospital h where h.town = '"+area+"') ";
        }else if (level==3){
            condition = " o.belong_community = '"+area+"' ";
        UserDO user = userDao.findOne(userId);
        RoleDO role = roleDao.findOne(user.getRoleId());
        List<String> deviceIds = null;
        String conditionSql = "";
        String orderConditionSql = "";
        String oorderConditionSql = "";
        if ("replenisher".equals(role.getCode())) {
            deviceIds = mediicineDeviceUserDao.getdevicesbyuserid(userId, "1");
            String ids  ="";
            for (int i=0;i<deviceIds.size();i++){
                Mediicinedevice mediicinedevice = deviceDao.findOne(deviceIds.get(i));
                ids +="'"+mediicinedevice.getEquNum()+"',";
            }
            if (org.apache.commons.lang3.StringUtils.isNoneBlank(ids)){
                ids = ids.substring(0,ids.length()-1);
                condition  = " AND o.shipping_equ IN ("+ids+")";
            }
        } else {
            String belongCommunitys = "";
            String tempSql = "";
            //获取管理员所在社区code字符串
            {
                //市管理员
                if ("saasAdmin".equals(role.getCode())) {
                    tempSql = "SELECT\n" +
                            "\t`code`\tas community\n" +
                            "FROM\n" +
                            "\tdm_hospital\n" +
                            "WHERE\n" +
                            "\tdel = 1";
                }
                //区域管理员
                if ("regionAdmin".equals(role.getCode())) {
                    tempSql = "SELECT\n" +
                            "\tdh.`code` AS community\n" +
                            "FROM\n" +
                            "\twlyy_user_area t\n" +
                            "LEFT JOIN dm_hospital dh ON t.town = dh.town\n" +
                            "WHERE\n" +
                            "\tt.user_id = '" + userId + "'\n" +
                            "AND t.del = 1\n" +
                            "AND dh.del = 1";
                }
                //社区管理员
                if ("communityAdmin".equals(role.getCode())) {
                    tempSql = "SELECT\n" +
                            "t.hospital AS community\n" +
                            "FROM\n" +
                            "wlyy_user_area AS t\n" +
                            "WHERE\n" +
                            "t.user_id = '" + userId + "'\n" +
                            "AND t.del = 1";
                }
                List<Map<String, Object>> list = hibenateUtils.createSQLQuery(tempSql);
                for (Map<String, Object> stringObjectMap : list) {
                    if (stringObjectMap.get("community") != null && !StringUtils.isEmpty(stringObjectMap.get("community").toString())) {
                        if (StringUtils.isEmpty(belongCommunitys)) {
                            belongCommunitys += stringObjectMap.get("community").toString();
                        } else {
                            belongCommunitys += "," +  stringObjectMap.get("community").toString();
                        }
                    }
                }
            }
            if (!StringUtils.isEmpty(belongCommunitys)) {
                condition += "AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',o.belong_community,',%')\n";
            }
        }
        Date startDate = null;
        if (day==1){
            startDate = DateUtil.strToDateLong(DateUtil.getStringDateShort()+" 00:00:00");
        }else {
            startDate = DateUtil.getPreDays(new Date(),-day);
        String timeCondition = "";
        String areaCondition = "";
        if (level!=null){
            if(level==1){
                areaCondition = " and o.belong_community IN(select d.code from dm_hospital d where d.city='"+area+"')  ";
            }else if(level==2){
                areaCondition = " and o.belong_community IN(select d.code from dm_hospital d where d.town='"+area+"')  ";
            }else if(level==3){
                areaCondition = " and o.belong_community ='"+area+"'  ";
            }
        }
        if (day != null) {
            if (day == 1) {
                startDate = DateUtil.strToDateLong(DateUtil.getStringDateShort() + " 00:00:00");
            } else {
                startDate = DateUtil.getPreDays(new Date(), -day);
            }
            endTime = DateUtil.getStringDate();
            timeCondition = " and o.create_time >='" + DateUtil.dateToStrLong(startDate) + "' and o.create_time <= '" + endTime + "'  ";
        }
        if (org.apache.commons.lang3.StringUtils.isNotBlank(startTime)){
            timeCondition = " and o.create_time >='" + startTime + "' ";
        }
        if (org.apache.commons.lang3.StringUtils.isNotBlank(endTime)){
            timeCondition += " and o.create_time <= '" + endTime + "'  ";
        }
        String endTime = DateUtil.getStringDate();
        String timeCondition = " and o.create_time >='"+DateUtil.dateToStrLong(startDate)+"' and o.create_time <= '"+endTime+"'  ";
        String sql = "SELECT o.belong_community,o.community,count(o.id) 'orderTotal',count(IF(o.sell_state=1,1,null)) 'sellTotal'" +
                " FROM t_mediicine_order o WHERE 1=1 "+condition+ timeCondition;
                " FROM t_mediicine_order o WHERE 1=1 "+condition+ timeCondition+areaCondition;
        sql += " group by o.belong_community order by orderTotal desc";
        return jdbcTemplate.queryForList(sql);
    }
@ -6773,6 +6856,14 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
            }
        }
        sql = "SELECT count(1) as 'count' FROM t_mediicine_order o WHERE 1=1 and order_source='厦门i健康' "+condition+ timeCondition+areaCondition;
        Integer onlineTotal = jdbcTemplate.queryForObject(sql,Integer.class);
        sql = "SELECT count(1) as 'count' FROM t_mediicine_order o WHERE 1=1 and order_source='智业系统' "+condition+ timeCondition+areaCondition;
        Integer offlineTotal = jdbcTemplate.queryForObject(sql,Integer.class);
        object.put("onlineTotal",onlineTotal);
        object.put("offlineTotal",offlineTotal);
        object.put("total",total);
        String drugSql = "select sum(od.quantity) as quantity from t_mediicine_order_detail od where od.id_order IN (SELECT o.id as id  FROM t_mediicine_order o WHERE 1=1 "+condition+ timeCondition+areaCondition+")";
        Map<String,Object> drugTotalMap = jdbcTemplate.queryForMap(drugSql);

+ 4 - 3
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/MedicineService.java

@ -225,7 +225,7 @@ public class MedicineService {
        List<Mediicineorder> mediicineorderList = mediicineorderDao.findMediicineorderBySellState("0");
        int i=0;
        for (Mediicineorder mediicineorder:mediicineorderList){
            String result = getDataStatus(mediicineorder.getPickUpNum());
            String result = getDataStatus(mediicineorder.getPickUpNum(),mediicineorder.getBelongCommunity());
            if (StringUtils.isNoneBlank(result)){
                JSONObject resObj = JSONObject.parseObject(result);
                if (resObj.getString("status").equalsIgnoreCase("200")){
@ -286,7 +286,7 @@ public class MedicineService {
     * @param realOrder
     * @return
     */
    public String getDataStatus(String realOrder){
    public String getDataStatus(String realOrder,String hospital){
        OauthWlyyConfigDO oauthWlyyConfigDO = oauthWlyyConfigDao.findOne("getDataStatus");
        //token获取accesstoken
        List<NameValuePair> params = new ArrayList<>();
@ -303,7 +303,8 @@ public class MedicineService {
            //设置入参
            List<NameValuePair> p = new ArrayList<>();
            p.add(new BasicNameValuePair("jwCode", realOrder));
            p.add(new BasicNameValuePair("recipeNo", realOrder));
            p.add(new BasicNameValuePair("hospital", hospital));
            //设置头部
            token = rsjson.getJSONObject("result").getString("accesstoken");