Explorar o código

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

wangzhinan %!s(int64=3) %!d(string=hai) anos
pai
achega
0cc5f8efb4

+ 13 - 6
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/a4endpoint/MedicineDeviceEndpoint.java

@ -898,9 +898,11 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseRequestMapping.BaseDevice.getFirstPageInfo)
    @ApiOperation(value = "获取移动端首页信息", notes = "获取移动端首页信息")
    public Envelop getFirstPageInfo(@ApiParam(name = "userId", value = "用户id", required = true)
    public Envelop getFirstPageInfo(@ApiParam(name = "belongCommunity", value = "单个社区")
                                        @RequestParam(value = "belongCommunity", required = false) String belongCommunity,
            @ApiParam(name = "userId", value = "用户id", required = true)
                                   @RequestParam(value = "userId") String userId) throws Exception {
        JSONObject jsonObject = deviceService.getFirstPageInfo(userId);
        JSONObject jsonObject = deviceService.getFirstPageInfo(belongCommunity, userId);
        if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
            return failed(jsonObject.getString("msg"));
        }
@ -910,32 +912,37 @@ public class MedicineDeviceEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = BaseRequestMapping.BaseDevice.getDevicePriceStatisticsByUserId)
    @ApiOperation(value = "总览-销量", notes = "总览-销量")
    public Envelop getDevicePriceStatisticsByUserId(
    public Envelop getDevicePriceStatisticsByUserId(@ApiParam(name = "belongCommunity", value = "单个社区")
                                                        @RequestParam(value = "belongCommunity", required = false) String belongCommunity,
            @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));
        return success(deviceService.getDevicePriceStatisticsByUserId(belongCommunity,userId, day));
    }
    @GetMapping(value = BaseRequestMapping.BaseDevice.getShippingTypeByUserId)
    @ApiOperation(value = "总览-取药情况统计", notes = "总览-取药情况统计")
    public Envelop getShippingTypeByUserId(
            @ApiParam(name = "belongCommunity", value = "单个社区")
            @RequestParam(value = "belongCommunity", required = false) String belongCommunity,
            @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));
        return success(deviceService.getShippingTypeByUserId(belongCommunity, userId, day));
    }
    @GetMapping(value = BaseRequestMapping.BaseDevice.getPrescriptionStaticsByUserId)
    @ApiOperation(value = "总览-处方订单情况统计", notes = "总览-处方订单情况统计")
    public Envelop getPrescriptionStaticsByUserId(
            @ApiParam(name = "belongCommunity", value = "单个社区")
            @RequestParam(value = "belongCommunity", required = false) String belongCommunity,
            @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));
        return success(deviceService.getPrescriptionStaticsByUserId(belongCommunity, userId, day));
    }
}

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

@ -910,6 +910,27 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
        List<MedicineWarrayRule> rules = medicineWarrayRuleDao.findMedicineWarrayRulesByEquNumAndDel(inventory.getEquNum(), 1);
        //不缺货
        mediicinedevice.setStatus("1");
        //bug:13663
        if (rules == null || rules.size() == 0) {
            for (Map<String, Object> stringObjectMap : collect) {
                if (isExit) {
                    if (inventoryDO.getDrugCode() != null && inventoryDO.getOrgCode() != null) {
                        if (inventoryDO.getDrugCode().equals(stringObjectMap.get("drugCode")) && inventoryDO.getOrgCode().equals(stringObjectMap.get("orgCode"))) {
                            stringObjectMap.put("qty", (int) Double.parseDouble(stringObjectMap.get("qty") + "") + inventoryDO.getQty());
                            stringObjectMap.put("ratedInventory", (int) Double.parseDouble(stringObjectMap.get("ratedInventory") + "") + inventoryDO.getRatedInventory());
                        }
                    }
                }
                Integer tempQty = (int) Double.parseDouble(stringObjectMap.get("qty") + "");
                if (tempQty == 0) {
                    mediicinedevice.setStatus("0");
                } else {
                    mediicinedevice.setStatus("1");
                }
            }
            deviceDao.save(mediicinedevice);
        }
        //bug:end
        quit:for (MedicineWarrayRule rule : rules) {
            for (Map<String, Object> stringObjectMap : collect) {
                if (isExit) {

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

@ -5262,7 +5262,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
     * @return
     * @throws Exception
     */
    public JSONObject getFirstPageInfo(String userId) throws Exception {
    public JSONObject getFirstPageInfo(String belongCommunity, String userId) throws Exception {
        JSONObject result = new JSONObject();
        JSONObject jsonObject = new JSONObject();
        String condition = "";
@ -5281,7 +5281,17 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        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";
//            orderConditionSql  = "AND ',"+ String.join(",", deviceIds) +",' LIKE CONCAT('%,',d.shipping_equ,',%')\n";
            List<String> belongCommunitys = new ArrayList<>();
            for (String deviceId : deviceIds) {
                Mediicinedevice mediicinedevice = deviceDao.findOne(deviceId);
                if (mediicinedevice != null) {
                    if (belongCommunitys.indexOf(mediicinedevice.getBelongCommunity()) == -1) {
                        belongCommunitys.add(mediicinedevice.getBelongCommunity());
                    }
                }
            }
            orderConditionSql += "AND ',"+ String.join(",", belongCommunitys) +",' LIKE CONCAT('%,',d.belong_community,',%')\n";
        } else {
            String belongCommunitys = "";
            String tempSql = "";
@ -5329,6 +5339,10 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                    }
                }
            }
            //选择单个社区
            if (belongCommunity != null && !StringUtils.isEmpty(belongCommunity)) {
                belongCommunitys = belongCommunity;
            }
            if (!StringUtils.isEmpty(belongCommunitys)) {
                conditionSql += "AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',d.belong_community,',%')\n";
                orderConditionSql += "AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',d.belong_community,',%')\n";
@ -5410,11 +5424,11 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
        jsonObject.put("maintain", maintain);
        jsonObject.put("prescriptionStatics", getPrescriptionStaticsByUserId(userId, 1));
        jsonObject.put("prescriptionStatics", getPrescriptionStaticsByUserId(belongCommunity, userId, 1));
        //非设备管理员
        if (!"replenisher".equals(role.getCode())) {
            jsonObject.put("devicePriceStatistics", getDevicePriceStatisticsByUserId(userId, 1));
            jsonObject.put("shippingType", getShippingTypeByUserId(userId, 1));
            jsonObject.put("devicePriceStatistics", getDevicePriceStatisticsByUserId(belongCommunity, userId, 1));
            jsonObject.put("shippingType", getShippingTypeByUserId(belongCommunity, userId, 1));
        }
        result.put("response",ConstantUtils.SUCCESS);
        result.put("msg", jsonObject);
@ -5428,7 +5442,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
     * @param userId
     * @return
     */
    public JSONObject getDevicePriceStatisticsByUserId(String userId,Integer day){
    public JSONObject getDevicePriceStatisticsByUserId(String belongCommunity, String userId,Integer day){
        JSONObject object = new JSONObject();
        String condition = "";
@ -5486,6 +5500,9 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                    }
                }
            }
            if (belongCommunity != null && !StringUtils.isEmpty(belongCommunity)) {
                belongCommunitys = belongCommunity;
            }
            if (!StringUtils.isEmpty(belongCommunitys)) {
                condition += "AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',o.belong_community,',%')\n";
            }
@ -5561,7 +5578,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
     * @param userId
     * @return
     */
    public JSONObject getShippingTypeByUserId(String userId,Integer day){
    public JSONObject getShippingTypeByUserId(String belongCommunity, String userId,Integer day){
        JSONObject object = new JSONObject();
        String condition = "";
@ -5619,6 +5636,9 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                    }
                }
            }
            if (belongCommunity != null && !StringUtils.isEmpty(belongCommunity)) {
                belongCommunitys = belongCommunity;
            }
            if (!StringUtils.isEmpty(belongCommunitys)) {
                condition += "AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',o.belong_community,',%')\n";
            }
@ -5678,18 +5698,24 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
     * @param day
     * @return
     */
    public JSONObject getPrescriptionStaticsByUserId(String userId,Integer day){
    public JSONObject getPrescriptionStaticsByUserId(String belongCommunity, 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";
            List<String> belongCommunitys = new ArrayList<>();
            for (String deviceId : deviceIds) {
                Mediicinedevice mediicinedevice = deviceDao.findOne(deviceId);
                if (mediicinedevice != null) {
                    if (belongCommunitys.indexOf(mediicinedevice.getBelongCommunity()) == -1) {
                        belongCommunitys.add(mediicinedevice.getBelongCommunity());
                    }
                }
            }
            orderConditionSql += "AND ',"+ String.join(",", belongCommunitys) +",' LIKE CONCAT('%,',o.belong_community,',%')\n";
        } else {
            String belongCommunitys = "";
            String tempSql = "";
@ -5737,8 +5763,11 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
                    }
                }
            }
            if (belongCommunity != null && !StringUtils.isEmpty(belongCommunity)) {
                belongCommunitys = belongCommunity;
            }
            if (!StringUtils.isEmpty(belongCommunitys)) {
                condition += "AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',o.belong_community,',%')\n";
                orderConditionSql += "AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',o.belong_community,',%')\n";
            }
        }
        Date startDate = null;
@ -5753,7 +5782,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 "+orderConditionSql+ timeCondition;
        Map<String,Object> totalMap = jdbcTemplate.queryForMap(sql);
        int total =0;
        if (totalMap!=null){
@ -5763,7 +5792,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 "+orderConditionSql+ timeCondition+")";
        Map<String,Object> drugTotalMap = jdbcTemplate.queryForMap(drugSql);
        Double quantity =0.0;
        if (drugTotalMap!=null){