Commit fbbc38b1c0fcb7df7b61c340389bfe452d3fde76

Authored by jiangjiazhi
1 parent b93bf0f082
Exists in master

修改产检删除

Showing 2 changed files with 274 additions and 0 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/OrganizationGroupsController.java View file @ fbbc38b
  1 +package com.lyms.platform.operate.web.controller;
  2 +
  3 +import com.lyms.platform.common.annotation.TokenRequired;
  4 +import com.lyms.platform.common.base.BaseController;
  5 +import com.lyms.platform.common.base.LoginContext;
  6 +import com.lyms.platform.common.result.BaseResponse;
  7 +import com.lyms.platform.operate.web.facade.OrganizationGroupsFacade;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.stereotype.Controller;
  10 +import org.springframework.web.bind.annotation.RequestMapping;
  11 +import org.springframework.web.bind.annotation.RequestMethod;
  12 +import org.springframework.web.bind.annotation.RequestParam;
  13 +
  14 +import javax.servlet.http.HttpServletRequest;
  15 +
  16 +/**
  17 + * 机构组接口
  18 + * <p/>
  19 + * Created by Administrator on 2016/12/22 0022.
  20 + */
  21 +@Controller
  22 +public class OrganizationGroupsController extends BaseController {
  23 +
  24 + @Autowired
  25 + private OrganizationGroupsFacade organizationGroupsFacade;
  26 +
  27 + /**
  28 + * 查询当前帐号所有的机构组
  29 + *
  30 + * @param request
  31 + * @return
  32 + */
  33 + public BaseResponse queryByOwner(HttpServletRequest request) {
  34 +
  35 + return null;
  36 + }
  37 +
  38 + /**
  39 + * 增加机构组
  40 + *
  41 + * @param request
  42 + * @return
  43 + */
  44 + @TokenRequired
  45 + @RequestMapping(value = "/group",method = RequestMethod.POST)
  46 + public BaseResponse addOneEntity(HttpServletRequest request,
  47 + @RequestParam("groupName") String groupName,
  48 + @RequestParam("bType") Integer bType) {
  49 + LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
  50 + return organizationGroupsFacade.addOneEntity(groupName,bType,loginState.getId());
  51 + }
  52 +
  53 + /**
  54 + * 增加机构组
  55 + *
  56 + * @param request
  57 + * @return
  58 + */
  59 + @TokenRequired
  60 + @RequestMapping(value = "/groupitem",method = RequestMethod.POST)
  61 + public BaseResponse addOneItemEntity(HttpServletRequest request,
  62 + @RequestParam("groupName") String groupName,
  63 + @RequestParam("bType") Integer bType) {
  64 + return organizationGroupsFacade.addOneGroupItem();
  65 + }
  66 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/OrganizationGroupsFacade.java View file @ fbbc38b
  1 +package com.lyms.platform.operate.web.facade;
  2 +
  3 +import com.lyms.platform.biz.service.OrganizationGroupsItemService;
  4 +import com.lyms.platform.biz.service.OrganizationGroupsService;
  5 +import com.lyms.platform.common.constants.ErrorCodeConstants;
  6 +import com.lyms.platform.common.enums.YnEnums;
  7 +import com.lyms.platform.common.result.BaseListResponse;
  8 +import com.lyms.platform.common.result.BaseResponse;
  9 +import com.lyms.platform.operate.web.result.OrganizationGroupsResult;
  10 +import com.lyms.platform.permission.model.Organization;
  11 +import com.lyms.platform.permission.model.OrganizationQuery;
  12 +import com.lyms.platform.permission.service.OrganizationService;
  13 +import com.lyms.platform.pojo.OrganizationGroups;
  14 +import com.lyms.platform.pojo.OrganizationGroupsItems;
  15 +import com.lyms.platform.query.OrganizationGroupsItemQuery;
  16 +import com.lyms.platform.query.OrganizationGroupsQuery;
  17 +import org.apache.commons.collections.CollectionUtils;
  18 +import org.apache.commons.lang.StringUtils;
  19 +import org.springframework.beans.factory.annotation.Autowired;
  20 +import org.springframework.stereotype.Component;
  21 +
  22 +import java.util.ArrayList;
  23 +import java.util.Date;
  24 +import java.util.List;
  25 +
  26 +/**
  27 + * 机构组
  28 + * <p/>
  29 + * Created by Administrator on 2016/12/22 0022.
  30 + */
  31 +@Component
  32 +public class OrganizationGroupsFacade {
  33 + @Autowired
  34 + private OrganizationGroupsItemService groupsItemService;
  35 + @Autowired
  36 + private OrganizationGroupsService groupsService;
  37 + @Autowired
  38 + private AutoMatchFacade autoMatchFacade;
  39 + @Autowired
  40 + private OrganizationService organizationService;
  41 +
  42 +
  43 + /**
  44 + * 增加一个分组
  45 + *
  46 + * @param group
  47 + * @param bType
  48 + * @param userId
  49 + * @return
  50 + */
  51 + public BaseResponse addOneEntity(String group,Integer bType,Integer userId){
  52 + OrganizationGroups organizationGroups=new OrganizationGroups();
  53 + organizationGroups.setCreated(new Date());
  54 + organizationGroups.setGroupName(group);
  55 + organizationGroups.setbType(bType);
  56 + String hospital=autoMatchFacade.getHospitalId(userId);
  57 + organizationGroups.setOwner(Integer.valueOf(hospital));
  58 + groupsService.addOneEntity(organizationGroups);
  59 + return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功");
  60 + }
  61 +
  62 +
  63 + public BaseResponse addOneGroupItem(){
  64 + OrganizationGroupsItems organizationGroupsItems=new OrganizationGroupsItems();
  65 + organizationGroupsItems.setCreated(new Date());
  66 + organizationGroupsItems.setModified(new Date());
  67 + organizationGroupsItems.setType(1);
  68 + List<Integer> list=new ArrayList<>();
  69 + list.add(193);
  70 + list.add(195);
  71 + list.add(197);
  72 + list.add(204);
  73 + list.add(248);
  74 + list.add(1000000000);
  75 + list.add(1000000001);
  76 + organizationGroupsItems.sethId(list);
  77 + organizationGroupsItems.setParentId("100002");
  78 + groupsItemService.addOneEntity(organizationGroupsItems);
  79 + return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功");
  80 + }
  81 +
  82 + /**
  83 + * 查询当前用户可以查看那些医院
  84 + *
  85 + * @param userId 用户id
  86 + * @return
  87 + */
  88 + public List<String> findGroupHospital(Integer userId) {
  89 + String hospital = autoMatchFacade.getHospitalId(userId);
  90 + //查询当前帐号所在的组
  91 + String groupId = findByCurrentUserId(hospital);
  92 +
  93 + if (null == groupId) {
  94 + List<String> data = new ArrayList<>();
  95 + data.add(hospital);
  96 + return data;
  97 + }
  98 +
  99 + return findAllGroup(groupId);
  100 + }
  101 +
  102 + /**
  103 + * 获取当前医院所在组
  104 + *
  105 + * @param hospital
  106 + * @return
  107 + */
  108 + public String findByCurrentUserId(String hospital) {
  109 +
  110 + if (StringUtils.isNotEmpty(hospital)) {
  111 + Organization organization = organizationService.getOrganization(Integer.valueOf(hospital));
  112 + if (null != organization) {
  113 + OrganizationGroupsItemQuery organizationGroupsItemQuery = new OrganizationGroupsItemQuery();
  114 + List<Integer> hId = new ArrayList<>();
  115 + hId.add(Integer.valueOf(hospital));
  116 + organizationGroupsItemQuery.sethId(hId);
  117 + List<OrganizationGroupsItems> groupsItemses = groupsItemService.queryList(organizationGroupsItemQuery);
  118 +
  119 + if (CollectionUtils.isNotEmpty(groupsItemses)) {
  120 + return groupsItemses.get(0).getGroupId();
  121 + }
  122 + }
  123 + }
  124 + return null;
  125 + }
  126 +
  127 + /**
  128 + * 查询当前组里面包含的医院
  129 + *
  130 + * @param groupId
  131 + * @return
  132 + */
  133 + public List<String> findAllGroup(String groupId) {
  134 + OrganizationGroupsItemQuery organizationGroupsItemQuery = new OrganizationGroupsItemQuery();
  135 + organizationGroupsItemQuery.setGroupId(groupId);
  136 + List<OrganizationGroupsItems> groupsItemses = groupsItemService.queryList(organizationGroupsItemQuery);
  137 + List<String> hospital = new ArrayList<>();
  138 + if (CollectionUtils.isNotEmpty(groupsItemses)) {
  139 + for (OrganizationGroupsItems groupsItems : groupsItemses) {
  140 + //表示选择了具体的医院
  141 + if (1 == groupsItems.getType()) {
  142 + for (Integer in : groupsItems.gethId()) {
  143 + if (null != in) {
  144 + hospital.add(in + "");
  145 + }
  146 + }
  147 +
  148 + } else {
  149 + OrganizationQuery organizationQuery = new OrganizationQuery();
  150 + organizationQuery.setYn(YnEnums.YES.getId());
  151 + List<Organization> list = organizationService.queryOrganization(organizationQuery);
  152 + if (CollectionUtils.isNotEmpty(list)) {
  153 + for (Organization organization : list) {
  154 + hospital.add(organization.getId() + "");
  155 + }
  156 + }
  157 + }
  158 + }
  159 + }
  160 + return hospital;
  161 + }
  162 +
  163 +
  164 + /**
  165 + * 查询当前帐号能看到的机构组
  166 + *
  167 + * @param userId
  168 + * @return
  169 + */
  170 + public BaseListResponse queryByOnwer(Integer userId) {
  171 + String hospitalId = autoMatchFacade.getHospitalId(userId);
  172 + OrganizationGroupsQuery organizationGroupsQuery = new OrganizationGroupsQuery();
  173 + if (StringUtils.isNotEmpty(hospitalId)) {
  174 + organizationGroupsQuery.setOwner(Integer.valueOf(hospitalId));
  175 + }
  176 +
  177 + List<OrganizationGroups> data = groupsService.queryByOwner(organizationGroupsQuery);
  178 +
  179 + List<OrganizationGroupsResult> dataList = new ArrayList<>();
  180 + if (CollectionUtils.isNotEmpty(data)) {
  181 + for (OrganizationGroups groups : data) {
  182 + OrganizationGroupsResult organizationGroupsResult = new OrganizationGroupsResult();
  183 + organizationGroupsResult.convertToResult(groups);
  184 + OrganizationGroupsItemQuery organizationGroupsItemQuery = new OrganizationGroupsItemQuery();
  185 + organizationGroupsItemQuery.setGroupId(groups.getId());
  186 + //设置该组下面的
  187 + organizationGroupsResult.setCount(groupsItemService.count(organizationGroupsItemQuery));
  188 +
  189 + List<OrganizationGroupsItems> groupsItemses = groupsItemService.queryList(organizationGroupsItemQuery);
  190 + int count = 0;
  191 + if (CollectionUtils.isNotEmpty(groupsItemses)) {
  192 + for (OrganizationGroupsItems groupsItems : groupsItemses) {
  193 + //表示选择了具体的医院
  194 + if (1 == groupsItems.getType()) {
  195 + count += groupsItems.gethId().size();
  196 + } else {
  197 + //organizationService.queryOrganization();
  198 + }
  199 + }
  200 + }
  201 +
  202 + dataList.add(organizationGroupsResult);
  203 + }
  204 + }
  205 +
  206 + return new BaseListResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功");
  207 + }
  208 +}