| | |
| | | "@vitejs/plugin-vue-jsx": "^4.0.0", |
| | | "ant-design-vue": "^4.2.3", |
| | | "axios": "^1.7.2", |
| | | "echarts": "^5.5.1", |
| | | "pinia": "^2.1.7", |
| | | "pixi.js": "^5.3.12", |
| | | "vue": "^3.4.29", |
| | |
| | | "resolved": "https://registry.npmjs.org/earcut/-/earcut-2.2.4.tgz", |
| | | "integrity": "sha512-/pjZsA1b4RPHbeWZQn66SWS8nZZWLQQ23oE3Eam7aroEFGEvwKAsJfZ9ytiEMycfzXWpca4FA9QIOehf7PocBQ==" |
| | | }, |
| | | "node_modules/echarts": { |
| | | "version": "5.5.1", |
| | | "resolved": "https://registry.npmjs.org/echarts/-/echarts-5.5.1.tgz", |
| | | "integrity": "sha512-Fce8upazaAXUVUVsjgV6mBnGuqgO+JNDlcgF79Dksy4+wgGpQB2lmYoO4TSweFg/mZITdpGHomw/cNBJZj1icA==", |
| | | "dependencies": { |
| | | "tslib": "2.3.0", |
| | | "zrender": "5.6.0" |
| | | } |
| | | }, |
| | | "node_modules/electron-to-chromium": { |
| | | "version": "1.4.812", |
| | | "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.812.tgz", |
| | |
| | | "node": ">=4" |
| | | } |
| | | }, |
| | | "node_modules/tslib": { |
| | | "version": "2.3.0", |
| | | "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz", |
| | | "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==" |
| | | }, |
| | | "node_modules/update-browserslist-db": { |
| | | "version": "1.0.16", |
| | | "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.16.tgz", |
| | |
| | | "version": "3.1.1", |
| | | "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", |
| | | "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" |
| | | }, |
| | | "node_modules/zrender": { |
| | | "version": "5.6.0", |
| | | "resolved": "https://registry.npmjs.org/zrender/-/zrender-5.6.0.tgz", |
| | | "integrity": "sha512-uzgraf4njmmHAbEUxMJ8Oxg+P3fT04O+9p7gY+wJRVxo8Ge+KmYv0WJev945EH4wFuc4OY2NLXz46FZrWS9xJg==", |
| | | "dependencies": { |
| | | "tslib": "2.3.0" |
| | | } |
| | | } |
| | | }, |
| | | "dependencies": { |
| | |
| | | "resolved": "https://registry.npmjs.org/earcut/-/earcut-2.2.4.tgz", |
| | | "integrity": "sha512-/pjZsA1b4RPHbeWZQn66SWS8nZZWLQQ23oE3Eam7aroEFGEvwKAsJfZ9ytiEMycfzXWpca4FA9QIOehf7PocBQ==" |
| | | }, |
| | | "echarts": { |
| | | "version": "5.5.1", |
| | | "resolved": "https://registry.npmjs.org/echarts/-/echarts-5.5.1.tgz", |
| | | "integrity": "sha512-Fce8upazaAXUVUVsjgV6mBnGuqgO+JNDlcgF79Dksy4+wgGpQB2lmYoO4TSweFg/mZITdpGHomw/cNBJZj1icA==", |
| | | "requires": { |
| | | "tslib": "2.3.0", |
| | | "zrender": "5.6.0" |
| | | } |
| | | }, |
| | | "electron-to-chromium": { |
| | | "version": "1.4.812", |
| | | "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.812.tgz", |
| | |
| | | "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", |
| | | "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==" |
| | | }, |
| | | "tslib": { |
| | | "version": "2.3.0", |
| | | "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz", |
| | | "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==" |
| | | }, |
| | | "update-browserslist-db": { |
| | | "version": "1.0.16", |
| | | "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.16.tgz", |
| | |
| | | "version": "3.1.1", |
| | | "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", |
| | | "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" |
| | | }, |
| | | "zrender": { |
| | | "version": "5.6.0", |
| | | "resolved": "https://registry.npmjs.org/zrender/-/zrender-5.6.0.tgz", |
| | | "integrity": "sha512-uzgraf4njmmHAbEUxMJ8Oxg+P3fT04O+9p7gY+wJRVxo8Ge+KmYv0WJev945EH4wFuc4OY2NLXz46FZrWS9xJg==", |
| | | "requires": { |
| | | "tslib": "2.3.0" |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | "@vitejs/plugin-vue-jsx": "^4.0.0", |
| | | "ant-design-vue": "^4.2.3", |
| | | "axios": "^1.7.2", |
| | | "echarts": "^5.5.1", |
| | | "pinia": "^2.1.7", |
| | | "pixi.js": "^5.3.12", |
| | | "vue": "^3.4.29", |
| | |
| | | <script setup> |
| | | import { getCurrentInstance, ref } from 'vue'; |
| | | import { getCurrentInstance, ref, onMounted } from 'vue'; |
| | | import { get, post } from '@/utils/request.js' |
| | | import * as echarts from "echarts"; |
| | | const context = getCurrentInstance()?.appContext.config.globalProperties; |
| | | |
| | | let chartPie = null; |
| | | const chartPieContainer = ref(null); |
| | | let chartLine = null; |
| | | const chartLineContainer = ref(null); |
| | | |
| | | function getPieOptions() { |
| | | post('/api/charts/loc/use', {}).then(resp => { |
| | | let result = resp.data; |
| | | if (result.code == 200) { |
| | | let data = result.data; |
| | | |
| | | let pieOptions = { |
| | | title: { |
| | | text: '库位使用比例', |
| | | left: 'center', |
| | | top: '0%' |
| | | }, |
| | | tooltip: { |
| | | trigger: 'item', |
| | | top: '0%' |
| | | }, |
| | | grid: { |
| | | top: '0%', |
| | | left: '3%', |
| | | right: '4%', |
| | | bottom: '3%', |
| | | containLabel: true |
| | | }, |
| | | // legend: { |
| | | // orient: 'vertical', |
| | | // left: 'left' |
| | | // }, |
| | | series: [ |
| | | { |
| | | type: 'pie', |
| | | radius: '70%', |
| | | data: data, |
| | | emphasis: { |
| | | itemStyle: { |
| | | shadowBlur: 10, |
| | | shadowOffsetX: 0, |
| | | shadowColor: 'rgba(0, 0, 0, 0.5)' |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | } |
| | | |
| | | chartPie.setOption(pieOptions); |
| | | |
| | | } |
| | | }) |
| | | } |
| | | |
| | | function getLineOptions() { |
| | | post('/api/charts/loc/line', {}).then(resp => { |
| | | let result = resp.data; |
| | | if (result.code == 200) { |
| | | let data = result.data; |
| | | |
| | | let lineOptions = { |
| | | title: { |
| | | text: '日出入库数量', |
| | | left: 'center', |
| | | }, |
| | | tooltip: { |
| | | trigger: 'axis' |
| | | }, |
| | | legend: { |
| | | data: ['入库数量', '出库数量'], |
| | | top: '10%' |
| | | }, |
| | | grid: { |
| | | top: '20%', |
| | | left: '3%', |
| | | right: '4%', |
| | | bottom: '3%', |
| | | containLabel: true |
| | | }, |
| | | xAxis: { |
| | | type: 'category', |
| | | boundaryGap: false, |
| | | data: data.days |
| | | }, |
| | | yAxis: { |
| | | type: 'value' |
| | | }, |
| | | series: [ |
| | | { |
| | | name: '入库数量', |
| | | type: 'line', |
| | | data: data.in.value, |
| | | smooth: true |
| | | }, |
| | | { |
| | | name: '出库数量', |
| | | type: 'line', |
| | | data: data.out.value, |
| | | smooth: true |
| | | } |
| | | ] |
| | | } |
| | | |
| | | console.log(lineOptions); |
| | | |
| | | chartLine.setOption(lineOptions); |
| | | |
| | | } |
| | | }) |
| | | } |
| | | |
| | | function initChart() { |
| | | chartPie = echarts.init(chartPieContainer.value); |
| | | chartPie.setOption({ |
| | | type: Object, |
| | | required: true |
| | | }) |
| | | |
| | | chartLine = echarts.init(chartLineContainer.value); |
| | | chartLine.setOption({ |
| | | type: Object, |
| | | required: true |
| | | }) |
| | | } |
| | | |
| | | onMounted(() => { |
| | | initChart() |
| | | getPieOptions() |
| | | getLineOptions() |
| | | }) |
| | | |
| | | </script> |
| | | |
| | | <script> |
| | |
| | | </script> |
| | | |
| | | <template> |
| | | Hello World |
| | | <div style="display: flex;"> |
| | | <div ref="chartPieContainer" style="width: 49%;height: 400px;"></div> |
| | | <div ref="chartLineContainer" style="width: 49%;height: 400px;"></div> |
| | | <!-- <EChartView ref="chartChild2" /> --> |
| | | </div> |
| | | </template> |
| | |
| | | return calculate(date, val, timeUnit, false); |
| | | } |
| | | |
| | | public static Date getStartOfDay(Date date) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(date); |
| | | calendar.set(Calendar.HOUR_OF_DAY, 0); |
| | | calendar.set(Calendar.MINUTE, 0); |
| | | calendar.set(Calendar.SECOND, 0); |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | return calendar.getTime(); |
| | | } |
| | | |
| | | public static Date getEndOfDay(Date date) { |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(date); |
| | | calendar.set(Calendar.HOUR_OF_DAY, 23); |
| | | calendar.set(Calendar.MINUTE, 59); |
| | | calendar.set(Calendar.SECOND, 59); |
| | | calendar.set(Calendar.MILLISECOND, 999); |
| | | return calendar.getTime(); |
| | | } |
| | | |
| | | /** |
| | | * 时间对象DateEntity |
| | | */ |
New file |
| | |
| | | package com.zy.asrs.wms.asrs.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.framework.common.DateUtils; |
| | | import com.zy.asrs.framework.common.R; |
| | | import com.zy.asrs.wms.asrs.entity.Loc; |
| | | import com.zy.asrs.wms.asrs.entity.TaskLog; |
| | | import com.zy.asrs.wms.asrs.entity.echart.EChartLineBean; |
| | | import com.zy.asrs.wms.asrs.entity.echart.EChartPieBean; |
| | | import com.zy.asrs.wms.asrs.entity.enums.LocStsType; |
| | | import com.zy.asrs.wms.asrs.service.LocService; |
| | | import com.zy.asrs.wms.asrs.service.TaskLogService; |
| | | import com.zy.asrs.wms.system.controller.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | @RequestMapping("/api") |
| | | public class EChartController extends BaseController { |
| | | |
| | | @Autowired |
| | | private LocService locService; |
| | | @Autowired |
| | | private TaskLogService taskLogService; |
| | | |
| | | @PostMapping("/charts/loc/use") |
| | | public R locUse(){ |
| | | List<EChartPieBean> list = new ArrayList<>(); |
| | | |
| | | long fqty = locService.count(new LambdaQueryWrapper<Loc>().in(Loc::getLocStsId, LocStsType.F.val(), LocStsType.D.val())); |
| | | long oqty = locService.count(new LambdaQueryWrapper<Loc>().in(Loc::getLocStsId, LocStsType.O.val())); |
| | | long uqty = locService.count(new LambdaQueryWrapper<Loc>().in(Loc::getLocStsId, LocStsType.S.val(), LocStsType.R.val())); |
| | | long xqty = locService.count(new LambdaQueryWrapper<Loc>().in(Loc::getLocStsId, LocStsType.X.val())); |
| | | |
| | | EChartPieBean fbean = new EChartPieBean(); |
| | | fbean.setName("在库库位"); |
| | | fbean.setValue(fqty); |
| | | list.add(fbean); |
| | | |
| | | EChartPieBean obean = new EChartPieBean(); |
| | | obean.setName("空库位"); |
| | | obean.setValue(oqty); |
| | | list.add(obean); |
| | | |
| | | EChartPieBean ubean = new EChartPieBean(); |
| | | ubean.setName("使用库位"); |
| | | ubean.setValue(uqty); |
| | | list.add(ubean); |
| | | |
| | | EChartPieBean xbean = new EChartPieBean(); |
| | | xbean.setName("禁用库位"); |
| | | xbean.setValue(xqty); |
| | | list.add(xbean); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @PostMapping("/charts/loc/line") |
| | | public R locIoLineCharts(){ |
| | | SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.add(Calendar.DATE, -12); |
| | | |
| | | ArrayList<String> days = new ArrayList<>(); |
| | | ArrayList<Long> inData = new ArrayList<>(); |
| | | ArrayList<Long> outData = new ArrayList<>(); |
| | | for (int i = 0; i < 12; i++) { |
| | | calendar.add(Calendar.DATE, 1); |
| | | Date time = calendar.getTime(); |
| | | days.add(sf.format(time)); |
| | | |
| | | Date startOfDay = DateUtils.getStartOfDay(time); |
| | | Date endOfDay = DateUtils.getEndOfDay(time); |
| | | |
| | | LambdaQueryWrapper<TaskLog> inWrapper = new LambdaQueryWrapper<TaskLog>() |
| | | .ge(TaskLog::getCreateTime, startOfDay) |
| | | .le(TaskLog::getCreateTime, endOfDay) |
| | | .eq(TaskLog::getTaskSts, 100) |
| | | .in(TaskLog::getTaskType, 1, 53, 57); |
| | | |
| | | LambdaQueryWrapper<TaskLog> outWrapper = new LambdaQueryWrapper<TaskLog>() |
| | | .ge(TaskLog::getCreateTime, startOfDay) |
| | | .le(TaskLog::getCreateTime, endOfDay) |
| | | .eq(TaskLog::getTaskSts, 200) |
| | | .in(TaskLog::getTaskType, 101, 103, 107); |
| | | |
| | | long inCount = taskLogService.count(inWrapper); |
| | | long outCount = taskLogService.count(outWrapper); |
| | | |
| | | inData.add(inCount); |
| | | outData.add(outCount); |
| | | } |
| | | |
| | | EChartLineBean inBean = new EChartLineBean(); |
| | | inBean.setName("入库数量"); |
| | | inBean.setValue(inData); |
| | | |
| | | EChartLineBean outBean = new EChartLineBean(); |
| | | outBean.setName("出库数量"); |
| | | outBean.setValue(outData); |
| | | |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("in", inBean); |
| | | map.put("out", outBean); |
| | | map.put("days", days); |
| | | |
| | | return R.ok().add(map); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.wms.asrs.entity.echart; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class EChartLineBean { |
| | | |
| | | private String name; |
| | | |
| | | private List<Long> value; |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.wms.asrs.entity.echart; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class EChartPieBean { |
| | | |
| | | private String name; |
| | | |
| | | private Long value; |
| | | |
| | | } |