数字孪生:货位、库存、统计,
This commit is contained in:
@@ -0,0 +1,39 @@
|
|||||||
|
package com.ruoyi.api.controller;
|
||||||
|
|
||||||
|
import com.ruoyi.bas.cargoSpace.domain.BasCargoSpace;
|
||||||
|
import com.ruoyi.bas.cargoSpace.service.IBasCargoSpaceService;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.api.service.ITwinService;
|
||||||
|
import com.ruoyi.stock.stock.domain.BasStock;
|
||||||
|
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.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api2wms/twin")
|
||||||
|
public class TwinController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IBasCargoSpaceService basCargoSpaceService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ITwinService twinService;
|
||||||
|
|
||||||
|
@GetMapping("/getEmptyCargoSpace")
|
||||||
|
public AjaxResult getEmptyCargoSpace() {
|
||||||
|
List<BasCargoSpace> list = basCargoSpaceService.selectCargoSpaceWithStock();
|
||||||
|
return AjaxResult.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.YearMonth;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.time.temporal.WeekFields;
|
||||||
|
|
||||||
|
@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.getLotNo());
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.ruoyi.bas.cargoSpace.domain;
|
package com.ruoyi.bas.cargoSpace.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.ruoyi.common.annotation.Excel;
|
import com.ruoyi.common.annotation.Excel;
|
||||||
@@ -104,4 +105,12 @@ Y锁、N开 */
|
|||||||
private String spare7;
|
private String spare7;
|
||||||
|
|
||||||
private String stockStatus;
|
private String stockStatus;
|
||||||
|
|
||||||
|
/** 物料编码 */
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String productId;
|
||||||
|
|
||||||
|
/** 物料名称 */
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String productName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,5 +92,12 @@ public interface BasCargoSpaceMapper extends BaseMapper<BasCargoSpace>
|
|||||||
*/
|
*/
|
||||||
public List<BasCargoSpace> selectBasCargoSpaceListByRoadway(BasCargoSpace basCargoSpace);
|
public List<BasCargoSpace> selectBasCargoSpaceListByRoadway(BasCargoSpace basCargoSpace);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数字孪生用:查询库存信息(关联物料信息)
|
||||||
|
*
|
||||||
|
* @return 库存信息集合
|
||||||
|
*/
|
||||||
|
public List<BasCargoSpace> selectCargoSpaceWithStock();
|
||||||
|
|
||||||
void lockedCargoSpace(BasCargoSpace basCargoSpace);
|
void lockedCargoSpace(BasCargoSpace basCargoSpace);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,4 +84,11 @@ public interface IBasCargoSpaceService extends IService<BasCargoSpace>
|
|||||||
* @return 库存信息集合
|
* @return 库存信息集合
|
||||||
*/
|
*/
|
||||||
public List<BasCargoSpace> selectBasCargoSpaceListByRoadway(BasCargoSpace basCargoSpace);
|
public List<BasCargoSpace> selectBasCargoSpaceListByRoadway(BasCargoSpace basCargoSpace);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数字孪生用:查询库存信息(关联物料信息)
|
||||||
|
*
|
||||||
|
* @return 库存信息集合
|
||||||
|
*/
|
||||||
|
public List<BasCargoSpace> selectCargoSpaceWithStock();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,4 +130,14 @@ public class BasCargoSpaceServiceImpl extends ServiceImpl<BasCargoSpaceMapper,Ba
|
|||||||
return basCargoSpaceMapper.selectBasCargoSpaceListByRoadway(basCargoSpace);
|
return basCargoSpaceMapper.selectBasCargoSpaceListByRoadway(basCargoSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数字孪生用:查询库存信息(关联物料信息)
|
||||||
|
*
|
||||||
|
* @return 库存信息集合
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<BasCargoSpace> selectCargoSpaceWithStock() {
|
||||||
|
return basCargoSpaceMapper.selectCargoSpaceWithStock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -228,6 +228,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</if>
|
</if>
|
||||||
ORDER BY the_platoon, the_floor,the_column
|
ORDER BY the_platoon, the_floor,the_column
|
||||||
</select>
|
</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 id="selectBasCargoSpaceListByRoadway" parameterType="BasCargoSpace" resultMap="BasCargoSpaceResult">
|
||||||
select bcs.cargo_space_id, bcs.warehouse_id, bw.warehouse_name, bcs.roadway_id, bcs.cargo_area_id, bcs.the_type,
|
select bcs.cargo_space_id, bcs.warehouse_id, bw.warehouse_name, bcs.roadway_id, bcs.cargo_area_id, bcs.the_type,
|
||||||
bcs.the_type_name, bcs.cargo_space_name, bcs.the_platoon, bcs.the_column, bcs.the_floor, bcs.status, bcs.locked,
|
bcs.the_type_name, bcs.cargo_space_name, bcs.the_platoon, bcs.the_column, bcs.the_floor, bcs.status, bcs.locked,
|
||||||
|
|||||||
Reference in New Issue
Block a user