wangzhinan 3 years ago
parent
commit
1dccc4a3c2

+ 3 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/a2dao/MediicineorderDao.java

@ -31,9 +31,12 @@ public interface MediicineorderDao extends PagingAndSortingRepository<Mediicineo
    Mediicineorder findMediicineorderByPickUpNum(String pickUpNum);
    Mediicineorder findMediicineorderByPickUpNumAndSellState(String pickUpNum, String sellState);
    Mediicineorder findMediicineorderBySocialSecurityCardNum(String cardNum);
    List<Mediicineorder> findMediicineordersBySocialSecurityCardNum(String cardNum);
    List<Mediicineorder> findMediicineordersBySocialSecurityCardNumAndSellState(String cardNum, String sellState);
}

+ 3 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/a4endpoint/MedicineDrugsEndpoint.java

@ -105,11 +105,13 @@ public class MedicineDrugsEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "lowPrice", required = false) String lowPrice,
            @ApiParam(name = "heightPrice", value = "价格上限")
            @RequestParam(value = "heightPrice", required = false) String heightPrice,
            @ApiParam(name = "userId", value = "用户id", required = true)
            @RequestParam(value = "userId") 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 = drugsService.queryDrugListFullInfo(state, content, drugClass, drugType, lowVolume, heightVolume, lowPrice, heightPrice,page,size,wechatId);
        JSONObject result = drugsService.queryDrugListFullInfo(state, content, drugClass, drugType, lowVolume, heightVolume, lowPrice, heightPrice, userId,page,size,wechatId);
        return success(result.getJSONArray("msg"),result.getInteger("count"),page,size);
    }

+ 4 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/a4endpoint/MedicineUserEndpoint.java

@ -61,8 +61,10 @@ public class MedicineUserEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "deviceIds", value = "设备ids,多个用英文逗号隔开", required = false)
            @RequestParam(value = "deviceIds", required = false) String deviceIds,
            @ApiParam(name = "isAll", value = "是否全部设备", required = true)
            @RequestParam(value = "isAll") Boolean isAll) throws Exception {
        JSONObject result = userService.allotDevice(userIds, deviceIds, isAll);
            @RequestParam(value = "isAll") Boolean isAll,
            @ApiParam(name = "userId", value = "用户id", required = true)
            @RequestParam(value = "userId") String userId) throws Exception {
        JSONObject result = userService.allotDevice(userIds, deviceIds, isAll, userId);
        return success(result.getString("response"));
    }

+ 64 - 7
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicineDrugsService.java

@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.base.dao.a2dao.MediicinedrugsDao;
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.Mediicinedrugs;
@ -12,8 +14,10 @@ import com.yihu.jw.entity.a1entity.Mediicinedrugs;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import com.yihu.jw.entity.base.role.RoleDO;
import com.yihu.jw.entity.base.team.BaseTeamDO;
import com.yihu.jw.entity.base.team.BaseTeamMemberDO;
import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
@ -39,6 +43,13 @@ public class MedicineDrugsService extends BaseJpaService<Mediicinedrugs, Mediici
    @Autowired
    private MediicinedrugsDao drugsDao;
    @Autowired
    private UserDao userDao;
    @Autowired
    private RoleDao roleDao;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
@ -179,13 +190,56 @@ public class MedicineDrugsService extends BaseJpaService<Mediicinedrugs, Mediici
    public JSONObject queryDrugListFullInfo(String state, String content, String drugClass,
                                              String drugType, String lowVolume, String heightVolume,
                                              String lowPrice, String heightPrice, int page, int size,String wechatId) throws Exception {
                                              String lowPrice, String heightPrice,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;*/
        UserDO user = userDao.findOne(userId);
        RoleDO role = roleDao.findOne(user.getRoleId());
        String belongCommunitys = "";
        String tempSql = "";
        //获取管理员所在社区id字符串
        {
            //市管理员
            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()) || "replenisher".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();
                    }
                }
            }
        }
        String sql = "SELECT\n" +
                "    t.id as id,\n" +
                "    t.approval_num as approvalNum,\n" +
@ -229,9 +283,12 @@ public class MedicineDrugsService extends BaseJpaService<Mediicinedrugs, Mediici
                "    t.quantity_unit as quantityUnit,\n" +
                "    t.pack_unit as packUnit\n" +
                "FROM\n" +
                "    t_mediicine_drugs AS t where 1=1";
                "    t_mediicine_drugs AS t where 1=1\n";
        String conditionSql = "";
        if (!StringUtils.isEmpty(belongCommunitys)) {
            conditionSql += " AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',t.org_code,',%')\n";
        }
        if (!StringUtils.isEmpty(state)){
            conditionSql += " and t.state = '" + state + "'";
        }

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

@ -1250,11 +1250,11 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
        //订单列表
        List<Mediicineorder> orders = new ArrayList<>();
        if (!StringUtils.isEmpty(pickUpNum)) {
            mediicineorder = orderDao.findMediicineorderByPickUpNum(pickUpNum);
            mediicineorder = orderDao.findMediicineorderByPickUpNumAndSellState(pickUpNum, "0");
            orders.add(mediicineorder);
        }
        if (!StringUtils.isEmpty(cardNum)) {
            orders.addAll(orderDao.findMediicineordersBySocialSecurityCardNum(cardNum));
            orders.addAll(orderDao.findMediicineordersBySocialSecurityCardNumAndSellState(cardNum, "0"));
        }
        orders = orders.stream().distinct().collect(Collectors.toList());
        if (orders == null && orders.size() == 0) {

+ 130 - 8
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicineUserService.java

@ -199,7 +199,7 @@ public class MedicineUserService extends BaseJpaService<Mediicineuser, Mediicine
     * @return
     * @throws Exception
     */
    public JSONObject allotDevice(String userIds, String deviceIds, Boolean isAll) throws Exception {
    public JSONObject allotDevice(String userIds, String deviceIds, Boolean isAll, String operator) throws Exception {
        JSONObject result = new JSONObject();
        if (StringUtils.isEmpty(userIds)) {
            result.put("response", ConstantUtils.FAIL);
@ -210,28 +210,150 @@ public class MedicineUserService extends BaseJpaService<Mediicineuser, Mediicine
            if (!StringUtils.isEmpty(userId)) {
                //全部设备
                if(isAll) {
                    Iterable<Mediicinedevice> lists = deviceDao.findAll();
                    Iterator iterator = lists.iterator();
                    while(iterator.hasNext()){
                        Mediicinedevice mediicinedevice = ((Mediicinedevice) iterator.next());
                        if (mediicinedevice != null) {
                    UserDO user = userDao.findOne(operator);
                    RoleDO role = roleDao.findOne(user.getRoleId());
                    String belongCommunitys = "";
                    String tempSql = "";
                    //获取管理员所在社区id字符串
                    {
                        //市管理员
                        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();
                                }
                            }
                        }
                    }
                    String sql = "";
                    {
                        sql += "SELECT\n" +
                                "t.id AS id,\n" +
                                "t.belong_community AS belongCommunity,\n" +
                                "t.community AS community,\n" +
                                "t.del AS del,\n" +
                                "t.delivery_address AS deliveryAddress,\n" +
                                "t.detail_address AS detailAddress,\n" +
                                "t.equ_area AS equArea,\n" +
                                "t.equ_class AS equClass,\n" +
                                "t.equ_info AS equInfo,\n" +
                                "t.equ_name AS equName,\n" +
                                "t.equ_num AS equNum,\n" +
                                "t.equ_type AS equType,\n" +
                                "t.fbelong_community AS fbelongCommunity,\n" +
                                "t.machine_code AS machineCode,\n" +
                                "t.network_status AS networkStatus,\n" +
                                "t.poweron_test AS poweronTest,\n" +
                                "t.reg_date AS regDate,\n" +
                                "t.sale_status AS saleStatus,\n" +
                                "t.signalintensity AS signalintensity,\n" +
                                "t.upgr_adesit AS upgrAdesit,\n" +
                                "t.`status` AS `status`,\n" +
                                "t.card_status AS cardStatus,\n" +
                                "t.operator AS operator,\n" +
                                "t.pack_age AS packAge,\n" +
                                "t.usage_flow AS usageFlow,\n" +
                                "t.flow AS flow,\n" +
                                "t.create_time AS createTime,\n" +
                                "t.create_user AS createUser,\n" +
                                "t.create_user_name AS createUserName,\n" +
                                "t.update_time AS updateTime,\n" +
                                "t.update_user AS updateUser,\n" +
                                "t.update_user_name AS updateUserName,\n" +
                                "t.aisles AS aisles,\n" +
                                "t.capacity AS capacity,\n" +
                                "t.ratio AS ratio,\n" +
                                "t.cargo_capacity AS cargoCapacity,\n" +
                                "t.layer AS layer,\n" +
                                "t.wayer AS wayer,\n" +
                                "t.humidity AS humidity,\n" +
                                "t.temperature AS temperature,\n" +
                                "t.humiditycontrol AS humiditycontrol,\n" +
                                "t.temperaturecontrol AS temperaturecontrol,\n" +
                                "t.heat AS heat,\n" +
                                "t.warning_temperature_height AS warningTemperatureHeight,\n" +
                                "t.waring_humidity_height AS waringHumidityHeight,\n" +
                                "t.warning_temperature_low AS warningTemperatureLow,\n" +
                                "t.waring_humidity_low AS waringHumidityLow\n" +
                                "FROM\n" +
                                "t_mediicine_device AS t WHERE t.del = 1 AND ',"+ belongCommunitys +",' LIKE CONCAT('%,',t.belong_community,',%')\n";
                    }
                    List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql);
                    for (Map<String, Object> stringObjectMap : list) {
                        if (stringObjectMap != null && stringObjectMap.get("id") != null && !StringUtils.isEmpty(stringObjectMap.get("id").toString())) {
                            String countSql = " select " +
                                    "     COUNT(DISTINCT (t.id)) as count " +
                                    "   from " +
                                    "     t_mediicine_device_user t " +
                                    "  where " +
                                    "  1=1 AND t.del = 1 AND t.device_id = '" + mediicinedevice.getId() + "' AND t.user_id = '" + userId + "'";
                                    "  1=1 AND t.del = 1 AND t.device_id = '" + stringObjectMap.get("id").toString() + "' AND t.user_id = '" + userId + "'";
                            int count = jdbcTemplate.queryForObject(countSql,Integer.class);
                            if (count > 0) {
                                continue;
                            }
                            MediicineDeviceUser deviceUser = new MediicineDeviceUser();
                            deviceUser.setDel("1");
                            deviceUser.setDeviceId(mediicinedevice.getId());
                            deviceUser.setDeviceId(stringObjectMap.get("id").toString());
                            deviceUser.setUserId(userId);
                            deviceUserDao.save(deviceUser);
                        }
                    }
//                    Iterable<Mediicinedevice> lists = deviceDao.findAll();
//                    Iterator iterator = lists.iterator();
//                    while(iterator.hasNext()){
//                        Mediicinedevice mediicinedevice = ((Mediicinedevice) iterator.next());
//                        if (mediicinedevice != null) {
//                            String countSql = " select " +
//                                    "     COUNT(DISTINCT (t.id)) as count " +
//                                    "   from " +
//                                    "     t_mediicine_device_user t " +
//                                    "  where " +
//                                    "  1=1 AND t.del = 1 AND t.device_id = '" + mediicinedevice.getId() + "' AND t.user_id = '" + userId + "'";
//                            int count = jdbcTemplate.queryForObject(countSql,Integer.class);
//                            if (count > 0) {
//                                continue;
//                            }
//                            MediicineDeviceUser deviceUser = new MediicineDeviceUser();
//                            deviceUser.setDel("1");
//                            deviceUser.setDeviceId(mediicinedevice.getId());
//                            deviceUser.setUserId(userId);
//                            deviceUserDao.save(deviceUser);
//                        }
//                    }
                } else {
                    //删除移除设备
                    String sql = "SELECT\n" +