فهرست منبع

跟新相关bug

wangzhinan 3 سال پیش
والد
کامیت
ef89b12f51

+ 24 - 8
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/a4endpoint/MedicineDeviceEndpoint.java

@ -899,8 +899,12 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
    @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);
                                   @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 {
        JSONObject jsonObject = deviceService.getFirstPageInfo(userId,level,area);
        if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
            return failed(jsonObject.getString("msg"));
        }
@ -914,8 +918,12 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
            @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));
            @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.getDevicePriceStatisticsByUserId(userId, day,level,area));
    }
    @GetMapping(value = BaseRequestMapping.BaseDevice.getShippingTypeByUserId)
@ -924,8 +932,12 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
            @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));
            @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.getShippingTypeByUserId(userId, day,level,area));
    }
    @GetMapping(value = BaseRequestMapping.BaseDevice.getPrescriptionStaticsByUserId)
@ -934,8 +946,12 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
            @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));
            @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.getPrescriptionStaticsByUserId(userId, day,level,area));
    }
}

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

@ -5283,7 +5283,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
     * @return
     * @throws Exception
     */
    public JSONObject getFirstPageInfo(String userId) throws Exception {
    public JSONObject getFirstPageInfo(String userId,Integer level,String area) throws Exception {
        JSONObject result = new JSONObject();
        JSONObject jsonObject = new JSONObject();
        String condition = "";
@ -5357,10 +5357,20 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        }
        conditionSql += "AND d.belong_community IS NOT NULL\n";
        String areaCondition = "";
        if (level!=null){
            if(level==1){
                areaCondition = " and d.belong_community IN(select d.code from dm_hospital d where d.city='"+area+"')  ";
            }else if(level==2){
                areaCondition = " and d.belong_community IN(select d.code from dm_hospital d where d.town='"+area+"')  ";
            }else if(level==3){
                areaCondition = " and d.belong_community ='"+area+"'  ";
            }
        }
        Map<String, Object> totalMap = jdbcTemplate.queryForMap(total + conditionSql);
        Map<String,Object> onlineTotalMap = jdbcTemplate.queryForMap(onlineTotal + conditionSql);
        Map<String,Object> noOnlineTotalMap = jdbcTemplate.queryForMap(noOnlineTotal + conditionSql);
        Map<String, Object> totalMap = jdbcTemplate.queryForMap(total + conditionSql+areaCondition);
        Map<String,Object> onlineTotalMap = jdbcTemplate.queryForMap(onlineTotal + conditionSql+areaCondition);
        Map<String,Object> noOnlineTotalMap = jdbcTemplate.queryForMap(noOnlineTotal + conditionSql+areaCondition);
        Double onlineTotal1 = 0.0;
        Double total1 = 0.0;
        Integer noOnlineTotal1 = 0;
@ -5392,11 +5402,11 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        //缺货设备
        String add_total = total + conditionSql + "AND d.status = 0\n";
        String add_total = total + conditionSql+areaCondition + "AND d.status = 0\n";
        String noOnlineTotalWithUserId = total + conditionSql + " and d.network_status = 0 ";
        String noOnlineTotalWithUserId = total + conditionSql +areaCondition+ " and d.network_status = 0 ";
        String hcWaringTotal = total + conditionSql + " and abnormal like '%异常%'";
        String hcWaringTotal = total + conditionSql+areaCondition + " 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);
@ -5421,7 +5431,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        //温湿度预警数
        maintain.put("hcWaringTotalNum", hcWaringTotalNum);
        //未取药
        String noGetDrugSql = "SELECT COUNT(1) as \"count\" FROM t_mediicine_order d WHERE d.sell_state=0 \n" + orderConditionSql;
        String noGetDrugSql = "SELECT COUNT(1) as \"count\" FROM t_mediicine_order d WHERE d.sell_state=0 \n" + orderConditionSql+areaCondition;
        Map<String,Object> noGetDrugMap = jdbcTemplate.queryForMap(noGetDrugSql);
        Integer noGetDrugNum = 0;
        if (noGetDrugMap!=null){
@ -5431,11 +5441,11 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        jsonObject.put("maintain", maintain);
        jsonObject.put("prescriptionStatics", getPrescriptionStaticsByUserId(userId, 1));
        jsonObject.put("prescriptionStatics", getPrescriptionStaticsByUserId(userId, 1,level,area));
        //非设备管理员
        if (!"replenisher".equals(role.getCode())) {
            jsonObject.put("devicePriceStatistics", getDevicePriceStatisticsByUserId(userId, 1));
            jsonObject.put("shippingType", getShippingTypeByUserId(userId, 1));
            jsonObject.put("devicePriceStatistics", getDevicePriceStatisticsByUserId(userId, 1,level,area));
            jsonObject.put("shippingType", getShippingTypeByUserId(userId, 1,level,area));
        }
        result.put("response",ConstantUtils.SUCCESS);
        result.put("msg", jsonObject);
@ -5449,11 +5459,9 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
     * @param userId
     * @return
     */
    public JSONObject getDevicePriceStatisticsByUserId(String userId,Integer day){
    public JSONObject getDevicePriceStatisticsByUserId(String userId,Integer day,Integer level,String area){
        JSONObject object = new JSONObject();
        String condition = "";
        UserDO user = userDao.findOne(userId);
        RoleDO role = roleDao.findOne(user.getRoleId());
        List<String> deviceIds = null;
@ -5511,7 +5519,16 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                condition += "AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',o.belong_community,',%')\n";
            }
        }
        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+"'  ";
            }
        }
        Date startDate = null;
        String timeCondition = "";
        String endTime = DateUtil.getStringDate();
@ -5531,6 +5548,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                    "WHERE\n" +
                    "\t1 = 1\n" +
                    "AND o.shipping_time IS NOT NULL\n" +
                    areaCondition+
                    "ORDER BY\n" +
                    "\to.shipping_time ASC LIMIT 1";
@ -5547,7 +5565,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
            }
            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;
        String sql = "SELECT SUM(o.order_amount) as \"amount\" FROM t_mediicine_order o WHERE o.sell_state=1 "+condition+ timeCondition +areaCondition;
        Map<String,Object> totalMap = jdbcTemplate.queryForMap(sql);
        DecimalFormat df = new DecimalFormat("#.##");
@ -5561,7 +5579,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        }
        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\") ";
        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 +areaCondition+" 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){
@ -5582,10 +5600,19 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
     * @param userId
     * @return
     */
    public JSONObject getShippingTypeByUserId(String userId,Integer day){
    public JSONObject getShippingTypeByUserId(String userId,Integer day,Integer level,String area){
        JSONObject object = new JSONObject();
        String condition = "";
        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+"'  ";
            }
        }
        UserDO user = userDao.findOne(userId);
        RoleDO role = roleDao.findOne(user.getRoleId());
@ -5657,7 +5684,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
            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;
        String sql = "SELECT count(1) as \"count\" FROM t_mediicine_order o WHERE o.sell_state=1 "+condition+ timeCondition+ areaCondition;
        Map<String,Object> totalMap = jdbcTemplate.queryForMap(sql);
        int total =0;
        if (totalMap!=null){
@ -5699,7 +5726,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
     * @param day
     * @return
     */
    public JSONObject getPrescriptionStaticsByUserId(String userId,Integer day){
    public JSONObject getPrescriptionStaticsByUserId(String userId,Integer day,Integer level,String area){
        JSONObject object = new JSONObject();
        String condition = "";
        UserDO user = userDao.findOne(userId);
@ -5764,7 +5791,16 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        }
        Date startDate = null;
        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");
@ -5774,7 +5810,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
            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;
        String sql = "SELECT count(1) as \"count\" FROM t_mediicine_order o WHERE 1=1 "+condition+ timeCondition+areaCondition;
        Map<String,Object> totalMap = jdbcTemplate.queryForMap(sql);
        int total =0;
        if (totalMap!=null){
@ -5784,7 +5820,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        }
        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+")";
        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);
        Double quantity =0.0;
        if (drugTotalMap!=null){