소스 검색

健康上饶App-我的头像bug对应。

zdm 6 년 전
부모
커밋
93a757c98c

+ 97 - 10
src/main/java/com.yihu.ehr/basic/user/controller/UserEndPoint.java

@ -3,6 +3,8 @@ package com.yihu.ehr.basic.user.controller;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.ehr.basic.dict.service.SystemDictEntryService;
import com.yihu.ehr.basic.fileresource.service.FileResource;
import com.yihu.ehr.basic.fileresource.service.XFileResourceRepository;
import com.yihu.ehr.basic.getui.ConstantUtil;
import com.yihu.ehr.basic.org.model.OrgMemberRelation;
import com.yihu.ehr.basic.org.service.OrgMemberRelationService;
@ -76,6 +78,10 @@ public class UserEndPoint extends EnvelopRestEndPoint {
    private String orgcode;
    @Value("${jksr-app.registerRoleClientId}")
    public String registerRoleClientId;
    @Value("${fast-dfs.public-server}")
    private String fastDfsPublicServers;
    @Autowired
    private UserService userService;
    @Autowired
@ -98,6 +104,8 @@ public class UserEndPoint extends EnvelopRestEndPoint {
    private OrgMemberRelationService relationService;
    @Autowired
    private XUserTypeRolesRepository xUserTypeRolesRepository;
    @Autowired
    private XFileResourceRepository resourceRepository;
    @RequestMapping(value = ServiceApi.Users.Users, method = RequestMethod.GET)
    @ApiOperation(value = "获取用户列表", notes = "根据查询条件获取用户列表在前端表格展示")
@ -905,10 +913,10 @@ public class UserEndPoint extends EnvelopRestEndPoint {
        for (String rgAppId : appIds) {
            //根据用户类型、应用id判断是否关联角色,
            List<UserTypeRoles> list = xUserTypeRolesRepository.ListUserTypeRolesByTypeIdAndClientId(Integer.valueOf(ConstantUtil.PATIENTUSERTYPEID), rgAppId);
            if(null!=list && list.size()>0){
            if (null != list && list.size() > 0) {
                //卫生人员初始化授权
                userService.initializationAuthorization(Integer.valueOf(ConstantUtil.PATIENTUSERTYPEID),userId);
            }else{
                userService.initializationAuthorization(Integer.valueOf(ConstantUtil.PATIENTUSERTYPEID), userId);
            } else {
                // orgcode卫计委机构编码-PDY026797 添加居民的时候 默认 加到卫计委-居民角色中
                List<Roles> rolesList = rolesService.findByCodeAndAppIdAndOrgCode(Arrays.asList(new String[]{orgcode}), rgAppId, "Patient");
                Roles roles = new Roles();
@ -1119,11 +1127,11 @@ public class UserEndPoint extends EnvelopRestEndPoint {
    @ApiOperation(value = "根据用户类型id,用户id进行初始化授权")
    public Envelop initializationAuthorization(
            @ApiParam(name = "userTypeId", value = "用户类型id", defaultValue = "")
            @RequestParam(value = "userTypeId",required =true) int userTypeId,
            @RequestParam(value = "userTypeId", required = true) int userTypeId,
            @ApiParam(name = "userId", value = "用户id", defaultValue = "")
            @RequestParam(value = "userId",required =true) String userId) {
            @RequestParam(value = "userId", required = true) String userId) {
        Envelop envelop = new Envelop();
        boolean authorrizationFlag= userService.initializationAuthorization(userTypeId,userId);
        boolean authorrizationFlag = userService.initializationAuthorization(userTypeId, userId);
        if (authorrizationFlag) {
            envelop.setSuccessFlg(true);
        } else {
@ -1139,21 +1147,24 @@ public class UserEndPoint extends EnvelopRestEndPoint {
    public Envelop getUserInfoByLoginCode(
            @ApiParam(name = "userName", value = "登录账号", defaultValue = "")
            @PathVariable(value = "userName") String userName) {
        Envelop envelop=new Envelop();
        Envelop envelop = new Envelop();
        try {
            // 帐户:手机号,身份证号,登录账号
            List<User> users = userService.getUserForLogin(userName);
            envelop.setObj(users);
            if (users != null) {
                User user = users.get(0);
                String path = getImgPathByFileResource(users.get(0).getImgRemotePath());
                user.setImgRemotePath(path);
                envelop.setObj(users);
                if (users.size() == 1) {
                    List<OrgMemberRelation> memberRelations = orgMemberRelationService.findByField("userId", users.get(0).getId());
                    envelop.setSuccessFlg(true);
                    envelop.setDetailModelList(memberRelations);
                }else {
                } else {
                    envelop.setSuccessFlg(false);
                    envelop.setErrorMsg("账号重复,请联系管理员!");
                }
            }else {
            } else {
                envelop.setSuccessFlg(false);
                envelop.setErrorMsg("该账号不存在,请确认或联系管理员!");
            }
@ -1165,4 +1176,80 @@ public class UserEndPoint extends EnvelopRestEndPoint {
        return envelop;
    }
    @RequestMapping(value = BasicServiceApi.Users.UpdateUserByUsers, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "健康上饶app-修改用户", notes = "因为头像的获取方式与基础信息管理不同,基础信息管理在app-admin处理了图片路径")
    public MUser updateUserByUsers(
            @ApiParam(name = "user_json_data", value = "", defaultValue = "")
            @RequestBody String userJsonData) throws Exception {
        User user = toEntity(userJsonData, User.class);
        String userType = user.getUserType();
        SystemDictEntry dict = dictEntryService.getDictEntry(15, userType);
        if (dict != null) {
            user.setDType(userType);
        }
        //获取用户头像,保存至file_resource
        if (null != user.getImgRemotePath() && !StringUtils.isEmpty(user.getImgRemotePath())) {
            user.setImgRemotePath(saveImgFileSource(user.getImgRemotePath()));
        }
        userService.saveUser(user);
        //同时修改医生表及用户表信息
        Doctors doctors = doctorService.getByIdCardNo(user.getIdCardNo());
        if (!StringUtils.isEmpty(doctors)) {
            doctors.setName(user.getRealName());
            doctors.setPyCode(PinyinUtil.getPinYinHeadChar(user.getRealName(), false));
            doctors.setSex(user.getGender());
            doctors.setPhone(user.getTelephone());
            doctorService.save(doctors);
        }
        DemographicInfo demographicInfo = demographicService.getDemographicInfoByIdCardNo(user.getIdCardNo());
        if (!StringUtils.isEmpty(demographicInfo)) {
            demographicInfo.setName(user.getRealName());
            demographicInfo.setTelephoneNo("{\"联系电话\":\"" + user.getTelephone() + "\"}");
            demographicInfo.setGender(user.getGender());
            demographicInfo.setMartialStatus(user.getMartialStatus());
            demographicInfo.setBirthday(DateUtil.strToDate(user.getBirthday()));
            demographicService.save(demographicInfo);
        }
        return convertToModel(user, MUser.class);
    }
    /**
     * 健康上饶app,前端单独调用头像上传接口,将头像的路径传到后端。后端需要将路径保存到fileResource表中,再将id存到用户表
     * http://172.19.103.52:80/group1/M00/26/AF/rBFuWFr5BkWAZfYmAAAeqtdiKIY039.png
     *
     * @param path
     * @return
     */
    public String saveImgFileSource(String path) throws Exception {
        //获取用户头像,保存至file_resource
        FileResource fileResource = new FileResource();
        fileResource.setId(getObjectId(BizObject.FileResource));
        //获取groupName
        String[] str = path.split("/");
        String groupName = str[3];
        String remoteFileName = path.substring(path.indexOf(groupName) + groupName.length());
        //保存到resource表中
        fileResource.setStoragePath(groupName + ":" + remoteFileName);
        fileResource.setCreateDate(new Date());
        fileResource.setMime("user");
        fileResource.setObjectId("");
        return resourceRepository.save(fileResource).getId();
    }
    /**
     * 健康上饶app,根据fileResourceId获取图片路径
     *
     * @param fileResourceId
     * @return
     */
    public String getImgPathByFileResource(String fileResourceId) throws Exception {
        FileResource fileResource = resourceRepository.findById(fileResourceId);
        String path = null == fileResource ? "" : fileResource.getStoragePath();
        if (!StringUtils.isEmpty(path)) {
            return fastDfsPublicServers + "/" + path.replace(":", "/");
        }
        return "";
    }
}

+ 1 - 0
src/main/java/com.yihu.ehr/commons/constants/BasicServiceApi.java

@ -54,6 +54,7 @@ public class BasicServiceApi {
        //basic服务拆分之后追加
        public static final String GetUserByLoginCode = "/users/GetUserByLoginCode/{userName}";
        public static final String UpdateUserByUsers = "/users/UpdateUserByUsers";
    }