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;
import com.bsoft.api.common.Result;
import com.bsoft.api.common.annotations.CurrentUser;
import com.bsoft.api.common.annotations.Token;
import com.bsoft.api.model.SerDepartment;
import com.bsoft.api.model.reqmodel.QuerySummary;
import com.bsoft.api.service.SerDeptService;
import com.bsoft.api.service.SysUserOrgRsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
......@@ -18,7 +21,7 @@ import java.util.List;
@RestController
public class DeptController {
@Autowired
private SerDeptService serDeptService;
private SysUserOrgRsService sysUserOrgRsService;
/**
* 查询科室列表
......@@ -28,8 +31,8 @@ public class DeptController {
@PostMapping("/dept/list")
@Token
@ApiOperation("查询科室列表")
public Object getList(@RequestBody QuerySummary req) {
List<SerDepartment> list = serDeptService.getList(req.getDate());
return Result.success(list);
public Object getList(@ApiIgnore @CurrentUser Long userId) {
List<SerDepartment> sysMenuList = sysUserOrgRsService.getUserOrg(userId);
return Result.success(sysMenuList);
}
}
......@@ -45,7 +45,7 @@ public class SerProjValueController {
@Token
@ApiOperation("查询预算编制汇总数据")
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);
}
......
......@@ -3,21 +3,26 @@ package com.bsoft.api.controller;
import com.bsoft.api.common.Result;
import com.bsoft.api.common.annotations.CurrentUser;
import com.bsoft.api.common.annotations.Token;
import com.bsoft.api.model.SerDepartment;
import com.bsoft.api.model.SysRole;
import com.bsoft.api.model.SysUser;
import com.bsoft.api.model.respmodel.SysMenuList;
import com.bsoft.api.service.SysMenuService;
import com.bsoft.api.service.SysUserOrgRsService;
import com.bsoft.api.service.SysUserRoleRsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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 java.util.List;
@Api(tags = "用户API",produces="produces",consumes="consumes",protocols="protocols")
@Api(tags = "用户API", produces = "produces", consumes = "consumes", protocols = "protocols")
@RequestMapping("/user")
@RestController
public class UserController {
......@@ -25,38 +30,56 @@ public class UserController {
private SysUserRoleRsService sysUserRoleRsService;
@Autowired
private SysMenuService sysMenuService;
@Autowired
private SysUserOrgRsService sysUserOrgRsService;
@GetMapping()
@ApiIgnore
public Object user(@CurrentUser@ApiIgnore SysUser user){
public Object user(@CurrentUser @ApiIgnore SysUser user) {
return Result.success(user);
}
/**
* 根据用户id查询用户角色
*
* @param userId 用户id
* @return
*/
@PostMapping("roles")
@Token
@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);
return Result.success(sysRoleList);
}
/**
* 根据用户id查询用户菜单
*
* @param userId 用户id
* @return
*/
@PostMapping("menus")
@Token
@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);
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;
import com.bsoft.api.model.DicOrg;
import com.bsoft.api.model.SerDepartment;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -17,4 +18,6 @@ public interface DicOrgMapper {
List<DicOrg> selectByUser(@Param("userId") Long userId);
int updateByPrimaryKey(DicOrg record);
List<SerDepartment> selectDeptByUser(@Param("userId") Long userId);
}
\ No newline at end of file
......@@ -22,5 +22,5 @@ public interface SerProjMapper {
List<ProjectInfo> selectState(@Param("projType") Integer projType,
@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 {
@Param("typeState") Integer typeState,
@Param("exponentId") Integer exponentId,
@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;
public class QuerySummary {
@ApiModelProperty(value = "时间", required = true)
private Integer date;
@ApiModelProperty(value = "预算类型", required = true)
private Integer budgetType;
@ApiModelProperty(value = "页面")
private Integer page;
......
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.StateType;
import com.bsoft.api.common.enums.TypeState;
......@@ -9,7 +10,6 @@ import com.bsoft.api.mapper.SerProjMapper;
import com.bsoft.api.mapper.SerProjValueMapper;
import com.bsoft.api.model.SerPageValueConfig;
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.BudgetValue;
import com.bsoft.api.model.respmodel.*;
......@@ -51,7 +51,7 @@ public class SerProjValueServiceImpl implements SerProjValueService {
if(projectInfo != null && projectInfo.size() > 0){
for(ProjectInfo projInfo : projectInfo){
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));
if(resultValues != null && resultValues.size() > 0)
projInfo.setProjectValues(resultValues);
......@@ -85,8 +85,8 @@ public class SerProjValueServiceImpl implements SerProjValueService {
}
@Override
public Object getSummary(Integer date) {
List<Summary> result = serProjMapper.selectDept(date);
public Object getSummary(Integer date,Integer budgetType) {
List<Summary> result = serProjMapper.selectDept(date,budgetType);
if(result != null && result.size() > 0){
for(Summary summary : result){
summary.setProjTypeList(new ArrayList<>());
......@@ -98,7 +98,7 @@ public class SerProjValueServiceImpl implements SerProjValueService {
projType = new SummaryProjType();
projType.setProjTypeName(String.valueOf(enumInfo.get("description")));
List<SerProjValueResp> values = serProjValueMapper.selectValue((Integer)enumInfo.get("value"),null,
null,summary.getDeptCode(),date,1);
null,summary.getDeptCode(),date,budgetType);
if(values != null)
projType.setProject(values);
summary.getProjTypeList().add(projType);
......@@ -145,9 +145,16 @@ public class SerProjValueServiceImpl implements SerProjValueService {
for(SerProjValueResp data : list){
if(data.getParent().equals(parentcode)){
List<SerProjValueResp> childList = getLevelData(list,data.getProjId());
try{
if(data.getSort() != null){
childList = childList.stream().sorted(Comparator.comparing(SerProjValueResp::getSort)).collect(Collectors.toList());
}
data.setChilds(childList);
resultList.add(data);
}catch(Exception e){
e.printStackTrace();
}
}
}
return resultList;
......
package com.bsoft.api.service.Impl;
import com.bsoft.api.mapper.DicOrgMapper;
import com.bsoft.api.mapper.SysUserOrgRsMapper;
import com.bsoft.api.model.SerDepartment;
import com.bsoft.api.model.SysUserOrgRs;
import com.bsoft.api.service.SysUserOrgRsService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
@Service
public class SysUserOrgRsServiceImpl implements SysUserOrgRsService {
@Resource
private SysUserOrgRsMapper sysUserOrgRsMapper;
@Resource
private DicOrgMapper orgMapper;
@Override
public int add(SysUserOrgRs sysUserOrgRs) {
......@@ -43,4 +46,11 @@ public class SysUserOrgRsServiceImpl implements SysUserOrgRsService {
public int update(SysUserOrgRs 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 {
boolean save(AddBudgetValue request);
Object getSummary(Integer date);
Object getSummary(Integer date,Integer budgetType);
Object getData(Integer date,Integer page);
......
package com.bsoft.api.service;
import com.bsoft.api.model.SerDepartment;
import com.bsoft.api.model.SysUserOrgRs;
import java.util.List;
public interface SysUserOrgRsService extends ServiceBase<SysUserOrgRs> {
List<SerDepartment> getUserOrg(Long userId);
}
......@@ -12,7 +12,15 @@
<result column="ORG_ADDRESS" jdbcType="VARCHAR" property="orgAddress" />
<result column="PARENT_ID" jdbcType="DECIMAL" property="parentId" />
</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 from DIC_ORG
where ID = #{id,jdbcType=DECIMAL}
......@@ -65,4 +73,10 @@
where uor.ORG_ID=o.ID and uor.USER_ID= #{userId,jdbcType=DECIMAL}
and uor.STATE = 1 and o.STATE = 1
</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>
\ No newline at end of file
......@@ -75,12 +75,17 @@
order by e.SORT
</select>
<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
<if test="date!=null">
and "DATE"=#{date}
and v."DATE"=#{date}
</if>
GROUP BY DEPT_CODE,SORT
order by SORT
<if test="budgetType!=null">
and BitAnd(IS_BUDGET,#{budgetType})>0
</if>
GROUP BY v.DEPT_CODE,v.SORT
order by v.SORT
</select>
</mapper>
\ No newline at end of file
......@@ -126,8 +126,8 @@
<if test="exponentId!=null">
AND p.TYPE = #{exponentId,jdbcType=DECIMAL}
</if>
<if test="isBudget!=null">
AND p.IS_BUDGET = #{isBudget,jdbcType=DECIMAL}
<if test="budgetType!=null">
AND BitAnd(p.IS_BUDGET,#{budgetType})>0
</if>
ORDER BY p.SORT
</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