Sfoglia il codice sorgente

Merge branch 'dev' of chaoren1/wlyy2.0 into medicare

wangzhinan 3 anni fa
parent
commit
c882acae29

+ 11 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/a1entity/Mediicineorder.java

@ -220,6 +220,9 @@ public class Mediicineorder extends UuidIdentityEntityWithOperator implements Se
    private String socialSecurityCardNum;
    private String belongCommunity;
    public Mediicineorder() {
    }
@ -554,4 +557,12 @@ public class Mediicineorder extends UuidIdentityEntityWithOperator implements Se
    public void setSocialSecurityCardNum(String socialSecurityCardNum) {
        this.socialSecurityCardNum = socialSecurityCardNum;
    }
    public String getBelongCommunity() {
        return belongCommunity;
    }
    public void setBelongCommunity(String belongCommunity) {
        this.belongCommunity = belongCommunity;
    }
}

+ 5 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/a4endpoint/MedicineOrderEndpoint.java

@ -97,11 +97,15 @@ public class MedicineOrderEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "orderState", required = false) String orderState,
            @ApiParam(name = "dispensingWindow", value = "取药区域")
            @RequestParam(value = "dispensingWindow", required = false) String dispensingWindow,
            @ApiParam(name = "community", value = "所属社区")
            @RequestParam(value = "community", required = false) String community,
            @ApiParam(name = "userId", value = "用户id")
            @RequestParam(value = "userId", required = true) String userId,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        JSONObject result = orderservice.queryOrderListFullInfo(orderNum, equNum, contact, startTime, endTime, sellState, orderState, dispensingWindow,page,size,wechatId);
        JSONObject result = orderservice.queryOrderListFullInfo(orderNum, equNum, contact, startTime, endTime, sellState, orderState, dispensingWindow, community, userId,page,size,wechatId);
        return success(result.getJSONArray("msg"),result.getInteger("count"),page,size);
    }

+ 85 - 18
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicineOrderService.java

@ -4,9 +4,13 @@ package com.yihu.jw.base.service.a3service;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.base.dao.a2dao.*;
import com.yihu.jw.base.dao.role.RoleDao;
import com.yihu.jw.base.dao.user.UserDao;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.base.util.JavaBeanUtils;
import com.yihu.jw.entity.a1entity.*;
import com.yihu.jw.entity.base.role.RoleDO;
import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
@ -46,6 +50,11 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
    @Autowired
    private MediicineDeviceDao deviceDao;
    @Autowired
    private UserDao userDao;
    @Autowired
    private RoleDao roleDao;
    @Autowired
    private MediicinedrugsDao drugsDao;
@ -149,17 +158,71 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
    //orderNum, equNum, contact, startTime, endTime, sellState, orderState, dispensingWindow
    public JSONObject queryOrderListFullInfo(String orderNum, String equNum, String contact,
                                            String startTime, String endTime, String sellState,
                                            String orderState, String dispensingWindow, int page, int size,String wechatId) throws Exception {
                                            String orderState, String dispensingWindow, String community, String userId, int page, int size,String wechatId) throws Exception {
        JSONObject result = new JSONObject();
        /*String orgCodeVale = null == orgCode ? "" : orgCode;
        String del = null == docStatus ? "" : docStatus;
        String nameOrIdcardValue = null == nameOrIdcard ? "" : "%" + nameOrIdcard + "%";
        int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 15 : page * size;*/
        if (StringUtils.isEmpty(userId)) {
            result.put("msg", "userId is empty");
            result.put("response", ConstantUtils.FAIL);
            return result;
        }
        Date sTime = DateUtil.strToDate(startTime);
        Date eTime = DateUtil.strToDate(endTime);
        String sql="SELECT\n" +
        UserDO user = userDao.findOne(userId);
        RoleDO role = roleDao.findOne(user.getRoleId());
        //订单列表
        List<Map<String, Object>> orderList = null;
        String conditionSql = "";
        String belongCommunitys = "";
        String sql = "";
        //获取社区id,串
        {
            //市管理员
            if ("saasAdmin".equals(role.getCode())) {
                sql = "SELECT\n" +
                        "\tid\tas community\n" +
                        "FROM\n" +
                        "\tdm_hospital\n" +
                        "WHERE\n" +
                        "\tdel = 1";
            }
            //区域管理员
            if ("regionAdmin".equals(role.getCode())) {
                sql = "SELECT\n" +
                        "\tdh.id 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()) || "replenisher".equals(role.getCode())) {
                sql = "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(sql);
            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();
                    }
                }
            }
        }
        String sencodSql = "SELECT\n" +
                "    t.id as id,\n" +
                "    t.address as address,\n" +
                "    t.age as age,\n" +
@ -207,11 +270,18 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
                "    t.doctor_advice AS doctorAdvice,\n" +
                "    t.allergy_info AS allergyInfo,\n" +
                "    t.info AS info,\n" +
                "    t.social_security_card_num AS socialSecurityCardNum\n" +
                "    t.social_security_card_num AS socialSecurityCardNum,\n" +
                "    t.belong_community AS belongCommunity\n" +
                "FROM\n" +
                "    t_mediicine_order AS t where 1=1";
                "    t_mediicine_order AS t where 1=1 \n";
        String conditionSql = "";
        if (!StringUtils.isEmpty(belongCommunitys)) {
            conditionSql += " and ',"+ belongCommunitys +",' LIKE CONCAT('%,',t.belong_community,',%')\n";
        }
        if (!StringUtils.isEmpty(community)) {
            conditionSql += " and t.belong_community = '" + community + "'";
        }
        if (!StringUtils.isEmpty(orderNum)){
            conditionSql += " and t.order_num = '" + orderNum + "'";
        }
@ -222,8 +292,6 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
            conditionSql += " and t.contact like '%" + contact + "%'";
        }
        if (org.apache.commons.lang.StringUtils.isNotBlank(startTime)&& org.apache.commons.lang.StringUtils.isNotBlank(endTime)){
//            conditionSql += "  AND  t.prescribe_time BETWEEN to_date('" + startTime +"','yyyy-mm-dd hh24:mi:ss') " +
//                    " AND to_date('" + endTime + "','yyyy-mm-dd hh24:mi:ss')";
            conditionSql += "  AND  t.prescribe_time >= '" + startTime +"'" +
                    " AND t.prescribe_time <= '" + endTime + "'";
        }
@ -236,11 +304,9 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
        if (!StringUtils.isEmpty(dispensingWindow)){
            conditionSql += " and t.dispensing_window = '" + dispensingWindow + "'";
        }
        sencodSql = sencodSql + conditionSql;
        sql = sql + conditionSql;
        List<Map<String,Object>> list=null;
        list = hibenateUtils.createSQLQuery(sql,page,size);
        orderList = hibenateUtils.createSQLQuery(sencodSql, page, size);
        String countSql = " select " +
                "     COUNT(DISTINCT (t.id)) as count " +
@ -251,7 +317,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
                conditionSql;
        Logger.getAnonymousLogger().info("finalCountSql="+countSql);
        int count = jdbcTemplate.queryForObject(countSql,Integer.class);
        for (Map<String, Object> stringObjectMap : list) {
        for (Map<String, Object> stringObjectMap : orderList) {
            if (stringObjectMap.get("sellState") != null) {
                if (!StringUtils.isEmpty(stringObjectMap.get("sellState").toString())) {
                    if ("0".equals(stringObjectMap.get("sellState").toString())) {
@ -263,8 +329,9 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
                }
            }
        }
        result.put("response", ConstantUtils.SUCCESS);
        result.put("count", count);
        result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));
        result.put("msg", JavaBeanUtils.getInstance().mapListJson(orderList));
        return result;
    }

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

@ -1505,8 +1505,8 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                    "\tconcat(t.id_device, t.equ_num) like '%" + stringObjectMap.get("equNum") +"%'\n" +
                    "AND t.shelf_status = 1";
            //库存
            Integer qty = jdbcTemplate.queryForObject( tempSql, Integer.class);
            Integer qty = jdbcTemplate.queryForObject(tempSql, Integer.class);
            qty = qty == null ? 0 : qty;
            stringObjectMap.put("daibuQty", Integer.parseInt(stringObjectMap.get("capacity").toString()) - qty);
            tempSql = "SELECT\n" +
                    "\tCOUNT(DISTINCT(id))\n" +