Browse Source

首页接口

wangzhinan 3 years ago
parent
commit
aeea6eb094

+ 4 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java

@ -212,6 +212,7 @@ public class BaseRequestMapping {
        public static final String countall  = "/countall";
        public static final String countAllDevice  = "/countAllDevice";
        public static final String countOnline  = "/countOnline";
        public static final String getFirstPageInfo  = "/getFirstPageInfo";
        public static final String getDevicesByMoreContent  = "/getDevicesByMoreContent";
        public static final String getOrderDetailListById  = "/getOrderDetailListById";
        public static final String enableOrDis  = "/enableOrDis";
@ -245,8 +246,11 @@ public class BaseRequestMapping {
        public static final String getDeviceStatistics = "/getDeviceStatistics";
        public static final String getDevicePriceStatistics = "/getDevicePriceStatistics";
        public static final String getDevicePriceStatisticsByUserId = "/getDevicePriceStatisticsByUserId";
        public static final String getShippingType = "/getShippingType";
        public static final String getShippingTypeByUserId = "/getShippingTypeByUserId";
        public static final String getPrescriptionStatics = "/getPrescriptionStatics";
        public static final String getPrescriptionStaticsByUserId = "/getPrescriptionStaticsByUserId";
        public static final String SYSTEMUPDATE  = "/systemUpdate";
    }

+ 5 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/dao/a2dao/MediicineDeviceUserDao.java

@ -2,9 +2,13 @@ package com.yihu.jw.base.dao.a2dao;
import com.yihu.jw.entity.a1entity.MediicineDeviceUser;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface MediicineDeviceUserDao extends PagingAndSortingRepository<MediicineDeviceUser, String> {
import java.util.List;
public interface MediicineDeviceUserDao extends PagingAndSortingRepository<MediicineDeviceUser, String> {
    @Query("select deviceId as deviceId from MediicineDeviceUser where userId = ?1 and del = ?2")
    List<String> getdevicesbyuserid(String userId, String del);
}

+ 43 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/a4endpoint/MedicineDeviceEndpoint.java

@ -862,4 +862,47 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
        return success(jsonObject.getString("response"));
    }
    @GetMapping(value = BaseRequestMapping.BaseDevice.getFirstPageInfo)
    @ApiOperation(value = "获取移动端首页信息", notes = "获取移动端首页信息")
    public Envelop getFirstPageInfo(@ApiParam(name = "userId", value = "用户id", required = true)
                                   @RequestParam(value = "userId") String userId) throws Exception {
        JSONObject jsonObject = deviceService.getFirstPageInfo(userId);
        if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
            return failed(jsonObject.getString("msg"));
        }
        return success(jsonObject.getJSONObject("msg"));
    }
    @GetMapping(value = BaseRequestMapping.BaseDevice.getDevicePriceStatisticsByUserId)
    @ApiOperation(value = "总览-销量", notes = "总览-销量")
    public Envelop getDevicePriceStatisticsByUserId(
            @ApiParam(name = "day", value = "天数", required = false)
            @RequestParam(value = "day", required = false) Integer day,
            @ApiParam(name = "userId", value = "1、市级、2、区级、3、社区", required = true)
            @RequestParam(value = "userId") String userId) throws Exception {
        return success(deviceService.getDevicePriceStatisticsByUserId(userId, day));
    }
    @GetMapping(value = BaseRequestMapping.BaseDevice.getShippingTypeByUserId)
    @ApiOperation(value = "总览-取药情况统计", notes = "总览-取药情况统计")
    public Envelop getShippingTypeByUserId(
            @ApiParam(name = "day", value = "天数", required = false)
            @RequestParam(value = "day", required = false) Integer day,
            @ApiParam(name = "userId", value = "1、市级、2、区级、3、社区", required = true)
            @RequestParam(value = "userId") String userId) throws Exception {
        return success(deviceService.getShippingTypeByUserId(userId, day));
    }
    @GetMapping(value = BaseRequestMapping.BaseDevice.getPrescriptionStaticsByUserId)
    @ApiOperation(value = "总览-处方订单情况统计", notes = "总览-处方订单情况统计")
    public Envelop getPrescriptionStaticsByUserId(
            @ApiParam(name = "day", value = "天数", required = false)
            @RequestParam(value = "day", required = false) Integer day,
            @ApiParam(name = "userId", value = "1、市级、2、区级、3、社区", required = true)
            @RequestParam(value = "userId") String userId) throws Exception {
        return success(deviceService.getPrescriptionStaticsByUserId(userId, day));
    }
}

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

@ -58,6 +58,9 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
    @Autowired
    private MedicineDrugInventoryRecordDao inventoryRecordDao;
    @Autowired
    private MediicineDeviceUserDao mediicineDeviceUserDao;
    @Autowired
    MedicineServive medicineServive;
@ -4661,4 +4664,494 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        return result.toJSONString();
    }
    /**
     * 首页信息
     * @param userId
     * @return
     * @throws Exception
     */
    public JSONObject getFirstPageInfo(String userId) throws Exception {
        JSONObject result = new JSONObject();
        JSONObject jsonObject = new JSONObject();
        String condition = "";
        //设备总数
        String total = "SELECT COUNT(1) as \"count\" FROM t_mediicine_device d WHERE d.del=1 "+condition;
        //在线设备
        String onlineTotal = total + " and d.network_status = 1 ";
        //离线设备
        String noOnlineTotal = total + " and d.network_status = 0 ";
        //未分配
        String noDistributionTotal = total + " and d.belong_community is  null  ";
        Map<String,Object> totalMap = jdbcTemplate.queryForMap(total);
        Map<String,Object> onlineTotalMap = jdbcTemplate.queryForMap(onlineTotal);
        Map<String,Object> noOnlineTotalMap = jdbcTemplate.queryForMap(noOnlineTotal);
        Double onlineTotal1 = 0.0;
        Double total1 = 0.0;
        Integer noOnlineTotal1 = 0;
        if (onlineTotalMap!=null){
            onlineTotal1 = Double.parseDouble(onlineTotalMap.get("count").toString());
        }
        if (totalMap!=null){
            total1 = Double.parseDouble(totalMap.get("count").toString());
        }
        if (noOnlineTotalMap!=null){
            noOnlineTotal1 = Integer.parseInt(noOnlineTotalMap.get("count").toString());
        }
        DecimalFormat df = new DecimalFormat("#.##");
        String rate = df.format(onlineTotal1/total1);
        Double rate1 = Double.parseDouble(rate)*100;
        String onlineRate = rate1+"%";
        Map<String, Object> overview = new HashMap<>();
        overview.put("total", total1);
        overview.put("onlineTotal", onlineTotal1);
        overview.put("onlineRate",onlineRate);
        overview.put("noOnlineTotal",noOnlineTotal1);
        //设备概况
        jsonObject.put("overview", overview);
        UserDO user = userDao.findOne(userId);
        RoleDO role = roleDao.findOne(user.getRoleId());
        List<String> deviceIds = null;
        String conditionSql = "";
        String orderConditionSql = "";
        if ("replenisher".equals(role.getCode())) {
            deviceIds = mediicineDeviceUserDao.getdevicesbyuserid(userId, "1");
            conditionSql  = "AND ',"+ String.join(",", deviceIds) +",' LIKE CONCAT('%,',d.id,',%')\n";
            orderConditionSql  = "AND ',"+ String.join(",", deviceIds) +",' LIKE CONCAT('%,',d.shipping_equ,',%')\n";
        } 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)) {
                conditionSql += "AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',d.belong_community,',%')\n";
                orderConditionSql += "AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',d.belong_community,',%')\n";
            }
        }
        conditionSql += "AND d.belong_community IS NOT NULL\n";
        //缺货设备
        String add_total = total + conditionSql + "AND d.status = 0\n";
        String noOnlineTotalWithUserId = total + conditionSql + " and d.network_status = 0 ";
        String hcWaringTotal = total + conditionSql + " and abnormal like '%异常%'";
        Map<String,Object> addTotalMap = jdbcTemplate.queryForMap(add_total);
        Map<String,Object> noOnlineTotalWithUserIdMap = jdbcTemplate.queryForMap(noOnlineTotalWithUserId);
        Map<String,Object> hcWaringTotalMap = jdbcTemplate.queryForMap(hcWaringTotal);
        Integer addTotal1 = 0;
        Integer noOnlineTotal1WithUserId = 0;
        Integer hcWaringTotalNum = 0;
        if (addTotalMap!=null){
            addTotal1 = Integer.parseInt(addTotalMap.get("count").toString());
        }
        if (noOnlineTotalWithUserIdMap!=null){
            noOnlineTotal1WithUserId = Integer.parseInt(noOnlineTotalWithUserIdMap.get("count").toString());
        }
        if (hcWaringTotalMap!=null){
            hcWaringTotalNum = Integer.parseInt(hcWaringTotalMap.get("count").toString());
        }
        Map<String, Object> maintain = new HashMap<>();
        //待补设备数
        maintain.put("addTotal", addTotal1);
        //离线设备数
        maintain.put("noOnlineTotal1WithUserId", noOnlineTotal1WithUserId);
        //温湿度预警数
        maintain.put("hcWaringTotalNum", hcWaringTotalNum);
        //未取药
        String noGetDrugSql = "SELECT COUNT(1) as \"count\" FROM t_mediicine_order d WHERE d.sell_state=0 \n" + orderConditionSql;
        Map<String,Object> noGetDrugMap = jdbcTemplate.queryForMap(noGetDrugSql);
        Integer noGetDrugNum = 0;
        if (noGetDrugMap!=null){
            noGetDrugNum = Integer.parseInt(noGetDrugMap.get("count").toString());
        }
        maintain.put("noGetDrugNum", noGetDrugNum);
        jsonObject.put("maintain", maintain);
        jsonObject.put("prescriptionStatics", getPrescriptionStaticsByUserId(userId, 1));
        //非设备管理员
        if (!"replenisher".equals(role.getCode())) {
            jsonObject.put("devicePriceStatistics", getDevicePriceStatisticsByUserId(userId, 1));
            jsonObject.put("shippingType", getShippingTypeByUserId(userId, 1));
        }
        result.put("response",ConstantUtils.SUCCESS);
        result.put("msg", jsonObject);
        return result;
    }
    /**
     * 补货员端-销售额
     * @param userId
     * @return
     */
    public JSONObject getDevicePriceStatisticsByUserId(String userId,Integer day){
        JSONObject object = new JSONObject();
        String condition = "";
        UserDO user = userDao.findOne(userId);
        RoleDO role = roleDao.findOne(user.getRoleId());
        List<String> deviceIds = null;
        if ("replenisher".equals(role.getCode())) {
            deviceIds = mediicineDeviceUserDao.getdevicesbyuserid(userId, "1");
            condition  = "AND ',"+ String.join(",", deviceIds) +",' LIKE CONCAT('%,',o.shipping_equ,',%')\n";
        } 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;
        String timeCondition = "";
        if (day != null) {
            if (day == 1) {
                startDate = DateUtil.strToDateLong(DateUtil.getStringDateShort() + " 00:00:00");
            } else {
                startDate = DateUtil.getPreDays(new Date(), -day);
            }
            String endTime = DateUtil.getStringDate();
            timeCondition = " and o.shipping_time >='" + DateUtil.dateToStrLong(startDate) + "' and o.shipping_time <= '" + endTime + "'  ";
        }
        String sql = "SELECT SUM(o.order_amount) as \"amount\" FROM t_mediicine_order o WHERE o.sell_state=1 "+condition+ timeCondition;
        Map<String,Object> totalMap = jdbcTemplate.queryForMap(sql);
        DecimalFormat df = new DecimalFormat("#.##");
        String amount ="";
        if (totalMap!=null){
            if (totalMap.get("amount")!=null){
                amount =  df.format(Double.parseDouble(totalMap.get("amount").toString()));
            }else {
                amount="0";
            }
        }
        object.put("amount",amount);
        String lineSql = "SELECT DATE_FORMAT(o.shipping_time, \"%Y-%m-%d\") as \"date\",SUM(o.order_amount) as \"amount\" FROM t_mediicine_order o WHERE o.sell_state=1 "+condition+ timeCondition +" GROUP BY DATE_FORMAT(o.shipping_time, \"%Y-%m-%d\") ";
        List<Map<String,Object>> amountdateList = DateUtil.findDates(startDate,DateUtil.getNowDate());
        List<Map<String,Object>> amountLine  = jdbcTemplate.queryForList(lineSql);
        for (Map<String,Object> map:amountdateList){
            String date = map.get("date").toString();
            for (Map<String,Object> objectMap:amountLine){
                String date1 = objectMap.get("date").toString();
                if (date1.equalsIgnoreCase(date)){
                    map.put("count",objectMap.get("amount"));
                }
            }
        }
        object.put("amountdateList",amountdateList);
        return object;
    }
    /**
     * 补货员端-取药情况统计
     * @param userId
     * @return
     */
    public JSONObject getShippingTypeByUserId(String userId,Integer day){
        JSONObject object = new JSONObject();
        String condition = "";
        UserDO user = userDao.findOne(userId);
        RoleDO role = roleDao.findOne(user.getRoleId());
        List<String> deviceIds = null;
        if ("replenisher".equals(role.getCode())) {
            deviceIds = mediicineDeviceUserDao.getdevicesbyuserid(userId, "1");
            condition  = "AND ',"+ String.join(",", deviceIds) +",' LIKE CONCAT('%,',o.shipping_equ,',%')\n";
        } 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;
        String timeCondition = "";
        if (day != null) {
            if (day == 1) {
                startDate = DateUtil.strToDateLong(DateUtil.getStringDateShort() + " 00:00:00");
            } else {
                startDate = DateUtil.getPreDays(new Date(), -day);
            }
            String endTime = DateUtil.getStringDate();
            timeCondition = " and o.shipping_time >='" + DateUtil.dateToStrLong(startDate) + "' and o.shipping_time <= '" + endTime + "'  ";
        }
        String sql = "SELECT count(1) as \"count\" FROM t_mediicine_order o WHERE o.sell_state=1 "+condition+ timeCondition;
        Map<String,Object> totalMap = jdbcTemplate.queryForMap(sql);
        int total =0;
        if (totalMap!=null){
            if (totalMap.get("count")!=null){
                total = Integer.parseInt(totalMap.get("count").toString());
            }
        }
        object.put("total",total);
        //扫码次数
        String saomaSql = sql + " and o.shipping_type =1 ";
        Map<String,Object> saomaTotalMap = jdbcTemplate.queryForMap(saomaSql);
        int saomaTotal =0;
        if (saomaTotalMap!=null){
            if (saomaTotalMap.get("count")!=null){
                saomaTotal = Integer.parseInt(saomaTotalMap.get("count").toString());
            }
        }
        //医保卡次数
        String yibaoSql = sql + " and o.shipping_type =2 ";
        Map<String,Object> yibaoTotalMap = jdbcTemplate.queryForMap(yibaoSql);
        int yibaoTotal =0;
        if (yibaoTotalMap!=null){
            if (yibaoTotalMap.get("count")!=null){
                yibaoTotal = Integer.parseInt(yibaoTotalMap.get("count").toString());
            }
        }
        object.put("saomaTotal",saomaTotal);
        object.put("yibaoTotal",yibaoTotal);
        return object;
    }
    /**
     * 补货员端----处方订单情况统计
     * @param userId
     * @param day
     * @return
     */
    public JSONObject getPrescriptionStaticsByUserId(String userId,Integer day){
        JSONObject object = new JSONObject();
        String condition = "";
        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");
            condition  = "AND ',"+ String.join(",", deviceIds) +",' LIKE CONCAT('%,',o.shipping_equ,',%')\n";
        } 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;
        String timeCondition = "";
        if (day != null) {
            if (day == 1) {
                startDate = DateUtil.strToDateLong(DateUtil.getStringDateShort() + " 00:00:00");
            } else {
                startDate = DateUtil.getPreDays(new Date(), -day);
            }
            String endTime = DateUtil.getStringDate();
            timeCondition = " and o.create_time >='" + DateUtil.dateToStrLong(startDate) + "' and o.create_time <= '" + endTime + "'  ";
        }
        String sql = "SELECT count(1) as \"count\" FROM t_mediicine_order o WHERE 1=1 "+condition+ timeCondition;
        Map<String,Object> totalMap = jdbcTemplate.queryForMap(sql);
        int total =0;
        if (totalMap!=null){
            if (totalMap.get("count")!=null){
                total = Integer.parseInt(totalMap.get("count").toString());
            }
        }
        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+")";
        Map<String,Object> drugTotalMap = jdbcTemplate.queryForMap(drugSql);
        Double quantity =0.0;
        if (drugTotalMap!=null){
            if (drugTotalMap.get("quantity")!=null){
                quantity = Double.parseDouble(drugTotalMap.get("quantity").toString());
            }
        }
        object.put("drugTotal",quantity);
        return object;
    }
}