Commit bdbb316c authored by 陈晓晋's avatar 陈晓晋

Merge branch 'xjchen' into 'develop'

加入mybatis-plus-join20230807

See merge request !26
parents e146e61a 18081f61
......@@ -8,9 +8,11 @@ import com.censoft.censoftrongtong.service.ILedgerProjectService;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.entity.SysDept;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -66,20 +68,32 @@ public class IndexController extends BaseController {
@ApiOperation("项目按照不同纬度统计")
@GetMapping("/getProjectNumByType")
public R getProjectNumByType() {
public R getProjectNumByType(@Param("statisticsType") String statisticsType) {
Map<String, Object> map_rs = new HashMap<>();
List<Map<String,String>> list_rs=new ArrayList<>();
List<String> legendList=new ArrayList<>();
QueryWrapper<LedgerProject> queryWrap=new QueryWrapper<>();
queryWrap.select("count(*) 'num'","city").groupBy("city");
if(statisticsType!=null&&statisticsType.equals("city")){
queryWrap.select("count(*) 'num'","city").groupBy("city");
}else{
queryWrap.select("count(*) 'num'","dept_id").groupBy("dept_id");
}
List<LedgerProject> list=ledgerProjectService.list(queryWrap);
if (list!=null&&list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
Map<String,String> map_item=new HashMap<>();
LedgerProject ledgerProject=list.get(i);
map_item.put("name",ledgerProject.getCity());
if(statisticsType!=null&&statisticsType.equals("city")){
map_item.put("name",ledgerProject.getCity());
}else{
map_item.put("name",ledgerProject.getDeptId()+"");
}
map_item.put("value",ledgerProject.getNum());
list_rs.add(map_item);
legendList.add(ledgerProject.getCity());
......@@ -88,10 +102,81 @@ public class IndexController extends BaseController {
map_rs.put("legendData",legendList);
map_rs.put("seriesData",list_rs);
//MPJLambdaWrapper<LedgerBuilding> queryWrapper=new MPJLambdaWrapper<>();
//queryWrapper.select("count(*) num").select(LedgerProject::getName).leftJoin(LedgerProject.class,LedgerProject::getId,LedgerBuilding::getProjectId).groupBy(LedgerBuilding::getProjectId);
// //.eq(LedgerBuilding::getProjectId,1);
//List<LedgerBuilding> list1=ledgerBuildingService.selectJoinList(LedgerBuilding.class,queryWrapper);
return R.ok(map_rs);
}
/**
* 使用join实现连表查询
*/
@ApiOperation("项目按照不同纬度统计")
@GetMapping("/getProjectNumByTypeByJoin")
public R getProjectNumByTypeByJoin(@Param("statisticsType") String statisticsType) {
Map<String, Object> map_rs = new HashMap<>();
List<Map<String,String>> list_rs=new ArrayList<>();
List<String> legendList=new ArrayList<>();
List<LedgerBuilding> list1=new ArrayList<>();
List<LedgerProject> list2=new ArrayList<>();
MPJLambdaWrapper<LedgerBuilding> queryWrapper=new MPJLambdaWrapper<>();
queryWrapper.selectAll(LedgerBuilding.class).leftJoin(LedgerProject.class,LedgerProject::getId,LedgerBuilding::getProjectId)
.eq(LedgerBuilding::getProjectId,1);
List<LedgerBuilding> list1=ledgerBuildingService.selectJoinList(LedgerBuilding.class,queryWrapper);
MPJLambdaWrapper<LedgerProject> queryWrapper1=new MPJLambdaWrapper<>();
if(statisticsType!=null&&statisticsType.equals("city")){
queryWrapper=new MPJLambdaWrapper<>();
queryWrapper.select("count(*) num").select(LedgerProject::getCity).leftJoin(LedgerProject.class,LedgerProject::getId,LedgerBuilding::getProjectId).groupBy(LedgerBuilding::getCity);
//.eq(LedgerBuilding::getProjectId,1);
list1=ledgerBuildingService.selectJoinList(LedgerBuilding.class,queryWrapper);
if (list1!=null&&list1.size() > 0) {
for (int i = 0; i < list1.size(); i++) {
Map<String,String> map_item=new HashMap<>();
LedgerBuilding ledgerBuilding=list1.get(i);
map_item.put("name",ledgerBuilding.getCity());
legendList.add(ledgerBuilding.getCity());
map_item.put("value",ledgerBuilding.getNum());
list_rs.add(map_item);
}
}
}else{
queryWrapper1=new MPJLambdaWrapper<>();
queryWrapper1.select("count(*) num").select(SysDept::getDeptName).leftJoin(SysDept.class,SysDept::getDeptId,LedgerProject::getDeptId).groupBy(LedgerProject::getDeptId);
//.eq(LedgerBuilding::getProjectId,1);
list2=ledgerProjectService.selectJoinList(LedgerProject.class,queryWrapper1);
if (list2!=null&&list2.size() > 0) {
for (int i = 0; i < list2.size(); i++) {
Map<String,String> map_item=new HashMap<>();
LedgerProject ledgerProject=list2.get(i);
map_item.put("name",ledgerProject.getDeptName());
legendList.add(ledgerProject.getDeptName());
map_item.put("value",ledgerProject.getNum());
list_rs.add(map_item);
}
}
}
map_rs.put("legendData",legendList);
map_rs.put("seriesData",list_rs);
......@@ -107,4 +192,5 @@ public class IndexController extends BaseController {
}
package com.censoft.censoftrongtong.domain;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableField;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntityClean;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import java.math.BigDecimal;
/**
* 基础数据-楼宇对象 ledger_building
......@@ -86,6 +83,12 @@ public class LedgerBuilding extends BaseEntityClean
@TableField(exist = false)
private String deptName;
/**
* 数量
*/
@TableField(exist = false)
private String num;
......
......@@ -184,6 +184,14 @@
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatis-plus.version}</version>
</dependency>
<!--mybatis-plus-join-->
<dependency>
<groupId>com.github.yulichang</groupId>
<artifactId>mybatis-plus-join-boot-starter</artifactId>
<version>1.4.5</version>
</dependency>
<!-- pagehelper 分页插件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
......
package com.ruoyi.web.controller.system;
import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
......@@ -31,6 +15,16 @@ import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.ISysPostService;
import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.stream.Collectors;
/**
* 用户信息
......@@ -242,7 +236,7 @@ public class SysUserController extends BaseController
/**
* 获取部门树列表
*/
@PreAuthorize("@ss.hasPermi('system:user:list')")
//@PreAuthorize("@ss.hasPermi('system:user:list')")
@GetMapping("/deptTree")
public AjaxResult deptTree(SysDept dept)
{
......
......@@ -16,7 +16,10 @@
</description>
<dependencies>
<dependency>
<groupId>com.github.yulichang</groupId>
<artifactId>mybatis-plus-join-boot-starter</artifactId>
</dependency>
<!-- Spring框架基本的核心工具 -->
<dependency>
<groupId>org.springframework</groupId>
......
......@@ -2,7 +2,7 @@ package ${packageName}.mapper;
import java.util.List;
import ${packageName}.domain.${ClassName};
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.yulichang.base.MPJBaseMapper;
#if($table.sub)
import ${packageName}.domain.${subClassName};
#end
......@@ -13,7 +13,7 @@ import ${packageName}.domain.${subClassName};
* @author ${author}
* @date ${datetime}
*/
public interface ${ClassName}Mapper extends BaseMapper<${ClassName}>
public interface ${ClassName}Mapper extends MPJBaseMapper<${ClassName}>
{
/**
* 查询${functionName}
......
......@@ -2,14 +2,14 @@ package ${packageName}.service;
import java.util.List;
import ${packageName}.domain.${ClassName};
import com.baomidou.mybatisplus.extension.service.IService;
import com.github.yulichang.base.MPJBaseService;
/**
* ${functionName}Service接口
*
* @author ${author}
* @date ${datetime}
*/
public interface I${ClassName}Service extends IService<${ClassName}>
public interface I${ClassName}Service extends MPJBaseService<${ClassName}>
{
/**
* 查询${functionName}
......
......@@ -18,7 +18,7 @@ import ${packageName}.domain.${subClassName};
import ${packageName}.mapper.${ClassName}Mapper;
import ${packageName}.domain.${ClassName};
import ${packageName}.service.I${ClassName}Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.base.MPJBaseServiceImpl;
/**
* ${functionName}Service业务层处理
*
......@@ -26,7 +26,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
* @date ${datetime}
*/
@Service
public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}> implements I${ClassName}Service
public class ${ClassName}ServiceImpl extends MPJBaseServiceImpl<${ClassName}Mapper, ${ClassName}> implements I${ClassName}Service
{
@Autowired
private ${ClassName}Mapper ${className}Mapper;
......
package com.ruoyi.system.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.github.yulichang.base.MPJBaseMapper;
import com.ruoyi.common.core.domain.entity.SysDept;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 部门管理 数据层
*
* @author ruoyi
*/
public interface SysDeptMapper
public interface SysDeptMapper extends MPJBaseMapper<SysDept>
{
/**
* 查询部门管理数据
......
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