Commit 6c988018 authored by tangwei's avatar tangwei

增加查询单位接口

parent a9277e2c
......@@ -110,4 +110,6 @@ public interface OrgUsrMapper extends BaseMapper<OrgUsr> {
Map<String,String> selectPersonone(@Param("name")String name ,@Param("id")Long id);
List<OrgUsr> listByOrgTypes(@Param("orgTypeList") List<String> orgTypeList,@Param("bizOrgCode") String bizOrgCode);
String getParentList(@Param("id") String id);
}
......@@ -807,4 +807,11 @@ LEFT JOIN (
where u.biz_org_type='PERSON' and g.field_code='fireManagementPostCode' and g.field_value_label =#{name} and u.parent_id=#{id}
</select>
<select id="getParentList" resultType="java.lang.String">
select getParentList(#{id}) as id;
</select>
</mapper>
......@@ -16,7 +16,9 @@ import com.yeejoin.amos.boot.module.common.api.dto.FireTeamListDto;
import com.yeejoin.amos.boot.module.common.api.dto.FirefightersDto;
import com.yeejoin.amos.boot.module.common.api.dto.OrgMenuDto;
import com.yeejoin.amos.boot.module.common.api.entity.FireTeam;
import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr;
import com.yeejoin.amos.boot.module.common.api.enums.OrgPersonEnum;
import com.yeejoin.amos.boot.module.common.api.mapper.OrgUsrMapper;
import com.yeejoin.amos.boot.module.common.biz.service.impl.FireTeamServiceImpl;
import com.yeejoin.amos.boot.module.common.biz.service.impl.OrgUsrServiceImpl;
import io.swagger.annotations.Api;
......@@ -32,6 +34,7 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.HashMap;
......@@ -54,7 +57,8 @@ public class FireTeamController extends BaseController {
@Autowired
OrgUsrServiceImpl iOrgUsrService;
@Autowired
OrgUsrMapper orgUsrMapper;
@Value("${auth-key-fire-team:fire_team_info}")
private String authKey;
......@@ -170,6 +174,53 @@ public class FireTeamController extends BaseController {
return ResponseHelper.buildResponse(menus);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{companyId}/listTreetype", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "查询所属单位下消防队伍树", notes = "查询所属单位下消防队伍树")
public ResponseModel<List<Menu>> getlistTreeByCompanyId(
@PathVariable(value = "companyId") String companyId) throws Exception {
Map<String, Object> columnMap = new HashMap<>();
columnMap.put("is_delete", 0);
OrgUsr our=iOrgUsrService.getById(companyId);
if(our.getParentId()!=null){
//判断是不是部门
if(our.getBizOrgType().equals("COMPANY")){
columnMap.put("company", companyId);
}else{
String id= orgUsrMapper.getParentList(companyId);
columnMap.put("company", id);
}
}
List<Menu> menus = iFireTeamService.getTeamTree(columnMap);
return ResponseHelper.buildResponse(menus);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/{companyId}/getBizCode", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "获取bizcode", notes = "获取bizcode")
public ResponseModel<String> getBizCode(
@PathVariable(value = "companyId") String companyId) throws Exception {
OrgUsr our=iOrgUsrService.getById(companyId);
if(our.getParentId()!=null){
//判断是不是部门
if(our.getBizOrgType().equals("COMPANY")){
return ResponseHelper.buildResponse(our.getBizOrgCode());
}else{
String id= orgUsrMapper.getParentList(companyId);
OrgUsr ourf=iOrgUsrService.getById(id);
return ResponseHelper.buildResponse(ourf.getBizOrgCode());
}
}
return ResponseHelper.buildResponse(our.getBizOrgCode());
}
/**
* 列表分页查询
*
......
......@@ -2724,7 +2724,30 @@
</sql>
</changeSet>
<changeSet author="tw" id="20220207-1" runAlways="true">
<comment>`getParentList`</comment>
<sql endDelimiter="#">
DROP FUNCTION IF EXISTS `getParentList`#
CREATE FUNCTION `getParentList`(rootId varchar(100))
RETURNS varchar(1000)
BEGIN
DECLARE fid varchar(100) default '';
DECLARE type varchar(100) default '';
DECLARE str varchar(1000) default rootId;
WHILE rootId is not null do
SET type =(SELECT biz_org_type FROM cb_org_usr WHERE sequence_nbr = rootId);
SET fid =(SELECT parent_id FROM cb_org_usr WHERE sequence_nbr = rootId);
IF type ='COMPANY' THEN
SET str = (SELECT sequence_nbr FROM cb_org_usr WHERE sequence_nbr = rootId);
SET rootId = null;
ELSE
SET rootId = fid;
END IF;
END WHILE;
return str;
END#
</sql>
</changeSet>
</databaseChangeLog>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment