Commit 77bf4eb9 by Suvalue

汇总数据查询接口

parent 048c3c81
package com.bsoft.api.common.enums;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public enum BudgetType {
NOT(1,"无"),
SUMMARY(2,"汇总"),
OUT(4,"门诊"),
SUMMARY_OUT(8,"汇总/门诊");
private int value;
private String desc;
BudgetType(int value,String desc) {
this.value = value;
this.desc = desc;
}
public int getValue() {
return value;
}
public String getDesc() {
return desc;
}
public static List<Map<String,Object>> all() {
List<Map<String,Object>> list = new ArrayList<>();
for(BudgetType projectType : values()){
Map<String,Object> map = new HashMap<String,Object>() {
{
put("value",projectType.getValue());
put("description",projectType.getDesc());
}
};
list.add(map);
}
return list;
}
}
package com.bsoft.api.controller; package com.bsoft.api.controller;
import com.bsoft.api.common.Result; import com.bsoft.api.common.Result;
import com.bsoft.api.common.annotations.CurrentUser;
import com.bsoft.api.common.annotations.Token; import com.bsoft.api.common.annotations.Token;
import com.bsoft.api.model.SerDepartment; import com.bsoft.api.model.SerDepartment;
import com.bsoft.api.model.reqmodel.QuerySummary; import com.bsoft.api.model.reqmodel.QuerySummary;
import com.bsoft.api.service.SerDeptService; import com.bsoft.api.service.SerDeptService;
import com.bsoft.api.service.SysUserOrgRsService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List; import java.util.List;
...@@ -18,7 +21,7 @@ import java.util.List; ...@@ -18,7 +21,7 @@ import java.util.List;
@RestController @RestController
public class DeptController { public class DeptController {
@Autowired @Autowired
private SerDeptService serDeptService; private SysUserOrgRsService sysUserOrgRsService;
/** /**
* 查询科室列表 * 查询科室列表
...@@ -28,8 +31,8 @@ public class DeptController { ...@@ -28,8 +31,8 @@ public class DeptController {
@PostMapping("/dept/list") @PostMapping("/dept/list")
@Token @Token
@ApiOperation("查询科室列表") @ApiOperation("查询科室列表")
public Object getList(@RequestBody QuerySummary req) { public Object getList(@ApiIgnore @CurrentUser Long userId) {
List<SerDepartment> list = serDeptService.getList(req.getDate()); List<SerDepartment> sysMenuList = sysUserOrgRsService.getUserOrg(userId);
return Result.success(list); return Result.success(sysMenuList);
} }
} }
...@@ -45,7 +45,7 @@ public class SerProjValueController { ...@@ -45,7 +45,7 @@ public class SerProjValueController {
@Token @Token
@ApiOperation("查询预算编制汇总数据") @ApiOperation("查询预算编制汇总数据")
public Object getSummary(@RequestBody QuerySummary request) throws Throwable { public Object getSummary(@RequestBody QuerySummary request) throws Throwable {
Object result = projValueService.getSummary(request.getDate()); Object result = projValueService.getSummary(request.getDate(),request.getBudgetType());
return Result.success(result); return Result.success(result);
} }
......
...@@ -3,21 +3,26 @@ package com.bsoft.api.controller; ...@@ -3,21 +3,26 @@ package com.bsoft.api.controller;
import com.bsoft.api.common.Result; import com.bsoft.api.common.Result;
import com.bsoft.api.common.annotations.CurrentUser; import com.bsoft.api.common.annotations.CurrentUser;
import com.bsoft.api.common.annotations.Token; import com.bsoft.api.common.annotations.Token;
import com.bsoft.api.model.SerDepartment;
import com.bsoft.api.model.SysRole; import com.bsoft.api.model.SysRole;
import com.bsoft.api.model.SysUser; import com.bsoft.api.model.SysUser;
import com.bsoft.api.model.respmodel.SysMenuList; import com.bsoft.api.model.respmodel.SysMenuList;
import com.bsoft.api.service.SysMenuService; import com.bsoft.api.service.SysMenuService;
import com.bsoft.api.service.SysUserOrgRsService;
import com.bsoft.api.service.SysUserRoleRsService; import com.bsoft.api.service.SysUserRoleRsService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import java.util.List; import java.util.List;
@Api(tags = "用户API",produces="produces",consumes="consumes",protocols="protocols") @Api(tags = "用户API", produces = "produces", consumes = "consumes", protocols = "protocols")
@RequestMapping("/user") @RequestMapping("/user")
@RestController @RestController
public class UserController { public class UserController {
...@@ -25,38 +30,56 @@ public class UserController { ...@@ -25,38 +30,56 @@ public class UserController {
private SysUserRoleRsService sysUserRoleRsService; private SysUserRoleRsService sysUserRoleRsService;
@Autowired @Autowired
private SysMenuService sysMenuService; private SysMenuService sysMenuService;
@Autowired
private SysUserOrgRsService sysUserOrgRsService;
@GetMapping() @GetMapping()
@ApiIgnore @ApiIgnore
public Object user(@CurrentUser@ApiIgnore SysUser user){ public Object user(@CurrentUser @ApiIgnore SysUser user) {
return Result.success(user); return Result.success(user);
} }
/** /**
* 根据用户id查询用户角色 * 根据用户id查询用户角色
*
* @param userId 用户id * @param userId 用户id
* @return * @return
*/ */
@PostMapping("roles") @PostMapping("roles")
@Token @Token
@ApiOperation("查询用户角色") @ApiOperation("查询用户角色")
public Object getRoleListByUser(@ApiIgnore@CurrentUser Long userId)throws Exception{ public Object getRoleListByUser(@ApiIgnore @CurrentUser Long userId) throws Exception {
List<SysRole> sysRoleList = sysUserRoleRsService.getRoleListByUser(userId); List<SysRole> sysRoleList = sysUserRoleRsService.getRoleListByUser(userId);
return Result.success(sysRoleList); return Result.success(sysRoleList);
} }
/** /**
* 根据用户id查询用户菜单 * 根据用户id查询用户菜单
*
* @param userId 用户id * @param userId 用户id
* @return * @return
*/ */
@PostMapping("menus") @PostMapping("menus")
@Token @Token
@ApiOperation("查询用户菜单") @ApiOperation("查询用户菜单")
public Object getMenuByUser(@ApiIgnore@CurrentUser Long userId)throws Exception{ public Object getMenuByUser(@ApiIgnore @CurrentUser Long userId) throws Exception {
List<SysMenuList> sysMenuList = sysMenuService.getMenu(userId); List<SysMenuList> sysMenuList = sysMenuService.getMenu(userId);
return Result.success(sysMenuList); return Result.success(sysMenuList);
} }
/**
* 根据用户id查询用户机构
*
* @param userId 用户id
* @return
*/
@PostMapping("dept")
@Token
@ApiOperation("查询用户科室")
public Object getOrgByUser(@ApiIgnore @CurrentUser Long userId) throws Exception {
List<SerDepartment> sysMenuList = sysUserOrgRsService.getUserOrg(userId);
return Result.success(sysMenuList);
}
} }
package com.bsoft.api.mapper; package com.bsoft.api.mapper;
import com.bsoft.api.model.DicOrg; import com.bsoft.api.model.DicOrg;
import com.bsoft.api.model.SerDepartment;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
...@@ -17,4 +18,6 @@ public interface DicOrgMapper { ...@@ -17,4 +18,6 @@ public interface DicOrgMapper {
List<DicOrg> selectByUser(@Param("userId") Long userId); List<DicOrg> selectByUser(@Param("userId") Long userId);
int updateByPrimaryKey(DicOrg record); int updateByPrimaryKey(DicOrg record);
List<SerDepartment> selectDeptByUser(@Param("userId") Long userId);
} }
\ No newline at end of file
...@@ -22,5 +22,5 @@ public interface SerProjMapper { ...@@ -22,5 +22,5 @@ public interface SerProjMapper {
List<ProjectInfo> selectState(@Param("projType") Integer projType, List<ProjectInfo> selectState(@Param("projType") Integer projType,
@Param("typeState") Integer typeState); @Param("typeState") Integer typeState);
List<Summary> selectDept(@Param("date") Integer date); List<Summary> selectDept(@Param("date") Integer date,@Param("budgetType") Integer budgetType);
} }
\ No newline at end of file
...@@ -22,5 +22,5 @@ public interface SerProjValueMapper { ...@@ -22,5 +22,5 @@ public interface SerProjValueMapper {
@Param("typeState") Integer typeState, @Param("typeState") Integer typeState,
@Param("exponentId") Integer exponentId, @Param("exponentId") Integer exponentId,
@Param("dept") String dept,@Param("date") Integer date, @Param("dept") String dept,@Param("date") Integer date,
@Param("isBudget") Integer isBudget); @Param("budgetType") Integer budgetType);
} }
\ No newline at end of file
...@@ -7,6 +7,8 @@ import lombok.Data; ...@@ -7,6 +7,8 @@ import lombok.Data;
public class QuerySummary { public class QuerySummary {
@ApiModelProperty(value = "时间", required = true) @ApiModelProperty(value = "时间", required = true)
private Integer date; private Integer date;
@ApiModelProperty(value = "预算类型", required = true)
private Integer budgetType;
@ApiModelProperty(value = "页面") @ApiModelProperty(value = "页面")
private Integer page; private Integer page;
......
package com.bsoft.api.service.Impl; package com.bsoft.api.service.Impl;
import com.bsoft.api.common.enums.BudgetType;
import com.bsoft.api.common.enums.ProjectType; import com.bsoft.api.common.enums.ProjectType;
import com.bsoft.api.common.enums.StateType; import com.bsoft.api.common.enums.StateType;
import com.bsoft.api.common.enums.TypeState; import com.bsoft.api.common.enums.TypeState;
...@@ -9,7 +10,6 @@ import com.bsoft.api.mapper.SerProjMapper; ...@@ -9,7 +10,6 @@ import com.bsoft.api.mapper.SerProjMapper;
import com.bsoft.api.mapper.SerProjValueMapper; import com.bsoft.api.mapper.SerProjValueMapper;
import com.bsoft.api.model.SerPageValueConfig; import com.bsoft.api.model.SerPageValueConfig;
import com.bsoft.api.model.SerProjValue; import com.bsoft.api.model.SerProjValue;
import com.bsoft.api.model.SysMenu;
import com.bsoft.api.model.reqmodel.AddBudgetValue; import com.bsoft.api.model.reqmodel.AddBudgetValue;
import com.bsoft.api.model.reqmodel.BudgetValue; import com.bsoft.api.model.reqmodel.BudgetValue;
import com.bsoft.api.model.respmodel.*; import com.bsoft.api.model.respmodel.*;
...@@ -51,7 +51,7 @@ public class SerProjValueServiceImpl implements SerProjValueService { ...@@ -51,7 +51,7 @@ public class SerProjValueServiceImpl implements SerProjValueService {
if(projectInfo != null && projectInfo.size() > 0){ if(projectInfo != null && projectInfo.size() > 0){
for(ProjectInfo projInfo : projectInfo){ for(ProjectInfo projInfo : projectInfo){
values = serProjValueMapper.selectValue(projectType,(Integer)enumInfo.get("value"), values = serProjValueMapper.selectValue(projectType,(Integer)enumInfo.get("value"),
projInfo.getExponentId(),deptCode,date,null); projInfo.getExponentId(),deptCode,date,BudgetType.NOT.getValue());
resultValues = getLevelData(values,BigDecimal.valueOf(PROJ_TOP_PARENT_ID)); resultValues = getLevelData(values,BigDecimal.valueOf(PROJ_TOP_PARENT_ID));
if(resultValues != null && resultValues.size() > 0) if(resultValues != null && resultValues.size() > 0)
projInfo.setProjectValues(resultValues); projInfo.setProjectValues(resultValues);
...@@ -85,8 +85,8 @@ public class SerProjValueServiceImpl implements SerProjValueService { ...@@ -85,8 +85,8 @@ public class SerProjValueServiceImpl implements SerProjValueService {
} }
@Override @Override
public Object getSummary(Integer date) { public Object getSummary(Integer date,Integer budgetType) {
List<Summary> result = serProjMapper.selectDept(date); List<Summary> result = serProjMapper.selectDept(date,budgetType);
if(result != null && result.size() > 0){ if(result != null && result.size() > 0){
for(Summary summary : result){ for(Summary summary : result){
summary.setProjTypeList(new ArrayList<>()); summary.setProjTypeList(new ArrayList<>());
...@@ -98,7 +98,7 @@ public class SerProjValueServiceImpl implements SerProjValueService { ...@@ -98,7 +98,7 @@ public class SerProjValueServiceImpl implements SerProjValueService {
projType = new SummaryProjType(); projType = new SummaryProjType();
projType.setProjTypeName(String.valueOf(enumInfo.get("description"))); projType.setProjTypeName(String.valueOf(enumInfo.get("description")));
List<SerProjValueResp> values = serProjValueMapper.selectValue((Integer)enumInfo.get("value"),null, List<SerProjValueResp> values = serProjValueMapper.selectValue((Integer)enumInfo.get("value"),null,
null,summary.getDeptCode(),date,1); null,summary.getDeptCode(),date,budgetType);
if(values != null) if(values != null)
projType.setProject(values); projType.setProject(values);
summary.getProjTypeList().add(projType); summary.getProjTypeList().add(projType);
...@@ -145,9 +145,16 @@ public class SerProjValueServiceImpl implements SerProjValueService { ...@@ -145,9 +145,16 @@ public class SerProjValueServiceImpl implements SerProjValueService {
for(SerProjValueResp data : list){ for(SerProjValueResp data : list){
if(data.getParent().equals(parentcode)){ if(data.getParent().equals(parentcode)){
List<SerProjValueResp> childList = getLevelData(list,data.getProjId()); List<SerProjValueResp> childList = getLevelData(list,data.getProjId());
childList = childList.stream().sorted(Comparator.comparing(SerProjValueResp::getSort)).collect(Collectors.toList()); try{
data.setChilds(childList); if(data.getSort() != null){
resultList.add(data); childList = childList.stream().sorted(Comparator.comparing(SerProjValueResp::getSort)).collect(Collectors.toList());
}
data.setChilds(childList);
resultList.add(data);
}catch(Exception e){
e.printStackTrace();
}
} }
} }
return resultList; return resultList;
......
package com.bsoft.api.service.Impl; package com.bsoft.api.service.Impl;
import com.bsoft.api.mapper.DicOrgMapper;
import com.bsoft.api.mapper.SysUserOrgRsMapper; import com.bsoft.api.mapper.SysUserOrgRsMapper;
import com.bsoft.api.model.SerDepartment;
import com.bsoft.api.model.SysUserOrgRs; import com.bsoft.api.model.SysUserOrgRs;
import com.bsoft.api.service.SysUserOrgRsService; import com.bsoft.api.service.SysUserOrgRsService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
@Service @Service
public class SysUserOrgRsServiceImpl implements SysUserOrgRsService { public class SysUserOrgRsServiceImpl implements SysUserOrgRsService {
@Resource @Resource
private SysUserOrgRsMapper sysUserOrgRsMapper; private SysUserOrgRsMapper sysUserOrgRsMapper;
@Resource
private DicOrgMapper orgMapper;
@Override @Override
public int add(SysUserOrgRs sysUserOrgRs) { public int add(SysUserOrgRs sysUserOrgRs) {
...@@ -43,4 +46,11 @@ public class SysUserOrgRsServiceImpl implements SysUserOrgRsService { ...@@ -43,4 +46,11 @@ public class SysUserOrgRsServiceImpl implements SysUserOrgRsService {
public int update(SysUserOrgRs sysUserRoleRs) { public int update(SysUserOrgRs sysUserRoleRs) {
return sysUserOrgRsMapper.updateByPrimaryKey(sysUserRoleRs); return sysUserOrgRsMapper.updateByPrimaryKey(sysUserRoleRs);
} }
@Override
public List<SerDepartment> getUserOrg(Long userId) {
List<SerDepartment> list = orgMapper.selectDeptByUser(userId);
return list;
}
} }
...@@ -12,7 +12,7 @@ public interface SerProjValueService { ...@@ -12,7 +12,7 @@ public interface SerProjValueService {
boolean save(AddBudgetValue request); boolean save(AddBudgetValue request);
Object getSummary(Integer date); Object getSummary(Integer date,Integer budgetType);
Object getData(Integer date,Integer page); Object getData(Integer date,Integer page);
......
package com.bsoft.api.service; package com.bsoft.api.service;
import com.bsoft.api.model.SerDepartment;
import com.bsoft.api.model.SysUserOrgRs; import com.bsoft.api.model.SysUserOrgRs;
import java.util.List;
public interface SysUserOrgRsService extends ServiceBase<SysUserOrgRs> { public interface SysUserOrgRsService extends ServiceBase<SysUserOrgRs> {
List<SerDepartment> getUserOrg(Long userId);
} }
...@@ -12,7 +12,15 @@ ...@@ -12,7 +12,15 @@
<result column="ORG_ADDRESS" jdbcType="VARCHAR" property="orgAddress" /> <result column="ORG_ADDRESS" jdbcType="VARCHAR" property="orgAddress" />
<result column="PARENT_ID" jdbcType="DECIMAL" property="parentId" /> <result column="PARENT_ID" jdbcType="DECIMAL" property="parentId" />
</resultMap> </resultMap>
<resultMap id="SummaryDept" type="com.bsoft.api.model.SerDepartment">
<id column="ID" jdbcType="DECIMAL" property="id" />
<result column="CREATE_DATE" jdbcType="TIMESTAMP" property="createDate" />
<result column="CREATE_USERID" jdbcType="DECIMAL" property="createUserid" />
<result column="STATE" jdbcType="DECIMAL" property="state" />
<result column="ORG_ID" jdbcType="VARCHAR" property="orgId" />
<result column="KSBM" jdbcType="VARCHAR" property="ksbm" />
<result column="KSMC" jdbcType="VARCHAR" property="ksmc" />
</resultMap>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from DIC_ORG delete from DIC_ORG
where ID = #{id,jdbcType=DECIMAL} where ID = #{id,jdbcType=DECIMAL}
...@@ -21,11 +29,11 @@ ...@@ -21,11 +29,11 @@
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long"> <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
select SEQ_DIC_ORG_ID.nextval from dual select SEQ_DIC_ORG_ID.nextval from dual
</selectKey> </selectKey>
insert into DIC_ORG (CREATE_DATE, CREATE_USERID, STATE, insert into DIC_ORG (CREATE_DATE, CREATE_USERID, STATE,
ORG_CODE, ORG_NAME, ORG_NO, ORG_CODE, ORG_NAME, ORG_NO,
ORG_SHORT_NAME, ORG_GROUP, ORG_TYPE, ORG_SHORT_NAME, ORG_GROUP, ORG_TYPE,
ORG_ADDRESS, PARENT_ID) ORG_ADDRESS, PARENT_ID)
values (#{createDate,jdbcType=TIMESTAMP}, #{createUserid,jdbcType=DECIMAL}, #{state,jdbcType=DECIMAL}, values (#{createDate,jdbcType=TIMESTAMP}, #{createUserid,jdbcType=DECIMAL}, #{state,jdbcType=DECIMAL},
#{orgCode,jdbcType=VARCHAR}, #{orgName,jdbcType=VARCHAR}, #{orgNo,jdbcType=VARCHAR}, #{orgCode,jdbcType=VARCHAR}, #{orgName,jdbcType=VARCHAR}, #{orgNo,jdbcType=VARCHAR},
#{orgShortName,jdbcType=VARCHAR}, #{orgGroup,jdbcType=VARCHAR}, #{orgType,jdbcType=VARCHAR}, #{orgShortName,jdbcType=VARCHAR}, #{orgGroup,jdbcType=VARCHAR}, #{orgType,jdbcType=VARCHAR},
#{orgAddress,jdbcType=VARCHAR}, #{parentId,jdbcType=DECIMAL}) #{orgAddress,jdbcType=VARCHAR}, #{parentId,jdbcType=DECIMAL})
...@@ -65,4 +73,10 @@ ...@@ -65,4 +73,10 @@
where uor.ORG_ID=o.ID and uor.USER_ID= #{userId,jdbcType=DECIMAL} where uor.ORG_ID=o.ID and uor.USER_ID= #{userId,jdbcType=DECIMAL}
and uor.STATE = 1 and o.STATE = 1 and uor.STATE = 1 and o.STATE = 1
</select> </select>
<select id="selectDeptByUser" resultMap="SummaryDept">
select o.ID,o.ORG_CODE as KSBM,o.ORG_NAME as KSMC
from SYS_USER_ORG_RS rs
join DIC_ORG o on o.id = rs.ORG_ID and rs.STATE = 1
where o.STATE = 1 and o.PARENT_ID != 0 and rs.USER_ID = #{userId,jdbcType=DECIMAL}
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -75,12 +75,17 @@ ...@@ -75,12 +75,17 @@
order by e.SORT order by e.SORT
</select> </select>
<select id="selectDept" resultMap="Summary"> <select id="selectDept" resultMap="Summary">
select DEPT_CODE from SER_PROJ_VALUE select v.DEPT_CODE
from SER_PROJ_VALUE v
join SER_PROJ p on p.ID =v.PROJ_ID and p.STATE = 1
where 1=1 where 1=1
<if test="date!=null"> <if test="date!=null">
and "DATE"=#{date} and v."DATE"=#{date}
</if> </if>
GROUP BY DEPT_CODE,SORT <if test="budgetType!=null">
order by SORT and BitAnd(IS_BUDGET,#{budgetType})>0
</if>
GROUP BY v.DEPT_CODE,v.SORT
order by v.SORT
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -126,8 +126,8 @@ ...@@ -126,8 +126,8 @@
<if test="exponentId!=null"> <if test="exponentId!=null">
AND p.TYPE = #{exponentId,jdbcType=DECIMAL} AND p.TYPE = #{exponentId,jdbcType=DECIMAL}
</if> </if>
<if test="isBudget!=null"> <if test="budgetType!=null">
AND p.IS_BUDGET = #{isBudget,jdbcType=DECIMAL} AND BitAnd(p.IS_BUDGET,#{budgetType})>0
</if> </if>
ORDER BY p.SORT ORDER BY p.SORT
</select> </select>
......
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