Browse Source

批发数据导入、导出

master
lzh 2 years ago
parent
commit
04d54acc71
  1. 14
      base-ui/src/api/kucun/wholesale.js
  2. 80
      base-ui/src/views/kucun/pfsjgl/index.vue
  3. 230
      base-ui/src/views/kucun/xssjgl/index.vue
  4. 18
      yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdwholesale/GdWholesaleLogService.java
  5. 26
      yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdwholesale/GdWholesaleMapper.java
  6. 6
      yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdwholesale/GdWholesaleRest.java
  7. 63
      yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdwholesale/GdWholesaleService.java

14
base-ui/src/api/kucun/wholesale.js

@ -1,8 +1,20 @@
import request from '@/utils/request'
// 条件查询
export function exportExcel(logId) {
export function buildExcel(logId) {
return request({
url: '/wholesale/buildExcel/' + logId
})
}
// 加盟店入库明细表按天查询
export function logsPagerList(data) {
return request({
url: '/wholesale/logsPagerList',
data,
method: 'post',
headers: {
'Content-Type': 'application/json'
}
})
}

80
base-ui/src/views/kucun/pfsjgl/index.vue

@ -38,24 +38,14 @@
<el-table-column fixed width="50" type="selection" align="center" />
<el-table-column fixed width="180" label="操作" align="center">
<template slot-scope="scope">
<el-button type="primary" size="mini" @click="toEdit(scope.row)">办理</el-button>
<el-button type="primary" size="mini">撤回</el-button>
<el-button type="primary" size="mini" @click="toInfo(scope.row)">查看</el-button>
<el-button type="primary" size="mini" @click="downExcel(scope.row)">下载批发数据Excel</el-button>
</template>
</el-table-column>
<el-table-column prop="createSid" label="状态" align="center" width="120" />
<el-table-column prop="code" label="订单编号" align="center" width="150" />
<el-table-column prop="buyerName" label="填单人" align="center" width="120" />
<el-table-column label="填单日期" align="center" width="120">
<template slot-scope="scope">
<span>{{ scope.row.purchaseDate.substring(0, scope.row.purchaseDate.length - 9) }}</span>
</template>
</el-table-column>
<el-table-column prop="supplierName" label="供应商单位" header-align="center" align="left" />
<el-table-column prop="packageTotalPrice" label="订单金额(元)" align="center" />
<el-table-column prop="purchasingDeptName" label="要货单位" align="center" />
<el-table-column prop="arrivalDate" label="到货日期" align="center" width="120" />
<el-table-column prop="completionStatus" label="完成状态" align="center" width="120" />
<el-table-column prop="orderDate" label="单据日期" align="center" width="120" />
<el-table-column prop="createTime" label="记录创建时间" align="center" />
<el-table-column prop="allNum" label="总记录数" align="center" width="120" />
<el-table-column prop="validNum" label="监管记录数" align="center" width="120" />
<el-table-column prop="supplierName" label="出错的条数" align="center" width="120" />
</el-table>
</div>
<!-- End 项目列表 -->
@ -91,24 +81,15 @@
<div>共导入数据{{ currentLog.allNum }} 符合监管条件的数据{{ currentLog.validNum }} 用时{{ currentLog.durations }} 毫秒</div>
</el-card>
</div>
<div>
<h3>库存汇总数据</h3>
<el-card class="box-card">
<div>{{ hzResultMesssage }}</div>
<div>
<el-button :disabled="!hzFilePath" size="small" type="primary" @click="doDownloadHz">下载汇总文件</el-button>
<el-button :disabled="!ychzFilePath" size="small" type="primary" @click="doDownloadHzYc">下载烟草汇总文件</el-button>
</div>
</el-card>
</div>
<div><el-button :disabled="filecandown" size="small" type="primary" @click="doDownloadHz">下载批发数据文件</el-button></div>
</el-card>
<span slot="footer" class="dialog-footer"><el-button @click="dialogVisible = false"> </el-button></span>
<span slot="footer" class="dialog-footer"><el-button @click="dialogClose"> </el-button></span>
</el-dialog>
</div>
</template>
<script>
import { exportExcel } from '@/api/kucun/wholesale'
import { buildExcel, logsPagerList } from '@/api/kucun/wholesale'
import ButtonBar from '@/components/ButtonBar'
import Pagination from '@/components/pagination'
import pageye from '@/components/pagination/pageye'
@ -156,6 +137,7 @@ export default {
updateAction: process.env.VUE_APP_BASE_API + '/wholesale/uploadPszxpfsj',
fileList: [],
currentLog: {},
filecandown: true,
fullscreenloading: null,
name: '批发数据管理'
}
@ -164,8 +146,7 @@ export default {
this.$refs['btnbar'].setButtonList(this.btnList)
},
created() {
//
// this.loadList()
this.loadList()
},
methods: {
//
@ -209,7 +190,19 @@ export default {
}
this.loadList()
},
loadList() {},
loadList() {
logsPagerList(this.queryParams)
.then(res => {
console.log('1111', res)
this.dataList = res.data.records
this.queryParams.total = res.data.total
this.queryParams.current = res.data.current
this.queryParams.size = res.data.size
})
.catch(e => {
console.log(e)
})
},
toAdd() {
this.dialogVisible = true
},
@ -217,7 +210,12 @@ export default {
this.$store.dispatch('tagsView/delView', this.$route)
this.$router.go(-1)
},
dialogClose() {},
dialogClose() {
this.currentLog = {}
this.fileList = []
this.filecandown = true
this.dialogVisible = false
},
submitUpload() {
this.$refs.upload.submit()
},
@ -238,11 +236,12 @@ export default {
_this.fullscreenloading.text = '数据导入完成,进行数据整理'
_this.currentLog = resp.data
exportExcel(_this.currentLog.idStr)
buildExcel(_this.currentLog.idStr)
.then(res => {
if (this.fullscreenloading) this.fullscreenloading.close()
this.fullscreenloading = null
_this.currentLog = resp.data
_this.currentLog = res.data
_this.filecandown = false
})
.catch(e => {
if (this.fullscreenloading) this.fullscreenloading.close()
@ -250,7 +249,18 @@ export default {
})
},
doDownloadHz() {
window.open(this.hzFilePath, '_blank')
window.open(this.currentLog.fileUrl, '_blank')
this.dialogClose()
},
downExcel(row) {
if (row.fileUrl) {
window.open(row.fileUrl, '_blank')
} else {
this.$message({
message: '无数据,不能导出!',
type: 'error'
})
}
}
}
}

230
base-ui/src/views/kucun/xssjgl/index.vue

@ -1,36 +1,236 @@
<template>
<div class="app-container">
<el-card class="box-card">
<div slot="header" class="clearfix"><span>下载汇总数据</span></div>
<div>
<el-button>在途数据下载</el-button>
<el-button>销售数据下载</el-button>
<div v-show="viewState == 1">
<button-bar ref="btnbar" view-title="批发数据上传记录" :btndisabled="btndisabled" @btnhandle="btnHandle" />
<div class="main-content">
<div class="searchcon">
<el-button size="small" class="searchbtn" @click="clicksearchShow">{{ searchxianshitit }}</el-button>
<div v-show="isSearchShow" class="search">
<el-form ref="queryParams" :inline="true" :model="queryParams" class="tab-header">
<el-form-item label="数据日期">
<el-date-picker v-model="queryParams.params.orderDateStart" type="date" clearable value-format="yyyy-MM-dd" placeholder="选择日期" />
<span style="padding: 0 8px"></span>
<el-date-picker v-model="queryParams.params.orderDateEnd" type="date" clearable value-format="yyyy-MM-dd" placeholder="选择日期" />
</el-form-item>
</el-form>
<div class="btn" style="text-align: center;">
<el-button type="primary" size="small" icon="el-icon-search" @click="dosearch">查询</el-button>
<el-button type="primary" size="small" icon="el-icon-refresh" @click="resetQuery">重置</el-button>
</div>
</div>
</div>
<!-- Start 项目列表头部 -->
<div class="listtop">
<div class="tit">采购订单列表</div>
<pageye
v-show="dataList.length > 0"
:total="queryParams.total"
:page.sync="queryParams.current"
:limit.sync="queryParams.size"
class="pagination"
@pagination="loadList"
/>
</div>
<!-- End 项目列表头部 -->
<!-- Start 项目列表 -->
<div class="">
<el-table v-loading="tableLoading" :data="dataList" border style="width: 100%" @selection-change="handleSelectionChange">
<el-table-column fixed width="50" type="selection" align="center" />
<el-table-column fixed width="180" label="操作" align="center">
<template slot-scope="scope">
<el-button type="primary" size="mini" @click="downExcel(scope.row)">下载批发数据Excel</el-button>
</template>
</el-table-column>
<el-table-column prop="orderDate" label="单据日期" align="center" width="120" />
<el-table-column prop="createTime" label="记录创建时间" align="center" />
<el-table-column prop="allNum" label="总记录数" align="center" width="120" />
<el-table-column prop="validNum" label="监管记录数" align="center" width="120" />
<el-table-column prop="supplierName" label="出错的条数" align="center" width="120" />
</el-table>
</div>
<!-- End 项目列表 -->
<div class="pages">
<div class="tit" />
<!-- 翻页 -->
<pagination v-show="dataList.length > 0" :total="queryParams.total" :page.sync="queryParams.current" :limit.sync="queryParams.size" @pagination="loadList" />
</div>
</div>
</div>
</el-card>
</div>
</template>
<script>
import ButtonBar from '@/components/ButtonBar'
import Pagination from '@/components/pagination'
import pageye from '@/components/pagination/pageye'
export default {
name: 'KucunXssjglIndex',
// components: { },
components: {
ButtonBar,
Pagination,
pageye
},
data() {
return {
btndisabled: false,
viewState: 1, // 1 2 3 4
isSearchShow: false,
searchxianshitit: '显示查询条件',
btnList: [
{
type: 'primary',
size: 'small',
icon: 'upload',
btnKey: 'toAdd',
btnLabel: '上传批发数据'
},
{
type: 'info',
size: 'small',
icon: 'cross',
btnKey: 'doClose',
btnLabel: '关闭'
}
],
tableLoading: false,
dataList: [],
queryParams: {
current: 1,
size: 10,
total: 0,
params: {
orderDateStart: '',
orderDateEnd: ''
}
},
dialogVisible: false,
updateAction: process.env.VUE_APP_BASE_API + '/wholesale/uploadPszxpfsj',
fileList: [],
currentLog: {},
filecandown: true,
fullscreenloading: null,
name: '销售数据管理'
}
},
mounted() {
this.$refs['btnbar'].setButtonList(this.btnList)
},
created() {
//
this.init()
//
// this.getList()
this.loadList()
},
methods: {
init() {},
getList() {},
//
handleReturn() {
//
clicksearchShow() {
this.isSearchShow = !this.isSearchShow
if (this.isSearchShow) {
this.searchxianshitit = '隐藏查询条件'
} else {
this.searchxianshitit = '显示查询条件'
}
},
btnHandle(btnKey) {
switch (btnKey) {
case 'toAdd':
this.toAdd()
break
case 'doDel':
this.doDel()
break
case 'doClose':
this.doClose()
break
default:
break
}
},
handleSelectionChange(row) {},
dosearch() {
this.queryParams.current = 1
this.loadList()
},
resetQuery() {
this.queryParams = {
current: 1,
size: 10,
total: 0,
params: {
orderDateStart: '',
orderDateEnd: ''
}
}
this.loadList()
},
loadList() {
logsPagerList(this.queryParams)
.then(res => {
console.log('1111', res)
this.dataList = res.data.records
this.queryParams.total = res.data.total
this.queryParams.current = res.data.current
this.queryParams.size = res.data.size
})
.catch(e => {
console.log(e)
})
},
toAdd() {
this.dialogVisible = true
},
doClose() {
this.$store.dispatch('tagsView/delView', this.$route)
this.$router.go(-1)
},
dialogClose() {
this.currentLog = {}
this.fileList = []
this.filecandown = true
this.dialogVisible = false
},
submitUpload() {
this.$refs.upload.submit()
},
handleProgress(event, file, fileList) {
const _this = this
this.fullscreenloading = this.$loading({
lock: true,
text: '文件正在上传',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
if (event.percent >= 100) {
_this.fullscreenloading.text = '上传完成,正在导入数据库'
}
},
handleSuccess(resp, file, fileList) {
const _this = this
_this.fullscreenloading.text = '数据导入完成,进行数据整理'
_this.currentLog = resp.data
buildExcel(_this.currentLog.idStr)
.then(res => {
if (this.fullscreenloading) this.fullscreenloading.close()
this.fullscreenloading = null
_this.currentLog = res.data
_this.filecandown = false
})
.catch(e => {
if (this.fullscreenloading) this.fullscreenloading.close()
this.fullscreenloading = null
})
},
doDownloadHz() {
window.open(this.currentLog.fileUrl, '_blank')
this.dialogClose()
},
downExcel(row) {
if (row.fileUrl) {
window.open(row.fileUrl, '_blank')
} else {
this.$message({
message: '无数据,不能导出!',
type: 'error'
})
}
}
}
}

18
yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdwholesale/GdWholesaleLogService.java

@ -2,6 +2,7 @@ package com.yxt.supervise.portal.biz.gdwholesale;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yxt.common.base.utils.PagerUtil;
@ -19,15 +20,26 @@ public class GdWholesaleLogService extends ServiceImpl<GdWholesaleLogMapper,GdWh
GdWholesaleQuery query = pq.getParams();
QueryWrapper<GdWholesaleLog> qw = new QueryWrapper<>();
if (StrUtil.isNotBlank(query.getOrderDateStart())) {
qw.ge("dataDate",query.getOrderDateStart());
qw.ge("orderDate", query.getOrderDateStart());
}
if (StrUtil.isNotBlank(query.getOrderDateEnd())) {
qw.lt("dataDate",query.getOrderDateEnd());
qw.lt("orderDate", query.getOrderDateEnd());
}
qw.orderByDesc("dataDate");
qw.orderByDesc("orderDate");
IPage<GdWholesaleLog> page = PagerUtil.queryToPage(pq);
IPage<GdWholesaleLog> pagging = baseMapper.selectPage(page, qw);
PagerVo<GdWholesaleLog> p = PagerUtil.pageToVo(pagging, null);
return p;
}
public GdWholesaleLog fetchById(String logId) {
return baseMapper.selectById(logId);
}
public void updateUrlById(String id, String url) {
UpdateWrapper<GdWholesaleLog> uw = new UpdateWrapper<>();
uw.set("fileUrl", url);
uw.eq("id", id);
baseMapper.update(null, uw);
}
}

26
yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdwholesale/GdWholesaleMapper.java

@ -4,10 +4,36 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@Mapper
public interface GdWholesaleMapper extends BaseMapper<GdWholesale> {
@Delete("delete from gd_wholesale where dataDate=#{dataDate} ")
void clearByDataDate(@Param("dataDate") String dataDate);
// @Select("SELECT " +
// "orderType as 订单类型, " +
// "orderNo as 销售订单号, " +
// "prodCode as 商品编码, " +
// "prodBarCode as 商品条码, " +
// "prodName as 商品名称, " +
// "brandCode as 品牌代码, " +
// "brandName as 品牌名称, " +
// "categoryb as 商品大类, " +
// "categorym as 商品中类, " +
// "categorys as 商品小类, " +
// "customerCode as 客户代码, " +
// "customerName as 客户名称, " +
// "saleNum as 销售数量, " +
// "storeCode as 销售渠道, " +
// "salePrice as 销售价格, " +
// "saleCost as 销售成本, " +
// "profit as 利润, " +
// "dataDate as 数据日期 " +
// " FROM gd_wholesale where dataDate=#{dataDate} ")
@Select("SELECT * FROM gd_wholesale where dataDate=#{dataDate} ")
List<GdWholesale> excelListByOrderDate(@Param("dataDate") String orderDate);
}

6
yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdwholesale/GdWholesaleRest.java

@ -36,8 +36,8 @@ public class GdWholesaleRest {
return rb.success().setData(pv);
}
@GetMapping("/buildExcel/logId")
public ResultBean<GdWholesaleLog> buildExcel() {
return gdWholesaleService.buildExcel();
@GetMapping("/buildExcel/{logId}")
public ResultBean<GdWholesaleLog> buildExcel(@PathVariable("logId") String logId) {
return gdWholesaleService.buildExcel(logId);
}
}

63
yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/gdwholesale/GdWholesaleService.java

@ -1,24 +1,33 @@
package com.yxt.supervise.portal.biz.gdwholesale;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yxt.common.base.config.component.FileUploadComponent;
import com.yxt.common.core.result.FileUploadResult;
import com.yxt.common.core.result.ResultBean;
import com.yxt.supervise.portal.biz.gdinstorage.GdInstorageGd;
import com.yxt.supervise.portal.biz.gdinventory.GdRescategoryProdService;
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 java.io.File;
import java.util.ArrayList;
import java.util.List;
@Service
public class GdWholesaleService extends ServiceImpl<GdWholesaleMapper, GdWholesale> {
@Value("${image.upload.path:static/upload/}")
private String uploadPath;
@Value("${image.url.prefix:http://127.0.0.1:8080/upload/}")
private String urlPrefix;
@Autowired
private FileUploadComponent fileUploadComponent;
@Autowired
@ -83,6 +92,8 @@ public class GdWholesaleService extends ServiceImpl<GdWholesaleMapper, GdWholesa
String prodCode = "" + r.get(3); //商品编码
String dataDate = "" + r.get(18); //数据日期
if (StrUtil.isNotBlank(prodCode)) { //商品编码不为空才插入,过滤掉统计行
if (odate == null)
odate = dataDate;
GdWholesaleGd gd = rowToEntity(r);
toInsertListGd.add(gd);
if (gdRescategoryProdService.containsCode(prodCode)) {
@ -112,6 +123,7 @@ public class GdWholesaleService extends ServiceImpl<GdWholesaleMapper, GdWholesa
gdlog.setAllNum(x);
gdlog.setValidNum(y);
gdlog.setErrRowNum(errnum);
gdlog.setOrderDate(odate);
RowHandler.super.doAfterAllAnalysed();
}
};
@ -121,8 +133,51 @@ public class GdWholesaleService extends ServiceImpl<GdWholesaleMapper, GdWholesa
baseMapper.clearByDataDate(dataDate);
}
public ResultBean<GdWholesaleLog> buildExcel() {
return null;
public ResultBean<GdWholesaleLog> buildExcel(String logId) {
ResultBean rb = ResultBean.fireFail();
GdWholesaleLog gwl = gdWholesaleLogService.fetchById(logId);
if (gwl == null)
return rb.setMsg("上传记录未找到");
String orderDate = gwl.getOrderDate();
String tfile = "kchzb/批发数据" + orderDate + ".xlsx";
String url = urlPrefix + tfile;
String toFileName = uploadPath + tfile;
List<GdWholesale> toList = baseMapper.excelListByOrderDate(orderDate);
if (toList == null || toList.isEmpty())
return rb.setMsg("没有该日期的批发数据");
// File file = FileUtil.file(toFileName);
ExcelWriter writer = ExcelUtil.getWriter(toFileName);
writer.addHeaderAlias("id", "编号");
writer.addHeaderAlias("orgCode", "企业组织机构代码证");
writer.addHeaderAlias("orderType", "订单类型");
writer.addHeaderAlias("orderNo", "销售订单号");
writer.addHeaderAlias("prodCode", "商品编码");
writer.addHeaderAlias("prodBarCode", "商品条码");
writer.addHeaderAlias("prodName", "商品名称");
writer.addHeaderAlias("brandCode", "品牌代码");
writer.addHeaderAlias("brandName", "品牌名称");
writer.addHeaderAlias("categoryb", "商品大类");
writer.addHeaderAlias("categorym", "商品中类");
writer.addHeaderAlias("categorys", "商品小类");
writer.addHeaderAlias("customerCode", "客户代码");
writer.addHeaderAlias("customerName", "客户名称");
writer.addHeaderAlias("saleNum", "销售数量");
writer.addHeaderAlias("storeCode", "销售渠道");
writer.addHeaderAlias("salePrice", "销售价格");
writer.addHeaderAlias("saleCost", "销售成本");
writer.addHeaderAlias("profit", "利润");
writer.addHeaderAlias("dataDate", "数据日期");
writer.write(toList);
writer.flush();
writer.close();
gwl.setFileUrl(url);
gwl.setOutFilePath(toFileName);
gdWholesaleLogService.updateById(gwl);
return rb.success().setData(gwl);
}
}

Loading…
Cancel
Save