Browse Source

设备初始化无法显示为缺货的bug

wangzhinan 3 years ago
parent
commit
aaf5da1f12

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

@ -42,11 +42,13 @@ public class MedicineUserEndpoint extends EnvelopRestEndpoint {
    public PageEnvelop getDeviceFullInfolist(
            @ApiParam(name = "content", value = "搜索内容")
            @RequestParam(value = "content", required = false) String content,
            @ApiParam(name = "userId", value = "用户id", required = true )
            @RequestParam(name = "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 = userService.queryUserListFullInfo(content, page, size, wechatId);
        JSONObject result = userService.queryUserListFullInfo(content,userId, page, size, wechatId);
        return success(result.getJSONArray("msg"), result.getInteger("count"), page, size);
    }

+ 68 - 33
svr/svr-base/src/main/java/com/yihu/jw/base/service/a3service/MedicineUserService.java

@ -6,11 +6,15 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.base.dao.a2dao.MediicineDeviceDao;
import com.yihu.jw.base.dao.a2dao.MediicineDeviceUserDao;
import com.yihu.jw.base.dao.a2dao.MediicineUserDao;
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.MediicineDeviceUser;
import com.yihu.jw.entity.a1entity.Mediicinedevice;
import com.yihu.jw.entity.a1entity.Mediicineuser;
import com.yihu.jw.entity.base.role.RoleDO;
import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
@ -30,17 +34,21 @@ import java.util.logging.Logger;
@Service
public class MedicineUserService extends BaseJpaService<Mediicineuser, MediicineUserDao> {
    @Autowired
    private MediicineUserDao userDao;
    @Autowired
    private MediicineDeviceUserDao deviceUserDao;
    @Autowired
    private MediicineDeviceDao deviceDao;
    @Autowired
    private ObjectMapper objectMapper;
    private UserDao userDao;
    @Autowired
    private RoleDao roleDao;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private HibenateUtils hibenateUtils;
@ -55,9 +63,63 @@ public class MedicineUserService extends BaseJpaService<Mediicineuser, Mediicine
     * @return
     * @throws Exception
     */
    public JSONObject queryUserListFullInfo(String content,int page, int size,String wechatId) throws Exception {
    public JSONObject queryUserListFullInfo(String content,String userId,int page, int size,String wechatId) throws Exception {
        JSONObject result = new JSONObject();
        String sql = "SELECT\n" +
        UserDO user = userDao.findOne(userId);
        RoleDO role = roleDao.findOne(user.getRoleId());
        String sql = "";
        String conditionSql = "";
        //登录者所管理的社区code串
        String belongCommunitys = "";
        {
            //市管理员
            if ("saasAdmin".equals(role.getCode())) {
                sql = "SELECT\n" +
                        "\t`code`\tas community\n" +
                        "FROM\n" +
                        "\tdm_hospital\n" +
                        "WHERE\n" +
                        "\tdel = 1";
            }
            //区域管理员
            if ("regionAdmin".equals(role.getCode())) {
                sql = "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())) {
                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();
                    }
                }
            }
        }
        if (!StringUtils.isEmpty(belongCommunitys)) {
            conditionSql += "\tAND ',"+ belongCommunitys +",' LIKE CONCAT('%,',wua.hospital,',%')\n";
        }
        sql = "SELECT\n" +
                "\tb.id AS id,\n" +
                "\tb.create_time AS createTime,\n" +
                "\tb.create_user AS createUser,\n" +
@ -83,7 +145,7 @@ public class MedicineUserService extends BaseJpaService<Mediicineuser, Mediicine
                "\tb.last_login_failure_time AS lastLoginFailureTime,\n" +
                "\tb.role_id AS roleId\n" +
                "FROM\n" +
                "\tbase_user b\n" +
                "\tbase_user b LEFT JOIN wlyy_user_area wua on b.id = wua.user_id\n" +
                "WHERE\n" +
                "\tb.role_id IN (\n" +
                "\t\tSELECT\n" +
@ -96,36 +158,9 @@ public class MedicineUserService extends BaseJpaService<Mediicineuser, Mediicine
                "\t)\n" +
                "\tAND b.enabled = 1\n" +
                "\tAND b.locked = 0\n";
//        String sql = "SELECT\n" +
//                "    t.id AS id,\n" +
//                "    t.account AS account,\n" +
//                "    t.belong_community AS belongCommunity,\n" +
//                "    t.bir_date AS birDate,\n" +
//                "    t.confirm_password AS confirmPassword,\n" +
//                "    t.contact_info AS contactInfo,\n" +
//                "    t.`name` AS `name`,\n" +
//                "    t.`password` AS `password`,\n" +
//                "    t.res_med_cabinet AS resMedCabinet,\n" +
//                "    t.res_pon_area AS resPonArea,\n" +
//                "    t.role AS role,\n" +
//                "    t.sex AS sex,\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" +
//                "FROM\n" +
//                "    t_mediicine_user AS t\n" +
//                "WHERE\n" +
//                "    1=1\n";
        String conditionSql = "";
        if (!StringUtils.isEmpty(content)){
//            conditionSql += " AND CONCAT(t.account, t.`name`) like '%"+ content +"%'";
            conditionSql += "\tAND CONCAT(IFNULL(b.`mobile`,''),IFNULL(b.`name`,'')) like '%"+ content +"%'";
        }
        sql = sql + conditionSql;
        List<Map<String,Object>> list=null;

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

@ -445,7 +445,7 @@ public class MedicinedeviceService  extends BaseJpaService<Mediicinedevice, Medi
            result.put("response", ConstantUtils.FAIL);
            return result.toJSONString();
        }
        mediicinedevice.setStatus(networkStatus);
        mediicinedevice.setNetworkStatus(networkStatus);
        this.save(mediicinedevice);
        result.put("response",ConstantUtils.SUCCESS);
        result.put("msg",mediicinedevice);