Merge remote-tracking branch 'origin/master'

This commit is contained in:
lsymicc
2025-06-18 14:40:16 +08:00
33 changed files with 1560 additions and 200 deletions

View File

@@ -0,0 +1,97 @@
package com.ruoyi.index.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.ruoyi.index.domain.ViewIndexJob;
import com.ruoyi.index.mapper.ViewIndexJobMapper;
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;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.index.domain.BillStatusCount;
import com.ruoyi.index.domain.CargoSpaceCount;
import com.ruoyi.index.domain.IndexCount;
import com.ruoyi.index.service.IBillStatusCountService;
import com.ruoyi.index.service.ICargoSpaceCountService;
import com.ruoyi.index.service.IIndexCountService;
import com.ruoyi.job.mydojob.domain.MydoJob;
import com.ruoyi.job.mydojob.service.IMydoJobService;
import com.ruoyi.system.service.ISysDictDataService;
/**
* 首页统计信息Controller
*
* @author ruoyi
*/
@RestController
@RequestMapping("/index")
public class IndexController extends BaseController {
@Autowired
private IBillStatusCountService billStatusCountService;
@Autowired
private ICargoSpaceCountService cargoSpaceCountService;
@Autowired
private IIndexCountService indexCountService;
@Autowired
private IMydoJobService mydoJobService;
@Autowired
private ISysDictDataService dictDataService;
/**
* 查询单据状态统计
*/
@PreAuthorize("@ss.hasPermi('index:bill:list')")
@GetMapping("/bill/status")
public AjaxResult getBillStatusCount() {
List<BillStatusCount> list = billStatusCountService.selectAllBillStatusCount();
return success(list);
}
/**
* 查询各状态货位数量
*/
@PreAuthorize("@ss.hasPermi('index:cargospace:list')")
@GetMapping("/cargospace/count")
public AjaxResult getCargoSpaceCount() {
CargoSpaceCount cargoSpaceCount = cargoSpaceCountService.selectStatusCount();
return success(cargoSpaceCount);
}
/**
* 查询已完成单据数量统计
*/
@PreAuthorize("@ss.hasPermi('index:count:list')")
@GetMapping("/finishCount")
public AjaxResult getFinishCount() {
IndexCount indexCount = indexCountService.selectFinishCount();
return success(indexCount);
}
@Autowired
private ViewIndexJobMapper viewIndexJobMapper;
/**
* 获取任务状态统计
*/
@GetMapping("/job/status")
public AjaxResult getJobStatusCount() {
List<ViewIndexJob> allJobs = viewIndexJobMapper.selectViewIndexJobByStatus(null);
Map<String, List<ViewIndexJob>> result = new HashMap<>();
result.put("status2", allJobs.stream().filter(job -> "2".equals(job.getStatus())).collect(Collectors.toList()));
result.put("status3", allJobs.stream().filter(job -> "3".equals(job.getStatus())).collect(Collectors.toList()));
return AjaxResult.success(result);
}
}

View File

@@ -0,0 +1,34 @@
package com.ruoyi.index.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.index.domain.WeekJobCount;
import com.ruoyi.index.service.IWeekJobCountService;
/**
* 每周作业数量统计Controller
*
* @author ruoyi
* @date 2025-06-05
*/
@RestController
@RequestMapping("/index/weekjob")
public class WeekJobCountController
{
@Autowired
private IWeekJobCountService weekJobCountService;
/**
* 获取近一周的入库和出库作业数量统计
*/
@GetMapping("/count")
public AjaxResult getWeekJobCount()
{
WeekJobCount weekJobCount = weekJobCountService.getWeekJobCount();
return AjaxResult.success(weekJobCount);
}
}

View File

@@ -0,0 +1,18 @@
package com.ruoyi.index.domain;
import lombok.Data;
/**
* 单据状态统计对象
*/
@Data
public class BillStatusCount {
/** 单据ID */
private String id;
/** 单据状态(1:未执行,2:审核中,3:正执行) */
private String status;
/** 单据类型(1:入库,2:出库,3:盘点) */
private String type;
}

View File

@@ -0,0 +1,19 @@
package com.ruoyi.index.domain;
import java.util.List;
/**
* 货位状态统计对象
*/
public class CargoSpaceCount {
/** 各状态货位数量 */
private List<Integer> statusCounts;
public List<Integer> getStatusCounts() {
return statusCounts;
}
public void setStatusCounts(List<Integer> statusCounts) {
this.statusCounts = statusCounts;
}
}

View File

@@ -0,0 +1,53 @@
package com.ruoyi.index.domain;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 首页统计信息对象
*
* @author ruoyi
* @date 2025-05-29
*/
public class IndexCount extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 入库单数量 */
private Integer stockinCount;
/** 出库单数量 */
private Integer stockoutCount;
/** 盘点单数量 */
private Integer stockcheckCount;
public void setStockinCount(Integer stockinCount)
{
this.stockinCount = stockinCount;
}
public Integer getStockinCount()
{
return stockinCount;
}
public void setStockoutCount(Integer stockoutCount)
{
this.stockoutCount = stockoutCount;
}
public Integer getStockoutCount()
{
return stockoutCount;
}
public void setStockcheckCount(Integer stockcheckCount)
{
this.stockcheckCount = stockcheckCount;
}
public Integer getStockcheckCount()
{
return stockcheckCount;
}
}

View File

@@ -0,0 +1,83 @@
package com.ruoyi.index.domain;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 首页任务视图对象 view_index_job
*/
public class ViewIndexJob extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 作业ID */
@Excel(name = "作业ID")
private String jobId;
/** 状态 */
@Excel(name = "状态")
private String status;
/** 状态标签 */
@Excel(name = "状态标签")
private String statusLabel;
/** 任务类型 */
@Excel(name = "任务类型")
private String inOrOut;
/** 任务类型标签 */
@Excel(name = "任务类型标签")
private String inOrOutLabel;
/** 优先级 */
@Excel(name = "优先级")
private Integer priority;
public String getJobId() {
return jobId;
}
public void setJobId(String jobId) {
this.jobId = jobId;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getStatusLabel() {
return statusLabel;
}
public void setStatusLabel(String statusLabel) {
this.statusLabel = statusLabel;
}
public String getInOrOut() {
return inOrOut;
}
public void setInOrOut(String inOrOut) {
this.inOrOut = inOrOut;
}
public String getInOrOutLabel() {
return inOrOutLabel;
}
public void setInOrOutLabel(String inOrOutLabel) {
this.inOrOutLabel = inOrOutLabel;
}
public Integer getPriority() {
return priority;
}
public void setPriority(Integer priority) {
this.priority = priority;
}
}

View File

@@ -0,0 +1,38 @@
package com.ruoyi.index.domain;
import java.util.List;
/**
* 每周作业数量统计对象
*
* @author ruoyi
* @date 2025-06-05
*/
public class WeekJobCount
{
/** 入库作业数量列表 */
private List<Integer> inJobCounts;
/** 出库作业数量列表 */
private List<Integer> outJobCounts;
public List<Integer> getInJobCounts()
{
return inJobCounts;
}
public void setInJobCounts(List<Integer> inJobCounts)
{
this.inJobCounts = inJobCounts;
}
public List<Integer> getOutJobCounts()
{
return outJobCounts;
}
public void setOutJobCounts(List<Integer> outJobCounts)
{
this.outJobCounts = outJobCounts;
}
}

View File

@@ -0,0 +1,30 @@
package com.ruoyi.index.mapper;
import java.util.List;
import com.ruoyi.index.domain.BillStatusCount;
/**
* 单据状态统计Mapper接口
*/
public interface BillStatusCountMapper {
/**
* 查询入库单据状态统计
*
* @return 入库单据状态统计列表
*/
public List<BillStatusCount> selectStockinStatusCount();
/**
* 查询出库单据状态统计
*
* @return 出库单据状态统计列表
*/
public List<BillStatusCount> selectStockoutStatusCount();
/**
* 查询盘点单据状态统计
*
* @return 盘点单据状态统计列表
*/
public List<BillStatusCount> selectStockcheckStatusCount();
}

View File

@@ -0,0 +1,19 @@
package com.ruoyi.index.mapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Map;
/**
* 货位状态统计Mapper接口
*/
@Mapper
public interface CargoSpaceCountMapper {
/**
* 查询各状态货位数量
*
* @return 各状态货位数量列表
*/
public List<Map<String, Object>> selectStatusCount();
}

View File

@@ -0,0 +1,31 @@
package com.ruoyi.index.mapper;
/**
* 首页统计信息Mapper接口
*
* @author ruoyi
* @date 2025-05-29
*/
public interface IndexCountMapper
{
/**
* 查询已完成入库单数量
*
* @return 入库单数量
*/
public Integer selectStockinFinishCount();
/**
* 查询已完成出库单数量
*
* @return 出库单数量
*/
public Integer selectStockoutFinishCount();
/**
* 查询已完成盘点单数量
*
* @return 盘点单数量
*/
public Integer selectStockcheckFinishCount();
}

View File

@@ -0,0 +1,17 @@
package com.ruoyi.index.mapper;
import java.util.List;
import com.ruoyi.index.domain.ViewIndexJob;
/**
* 首页任务视图Mapper接口
*/
public interface ViewIndexJobMapper {
/**
* 根据状态查询任务列表
*
* @param status 任务状态
* @return 任务列表
*/
public List<ViewIndexJob> selectViewIndexJobByStatus(String status);
}

View File

@@ -0,0 +1,31 @@
package com.ruoyi.index.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
/**
* 每周作业数量统计Mapper接口
*
* @author ruoyi
* @date 2025-06-05
*/
public interface WeekJobCountMapper
{
/**
* 查询指定日期范围内每天的入库作业数量
*
* @param startDate 开始日期
* @param endDate 结束日期
* @return 每天的入库作业数量列表
*/
public List<Integer> selectInJobCounts(@Param("startDate") String startDate, @Param("endDate") String endDate);
/**
* 查询指定日期范围内每天的出库作业数量
*
* @param startDate 开始日期
* @param endDate 结束日期
* @return 每天的出库作业数量列表
*/
public List<Integer> selectOutJobCounts(@Param("startDate") String startDate, @Param("endDate") String endDate);
}

View File

@@ -0,0 +1,16 @@
package com.ruoyi.index.service;
import java.util.List;
import com.ruoyi.index.domain.BillStatusCount;
/**
* 单据状态统计Service接口
*/
public interface IBillStatusCountService {
/**
* 查询所有类型单据的状态统计
*
* @return 单据状态统计列表
*/
public List<BillStatusCount> selectAllBillStatusCount();
}

View File

@@ -0,0 +1,15 @@
package com.ruoyi.index.service;
import com.ruoyi.index.domain.CargoSpaceCount;
/**
* 货位状态统计Service接口
*/
public interface ICargoSpaceCountService {
/**
* 查询各状态货位数量
*
* @return 货位状态统计对象
*/
public CargoSpaceCount selectStatusCount();
}

View File

@@ -0,0 +1,19 @@
package com.ruoyi.index.service;
import com.ruoyi.index.domain.IndexCount;
/**
* 首页统计信息Service接口
*
* @author ruoyi
* @date 2025-05-29
*/
public interface IIndexCountService
{
/**
* 查询已完成单据数量统计
*
* @return 统计结果
*/
public IndexCount selectFinishCount();
}

View File

@@ -0,0 +1,19 @@
package com.ruoyi.index.service;
import com.ruoyi.index.domain.WeekJobCount;
/**
* 每周作业数量统计Service接口
*
* @author ruoyi
* @date 2025-06-05
*/
public interface IWeekJobCountService
{
/**
* 获取近一周的入库和出库作业数量统计
*
* @return 近一周的入库和出库作业数量统计
*/
public WeekJobCount getWeekJobCount();
}

View File

@@ -0,0 +1,51 @@
package com.ruoyi.index.service.impl;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.index.mapper.BillStatusCountMapper;
import com.ruoyi.index.domain.BillStatusCount;
import com.ruoyi.index.service.IBillStatusCountService;
/**
* 单据状态统计Service实现
*/
@Service
public class BillStatusCountServiceImpl implements IBillStatusCountService {
@Autowired
private BillStatusCountMapper billStatusCountMapper;
/**
* 查询所有类型单据的状态统计
*
* @return 单据状态统计列表
*/
@Override
public List<BillStatusCount> selectAllBillStatusCount() {
List<BillStatusCount> resultList = new ArrayList<>();
// 查询入库单据状态统计
List<BillStatusCount> stockinList = billStatusCountMapper.selectStockinStatusCount();
if (stockinList != null) {
resultList.addAll(stockinList);
}
// 查询出库单据状态统计
List<BillStatusCount> stockoutList = billStatusCountMapper.selectStockoutStatusCount();
if (stockoutList != null) {
resultList.addAll(stockoutList);
}
// 查询盘点单据状态统计
List<BillStatusCount> stockcheckList = billStatusCountMapper.selectStockcheckStatusCount();
if (stockcheckList != null) {
resultList.addAll(stockcheckList);
}
// 按照status降序排序(3、2、1)
resultList.sort((a, b) -> b.getStatus().compareTo(a.getStatus()));
return resultList;
}
}

View File

@@ -0,0 +1,50 @@
package com.ruoyi.index.service.impl;
import com.ruoyi.index.domain.CargoSpaceCount;
import com.ruoyi.index.mapper.CargoSpaceCountMapper;
import com.ruoyi.index.service.ICargoSpaceCountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 货位状态统计Service实现
*/
@Service
public class CargoSpaceCountServiceImpl implements ICargoSpaceCountService {
@Autowired
private CargoSpaceCountMapper cargoSpaceCountMapper;
/**
* 查询各状态货位数量
*
* @return 货位状态统计对象
*/
@Override
public CargoSpaceCount selectStatusCount() {
// 查询各状态货位数量
List<Map<String, Object>> statusCounts = cargoSpaceCountMapper.selectStatusCount();
// 初始化结果数组,默认所有状态数量为0
List<Integer> counts = new ArrayList<>();
for (int i = 0; i < 6; i++) {
counts.add(0);
}
// 填充实际统计数量
for (Map<String, Object> count : statusCounts) {
int status = Integer.parseInt(count.get("status").toString());
long countValue = Long.parseLong(count.get("count").toString());
counts.set(status - 1, (int)countValue);
}
// 封装结果
CargoSpaceCount result = new CargoSpaceCount();
result.setStatusCounts(counts);
return result;
}
}

View File

@@ -0,0 +1,35 @@
package com.ruoyi.index.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.index.mapper.IndexCountMapper;
import com.ruoyi.index.domain.IndexCount;
import com.ruoyi.index.service.IIndexCountService;
/**
* 首页统计信息Service业务层处理
*
* @author ruoyi
* @date 2025-05-29
*/
@Service
public class IndexCountServiceImpl implements IIndexCountService
{
@Autowired
private IndexCountMapper indexCountMapper;
/**
* 查询已完成单据数量统计
*
* @return 统计结果
*/
@Override
public IndexCount selectFinishCount()
{
IndexCount indexCount = new IndexCount();
indexCount.setStockinCount(indexCountMapper.selectStockinFinishCount());
indexCount.setStockoutCount(indexCountMapper.selectStockoutFinishCount());
indexCount.setStockcheckCount(indexCountMapper.selectStockcheckFinishCount());
return indexCount;
}
}

View File

@@ -0,0 +1,81 @@
package com.ruoyi.index.service.impl;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.index.domain.WeekJobCount;
import com.ruoyi.index.mapper.WeekJobCountMapper;
import com.ruoyi.index.service.IWeekJobCountService;
/**
* 每周作业数量统计Service业务层处理
*
* @author ruoyi
* @date 2025-06-05
*/
@Service
public class WeekJobCountServiceImpl implements IWeekJobCountService
{
@Autowired
private WeekJobCountMapper weekJobCountMapper;
/**
* 获取近一周的入库和出库作业数量统计
*
* @return 近一周的入库和出库作业数量统计
*/
@Override
public WeekJobCount getWeekJobCount()
{
// 获取当前日期
LocalDate now = LocalDate.now();
// 获取本周一的日期
LocalDate monday = now.with(DayOfWeek.MONDAY);
// 获取本周日的日期
LocalDate sunday = now.with(DayOfWeek.SUNDAY);
// 格式化日期
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String startDate = monday.format(formatter);
String endDate = sunday.format(formatter);
// 初始化一周的数组,默认值为0
List<Integer> inJobCounts = Arrays.asList(0, 0, 0, 0, 0, 0, 0);
List<Integer> outJobCounts = Arrays.asList(0, 0, 0, 0, 0, 0, 0);
// 查询近一周的入库和出库作业数量
List<Integer> queryInCounts = weekJobCountMapper.selectInJobCounts(startDate, endDate);
List<Integer> queryOutCounts = weekJobCountMapper.selectOutJobCounts(startDate, endDate);
// 如果查询结果不为空,更新对应日期的数量
if (queryInCounts != null && !queryInCounts.isEmpty()) {
inJobCounts = new ArrayList<>(inJobCounts);
for (int i = 0; i < queryInCounts.size(); i++) {
inJobCounts.set(i, queryInCounts.get(i));
}
}
if (queryOutCounts != null && !queryOutCounts.isEmpty()) {
outJobCounts = new ArrayList<>(outJobCounts);
for (int i = 0; i < queryOutCounts.size(); i++) {
outJobCounts.set(i, queryOutCounts.get(i));
}
}
// 封装结果
WeekJobCount weekJobCount = new WeekJobCount();
weekJobCount.setInJobCounts(inJobCounts);
weekJobCount.setOutJobCounts(outJobCounts);
return weekJobCount;
}
}

View File

@@ -0,0 +1,31 @@
<?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.index.mapper.BillStatusCountMapper">
<resultMap type="com.ruoyi.index.domain.BillStatusCount" id="BillStatusCountResult">
<result property="id" column="id"/>
<result property="status" column="status"/>
<result property="type" column="type"/>
</resultMap>
<select id="selectStockinStatusCount" resultMap="BillStatusCountResult">
select stockin_id as id, status, '1' as type
from in_stockin
where status in ('1', '2', '3')
</select>
<select id="selectStockoutStatusCount" resultMap="BillStatusCountResult">
select stockout_id as id, status, '2' as type
from out_stockout
where status in ('1', '2', '3')
</select>
<select id="selectStockcheckStatusCount" resultMap="BillStatusCountResult">
select stock_check_id as id, status, '3' as type
from check_stockin
where status in ('1', '2', '3')
</select>
</mapper>

View File

@@ -0,0 +1,15 @@
<?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.index.mapper.CargoSpaceCountMapper">
<select id="selectStatusCount" resultType="java.util.Map">
SELECT status, COUNT(*) as count
FROM bas_cargo_space
WHERE status IN ('1', '2', '3', '4', '5', '6')
GROUP BY status
ORDER BY status
</select>
</mapper>

View File

@@ -0,0 +1,22 @@
<?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.index.mapper.IndexCountMapper">
<!-- 查询已完成入库单数量 -->
<select id="selectStockinFinishCount" resultType="Integer">
select count(1) from in_stockin_finish
</select>
<!-- 查询已完成出库单数量 -->
<select id="selectStockoutFinishCount" resultType="Integer">
select count(1) from out_stockout_finish
</select>
<!-- 查询已完成盘点单数量 -->
<select id="selectStockcheckFinishCount" resultType="Integer">
select count(1) from check_stockin_finish
</select>
</mapper>

View File

@@ -0,0 +1,26 @@
<?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.index.mapper.ViewIndexJobMapper">
<resultMap type="ViewIndexJob" id="ViewIndexJobResult">
<result property="jobId" column="job_id" />
<result property="status" column="status" />
<result property="statusLabel" column="status_label" />
<result property="inOrOut" column="in_or_out" />
<result property="priority" column="priority" />
</resultMap>
<select id="selectViewIndexJobByStatus" parameterType="String" resultMap="ViewIndexJobResult">
select
job_id,
status,
status_label,
in_or_out,
priority
from view_index_job
</select>
</mapper>

View File

@@ -0,0 +1,37 @@
<?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.index.mapper.WeekJobCountMapper">
<!-- 查询指定日期范围内每天的入库作业数量 -->
<select id="selectInJobCounts" resultType="java.lang.Integer">
SELECT
COUNT(*) as count
FROM
mydo_job_finish
WHERE
in_or_out &lt; 20
AND CAST(create_time AS DATE) BETWEEN #{startDate} AND #{endDate}
GROUP BY
CAST(create_time AS DATE)
ORDER BY
CAST(create_time AS DATE)
</select>
<!-- 查询指定日期范围内每天的出库作业数量 -->
<select id="selectOutJobCounts" resultType="java.lang.Integer">
SELECT
COUNT(*) as count
FROM
mydo_job_finish
WHERE
in_or_out &gt;= 20
AND CAST(create_time AS DATE) BETWEEN #{startDate} AND #{endDate}
GROUP BY
CAST(create_time AS DATE)
ORDER BY
CAST(create_time AS DATE)
</select>
</mapper>