瀏覽代碼

修复我的处方

mengkang 5 年之前
父節點
當前提交
ba59b6df9e

+ 5 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/team/BaseTeamEndpoint.java

@ -16,6 +16,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@ -39,6 +40,9 @@ public class BaseTeamEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private BaseTeamService baseTeamService;
    @Value("${wechat.id}")
    private String wechatId;
    @PostMapping(value = BaseRequestMapping.BaseTeam.CREATE)
    @ApiOperation(value = "创建团队")
    public Envelop create(
@ -153,7 +157,7 @@ public class BaseTeamEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        JSONObject result = baseTeamService.getTeamInfoList(teamName, orgCode, status, page, size,getUserAgent());
        JSONObject result = baseTeamService.getTeamInfoList(teamName, orgCode, status, page, size,getUserAgent(),wechatId);
        return success(result.getJSONArray("msg"), result.getInteger("count"), page, size);
    }

+ 5 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/user/UserEndpoint.java

@ -16,6 +16,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@ -34,6 +35,9 @@ public class UserEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private UserService userService;
    @Value("${wechat.id}")
    private String wechatId;
    @PostMapping(value = BaseRequestMapping.User.CREATE)
    @ApiOperation(value = "创建")
    public Envelop create (
@ -192,7 +196,7 @@ public class UserEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        JSONObject result = userService.userInfoList(realName,saasid, roleId,page,size);
        JSONObject result = userService.userInfoList(realName,saasid, roleId,page,size,wechatId);
        return success(result.getJSONArray("msg"),result.getInteger("count"),page,size);
    }

+ 79 - 5
svr/svr-base/src/main/java/com/yihu/jw/base/service/team/BaseTeamService.java

@ -19,10 +19,13 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.base.team.BaseTeamMemberDO;
import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.restmodel.base.wx.WxGraphicMessageVO;
import com.yihu.jw.restmodel.base.wx.WxReplySceneVO;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Service;
import com.yihu.jw.entity.base.team.BaseTeamDO;
import org.springframework.transaction.annotation.Transactional;
@ -30,6 +33,7 @@ import org.springframework.util.CollectionUtils;
import java.io.IOException;
import java.util.*;
import java.util.logging.Logger;
/**
 * 
@ -303,7 +307,7 @@ public class BaseTeamService extends BaseJpaService<BaseTeamDO, BaseTeamDao> {
     * @return
     * @throws Exception
     */
    public JSONObject getTeamInfoList(String teamName,String orgCode,String status,int page,int size,JSONObject userAgent) throws Exception {
    public JSONObject getTeamInfoList(String teamName,String orgCode,String status,int page,int size,JSONObject userAgent,String wechatId) throws Exception {
        JSONObject result = new JSONObject();
      /*  int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 15 : page * size;*/
@ -311,11 +315,51 @@ public class BaseTeamService extends BaseJpaService<BaseTeamDO, BaseTeamDao> {
        String orgCodeValue = null == orgCode ? "" : orgCode;
        String statusValue = null == status ? "" : status;
//        String sql = " " +
//                "SELECT " +
//                "  team.id as \"teamId\", " +
//                "  team.name as \"name\", " +
//                "  case team.del when 0 then '已失效' when 1 then '生效中' end  as \"del\", " +
//                "  org.name as \"orgName\" " +
//                "FROM " +
//                "  base_team team, " +
//                "  base_org org " +
//                "WHERE " +
//                "  team.org_code = org.code " +
//                "  and (team.name like '{teamName}' or '' ='{teamName}') " +
//                "  and (team.org_code = '{orgCode}' or '' = '{orgCode}') " +
//                "  and ( team.del = '{status}' or '' = '{status}') " +
//                " ORDER BY team.create_time DESC " ;
//
//        String finalSql = sql
//                .replace("{teamName}","%" + teamNameValue + "%")
//                .replace("{orgCode}",orgCodeValue)
//                .replace("{status}",statusValue);
//
//        String countSql = "SELECT " +
//                "  count(team.id) " +
//                "FROM " +
//                "  base_team team, " +
//                "  base_org org " +
//                "WHERE " +
//                "  team.org_code = org.code " +
//                "  AND (team.name LIKE '{teamName}' OR '' = '{teamName}') " +
//                "  AND (team.org_code = '{orgCode}' OR '' = '{orgCode}') " +
//                "  AND (team.del = '{status}' OR '' = '{status}')";
//        String finalCountSql = countSql
//                .replace("{teamName}","%" + teamNameValue + "%")
//                .replace("{orgCode}",orgCodeValue)
//                .replace("{status}",statusValue);
//
//        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(finalSql,page,size);
//        int count = jdbcTemplate.queryForObject(finalCountSql,Integer.class);
        String sql = " " +
                "SELECT " +
                "  team.id as \"teamId\", " +
                "  team.name as \"name\", " +
                "  case team.del when 0 then '已失效' when 1 then '生效中' end status as \"del\", " +
                "  case  when team.del=0 then '已失效' when team.del=1 then '生效中' end  as \"del\", " +
                "  org.name as \"orgName\" " +
                "FROM " +
                "  base_team team, " +
@ -327,12 +371,43 @@ public class BaseTeamService extends BaseJpaService<BaseTeamDO, BaseTeamDao> {
                "  and ( team.del = '{status}' or '' = '{status}') " +
                " ORDER BY team.create_time DESC " ;
        String finalSql = sql
                .replace("{teamName}","%" + teamNameValue + "%")
                .replace("{orgCode}",orgCodeValue)
                .replace("{status}",statusValue);
        String countSql = "SELECT " +
        List<Map<String,Object>>  list=null;
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            String oracleSql="SELECT\n" +
                    "\t*\n" +
                    "FROM\n" +
                    "\t(\n" +
                    "\t\tSELECT\n" +
                    "\t\t\tA .*\n" +
                    "\t\tFROM\n" +
                    "\t\t\t(";
            oracleSql+=finalSql;
            oracleSql+="\t\t\t) A\n" +
                    "\t\tWHERE\n" +
                    "  ROWNUM <="+page*size +
                    "\t) \n" +
                    "WHERE\n" +
                    "\tROWNUM >= "+(page-1)*size;
            Logger.getAnonymousLogger().info("oracleSql="+oracleSql);
            list = jdbcTemplate.queryForList(oracleSql);
        }else {
            finalSql+=" LIMIT  " + (page - 1) * size + "," + size + "";
            Logger.getAnonymousLogger().info("oracleSql="+finalSql);
            list = jdbcTemplate.queryForList(finalSql);
        }
                String countSql = "SELECT " +
                "  count(team.id) " +
                "FROM " +
                "  base_team team, " +
@ -346,8 +421,7 @@ public class BaseTeamService extends BaseJpaService<BaseTeamDO, BaseTeamDao> {
                .replace("{teamName}","%" + teamNameValue + "%")
                .replace("{orgCode}",orgCodeValue)
                .replace("{status}",statusValue);
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(finalSql,page,size);
        Logger.getAnonymousLogger().info("finalCountSql="+finalCountSql);
        int count = jdbcTemplate.queryForObject(finalCountSql,Integer.class);
        result.put("count", count);
        result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));

+ 116 - 30
svr/svr-base/src/main/java/com/yihu/jw/base/service/user/UserService.java

@ -20,6 +20,8 @@ import com.yihu.jw.entity.base.saas.SaasDO;
import com.yihu.jw.entity.base.user.UserDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.restmodel.base.wx.WxGraphicMessageVO;
import com.yihu.jw.restmodel.base.wx.WxReplySceneVO;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
@ -37,6 +39,7 @@ import org.springframework.util.StringUtils;
import java.io.IOException;
import java.util.*;
import java.util.logging.Logger;
/**
 * Service - 后台管理员
@ -623,7 +626,7 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
     * @return
     * @throws Exception
     */
    public JSONObject userInfoList(String name,String saasid,String roleId,int page,int size) throws Exception {
    public JSONObject userInfoList(String name,String saasid,String roleId,int page,int size,String wechatId) throws Exception {
        JSONObject result = new JSONObject();
   /*     int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 15 : page * size;*/
@ -631,50 +634,133 @@ public class UserService extends BaseJpaService<UserDO, UserDao> {
        String saasidValue = null == saasid ? "" : saasid;
        String roleIdValue = null == roleId ? "" : roleId;
        String sql = "SELECT " +
                "  user.id as \"id\", " +
                "  user.name as \"realName\", " +
                "  user.username as \"username\", " +
                "  case user.enabled when 0 then '已失效' when 1 then '生效中' end status as \"enabled\", " +
                "  user.mobile as \"mobile\", " +
                "  saas.name as \"saasName\", " +
                "  role.name as \"roleName\" " +
                " FROM " +
                "  base_user user, " +
                "  base_saas saas, " +
                "  base_role role " +
                " WHERE " +
                "  user.saas_id = saas.id " +
                "  AND " +
                "  user.role_id = role.id " +
                " and (user.name like '{realName}' or '' ='{realName}') " +
                "  and (saas.id = '{saasid}' or '' = '{saasid}') " +
                "  and ( user.role_id = '{roleId}' or '' = '{roleId}') " +
                " ORDER BY user.create_time DESC";
        String finalSql = sql
//        String sql = "SELECT " +
//                "  usr.id as \"id\", " +
//                "  usr.name as \"realName\", " +
//                "  usr.username as \"username\", " +
//                "  case when usr.enabled=0 then '已失效' when usr.enabled=1 then '生效中' end  as \"enabled\", " +
//                "  usr.mobile as \"mobile\", " +
//                "  saas.name as \"saasName\", " +
//                "  role.name as \"roleName\" " +
//                " FROM " +
//                "  base_user usr, " +
//                "  base_saas saas, " +
//                "  base_role role " +
//                " WHERE " +
//                "  usr.saas_id = saas.id " +
//                "  AND " +
//                "  usr.role_id = role.id " +
//                " and (usr.name like '{realName}' or '' ='{realName}') " +
//                "  and (saas.id = '{saasid}' or '' = '{saasid}') " +
//                "  and ( usr.role_id = '{roleId}' or '' = '{roleId}') " +
//                " ORDER BY usr.create_time DESC";
//        String finalSql = sql
//                .replace("{realName}","%" + realName + "%")
//                .replace("{saasid}",saasidValue)
//                .replace("{roleId}",roleIdValue);
//
//        String countSql = "SELECT " +
//                "  count(usr.id) " +
//                "FROM " +
//                "  base_user usr, " +
//                "  base_saas saas, " +
//                "  base_role role " +
//                "WHERE " +
//                "  usr.saas_id = saas.id " +
//                "  AND " +
//                "  usr.role_id = role.id " +
//                " and (usr.name like '{realName}' or '' ='{realName}') " +
//                "  and (saas.id = '{saasid}' or '' = '{saasid}') " +
//                "  and ( usr.role_id = '{roleId}' or '' = '{roleId}') ";
//        String finalCountSql = countSql
//                .replace("{realName}", "%" + realName + "%")
//                .replace("{saasid}",  saasidValue )
//                .replace("{roleId}",  roleIdValue );
//        Logger.getAnonymousLogger().info("sql="+sql);
//        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(finalSql,page,size);
//        Integer count = jdbcTemplate.queryForObject(finalCountSql, Integer.class);
//        result.put("count", count);
//        result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));
        String finalSql="SELECT\n" +
                "\t\t\tusr . ID AS \"id\",\n" +
                "\t\t\tusr . NAME AS \"realName\",\n" +
                "\t\t\tusr .username AS \"username\",\n" +
                "\t\t\tCASE \n" +
                "\t\tWHEN usr .enabled=0 THEN\n" +
                "\t\t\t'已失效'\n" +
                "\t\tWHEN usr .enabled=1 THEN\n" +
                "\t\t\t'生效中'\n" +
                "\t\tEND  AS \"enabled\",\n" +
                "\t\tusr .mobile AS \"mobile\",\n" +
                "\t\tsaas. NAME AS \"saasName\",\n" +
                "\t\tROLE . NAME AS \"roleName\"\n" +
                "\tFROM\n" +
                "\t\tbase_user usr,\n" +
                "\t\tbase_saas saas,\n" +
                "\t\tbase_role ROLE\n" +
                "\tWHERE\n" +
                "\t\tusr .saas_id = saas. ID\n" +
                "\tAND usr .role_id = ROLE . ID\n" +
                "\tAND (usr . NAME LIKE '%%' OR '' = '%%')\n" +
                "\tAND (saas. ID = '' OR '' = '')\n" +
                "\tAND (usr .role_id = '' OR '' = '')\n" +
                "\tORDER BY\n" +
                "\t\tusr .create_time DESC";
        String sql = finalSql
                .replace("{realName}","%" + realName + "%")
                .replace("{saasid}",saasidValue)
                .replace("{roleId}",roleIdValue);
        List<Map<String, Object>> list=null;
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            String oracleSql="SELECT\n" +
                    "\t*\n" +
                    "FROM\n" +
                    "\t(\n" +
                    "\t\tSELECT\n" +
                    "\t\t\tA .*\n" +
                    "\t\tFROM\n" +
                    "\t\t\t(";
            oracleSql+=sql;
            oracleSql+="\t\t\t) A\n" +
                    "\t\tWHERE\n" +
                    "  ROWNUM <="+page*size +
                    "\t) \n" +
                    "WHERE\n" +
                    "\tROWNUM >= "+(page-1)*size;
            Logger.getAnonymousLogger().info("oracleSql="+oracleSql);
            list = jdbcTemplate.queryForList(oracleSql);
        }else {
            sql+=" LIMIT  " + (page - 1) * size + "," + size + "";
            Logger.getAnonymousLogger().info("sql="+sql);
            list = jdbcTemplate.queryForList(sql);
        }
        String countSql = "SELECT " +
                "  count(user.id) " +
                "  COUNT(usr.id) " +
                "FROM " +
                "  base_user user, " +
                "  base_user usr, " +
                "  base_saas saas, " +
                "  base_role role " +
                "WHERE " +
                "  user.saas_id = saas.id " +
                "  usr.saas_id = saas.id " +
                "  AND " +
                "  user.role_id = role.id " +
                " and (user.name like '{realName}' or '' ='{realName}') " +
                "  usr.role_id = role.id " +
                " and (usr.name like '{realName}' or '' ='{realName}') " +
                "  and (saas.id = '{saasid}' or '' = '{saasid}') " +
                "  and ( user.role_id = '{roleId}' or '' = '{roleId}') ";
                "  and ( usr.role_id = '{roleId}' or '' = '{roleId}') ";
        String finalCountSql = countSql
                .replace("{realName}", "%" + realName + "%")
                .replace("{saasid}",  saasidValue )
                .replace("{roleId}",  roleIdValue );
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(finalSql,page,size);
        Logger.getAnonymousLogger().info("finalCountSql="+finalCountSql);
        Integer count = jdbcTemplate.queryForObject(finalCountSql, Integer.class);
        result.put("count", count);
        result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));