数字孪生后台
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package com.ruoyi.api.controller;
|
||||
|
||||
import com.ruoyi.api.service.ITwinService;
|
||||
import com.ruoyi.bas.cargoSpace.domain.BasCargoSpace;
|
||||
import com.ruoyi.bas.cargoSpace.service.IBasCargoSpaceService;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.annotation.Anonymous;
|
||||
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 java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api2wms/twin")
|
||||
public class TwinController {
|
||||
|
||||
@Autowired
|
||||
private IBasCargoSpaceService basCargoSpaceService;
|
||||
|
||||
@Autowired
|
||||
private ITwinService twinService;
|
||||
|
||||
@Anonymous
|
||||
@GetMapping("/getEmptyCargoSpace")
|
||||
public AjaxResult getEmptyCargoSpace() {
|
||||
List<BasCargoSpace> list = basCargoSpaceService.selectCargoSpaceWithStock();
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
@Anonymous
|
||||
@GetMapping("/getStockList")
|
||||
public Map<String, Object> getStockList() {
|
||||
return twinService.getStockListOverview();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.ruoyi.api.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ITwinService {
|
||||
Map<String, Object> getStockListOverview();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,253 @@
|
||||
package com.ruoyi.api.service.impl;
|
||||
|
||||
import com.ruoyi.api.service.ITwinService;
|
||||
import com.ruoyi.bas.cargoSpace.domain.BasCargoSpace;
|
||||
import com.ruoyi.bas.cargoSpace.service.IBasCargoSpaceService;
|
||||
import com.ruoyi.in.stockinfinish.domain.InStockinFinish;
|
||||
import com.ruoyi.in.stockinfinish.service.IInStockinFinishService;
|
||||
import com.ruoyi.out.outStockoutFinish.domain.OutStockoutFinish;
|
||||
import com.ruoyi.out.outStockoutFinish.service.IOutStockoutFinishService;
|
||||
import com.ruoyi.stock.stock.domain.BasStock;
|
||||
import com.ruoyi.stock.stock.service.IBasStockService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.YearMonth;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.WeekFields;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class TwinServiceImpl implements ITwinService {
|
||||
@Autowired
|
||||
private IBasStockService basStockService;
|
||||
@Autowired
|
||||
private IBasCargoSpaceService basCargoSpaceService;
|
||||
@Autowired
|
||||
private IInStockinFinishService inStockinFinishService;
|
||||
@Autowired
|
||||
private IOutStockoutFinishService outStockoutFinishService;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getStockListOverview() {
|
||||
BasStock basStock = new BasStock();
|
||||
List<BasStock> list = basStockService.selectBasStockList(basStock);
|
||||
List<Map<String, Object>> stockList = new ArrayList<>();
|
||||
int limit = Math.min(list.size(), 50);
|
||||
for (int i = 0; i < limit; i++) {
|
||||
BasStock stock = list.get(i);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("productCode", stock.getProductId());
|
||||
map.put("productName", stock.getProductName());
|
||||
map.put("lotNo", stock.getTrayCode());
|
||||
map.put("quantity", stock.getQuantity() != null ? stock.getQuantity().toString() : "0");
|
||||
stockList.add(map);
|
||||
}
|
||||
|
||||
List<BasCargoSpace> cargoSpaces = basCargoSpaceService.selectBasCargoSpaceList(new BasCargoSpace());
|
||||
int ky = 0;
|
||||
int zy = 0;
|
||||
int sd = 0;
|
||||
int zs = cargoSpaces.size();
|
||||
int c1 = 0;
|
||||
int c2 = 0;
|
||||
int c3 = 0;
|
||||
int c4 = 0;
|
||||
int c5 = 0;
|
||||
int c6 = 0;
|
||||
for (BasCargoSpace cs : cargoSpaces) {
|
||||
String s = cs.getStatus();
|
||||
if ("1".equals(s) || "3".equals(s) || "5".equals(s)) {
|
||||
ky++;
|
||||
} else if ("2".equals(s) || "4".equals(s) || "6".equals(s)) {
|
||||
zy++;
|
||||
}
|
||||
if ("1".equals(s)) {
|
||||
c1++;
|
||||
} else if ("2".equals(s)) {
|
||||
c2++;
|
||||
} else if ("3".equals(s)) {
|
||||
c3++;
|
||||
} else if ("4".equals(s)) {
|
||||
c4++;
|
||||
} else if ("5".equals(s)) {
|
||||
c5++;
|
||||
} else if ("6".equals(s)) {
|
||||
c6++;
|
||||
}
|
||||
if ("Y".equalsIgnoreCase(cs.getLocked())) {
|
||||
sd++;
|
||||
}
|
||||
}
|
||||
Map<String, Object> information = new HashMap<>();
|
||||
information.put("ky", String.valueOf(ky));
|
||||
information.put("zy", String.valueOf(zy));
|
||||
information.put("sd", String.valueOf(sd));
|
||||
information.put("zs", String.valueOf(zs));
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("stock", stockList);
|
||||
result.put("information", information);
|
||||
List<Integer> charts = new ArrayList<>();
|
||||
charts.add(c1);
|
||||
charts.add(c2);
|
||||
charts.add(c3);
|
||||
charts.add(c4);
|
||||
charts.add(c5);
|
||||
charts.add(c6);
|
||||
result.put("charts", charts);
|
||||
|
||||
List<InStockinFinish> finishes = inStockinFinishService.selectInStockinFinishList(new InStockinFinish());
|
||||
LocalDate today = LocalDate.now(ZoneId.systemDefault());
|
||||
WeekFields wf = WeekFields.ISO;
|
||||
LocalDate weekStart = today.with(wf.dayOfWeek(), 1);
|
||||
LocalDate weekEnd = today.with(wf.dayOfWeek(), 7);
|
||||
int[] weekCounts = new int[7];
|
||||
DateTimeFormatter[] fmts = new DateTimeFormatter[] {
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"),
|
||||
DateTimeFormatter.ofPattern("yyyy-MM-dd"),
|
||||
DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"),
|
||||
DateTimeFormatter.ofPattern("yyyy/MM/dd")
|
||||
};
|
||||
for (InStockinFinish f : finishes) {
|
||||
String cd = f.getCreateDate();
|
||||
if (cd == null || cd.isEmpty()) continue;
|
||||
LocalDate date = null;
|
||||
for (DateTimeFormatter fmt : fmts) {
|
||||
try {
|
||||
if (fmt.toString().contains("H")) {
|
||||
LocalDateTime dt = LocalDateTime.parse(cd, fmt);
|
||||
date = dt.toLocalDate();
|
||||
} else {
|
||||
date = LocalDate.parse(cd, fmt);
|
||||
}
|
||||
break;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
if (date == null) continue;
|
||||
if (!date.isBefore(weekStart) && !date.isAfter(weekEnd)) {
|
||||
int idx = date.getDayOfWeek().getValue() - 1;
|
||||
weekCounts[idx]++;
|
||||
}
|
||||
}
|
||||
List<String> weekData = new ArrayList<>();
|
||||
for (int i = 0; i < 7; i++) {
|
||||
weekData.add(String.valueOf(weekCounts[i]));
|
||||
}
|
||||
Map<String, Object> weekInStock = new HashMap<>();
|
||||
weekInStock.put("time", List.of("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"));
|
||||
weekInStock.put("data", weekData);
|
||||
result.put("weekInStock", weekInStock);
|
||||
|
||||
YearMonth ym = YearMonth.now(ZoneId.systemDefault());
|
||||
int daysInMonth = ym.lengthOfMonth();
|
||||
int[] monthCounts = new int[daysInMonth];
|
||||
for (InStockinFinish f : finishes) {
|
||||
String cd = f.getCreateDate();
|
||||
if (cd == null || cd.isEmpty()) continue;
|
||||
LocalDate date = null;
|
||||
for (DateTimeFormatter fmt : fmts) {
|
||||
try {
|
||||
if (fmt.toString().contains("H")) {
|
||||
LocalDateTime dt = LocalDateTime.parse(cd, fmt);
|
||||
date = dt.toLocalDate();
|
||||
} else {
|
||||
date = LocalDate.parse(cd, fmt);
|
||||
}
|
||||
break;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
if (date == null) continue;
|
||||
if (YearMonth.from(date).equals(ym)) {
|
||||
int d = date.getDayOfMonth();
|
||||
monthCounts[d - 1]++;
|
||||
}
|
||||
}
|
||||
List<Integer> monthTime = new ArrayList<>();
|
||||
List<Integer> monthData = new ArrayList<>();
|
||||
for (int i = 1; i <= daysInMonth; i++) {
|
||||
monthTime.add(i);
|
||||
monthData.add(monthCounts[i - 1]);
|
||||
}
|
||||
Map<String, Object> monthInStock = new HashMap<>();
|
||||
monthInStock.put("time", monthTime);
|
||||
monthInStock.put("data", monthData);
|
||||
result.put("monthInStock", monthInStock);
|
||||
|
||||
List<OutStockoutFinish> outFinishes = outStockoutFinishService.selectOutStockoutFinishList(new OutStockoutFinish());
|
||||
int[] weekCountsOut = new int[7];
|
||||
for (OutStockoutFinish f : outFinishes) {
|
||||
String cd = f.getCreateDate();
|
||||
if (cd == null || cd.isEmpty()) continue;
|
||||
LocalDate date = null;
|
||||
for (DateTimeFormatter fmt : fmts) {
|
||||
try {
|
||||
if (fmt.toString().contains("H")) {
|
||||
LocalDateTime dt = LocalDateTime.parse(cd, fmt);
|
||||
date = dt.toLocalDate();
|
||||
} else {
|
||||
date = LocalDate.parse(cd, fmt);
|
||||
}
|
||||
break;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
if (date == null) continue;
|
||||
if (!date.isBefore(weekStart) && !date.isAfter(weekEnd)) {
|
||||
int idx = date.getDayOfWeek().getValue() - 1;
|
||||
weekCountsOut[idx]++;
|
||||
}
|
||||
}
|
||||
List<String> weekDataOut = new ArrayList<>();
|
||||
for (int i = 0; i < 7; i++) {
|
||||
weekDataOut.add(String.valueOf(weekCountsOut[i]));
|
||||
}
|
||||
Map<String, Object> weekOutStock = new HashMap<>();
|
||||
weekOutStock.put("time", List.of("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"));
|
||||
weekOutStock.put("data", weekDataOut);
|
||||
result.put("weekOutStock", weekOutStock);
|
||||
|
||||
int[] monthCountsOut = new int[daysInMonth];
|
||||
for (OutStockoutFinish f : outFinishes) {
|
||||
String cd = f.getCreateDate();
|
||||
if (cd == null || cd.isEmpty()) continue;
|
||||
LocalDate date = null;
|
||||
for (DateTimeFormatter fmt : fmts) {
|
||||
try {
|
||||
if (fmt.toString().contains("H")) {
|
||||
LocalDateTime dt = LocalDateTime.parse(cd, fmt);
|
||||
date = dt.toLocalDate();
|
||||
} else {
|
||||
date = LocalDate.parse(cd, fmt);
|
||||
}
|
||||
break;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
if (date == null) continue;
|
||||
if (YearMonth.from(date).equals(ym)) {
|
||||
int d = date.getDayOfMonth();
|
||||
monthCountsOut[d - 1]++;
|
||||
}
|
||||
}
|
||||
List<Integer> monthTimeOut = new ArrayList<>();
|
||||
List<Integer> monthDataOut = new ArrayList<>();
|
||||
for (int i = 1; i <= daysInMonth; i++) {
|
||||
monthTimeOut.add(i);
|
||||
monthDataOut.add(monthCountsOut[i - 1]);
|
||||
}
|
||||
Map<String, Object> monthOutStock = new HashMap<>();
|
||||
monthOutStock.put("time", monthTimeOut);
|
||||
monthOutStock.put("data", monthDataOut);
|
||||
result.put("monthOutStock", monthOutStock);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -84,4 +84,11 @@ public interface BasCargoSpaceMapper extends BaseMapper<BasCargoSpace>
|
||||
* @return 库存信息集合
|
||||
*/
|
||||
public List<BasCargoSpace> selectBasCargoSpaceListByRoadway(BasCargoSpace basCargoSpace);
|
||||
|
||||
/**
|
||||
* 数字孪生用:查询库存信息(关联物料信息)
|
||||
*
|
||||
* @return 库存信息集合
|
||||
*/
|
||||
public List<BasCargoSpace> selectCargoSpaceWithStock();
|
||||
}
|
||||
|
||||
@@ -76,4 +76,11 @@ public interface IBasCargoSpaceService extends IService<BasCargoSpace>
|
||||
* @return 库存信息集合
|
||||
*/
|
||||
public List<BasCargoSpace> selectBasCargoSpaceListByRoadway(BasCargoSpace basCargoSpace);
|
||||
|
||||
/**
|
||||
* 数字孪生用:查询库存信息(关联物料信息)
|
||||
*
|
||||
* @return 库存信息集合
|
||||
*/
|
||||
public List<BasCargoSpace> selectCargoSpaceWithStock();
|
||||
}
|
||||
|
||||
@@ -113,4 +113,13 @@ public class BasCargoSpaceServiceImpl extends ServiceImpl<BasCargoSpaceMapper,Ba
|
||||
return basCargoSpaceMapper.selectBasCargoSpaceListByRoadway(basCargoSpace);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数字孪生用:查询库存信息(关联物料信息)
|
||||
*
|
||||
* @return 库存信息集合
|
||||
*/
|
||||
@Override
|
||||
public List<BasCargoSpace> selectCargoSpaceWithStock() {
|
||||
return basCargoSpaceMapper.selectCargoSpaceWithStock();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ ruoyi:
|
||||
# 开发环境配置
|
||||
server:
|
||||
# 服务器的HTTP端口,默认为8080
|
||||
port: 8081
|
||||
port: 8080
|
||||
servlet:
|
||||
# 应用的访问路径
|
||||
context-path: /
|
||||
|
||||
@@ -195,6 +195,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</if>
|
||||
ORDER BY the_platoon, the_floor,the_column
|
||||
</select>
|
||||
<select id="selectCargoSpaceWithStock" resultMap="BasCargoSpaceResult">
|
||||
select
|
||||
bcs.cargo_space_id,
|
||||
bcs.cargo_space_name,
|
||||
bcs.the_platoon,
|
||||
bcs.the_column,
|
||||
bcs.the_floor,
|
||||
bcs.status,
|
||||
bs.tray_code,
|
||||
bs.product_id,
|
||||
bs.product_name
|
||||
from bas_cargo_space bcs
|
||||
left join bas_stock bs on bcs.cargo_space_id = bs.cargo_space_id
|
||||
where bcs.status in ('1', '2')
|
||||
</select>
|
||||
<select id="selectBasCargoSpaceListByRoadway" parameterType="BasCargoSpace" resultMap="BasCargoSpaceResult">
|
||||
select bcs.cargo_space_id, bcs.warehouse_id, bcs.roadway_id, bcs.cargo_space_name,
|
||||
bcs.the_platoon, bcs.the_column, bcs.the_floor, bcs.status, bcs.locked, bs.tray_code, bs.product_id,
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.framework.security.context.PermissionContextHolder;
|
||||
import org.springframework.security.core.Authentication;
|
||||
|
||||
/**
|
||||
* 数据过滤处理
|
||||
@@ -69,17 +70,21 @@ public class DataScopeAspect
|
||||
|
||||
protected void handleDataScope(final JoinPoint joinPoint, DataScope controllerDataScope)
|
||||
{
|
||||
// 获取当前的用户
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (StringUtils.isNotNull(loginUser))
|
||||
Authentication authentication = SecurityUtils.getAuthentication();
|
||||
if (authentication == null) {
|
||||
return;
|
||||
}
|
||||
Object principal = authentication.getPrincipal();
|
||||
if (!(principal instanceof LoginUser)) {
|
||||
return;
|
||||
}
|
||||
LoginUser loginUser = (LoginUser) principal;
|
||||
SysUser currentUser = loginUser.getUser();
|
||||
// 如果是超级管理员,则不过滤数据
|
||||
if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin())
|
||||
{
|
||||
SysUser currentUser = loginUser.getUser();
|
||||
// 如果是超级管理员,则不过滤数据
|
||||
if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin())
|
||||
{
|
||||
String permission = StringUtils.defaultIfEmpty(controllerDataScope.permission(), PermissionContextHolder.getContext());
|
||||
dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(), controllerDataScope.userAlias(),controllerDataScope.warehouseAlias(), permission);
|
||||
}
|
||||
String permission = StringUtils.defaultIfEmpty(controllerDataScope.permission(), PermissionContextHolder.getContext());
|
||||
dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(), controllerDataScope.userAlias(),controllerDataScope.warehouseAlias(), permission);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ const CompressionPlugin = require('compression-webpack-plugin')
|
||||
|
||||
const name = process.env.VUE_APP_TITLE || '若依管理系统' // 网页标题
|
||||
|
||||
const baseUrl = 'http://localhost:8081' // 后端接口
|
||||
const baseUrl = 'http://localhost:8080' // 后端接口
|
||||
|
||||
const port = process.env.port || process.env.npm_config_port || 80 // 端口
|
||||
|
||||
|
||||
Reference in New Issue
Block a user