
16 changed files with 408 additions and 2 deletions
@ -0,0 +1,69 @@ |
|||
{ |
|||
"name": "admin-template", |
|||
"version": "4.4.0", |
|||
"description": "A vue admin template with Element UI & axios & iconfont & permission control & lint", |
|||
"author": "Pan <panfree23@gmail.com>", |
|||
"scripts": { |
|||
"dev": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve", |
|||
"build:prod": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build", |
|||
"build:stage": "vue-cli-service build --mode staging", |
|||
"preview": "node build/index.js --preview", |
|||
"svgo": "svgo -f src/icons/svg --config=src/icons/svgo.yml", |
|||
"lint": "eslint --ext .js,.vue src", |
|||
"test:unit": "jest --clearCache && vue-cli-service test:unit", |
|||
"test:ci": "npm run lint && npm run test:unit" |
|||
}, |
|||
"dependencies": { |
|||
"axios": "0.18.1", |
|||
"core-js": "^3.26.1", |
|||
"element-ui": "2.13.2", |
|||
"js-cookie": "2.2.0", |
|||
"normalize.css": "7.0.0", |
|||
"nprogress": "0.2.0", |
|||
"path-to-regexp": "2.4.0", |
|||
"portfinder": "^1.0.21", |
|||
"qs": "^6.9.4", |
|||
"sass-resources-loader": "^2.1.1", |
|||
"viewerjs": "^1.9.0", |
|||
"vue": "2.6.10", |
|||
"vue-amap": "^0.5.10", |
|||
"vue-router": "3.0.6", |
|||
"vuex": "3.1.0", |
|||
"vuex-persistedstate": "^4.0.0" |
|||
}, |
|||
"devDependencies": { |
|||
"@vue/cli-plugin-babel": "4.4.4", |
|||
"@vue/cli-plugin-eslint": "4.4.4", |
|||
"@vue/cli-plugin-unit-jest": "4.4.4", |
|||
"@vue/cli-service": "4.4.4", |
|||
"@vue/test-utils": "1.0.0-beta.29", |
|||
"autoprefixer": "9.5.1", |
|||
"babel-eslint": "10.1.0", |
|||
"babel-jest": "23.6.0", |
|||
"babel-plugin-dynamic-import-node": "2.3.3", |
|||
"babel-polyfill": "^6.26.0", |
|||
"chalk": "2.4.2", |
|||
"connect": "3.6.6", |
|||
"eslint": "6.7.2", |
|||
"eslint-plugin-vue": "6.2.2", |
|||
"html-webpack-plugin": "3.2.0", |
|||
"mockjs": "1.0.1-beta3", |
|||
"runjs": "4.3.2", |
|||
"sass": "1.26.8", |
|||
"sass-loader": "8.0.2", |
|||
"script-ext-html-webpack-plugin": "2.1.3", |
|||
"serve-static": "1.13.2", |
|||
"svg-sprite-loader": "4.1.3", |
|||
"svgo": "1.2.2", |
|||
"vue-template-compiler": "2.6.10" |
|||
}, |
|||
"browserslist": [ |
|||
"> 1%", |
|||
"last 2 versions" |
|||
], |
|||
"engines": { |
|||
"node": ">=8.9", |
|||
"npm": ">= 3.0.0" |
|||
}, |
|||
"license": "MIT" |
|||
} |
@ -0,0 +1,30 @@ |
|||
package com.yxt.supervise.portal.biz.gdwholesale; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.yxt.common.core.domain.EntityWithId; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
@TableName("gd_wholesale") |
|||
public class GdWholesale extends EntityWithId { |
|||
|
|||
private String orgCode; // 企业组织机构代码证
|
|||
private String orderType; // 订单类型
|
|||
private String orderNo; // 销售订单号
|
|||
private String prodCode; // 商品编码
|
|||
private String prodBarCode; // 商品条码
|
|||
private String prodName; // 商品名称
|
|||
private String brandCode; // 品牌代码
|
|||
private String brandName; // 品牌名称
|
|||
private String categoryb; // 商品大类
|
|||
private String categorym; // 商品中类
|
|||
private String categorys; // 商品小类
|
|||
private String customerCode; // 客户代码
|
|||
private String customerName; // 客户名称
|
|||
private String saleNum; // 销售数量
|
|||
private String storeCode; // 销售渠道
|
|||
private String salePrice; // 销售价格
|
|||
private String saleCost; // 销售成本
|
|||
private String profit; // 利润
|
|||
private String dataDate; // 数据日期
|
|||
} |
@ -0,0 +1,30 @@ |
|||
package com.yxt.supervise.portal.biz.gdwholesale; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.yxt.common.core.domain.EntityWithId; |
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
@TableName("gd_wholesale_gd") |
|||
public class GdWholesaleGd extends EntityWithId { |
|||
|
|||
private String orgCode; // 企业组织机构代码证
|
|||
private String orderType; // 订单类型
|
|||
private String orderNo; // 销售订单号
|
|||
private String prodCode; // 商品编码
|
|||
private String prodBarCode; // 商品条码
|
|||
private String prodName; // 商品名称
|
|||
private String brandCode; // 品牌代码
|
|||
private String brandName; // 品牌名称
|
|||
private String categoryb; // 商品大类
|
|||
private String categorym; // 商品中类
|
|||
private String categorys; // 商品小类
|
|||
private String customerCode; // 客户代码
|
|||
private String customerName; // 客户名称
|
|||
private String saleNum; // 销售数量
|
|||
private String storeCode; // 销售渠道
|
|||
private String salePrice; // 销售价格
|
|||
private String saleCost; // 销售成本
|
|||
private String profit; // 利润
|
|||
private String dataDate; // 数据日期
|
|||
} |
@ -0,0 +1,13 @@ |
|||
package com.yxt.supervise.portal.biz.gdwholesale; |
|||
|
|||
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; |
|||
|
|||
@Mapper |
|||
public interface GdWholesaleGdMapper extends BaseMapper<GdWholesaleGd> { |
|||
|
|||
@Delete("delete from gd_wholesale_gd where dataDate=#{dataDate} ") |
|||
void clearByDataDate(@Param("dataDate") String dataDate); |
|||
} |
@ -0,0 +1,11 @@ |
|||
package com.yxt.supervise.portal.biz.gdwholesale; |
|||
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class GdWholesaleGdService extends ServiceImpl<GdWholesaleGdMapper, GdWholesaleGd> { |
|||
public void clearByDataDate(String dataDate) { |
|||
baseMapper.clearByDataDate(dataDate); |
|||
} |
|||
} |
@ -0,0 +1,31 @@ |
|||
package com.yxt.supervise.portal.biz.gdwholesale; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import com.yxt.common.core.domain.EntityWithId; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
@Data |
|||
@TableName("gd_wholesale_log") |
|||
public class GdWholesaleLog extends EntityWithId { |
|||
public GdWholesaleLog() { |
|||
} |
|||
|
|||
public GdWholesaleLog(String fileFullPath) { |
|||
this.fileFullPath = fileFullPath; |
|||
} |
|||
|
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
|||
private Date createTime = new Date(); // 记录创建时间/
|
|||
private String remarks; // 备注说明',
|
|||
private String fileFullPath; // 文件完整路径',
|
|||
private String outFilePath; // 汇总文件路径',
|
|||
private String fileUrl; // 文件下载地址',
|
|||
private int allNum = 0; // 总记录数',
|
|||
private int validNum = 0; // 有效记录数',
|
|||
private long durations = 0; // 程序运行时长',
|
|||
private int errRowNum = 0; // 出错的条数',
|
|||
private String orderDate; // 单据日期',
|
|||
} |
@ -0,0 +1,24 @@ |
|||
package com.yxt.supervise.portal.biz.gdwholesale; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import com.yxt.common.core.domain.EntityWithId; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
@Data |
|||
@TableName("gd_wholesale_log_err") |
|||
public class GdWholesaleLogErr extends EntityWithId { |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
|||
private Date createTime = new Date(); // 记录创建时间',
|
|||
private String remarks; // 备注说明',
|
|||
private String fileFullPath; // 文件完整路径',
|
|||
private String errInfo; // 异常信息',
|
|||
private String rowContent; // 原记录内容',
|
|||
private int rowNum; // 出错行数',
|
|||
private String orderDate; // 单据日期
|
|||
private String orderNo; // 销售订单号
|
|||
private String prodCode; //商品编码
|
|||
private String prodName; //商品名称
|
|||
} |
@ -0,0 +1,8 @@ |
|||
package com.yxt.supervise.portal.biz.gdwholesale; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
@Mapper |
|||
public interface GdWholesaleLogErrMapper extends BaseMapper<GdWholesaleLogErr> { |
|||
} |
@ -0,0 +1,8 @@ |
|||
package com.yxt.supervise.portal.biz.gdwholesale; |
|||
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class GdWholesaleLogErrService extends ServiceImpl<GdWholesaleLogErrMapper, GdWholesaleLogErr> { |
|||
} |
@ -0,0 +1,8 @@ |
|||
package com.yxt.supervise.portal.biz.gdwholesale; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
@Mapper |
|||
public interface GdWholesaleLogMapper extends BaseMapper<GdWholesaleLog> { |
|||
} |
@ -0,0 +1,8 @@ |
|||
package com.yxt.supervise.portal.biz.gdwholesale; |
|||
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class GdWholesaleLogService extends ServiceImpl<GdWholesaleLogMapper,GdWholesaleLog> { |
|||
} |
@ -0,0 +1,13 @@ |
|||
package com.yxt.supervise.portal.biz.gdwholesale; |
|||
|
|||
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; |
|||
|
|||
@Mapper |
|||
public interface GdWholesaleMapper extends BaseMapper<GdWholesale> { |
|||
|
|||
@Delete("delete from gd_wholesale where dataDate=#{dataDate} ") |
|||
void clearByDataDate(@Param("dataDate") String dataDate); |
|||
} |
@ -0,0 +1,28 @@ |
|||
package com.yxt.supervise.portal.biz.gdwholesale; |
|||
|
|||
import com.yxt.common.core.result.ResultBean; |
|||
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.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
@RestController("com.yxt.supervise.portal.biz.gdwholesale.GdWholesaleRest") |
|||
@RequestMapping("/wholesale") |
|||
public class GdWholesaleRest { |
|||
|
|||
@Autowired |
|||
private GdWholesaleService gdWholesaleService; |
|||
|
|||
|
|||
/** |
|||
* 上传配送中心批发数据 |
|||
* @param file |
|||
* @return |
|||
*/ |
|||
@PostMapping("/uploadPszxpfsj") |
|||
public ResultBean<GdWholesaleLog> uploadGdData(@RequestParam("file") MultipartFile file) { |
|||
return gdWholesaleService.uploadAndInsert(file); |
|||
} |
|||
} |
@ -0,0 +1,123 @@ |
|||
package com.yxt.supervise.portal.biz.gdwholesale; |
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import cn.hutool.core.util.StrUtil; |
|||
import cn.hutool.poi.excel.ExcelUtil; |
|||
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.gdinventory.GdRescategoryProdService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
@Service |
|||
public class GdWholesaleService extends ServiceImpl<GdWholesaleMapper, GdWholesale> { |
|||
|
|||
@Autowired |
|||
private FileUploadComponent fileUploadComponent; |
|||
@Autowired |
|||
private GdWholesaleLogService gdWholesaleLogService; |
|||
@Autowired |
|||
private GdRescategoryProdService gdRescategoryProdService; |
|||
@Autowired |
|||
private GdWholesaleGdService gdWholesaleGdService; |
|||
|
|||
public ResultBean<GdWholesaleLog> uploadAndInsert(MultipartFile file) { |
|||
ResultBean rb = ResultBean.fireFail(); |
|||
|
|||
ResultBean<FileUploadResult> fub = fileUploadComponent.uploadFile(file, "pszxpfsj"); |
|||
String filePath = fub.getData().getFilePath(); |
|||
String fp = fileUploadComponent.getUploadPath() + filePath; |
|||
|
|||
long millis = System.currentTimeMillis(); |
|||
GdWholesaleLog gdlog = new GdWholesaleLog(fp); |
|||
ExcelUtil.read07BySax(fp, -1, createRowHandler(gdlog)); |
|||
gdlog.setDurations(System.currentTimeMillis() - millis); |
|||
gdWholesaleLogService.save(gdlog); |
|||
|
|||
return rb.success().setData(gdlog); |
|||
} |
|||
|
|||
private RowHandler createRowHandler(GdWholesaleLog gdlog) { |
|||
return new RowHandler() { |
|||
|
|||
private List<GdWholesaleGd> toInsertListGd = new ArrayList<>(); |
|||
private List<GdWholesale> toInsertList = new ArrayList<>(); |
|||
private List<GdWholesaleLogErr> errList = new ArrayList<>(); |
|||
private int x = 0, y = 0, errnum = 0; |
|||
private String odate = null; |
|||
|
|||
private GdWholesaleGd rowToEntity(List<Object> r) { |
|||
GdWholesaleGd gd = new GdWholesaleGd(); |
|||
gd.setOrgCode("" + r.get(0)); // 企业组织机构代码证
|
|||
gd.setOrderType("" + r.get(1)); // 订单类型
|
|||
gd.setOrderNo("" + r.get(2)); // 销售订单号
|
|||
gd.setProdCode("" + r.get(3)); // 商品编码
|
|||
gd.setProdBarCode("" + r.get(4)); // 商品条码
|
|||
gd.setProdName("" + r.get(5)); // 商品名称
|
|||
gd.setBrandCode("" + r.get(6)); // 品牌代码
|
|||
gd.setBrandName("" + r.get(7)); // 品牌名称
|
|||
gd.setCategoryb("" + r.get(8)); // 商品大类
|
|||
gd.setCategorym("" + r.get(9)); // 商品中类
|
|||
gd.setCategorys("" + r.get(10)); // 商品小类
|
|||
gd.setCustomerCode("" + r.get(11)); // 客户代码
|
|||
gd.setCustomerName("" + r.get(12)); // 客户名称
|
|||
gd.setSaleNum("" + r.get(13)); // 销售数量
|
|||
gd.setStoreCode("" + r.get(14)); // 销售渠道
|
|||
gd.setSalePrice("" + r.get(15)); // 销售价格
|
|||
gd.setSaleCost("" + r.get(16)); // 销售成本
|
|||
gd.setProfit("" + r.get(17)); // 利润
|
|||
gd.setDataDate("" + r.get(18)); // 数据日期
|
|||
return gd; |
|||
} |
|||
|
|||
@Override |
|||
public void handle(int sheetIndex, long rowIndex, List<Object> r) { |
|||
if (rowIndex > 0) { //跳过标题行
|
|||
String prodCode = "" + r.get(3); //商品编码
|
|||
String dataDate = "" + r.get(18); //数据日期
|
|||
if (StrUtil.isNotBlank(prodCode)) { //商品编码不为空才插入,过滤掉统计行
|
|||
GdWholesaleGd gd = rowToEntity(r); |
|||
toInsertListGd.add(gd); |
|||
if (gdRescategoryProdService.containsCode(prodCode)) { |
|||
GdWholesale gw = new GdWholesale(); |
|||
BeanUtil.copyProperties(gd, gw); |
|||
toInsertList.add(gw); |
|||
y++; |
|||
} |
|||
x++; |
|||
} |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void doAfterAllAnalysed() { |
|||
if (toInsertListGd != null && !toInsertListGd.isEmpty()) { |
|||
GdWholesaleGd gd = toInsertListGd.get(0); |
|||
gdWholesaleGdService.clearByDataDate(gd.getDataDate()); |
|||
gdWholesaleGdService.saveBatch(toInsertListGd); |
|||
} |
|||
if (toInsertList != null && !toInsertList.isEmpty()) { |
|||
GdWholesale gd = toInsertList.get(0); |
|||
GdWholesaleService.this.clearByDataDate(gd.getDataDate()); |
|||
GdWholesaleService.this.saveBatch(toInsertList); |
|||
} |
|||
|
|||
gdlog.setAllNum(x); |
|||
gdlog.setValidNum(y); |
|||
gdlog.setErrRowNum(errnum); |
|||
RowHandler.super.doAfterAllAnalysed(); |
|||
} |
|||
}; |
|||
} |
|||
|
|||
public void clearByDataDate(String dataDate) { |
|||
baseMapper.clearByDataDate(dataDate); |
|||
} |
|||
} |
Loading…
Reference in new issue