统计数据

This commit is contained in:
磷叶 2025-01-14 11:03:24 +08:00
parent fe4c813b0f
commit a21d58b19a
8 changed files with 130 additions and 3 deletions

View File

@ -0,0 +1,20 @@
package com.ruoyi.yh.dashboard.domain;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author wjh
* 2025/1/14
*/
@Data
public class UserProdStatisticsVO {
@ApiModelProperty("总产量")
private BigDecimal totalNum;
@ApiModelProperty("总工资")
private BigDecimal totalPrice;
}

View File

@ -0,0 +1,13 @@
package com.ruoyi.yh.dashboard.mapper;
import com.ruoyi.yh.dashboard.domain.UserProdStatisticsVO;
import com.ruoyi.yh.reportUserProd.domain.ReportUserProdQuery;
import org.apache.ibatis.annotations.Param;
/**
* @author wjh
* 2025/1/14
*/
public interface DashboardMapper {
UserProdStatisticsVO selectUserProd(@Param("query") ReportUserProdQuery query);
}

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.yh.dashboard.mapper.DashboardMapper">
<resultMap id="UserProdStatisticsVO" type="UserProdStatisticsVO">
<result property="totalNum" column="total_num" typeHandler="com.ruoyi.common.mybatis.typehandler.NonNullDecimalTypeHandler"/>
<result property="totalPrice" column="total_price" typeHandler="com.ruoyi.common.mybatis.typehandler.NonNullDecimalTypeHandler"/>
</resultMap>
<select id="selectUserProd" resultMap="UserProdStatisticsVO">
select
sum(brup.num) as total_num,
sum(brp.price_price * brup.num) as total_price
<include refid="com.ruoyi.yh.reportUserProd.mapper.ReportUserProdMapper.searchTables"/>
<where>
<include refid="com.ruoyi.yh.reportUserProd.mapper.ReportUserProdMapper.searchCondition"/>
</where>
</select>
</mapper>

View File

@ -0,0 +1,22 @@
package com.ruoyi.yh.dashboard.service;
import com.ruoyi.yh.dashboard.domain.UserProdStatisticsVO;
import com.ruoyi.yh.dashboard.mapper.DashboardMapper;
import com.ruoyi.yh.reportUserProd.domain.ReportUserProdQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author wjh
* 2025/1/14
*/
@Service
public class DashboardService {
@Autowired
private DashboardMapper dashboardMapper;
public UserProdStatisticsVO selectUserProd(ReportUserProdQuery query) {
return dashboardMapper.selectUserProd(query);
}
}

View File

@ -1,5 +1,6 @@
package com.ruoyi.yh.price.service.impl; package com.ruoyi.yh.price.service.impl;
import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.validate.ValidGroup; import com.ruoyi.common.core.validate.ValidGroup;
@ -436,10 +437,13 @@ public class PriceServiceImpl implements PriceService
@Override @Override
public PriceSearchConditionVO selectSearchCondition(PriceQuery query) { public PriceSearchConditionVO selectSearchCondition(PriceQuery query) {
PriceSearchConditionVO vo = new PriceSearchConditionVO(); PriceSearchConditionVO vo = new PriceSearchConditionVO();
PageHelper.startPage(1, 20);
vo.setCategoryList(priceMapper.selectColumnCount(query, PriceColumn.category.name())); vo.setCategoryList(priceMapper.selectColumnCount(query, PriceColumn.category.name()));
PageHelper.startPage(1, 20);
vo.setSizeList(priceMapper.selectColumnCount(query, PriceColumn.size.name())); vo.setSizeList(priceMapper.selectColumnCount(query, PriceColumn.size.name()));
PageHelper.startPage(1, 20);
vo.setSurfaceList(priceMapper.selectColumnCount(query, PriceColumn.surface.name())); vo.setSurfaceList(priceMapper.selectColumnCount(query, PriceColumn.surface.name()));
PageHelper.startPage(1, 20);
vo.setPatternList(priceMapper.selectColumnCount(query, PriceColumn.pattern.name())); vo.setPatternList(priceMapper.selectColumnCount(query, PriceColumn.pattern.name()));
return vo; return vo;

View File

@ -50,6 +50,9 @@ public class ReportUserProdVO extends ReportUserProd {
@ApiModelProperty("部门名称") @ApiModelProperty("部门名称")
private String deptName; private String deptName;
@ApiModelProperty("部门ID")
private String deptId;
@Excel(name = "工序代码") @Excel(name = "工序代码")
@ApiModelProperty("工序代码") @ApiModelProperty("工序代码")
private String priceCode; private String priceCode;

View File

@ -20,11 +20,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
brp.price_unit as price_unit, brp.price_unit as price_unit,
brp.price_price as price_price, brp.price_price as price_price,
brp.report_id as report_id, brp.report_id as report_id,
br.report_date as report_date,
br.status as report_status,
brp.price_price * brup.num as total_price, brp.price_price * brup.num as total_price,
brp.price_code as price_code, brp.price_code as price_code,
br.report_date as report_date,
br.status as report_status,
br.dept_id as dept_id,
sd.dept_name as dept_name sd.dept_name as dept_name
<include refid="searchTables"/>
</sql>
<sql id="searchTables">
from bst_report_user_prod brup from bst_report_user_prod brup
left join sys_user su on su.user_id = brup.user_id left join sys_user su on su.user_id = brup.user_id
left join bst_report_prod brp on brp.id = brup.prod_id left join bst_report_prod brp on brp.id = brup.prod_id
@ -44,6 +49,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.month != null">and month(br.report_date) = #{query.month}</if> <if test="query.month != null">and month(br.report_date) = #{query.month}</if>
<if test="query.startDate != null">and date(br.report_date) >= #{query.startDate}</if> <if test="query.startDate != null">and date(br.report_date) >= #{query.startDate}</if>
<if test="query.endDate != null">and date(br.report_date) &lt;= #{query.endDate}</if> <if test="query.endDate != null">and date(br.report_date) &lt;= #{query.endDate}</if>
<if test="query.userName != null and query.userName != ''">and su.nick_name like concat('%', #{query.userName}, '%')</if>
<if test="query.priceName != null and query.priceName != ''">and brp.price_name like concat('%', #{query.priceName}, '%')</if>
<if test="query.priceCode != null and query.priceCode != ''">and brp.price_code like concat('%', #{query.priceCode}, '%')</if>
<if test="query.reportStatus != null and query.reportStatus != ''">and br.status = #{query.reportStatus}</if>
<if test="query.deptId != null">and br.dept_id = #{query.deptId}</if>
<if test="query.prodIds != null and query.prodIds.size() > 0 "> <if test="query.prodIds != null and query.prodIds.size() > 0 ">
and brup.prod_id in and brup.prod_id in
<foreach item="item" collection="query.prodIds" open="(" separator="," close=")"> <foreach item="item" collection="query.prodIds" open="(" separator="," close=")">

View File

@ -0,0 +1,34 @@
package com.ruoyi.web.yh;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.yh.dashboard.service.DashboardService;
import com.ruoyi.yh.reportUserProd.domain.ReportUserProdQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author wjh
* 2025/1/14
*/
@RestController
@RequestMapping("/yh/dashboard")
public class DashboardController extends BaseController {
@Autowired
private DashboardService dashboardService;
/**
* 查询员工产量统计
*/
@PreAuthorize("@ss.hasPermi('yh:reportUserProd:list')")
@GetMapping("/userProd")
@DataScope(deptAlias = "sd")
public AjaxResult getUserProd(ReportUserProdQuery query) {
return success(dashboardService.selectUserProd(query));
}
}