From 4e8024e68183bfe8070b1b366023d035be4b6b08 Mon Sep 17 00:00:00 2001 From: liupopo Date: Sun, 25 Jun 2023 20:03:55 +0800 Subject: [PATCH] 111 --- .../data_modify-gd_inventory_log.sql | 2 + .../table_modify-supervise_supplychain.sql | 2 + supervise-customer-ui/.env.development | 2 +- .../views/daydataupload/gdinventory/index.vue | 71 +++++--- .../src/layout/components/Navbar.vue | 16 +- .../yxt-supervise-dbcenter-ui/src/settings.js | 2 +- .../yxt-supervise-dbcenter-ui/vue.config.js | 2 +- .../api/gdinventorylog/GdInventoryLog.java | 5 + .../gdinventorylog/GdInventoryLogService.java | 14 +- .../gdinventoryok/GdInventoryOkService.java | 166 +++++++++++++++++- .../feign/report/ReportInventoryFeign.java | 19 ++ .../src/main/resources/application.yml | 18 +- .../src/main/resources/application.yml | 4 +- .../ReportInventoryDayGatherService.java | 5 +- .../src/main/resources/application.yml | 18 +- 15 files changed, 294 insertions(+), 52 deletions(-) create mode 100644 docs/databases/data_modify/data_modify-gd_inventory_log.sql create mode 100644 docs/databases/table_modify/table_modify-supervise_supplychain.sql create mode 100644 yxt_supervise/supervise-customer/supervise-customer-biz/src/main/java/com/yxt/supervise/customer/feign/report/ReportInventoryFeign.java diff --git a/docs/databases/data_modify/data_modify-gd_inventory_log.sql b/docs/databases/data_modify/data_modify-gd_inventory_log.sql new file mode 100644 index 00000000..b5df926b --- /dev/null +++ b/docs/databases/data_modify/data_modify-gd_inventory_log.sql @@ -0,0 +1,2 @@ + +update gd_inventory_log set outFilePath='test',state=4,fileUrl=CONCAT(CONCAT('http://8.130.39.13:7003/upload/kchzb/库存汇总表',orderDate),'.xlsx') where state=0 and orderDate is not null and orderDate<>'' diff --git a/docs/databases/table_modify/table_modify-supervise_supplychain.sql b/docs/databases/table_modify/table_modify-supervise_supplychain.sql new file mode 100644 index 00000000..d4022beb --- /dev/null +++ b/docs/databases/table_modify/table_modify-supervise_supplychain.sql @@ -0,0 +1,2 @@ +ALTER TABLE supervise_supplychain.gd_inventory_log ADD state int(11) default 0 COMMENT '当前状态:0:未上传;1:上传完成正导入数据库;2:导入完成创建报表;3:报表完成创建Excel;4:完成'; +ALTER TABLE supervise_supplychain.gd_inventory_log ADD sid varchar(100) NULL; diff --git a/supervise-customer-ui/.env.development b/supervise-customer-ui/.env.development index ebb0634b..96a7c40f 100644 --- a/supervise-customer-ui/.env.development +++ b/supervise-customer-ui/.env.development @@ -2,7 +2,7 @@ ENV = 'development' # base api -VUE_APP_BASE_API = '/api' +VUE_APP_BASE_API = '/api/service' ## 配置测试和本地开发时的 接口地址 ##VUE_APP_URL = "http://8.130.39.13:8112" diff --git a/supervise-customer-ui/src/views/daydataupload/gdinventory/index.vue b/supervise-customer-ui/src/views/daydataupload/gdinventory/index.vue index d1fdd2a9..75b192c7 100644 --- a/supervise-customer-ui/src/views/daydataupload/gdinventory/index.vue +++ b/supervise-customer-ui/src/views/daydataupload/gdinventory/index.vue @@ -35,7 +35,11 @@ @@ -247,33 +251,46 @@ console.log('222', resp) const rdata = resp.data const _this = this - _this.fullscreenloading.text = '数据导入完成,正在生成报表~' - this.fileList = [] - _this.uploadResultMesssage = '共导入数据:' + rdata.allNum + ' 条;普通商品数据:' + rdata.validNum + ' 条;烟草商品数据:' + rdata.errRowNum + ' 条;用时:' + rdata.durations + ' 毫秒。' - const param = { - orderDate: rdata.orderDate - } - req.kcReport(param) - .then(res => { - console.log('333', res) - _this.fullscreenloading.text = '报表数据完成,创建Excel文件' + if (this.fullscreenloading) this.fullscreenloading.close() + this.fullscreenloading = null + _this.uploadResultMesssage = '文件上传完成,正在进行数据整理~' + _this.loadList() + setTimeout(function() { + _this.dialogClose() + }, 3000) + // _this.fullscreenloading.text = '数据导入完成,正在生成报表~' + // this.fileList = [] + // _this.uploadResultMesssage = '共导入数据:' + rdata.allNum + ' 条;普通商品数据:' + rdata.validNum + ' 条;烟草商品数据:' + rdata.errRowNum + ' 条;用时:' + rdata.durations + ' 毫秒。' + // const param = { + // orderDate: rdata.orderDate + // } + // req.kcReport(param) + // .then(res => { + // console.log('333', res) + // _this.fullscreenloading.text = '报表数据完成,创建Excel文件' - req.kcExcel({ logid: rdata.id }) - .then(res => { - if (this.fullscreenloading) this.fullscreenloading.close() - this.fullscreenloading = null - console.log('444', res) - _this.hzFilePath = res.data.fileUrl - }) - .catch(e => { - if (this.fullscreenloading) this.fullscreenloading.close() - this.fullscreenloading = null - }) - }) - .catch(e => { - if (this.fullscreenloading) this.fullscreenloading.close() - this.fullscreenloading = null - }) + // req.kcExcel({ logid: rdata.id }) + // .then(res => { + // if (this.fullscreenloading) this.fullscreenloading.close() + // this.fullscreenloading = null + // console.log('444', res) + // _this.hzFilePath = res.data.fileUrl + // }) + // .catch(e => { + // if (this.fullscreenloading) this.fullscreenloading.close() + // this.fullscreenloading = null + // }) + // }) + // .catch(e => { + // if (this.fullscreenloading) this.fullscreenloading.close() + // this.fullscreenloading = null + // }) + }, + toDownload(row) { + console.log('lll', row) + if (row.fileUrl) { + window.open(row.fileUrl, '_blank') + } }, doDownloadHz() { window.open(this.hzFilePath, '_blank') diff --git a/yxt-supervise-dbcenter/yxt-supervise-dbcenter-ui/src/layout/components/Navbar.vue b/yxt-supervise-dbcenter/yxt-supervise-dbcenter-ui/src/layout/components/Navbar.vue index d669d6e0..d7842b7c 100644 --- a/yxt-supervise-dbcenter/yxt-supervise-dbcenter-ui/src/layout/components/Navbar.vue +++ b/yxt-supervise-dbcenter/yxt-supervise-dbcenter-ui/src/layout/components/Navbar.vue @@ -1,17 +1,17 @@ @@ -22,8 +22,8 @@ Orgname: '', departmentName: '', name: '', - year:'', - pNameAndDepartmentNameAndPostName:'' + year: '', + pNameAndDepartmentNameAndPostName: '' } }, mounted() { diff --git a/yxt-supervise-dbcenter/yxt-supervise-dbcenter-ui/src/settings.js b/yxt-supervise-dbcenter/yxt-supervise-dbcenter-ui/src/settings.js index adef8a7c..358411dc 100644 --- a/yxt-supervise-dbcenter/yxt-supervise-dbcenter-ui/src/settings.js +++ b/yxt-supervise-dbcenter/yxt-supervise-dbcenter-ui/src/settings.js @@ -1,6 +1,6 @@ module.exports = { - title: '汇融云眼贷后监管平台', + title: '汇融云眼仓后监管平台', /** * @type {boolean} true | false diff --git a/yxt-supervise-dbcenter/yxt-supervise-dbcenter-ui/vue.config.js b/yxt-supervise-dbcenter/yxt-supervise-dbcenter-ui/vue.config.js index 93b63c39..ccad0303 100644 --- a/yxt-supervise-dbcenter/yxt-supervise-dbcenter-ui/vue.config.js +++ b/yxt-supervise-dbcenter/yxt-supervise-dbcenter-ui/vue.config.js @@ -6,7 +6,7 @@ function resolve(dir) { return path.join(__dirname, dir) } -const name = defaultSettings.title || '汇融云眼贷后监管平台' // page title +const name = defaultSettings.title || '汇融云仓贷后监管平台' // page title // 如果端口设置为80, // 使用管理员权限执行命令行。 diff --git a/yxt_supervise/supervise-customer/supervise-customer-api/src/main/java/com/yxt/supervise/customer/api/gdinventorylog/GdInventoryLog.java b/yxt_supervise/supervise-customer/supervise-customer-api/src/main/java/com/yxt/supervise/customer/api/gdinventorylog/GdInventoryLog.java index 727267c8..45e0c1bf 100644 --- a/yxt_supervise/supervise-customer/supervise-customer-api/src/main/java/com/yxt/supervise/customer/api/gdinventorylog/GdInventoryLog.java +++ b/yxt_supervise/supervise-customer/supervise-customer-api/src/main/java/com/yxt/supervise/customer/api/gdinventorylog/GdInventoryLog.java @@ -1,5 +1,7 @@ package com.yxt.supervise.customer.api.gdinventorylog; +import cn.hutool.core.lang.UUID; +import cn.hutool.core.util.IdUtil; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import com.yxt.common.core.domain.EntityWithId; @@ -34,4 +36,7 @@ public class GdInventoryLog extends EntityWithId { private long durations; // 程序运行时长/ private int errRowNum; // 出错的条数/ private String orderDate; // 单据日期 + + private String sid = IdUtil.fastSimpleUUID(); + private int state = 0; } diff --git a/yxt_supervise/supervise-customer/supervise-customer-biz/src/main/java/com/yxt/supervise/customer/biz/gdinventorylog/GdInventoryLogService.java b/yxt_supervise/supervise-customer/supervise-customer-biz/src/main/java/com/yxt/supervise/customer/biz/gdinventorylog/GdInventoryLogService.java index 3e18417b..4629eb9d 100644 --- a/yxt_supervise/supervise-customer/supervise-customer-biz/src/main/java/com/yxt/supervise/customer/biz/gdinventorylog/GdInventoryLogService.java +++ b/yxt_supervise/supervise-customer/supervise-customer-biz/src/main/java/com/yxt/supervise/customer/biz/gdinventorylog/GdInventoryLogService.java @@ -58,6 +58,7 @@ public class GdInventoryLogService extends ServiceImpl qw = new QueryWrapper<>(); + qw.eq("fileFullPath", fp); + return baseMapper.selectOne(qw); + } } diff --git a/yxt_supervise/supervise-customer/supervise-customer-biz/src/main/java/com/yxt/supervise/customer/biz/gdinventoryok/GdInventoryOkService.java b/yxt_supervise/supervise-customer/supervise-customer-biz/src/main/java/com/yxt/supervise/customer/biz/gdinventoryok/GdInventoryOkService.java index d5ebea42..959319aa 100644 --- a/yxt_supervise/supervise-customer/supervise-customer-biz/src/main/java/com/yxt/supervise/customer/biz/gdinventoryok/GdInventoryOkService.java +++ b/yxt_supervise/supervise-customer/supervise-customer-biz/src/main/java/com/yxt/supervise/customer/biz/gdinventoryok/GdInventoryOkService.java @@ -3,9 +3,11 @@ package com.yxt.supervise.customer.biz.gdinventoryok; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.FileUtil; +import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.poi.excel.ExcelUtil; import cn.hutool.poi.excel.ExcelWriter; +import cn.hutool.poi.excel.sax.handler.RowHandler; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.read.builder.ExcelReaderBuilder; @@ -20,7 +22,10 @@ import com.yxt.common.core.result.FileUploadResult; import com.yxt.common.core.result.ResultBean; import com.yxt.common.core.vo.PagerVo; import com.yxt.supervise.customer.api.gdinventorylog.GdInventoryLog; -import com.yxt.supervise.customer.api.gdinventoryok.*; +import com.yxt.supervise.customer.api.gdinventoryok.GdInventoryOk; +import com.yxt.supervise.customer.api.gdinventoryok.GdInventoryOkExcelVo; +import com.yxt.supervise.customer.api.gdinventoryok.GdInventoryOkQuery; +import com.yxt.supervise.customer.api.gdinventoryok.GdInventoryOkVo; import com.yxt.supervise.customer.api.gdinventoryyc.GdInventoryYc; import com.yxt.supervise.customer.biz.gdinventorylog.GdInventoryLogService; import com.yxt.supervise.customer.biz.gdinventorylogerr.GdInventoryLogErrService; @@ -28,12 +33,15 @@ import com.yxt.supervise.customer.biz.gdinventoryyc.GdInventoryYcService; import com.yxt.supervise.customer.biz.gdrescategoryprod.GdRescategoryProdService; import com.yxt.supervise.customer.biz.storeindex.StoreIndexService; import com.yxt.supervise.customer.biz.storeinfo.StoreInfoService; +import com.yxt.supervise.customer.feign.report.ReportInventoryFeign; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.ss.usermodel.CellStyle; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; +import javax.annotation.Resource; import java.io.File; import java.util.*; @@ -64,6 +72,9 @@ public class GdInventoryOkService extends MybatisBaseService asyncRead2Db(fp)); +// ExcelUtil.read07BySax(fp, -1, createRowHandler(gdlog)); +// System.out.println("用时:" + (System.currentTimeMillis() - millis)); +// gdlog.setDurations(System.currentTimeMillis() - millis); + + return gdlog; + } + + private void asyncRead2Db(String fp) { + + GdInventoryLog gdlog = gdInventoryLogService.fetchByFileFullPath(fp); + long millis = System.currentTimeMillis(); ExcelReaderBuilder read = EasyExcel.read(fp, GdInventoryOk.class, createReadListener(gdlog)); read.sheet().doRead(); -// System.out.println("用时:" + (System.currentTimeMillis() - millis)); gdlog.setDurations(System.currentTimeMillis() - millis); - gdInventoryLogService.save(gdlog); + gdlog.setState(2); + gdInventoryLogService.updateById(gdlog); - return gdlog; + millis = System.currentTimeMillis(); + ResultBean r = reportInventoryFeign.kcReport(gdlog.getOrderDate()); + gdlog.setState(3); + gdlog.setRemarks(gdlog.getRemarks() + ";创建报表用时:" + (System.currentTimeMillis() - millis)); + gdInventoryLogService.updateById(gdlog); + gdInventoryLogService.buildExcelById(gdlog.getIdStr()); + + } + + private RowHandler createRowHandler(GdInventoryLog gdlog) { + return new RowHandler() { + + private List toInsertList = new ArrayList<>(); + private List toInsertListYc = new ArrayList<>(); + private int x = 0, y = 0, z = 0, errnum = 0; + private int num = 0, numyc = 0; + private String odate = null; + + private Map readMapFromRow(List r) { + Map map = new HashMap<>(); + map.put("orgCode", r.get(0));// 企业组织机构代码证 + map.put("warehouseCode", "" + r.get(1));// 仓库/门店编号 + map.put("warehouseName", r.get(2)); // 仓库/门店名称 + map.put("prodCode", "" + r.get(7)); // 商品编码 + map.put("prodBarCode", r.get(8));// 商品条码 + map.put("prodName", r.get(9)); // 商品名称 + map.put("warehouseType", r.get(10)); // 仓库类型 + map.put("prodNum", r.get(11)); // 商品数量 + map.put("prodValue", r.get(12)); // 商品货值 + map.put("suppliderName", r.get(13)); // 供应商 + map.put("datadate", r.get(14)); // 数据日期 + + + map.put("typeCode", r.get(3)); // 类别编号 + map.put("typeName", r.get(4)); // 类别名称 + map.put("typeOne", r.get(5)); // 一级类别名称 + map.put("typeTwo", r.get(6)); // 二级类别名称 + + return map; + } + + private boolean checkYcProd(String typeCode) { + if (StrUtil.isBlank(typeCode)) + return false; + if (typeCode.length() < 4) + return false; + String subCode = typeCode.substring(0, 4); + return "0811".equals(subCode) || "0813".equals(subCode) || "0815".equals(subCode); + } + + @Override + public void handle(int sheetIndex, long rowIndex, List r) { + String typeCode = "" + r.get(3); + if (rowIndex > 0 && StringUtils.isNotBlank(typeCode)) { + String prodCode = "" + r.get(7); + String warehouseCode = "" + r.get(1); + + if (StrUtil.isBlank(odate)) { + odate = "" + r.get(14); + gdlog.setOrderDate(odate); + } + + // System.out.println(",X:" + x + ",prodCode:" + prodCode); + + if (checkYcProd(typeCode)) { + GdInventoryYc yc = new GdInventoryYc(); + Map map = readMapFromRow(r); + + try { + BeanUtil.fillBeanWithMap(map, yc, true); + toInsertListYc.add(yc); + z++; + } catch (Exception e) { + errnum++; + e.printStackTrace(); + } + + if (990 == numyc) { + gdInventoryYcService.saveBatch(toInsertListYc); + numyc = 0; + toInsertListYc.clear(); + } else { + numyc++; + } + } else { + GdInventoryOk ok = new GdInventoryOk(); + Map map = readMapFromRow(r); + + try { + BeanUtil.fillBeanWithMap(map, ok, true); + toInsertList.add(ok); + y++; + } catch (Exception e) { + errnum++; + e.printStackTrace(); + } + + if (990 == num) { + GdInventoryOkService.this.saveBatch(toInsertList); + num = 0; + toInsertList.clear(); + } else { + num++; + } + } + x++; +// System.out.println(",X:" + x + ",Y:" + y); + } + } + + @Override + public void handleCell(int sheetIndex, long rowIndex, int cellIndex, Object value, CellStyle xssfCellStyle) { + RowHandler.super.handleCell(sheetIndex, rowIndex, cellIndex, value, xssfCellStyle); + } + + @Override + public void doAfterAllAnalysed() { + if (toInsertList != null && !toInsertList.isEmpty()) { + GdInventoryOkService.this.saveBatch(toInsertList); + } + if (toInsertListYc != null && !toInsertListYc.isEmpty()) { + gdInventoryYcService.saveBatch(toInsertListYc); + } + + gdlog.setAllNum(x); + gdlog.setValidNum(y); + gdlog.setErrRowNum(z); + RowHandler.super.doAfterAllAnalysed(); + } + }; } private ReadListener createReadListener(GdInventoryLog gdlog) { diff --git a/yxt_supervise/supervise-customer/supervise-customer-biz/src/main/java/com/yxt/supervise/customer/feign/report/ReportInventoryFeign.java b/yxt_supervise/supervise-customer/supervise-customer-biz/src/main/java/com/yxt/supervise/customer/feign/report/ReportInventoryFeign.java new file mode 100644 index 00000000..67d5e61b --- /dev/null +++ b/yxt_supervise/supervise-customer/supervise-customer-biz/src/main/java/com/yxt/supervise/customer/feign/report/ReportInventoryFeign.java @@ -0,0 +1,19 @@ +package com.yxt.supervise.customer.feign.report; + +import com.yxt.common.core.result.ResultBean; +import org.apache.commons.lang3.StringUtils; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +@FeignClient( + contextId = "supervise-report-ReportInventory", + name = "supervise-report", + path = "/reportinventory") +public interface ReportInventoryFeign { + + @GetMapping("/kcReport") + public ResultBean kcReport(@RequestParam("orderDate") String orderDate); +} + + diff --git a/yxt_supervise/supervise-customer/supervise-customer-biz/src/main/resources/application.yml b/yxt_supervise/supervise-customer/supervise-customer-biz/src/main/resources/application.yml index 28e3f80f..210376de 100644 --- a/yxt_supervise/supervise-customer/supervise-customer-biz/src/main/resources/application.yml +++ b/yxt_supervise/supervise-customer/supervise-customer-biz/src/main/resources/application.yml @@ -13,8 +13,8 @@ spring: # brokers: localhost:9092 #kafka的网络位置 # auto-create-topics: true profiles: - active: devv -# active: test +# active: devv + active: test messages: # 国际化资源文件路径 basename: i18n/messages @@ -61,6 +61,20 @@ logging: demojar: mapper: DEBUG +#hystrix的超时时间 +hystrix: + command: + default: + execution: + timeout: + enabled: true + isolation: + thread: + timeoutInMilliseconds: 60000 +#ribbon的超时时间 +ribbon: + ReadTimeout: 60000 + ConnectTimeout: 60000 diff --git a/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/resources/application.yml b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/resources/application.yml index bd6f0bf0..3f3bc859 100644 --- a/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/resources/application.yml +++ b/yxt_supervise/supervise-portal/supervise-portal-biz/src/main/resources/application.yml @@ -2,8 +2,8 @@ spring: application: name: supervise-portal profiles: -# active: devv - active: test + active: devv +# active: test messages: # 国际化资源文件路径 basename: i18n/messages diff --git a/yxt_supervise/supervise-report/supervise-report-biz/src/main/java/com/yxt/supervise/report/biz/reportinventory/ReportInventoryDayGatherService.java b/yxt_supervise/supervise-report/supervise-report-biz/src/main/java/com/yxt/supervise/report/biz/reportinventory/ReportInventoryDayGatherService.java index 19c3631c..c8f51e69 100644 --- a/yxt_supervise/supervise-report/supervise-report-biz/src/main/java/com/yxt/supervise/report/biz/reportinventory/ReportInventoryDayGatherService.java +++ b/yxt_supervise/supervise-report/supervise-report-biz/src/main/java/com/yxt/supervise/report/biz/reportinventory/ReportInventoryDayGatherService.java @@ -17,8 +17,9 @@ public class ReportInventoryDayGatherService extends ServiceImpl whInList = new ArrayList<>(); double countAmount = 0.0; - String serialNumber = "" + System.currentTimeMillis(); - String reportTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm"); + Date currentDateTime = new Date(); + String serialNumber = DateUtil.format(currentDateTime, "yyyyMMddHHmmssSSS"); + String reportTime = DateUtil.format(currentDateTime, "yyyy-MM-dd HH:mm"); List> whList = baseMapper.warehouseList(); for (Map map : whList) { diff --git a/yxt_supervise/supervise-report/supervise-report-biz/src/main/resources/application.yml b/yxt_supervise/supervise-report/supervise-report-biz/src/main/resources/application.yml index e1efb4fe..0081fe0c 100644 --- a/yxt_supervise/supervise-report/supervise-report-biz/src/main/resources/application.yml +++ b/yxt_supervise/supervise-report/supervise-report-biz/src/main/resources/application.yml @@ -15,8 +15,8 @@ spring: # brokers: localhost:9092 #kafka的网络位置 # auto-create-topics: true profiles: - active: devv -# active: test +# active: devv + active: test messages: # 国际化资源文件路径 basename: i18n/messages @@ -54,6 +54,20 @@ mybatis-plus: call-setters-on-nulls: true log-impl: org.apache.ibatis.logging.stdout.StdOutImpl +#hystrix的超时时间 +hystrix: + command: + default: + execution: + timeout: + enabled: true + isolation: + thread: + timeoutInMilliseconds: 60000 +#ribbon的超时时间 +ribbon: + ReadTimeout: 60000 + ConnectTimeout: 60000