gengby
4 months ago
17 changed files with 631 additions and 41 deletions
@ -0,0 +1,62 @@ |
|||
[交易说明] |
|||
交易名: WMS接口查询 |
|||
所属模块: |
|||
功能简述: |
|||
版权所有: |
|||
表引用: |
|||
版本经历: |
|||
|
|||
[数据库] |
|||
--指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 |
|||
|
|||
[IO定义] |
|||
################################################# |
|||
## 表字段对应输入参数 |
|||
################################################# |
|||
输入.flag TYPEAS s_string |
|||
|
|||
|
|||
|
|||
|
|||
[临时表] |
|||
--这边列出来的临时表就会在运行期动态创建 |
|||
|
|||
[临时变量] |
|||
--所有中间过程变量均可在此处定义 |
|||
|
|||
[业务过程] |
|||
|
|||
########################################## |
|||
# 1、输入输出检查 # |
|||
########################################## |
|||
|
|||
|
|||
########################################## |
|||
# 2、主过程前处理 # |
|||
########################################## |
|||
|
|||
|
|||
########################################## |
|||
# 3、业务主过程 # |
|||
########################################## |
|||
IF 输入.flag = "1" |
|||
QUERY |
|||
SELECT |
|||
inst.task_code, |
|||
inst.start_point_code, |
|||
inst.next_point_code, |
|||
CASE |
|||
WHEN inst.instruction_status = '0' THEN '就绪' |
|||
WHEN inst.instruction_status = '1' THEN '执行中' |
|||
WHEN inst.instruction_status = '2' THEN '完成' |
|||
ELSE '未知状态' |
|||
END AS task_status, |
|||
inst.carno, |
|||
inst.create_time |
|||
FROM |
|||
acs_instruction inst |
|||
WHERE |
|||
inst.`instruction_status` in ('0','1','2') and inst.task_code NOT LIKE '-%' and DATE(inst.create_time) = CURDATE() |
|||
ENDSELECT |
|||
ENDQUERY |
|||
ENDIF |
@ -0,0 +1,76 @@ |
|||
package org.nl.wms.bigScreen.controller; |
|||
|
|||
import cn.dev33.satoken.annotation.SaIgnore; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.common.logging.annotation.Log; |
|||
import org.nl.wms.bigScreen.service.BigScreenService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* @Description TODO |
|||
* @Author Gengby |
|||
* @Date 2024/8/2 |
|||
*/ |
|||
@Slf4j |
|||
@RestController |
|||
@RequestMapping("/api/bigScreen") |
|||
@SaIgnore |
|||
public class BigScreenController { |
|||
|
|||
@Autowired |
|||
private BigScreenService bigScreenService; |
|||
|
|||
@PostMapping("/inventoryAnalysis") |
|||
@Log("原料库存统计") |
|||
public ResponseEntity<Object> inventoryAnalysis() { |
|||
return new ResponseEntity<>(bigScreenService.inventoryAnalysis(), HttpStatus.OK); |
|||
} |
|||
|
|||
@PostMapping("/agvInfo") |
|||
@Log("获取AGV信息") |
|||
public ResponseEntity<Object> agvInfo() { |
|||
return new ResponseEntity<>(bigScreenService.agvInfo(), HttpStatus.OK); |
|||
} |
|||
|
|||
@PostMapping("/rgvInfo") |
|||
@Log("获取RGV信息") |
|||
public ResponseEntity<Object> rgvInfo() { |
|||
return new ResponseEntity<>(bigScreenService.rgvInfo(), HttpStatus.OK); |
|||
} |
|||
|
|||
@PostMapping("/todayProduceStatistic") |
|||
@Log("当日生产统计") |
|||
public ResponseEntity<Object> todayProduceStatistic() { |
|||
return new ResponseEntity<>(bigScreenService.todayProduceStatistic(), HttpStatus.OK); |
|||
} |
|||
|
|||
@PostMapping("/inventoryIOAnalysis") |
|||
@Log("当日出入库分析") |
|||
public ResponseEntity<Object> inventoryIOAnalysis() { |
|||
return new ResponseEntity<>(bigScreenService.inventoryIOAnalysis(), HttpStatus.OK); |
|||
} |
|||
|
|||
@PostMapping("/historyInventoryIOAnalysis") |
|||
@Log("历史出入库分析") |
|||
public ResponseEntity<Object> historyInventoryIOAnalysis() { |
|||
return new ResponseEntity<>(bigScreenService.historyInventoryIOAnalysis(), HttpStatus.OK); |
|||
} |
|||
|
|||
@PostMapping("/todayTask") |
|||
@Log("当日任务") |
|||
public ResponseEntity<Object> todayTask() { |
|||
return new ResponseEntity<>(bigScreenService.todayTask(), HttpStatus.OK); |
|||
} |
|||
|
|||
@PostMapping("/todayLoadingAndUnloadingStatistics") |
|||
@Log("当日车间上下料根据区域统计") |
|||
public ResponseEntity<Object> todayLoadingAndUnloadingStatistics() { |
|||
return new ResponseEntity<>(bigScreenService.todayLoadingAndUnloadingStatistics(), HttpStatus.OK); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,69 @@ |
|||
package org.nl.wms.bigScreen.service; |
|||
|
|||
import com.alibaba.fastjson.JSONArray; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @Description TODO |
|||
* @Author Gengby |
|||
* @Date 2024/8/2 |
|||
*/ |
|||
public interface BigScreenService { |
|||
/** |
|||
* 原料库存统计 |
|||
* |
|||
* @return |
|||
*/ |
|||
List<Map<String, Object>> inventoryAnalysis(); |
|||
|
|||
/** |
|||
* 获取AGV信息 |
|||
* |
|||
* @return |
|||
*/ |
|||
JSONArray agvInfo(); |
|||
|
|||
/** |
|||
* 获取RGV信息 |
|||
* |
|||
* @return |
|||
*/ |
|||
JSONArray rgvInfo(); |
|||
|
|||
/** |
|||
* 当日生产统计 |
|||
* |
|||
* @return |
|||
*/ |
|||
List<Map<String, Object>> todayProduceStatistic(); |
|||
|
|||
/** |
|||
* 当日上下料统计 |
|||
* |
|||
* @return |
|||
*/ |
|||
List<Map<String,Object>> todayLoadingAndUnloadingStatistics(); |
|||
|
|||
/** |
|||
* 当日任务 |
|||
* |
|||
* @return |
|||
*/ |
|||
JSONArray todayTask(); |
|||
|
|||
/** |
|||
* 历史分析(出库和入库近半个月的) |
|||
* |
|||
* @return |
|||
*/ |
|||
List<Map<String, Object>> historyInventoryIOAnalysis(); |
|||
|
|||
/** |
|||
* 当日出入库统计 |
|||
* |
|||
* @return |
|||
*/ |
|||
List<Map<String, Object>> inventoryIOAnalysis(); |
|||
} |
@ -0,0 +1,77 @@ |
|||
package org.nl.wms.bigScreen.service.impl; |
|||
|
|||
import com.alibaba.fastjson.JSONArray; |
|||
import org.nl.wms.bigScreen.service.BigScreenService; |
|||
import org.nl.wms.bigScreen.service.mapper.BigScreenMapper; |
|||
import org.nl.wms.ext.acs.service.WmsToAcsService; |
|||
import org.nl.wms.ext.acs.service.dto.to.wms.AcsResponse; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @Description TODO |
|||
* @Author Gengby |
|||
* @Date 2024/8/2 |
|||
*/ |
|||
@Service |
|||
public class BigScreenServiceImpl implements BigScreenService { |
|||
|
|||
@Autowired(required = false) |
|||
private BigScreenMapper bigScreenMapper; |
|||
@Autowired |
|||
private WmsToAcsService wmsToAcsService; |
|||
|
|||
@Override |
|||
public List<Map<String, Object>> inventoryAnalysis() { |
|||
List<Map<String, Object>> res = bigScreenMapper.inventoryAnalysis(); |
|||
return res; |
|||
} |
|||
|
|||
@Override |
|||
public JSONArray agvInfo() { |
|||
AcsResponse acsResponse = wmsToAcsService.agvInfo(); |
|||
JSONArray data = acsResponse.getData(); |
|||
return data; |
|||
} |
|||
|
|||
@Override |
|||
public JSONArray rgvInfo() { |
|||
AcsResponse acsResponse = wmsToAcsService.rgvInfo(); |
|||
JSONArray data = acsResponse.getData(); |
|||
return data; |
|||
} |
|||
|
|||
@Override |
|||
public List<Map<String, Object>> todayProduceStatistic() { |
|||
List<Map<String, Object>> res = bigScreenMapper.todayProduceStatistic(); |
|||
return res; |
|||
} |
|||
|
|||
@Override |
|||
public List<Map<String, Object>> todayLoadingAndUnloadingStatistics() { |
|||
List<Map<String, Object>> res = bigScreenMapper.todayLoadingAndUnloadingStatistics(); |
|||
return res; |
|||
} |
|||
|
|||
@Override |
|||
public JSONArray todayTask() { |
|||
AcsResponse acsResponse = wmsToAcsService.todayTask(); |
|||
JSONArray data = acsResponse.getData(); |
|||
return data; |
|||
} |
|||
|
|||
@Override |
|||
public List<Map<String, Object>> historyInventoryIOAnalysis() { |
|||
List<Map<String, Object>> res = bigScreenMapper.historyInventoryIOAnalysis(); |
|||
return res; |
|||
} |
|||
|
|||
@Override |
|||
public List<Map<String, Object>> inventoryIOAnalysis() { |
|||
List<Map<String, Object>> res = bigScreenMapper.inventoryIOAnalysis(); |
|||
return res; |
|||
} |
|||
} |
@ -0,0 +1,23 @@ |
|||
package org.nl.wms.bigScreen.service.mapper; |
|||
|
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @Description TODO |
|||
* @Author Gengby |
|||
* @Date 2024/8/2 |
|||
*/ |
|||
public interface BigScreenMapper { |
|||
|
|||
List<Map<String, Object>> inventoryAnalysis(); |
|||
|
|||
List<Map<String, Object>> todayProduceStatistic(); |
|||
|
|||
List<Map<String, Object>> inventoryIOAnalysis(); |
|||
|
|||
List<Map<String, Object>> historyInventoryIOAnalysis(); |
|||
|
|||
List<Map<String, Object>> todayLoadingAndUnloadingStatistics(); |
|||
} |
@ -0,0 +1,186 @@ |
|||
<?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="org.nl.wms.bigScreen.service.mapper.BigScreenMapper"> |
|||
|
|||
<!--原料库存物料分析 物料、数量、百分比--> |
|||
<select id="inventoryAnalysis" resultType="java.util.Map"> |
|||
SELECT vm.material_id, |
|||
material.material_code, |
|||
material.material_name, |
|||
SUM(vm.material_qty) AS total_material_qty, |
|||
CONCAT(FORMAT((SUM(vm.material_qty) / total.total_qty) * 100, 2), '%') AS percentage |
|||
FROM sch_base_point `point` |
|||
LEFT JOIN sch_base_vehiclematerialgroup vm ON `point`.vehicle_code = vm.vehicle_code |
|||
LEFT JOIN md_base_material material ON vm.material_id = material.material_id |
|||
CROSS JOIN ( |
|||
SELECT SUM(vm.material_qty) AS total_qty |
|||
FROM sch_base_point `point` |
|||
LEFT JOIN sch_base_vehiclematerialgroup vm ON `point`.vehicle_code = vm.vehicle_code |
|||
WHERE `point`.region_code = 'YCL' |
|||
AND vm.group_bind_material_status = '2' |
|||
AND vm.group_status = '2' |
|||
AND vm.link_status = '1' |
|||
) total |
|||
WHERE `point`.region_code = 'YCL' |
|||
AND vm.group_bind_material_status = '2' |
|||
AND vm.group_status = '2' |
|||
AND vm.link_status = '1' |
|||
GROUP BY vm.material_id, |
|||
material.material_code, |
|||
material.material_name, |
|||
total.total_qty; |
|||
</select> |
|||
|
|||
<!--根据任务流转统计当日搬运托数--> |
|||
<select id="todayProduceStatistic" resultType="java.util.Map"> |
|||
SELECT |
|||
region.region_name, |
|||
region.region_code, |
|||
COALESCE(task_counts.count, 0) AS count |
|||
FROM ( |
|||
SELECT |
|||
region.region_code, |
|||
region.region_name |
|||
FROM |
|||
sch_base_region region |
|||
LEFT JOIN sch_base_point `point` ON region.region_code = `point`.region_code |
|||
WHERE |
|||
`point`.point_code IN ('XKBSKT', 'ZQTLKT1', 'BCXZKKT') |
|||
GROUP BY |
|||
region.region_code |
|||
) AS region |
|||
LEFT JOIN ( |
|||
SELECT |
|||
`point`.region_code, |
|||
COUNT(task.task_id) AS count |
|||
FROM |
|||
sch_base_task task |
|||
LEFT JOIN sch_base_point `point` ON task.point_code1 = `point`.point_code |
|||
WHERE |
|||
task.point_code1 IN ('XKBSKT', 'ZQTLKT1', 'BCXZKKT') |
|||
AND task.task_status = '5' |
|||
AND task.create_time = CURDATE() |
|||
GROUP BY |
|||
`point`.region_code |
|||
) AS task_counts ON region.region_code = task_counts.region_code |
|||
ORDER BY |
|||
region.region_code; |
|||
</select> |
|||
|
|||
<!--查询当天物料的出入库数量--> |
|||
<select id="inventoryIOAnalysis" resultType="java.util.Map"> |
|||
SELECT COALESCE |
|||
( instorage.material_id, outstorage.material_id ) AS material_id, |
|||
material.material_code, |
|||
material.material_name, |
|||
COALESCE ( instorage.total_material_qty, 0 ) AS total_instorage_qty, |
|||
COALESCE ( outstorage.total_material_qty, 0 ) AS total_outstorage_qty |
|||
FROM |
|||
md_base_material material |
|||
LEFT JOIN ( |
|||
SELECT |
|||
vm.material_id, |
|||
SUM( vm.material_qty ) AS total_material_qty |
|||
FROM |
|||
sch_base_vehiclematerialgroup vm |
|||
WHERE |
|||
DATE ( vm.instorage_time ) = CURDATE() |
|||
AND (vm.group_bind_material_status = '2' or vm.group_bind_material_status = '3') |
|||
AND vm.group_status = '2' |
|||
AND vm.link_status = '1' |
|||
GROUP BY |
|||
vm.material_id |
|||
) AS instorage ON material.material_id = instorage.material_id |
|||
LEFT JOIN ( |
|||
SELECT |
|||
vm.material_id, |
|||
SUM( vm.material_qty ) AS total_material_qty |
|||
FROM |
|||
sch_base_vehiclematerialgroup vm |
|||
WHERE |
|||
DATE ( vm.update_time ) = CURDATE() |
|||
AND vm.group_bind_material_status = '3' |
|||
AND vm.group_status = '2' |
|||
AND vm.link_status = '1' |
|||
GROUP BY |
|||
vm.material_id |
|||
) AS outstorage ON material.material_id = outstorage.material_id |
|||
WHERE |
|||
instorage.material_id IS NOT NULL |
|||
OR outstorage.material_id IS NOT NULL; |
|||
</select> |
|||
|
|||
<!--查询历史出入库数量--> |
|||
<select id="historyInventoryIOAnalysis" resultType="java.util.Map"> |
|||
SELECT |
|||
DATE_FORMAT( date_table.DATE, '%m-%d' ) AS `data`, |
|||
SUM( |
|||
CASE |
|||
|
|||
WHEN (vm.group_bind_material_status = '2' or vm.group_bind_material_status = '3') |
|||
AND vm.group_status = '2' |
|||
AND vm.link_status = '1' |
|||
AND DATE ( vm.instorage_time ) = date_table.DATE THEN |
|||
vm.material_qty ELSE 0 |
|||
END |
|||
) AS total_instorage_qty, |
|||
SUM( |
|||
CASE |
|||
|
|||
WHEN vm.group_bind_material_status = '3' |
|||
AND vm.group_status = '2' |
|||
AND vm.link_status = '1' |
|||
AND DATE ( vm.update_time ) = date_table.DATE THEN |
|||
vm.material_qty ELSE 0 |
|||
END |
|||
) AS total_outstorage_qty |
|||
FROM |
|||
( |
|||
SELECT |
|||
CURDATE() - INTERVAL seq DAY AS DATE |
|||
FROM |
|||
( SELECT 0 AS seq UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 ) AS seq_table |
|||
) AS date_table |
|||
LEFT JOIN sch_base_vehiclematerialgroup vm ON DATE ( vm.instorage_time ) = date_table.DATE |
|||
OR DATE ( vm.update_time ) = date_table.DATE |
|||
GROUP BY |
|||
date_table.DATE |
|||
ORDER BY |
|||
date_table.DATE; |
|||
</select> |
|||
|
|||
<!--当日车间上下料根据区域统计--> |
|||
<select id="todayLoadingAndUnloadingStatistics" resultType="java.util.Map"> |
|||
SELECT |
|||
region.region_code, |
|||
region.region_name, |
|||
COALESCE(loading.material_loading_count, 0) AS material_loading_count, |
|||
COALESCE(unloading.material_unloading_count, 0) AS material_unloading_count |
|||
FROM sch_base_region region |
|||
LEFT JOIN ( |
|||
SELECT |
|||
`point`.region_code, |
|||
SUM(CASE WHEN point.point_type = '1' THEN 1 ELSE 0 END) AS material_loading_count |
|||
FROM sch_base_task task |
|||
LEFT JOIN sch_base_point `point` ON task.point_code2 = `point`.point_code |
|||
WHERE task.task_status = '5' |
|||
AND `point`.region_code NOT IN ('YCL', 'JLHC', 'ZP', 'KTPHC1', 'KTPHC2') |
|||
AND DATE(task.create_time) = CURDATE() |
|||
GROUP BY `point`.region_code |
|||
) AS loading ON region.region_code = loading.region_code |
|||
LEFT JOIN ( |
|||
SELECT |
|||
`point`.region_code, |
|||
SUM(CASE WHEN point.point_type = '2' THEN 1 ELSE 0 END) AS material_unloading_count |
|||
FROM sch_base_task task |
|||
LEFT JOIN sch_base_point `point` ON task.point_code1 = `point`.point_code |
|||
WHERE task.task_status = '5' |
|||
AND `point`.region_code NOT IN ('YCL', 'JLHC', 'ZP', 'KTPHC1', 'KTPHC2') |
|||
AND DATE(task.create_time) = CURDATE() |
|||
GROUP BY `point`.region_code |
|||
) AS unloading ON region.region_code = unloading.region_code |
|||
WHERE region.region_code NOT IN ('YCL', 'JLHC', 'ZP', 'KTPHC1', 'KTPHC2') |
|||
ORDER BY region.region_code; |
|||
</select> |
|||
|
|||
</mapper> |
Loading…
Reference in new issue