|
|
@ -26,10 +26,16 @@ |
|
|
|
package com.yxt.supervise.portal.biz.salesdata; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
import cn.hutool.poi.excel.ExcelUtil; |
|
|
|
import cn.hutool.poi.excel.sax.handler.RowHandler; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.yxt.common.base.config.component.FileUploadComponent; |
|
|
|
import com.yxt.common.core.result.FileUploadResult; |
|
|
|
import com.yxt.supervise.portal.api.brandinfo.BrandInfo; |
|
|
|
import com.yxt.supervise.portal.api.brandinfo.BrandInfoVo; |
|
|
|
import com.yxt.supervise.portal.api.dictcommon.DictCommon; |
|
|
@ -42,12 +48,16 @@ import com.yxt.supervise.portal.api.restrictedcategory.RestrictedCategory; |
|
|
|
import com.yxt.supervise.portal.api.storeinfo.StoreInfo; |
|
|
|
import com.yxt.supervise.portal.biz.brandinfo.BrandInfoService; |
|
|
|
import com.yxt.supervise.portal.biz.dictcommon.DictCommonService; |
|
|
|
import com.yxt.supervise.portal.biz.gdinventory.GdInventoryLog; |
|
|
|
import com.yxt.supervise.portal.biz.gdinventory.GdInventoryLogErr; |
|
|
|
import com.yxt.supervise.portal.biz.gdinventory.GdInventoryOk; |
|
|
|
import com.yxt.supervise.portal.biz.inventoryinformation.InventoryInformationService; |
|
|
|
import com.yxt.supervise.portal.biz.productinformation.ProductInformationService; |
|
|
|
import com.yxt.supervise.portal.biz.purchaserequisition.PurchaseRequisitionService; |
|
|
|
import com.yxt.supervise.portal.biz.purchaserequisitionpro.PurchaseRequisitionProService; |
|
|
|
import com.yxt.supervise.portal.biz.restrictedcategory.RestrictedCategoryService; |
|
|
|
import com.yxt.supervise.portal.biz.storeinfo.StoreInfoService; |
|
|
|
import com.yxt.supervise.portal.extexcel.ExcelTool; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
@ -63,10 +73,13 @@ import com.yxt.supervise.portal.api.salesdata.SalesDataDto; |
|
|
|
import com.yxt.supervise.portal.api.salesdata.SalesDataFeign; |
|
|
|
|
|
|
|
import org.apache.poi.hssf.usermodel.*; |
|
|
|
import org.apache.poi.ss.usermodel.CellStyle; |
|
|
|
import org.apache.poi.ss.usermodel.CellType; |
|
|
|
import org.apache.poi.ss.usermodel.HorizontalAlignment; |
|
|
|
import org.apache.poi.ss.util.CellRangeAddress; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.io.IOException; |
|
|
@ -107,6 +120,8 @@ public class SalesDataService extends MybatisBaseService<SalesDataMapper, SalesD |
|
|
|
private BrandInfoService brandInfoService; |
|
|
|
@Resource |
|
|
|
private DictCommonService dictCommonService; |
|
|
|
@Autowired |
|
|
|
private FileUploadComponent fileUploadComponent; |
|
|
|
private QueryWrapper<SalesData> createQueryWrapper(SalesDataQuery query) { |
|
|
|
// todo: 这里根据具体业务调整查询条件
|
|
|
|
// 多字段Like示例:qw.and(wrapper -> wrapper.like("name", query.getName()).or().like("remark", query.getName()));
|
|
|
@ -154,242 +169,209 @@ public class SalesDataService extends MybatisBaseService<SalesDataMapper, SalesD |
|
|
|
BeanUtil.copyProperties(entity, vo); |
|
|
|
return vo; |
|
|
|
} |
|
|
|
public void readBrandPeriodSorXls1(InputStream is, String sid) { |
|
|
|
HSSFWorkbook hssfWorkbook = null; |
|
|
|
try { |
|
|
|
hssfWorkbook = new HSSFWorkbook(is); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
private RowHandler createRowHandler( ) { |
|
|
|
return new RowHandler() { |
|
|
|
|
|
|
|
List<String> lisss=new ArrayList<>(); |
|
|
|
List<String> lisss2=new ArrayList<>(); |
|
|
|
HSSFSheet hssfSheet = hssfWorkbook.getSheetAt(0); |
|
|
|
// 循环行Row
|
|
|
|
for (int rowNum = 1; rowNum <= hssfSheet.getLastRowNum(); rowNum++) { |
|
|
|
SalesData sd=new SalesData(); |
|
|
|
HSSFRow hssfRow = hssfSheet.getRow(rowNum); |
|
|
|
List<SalesData> salesDatas=new ArrayList<>(); |
|
|
|
int i = 0; |
|
|
|
try{ |
|
|
|
int j = 0; |
|
|
|
@Override |
|
|
|
public void handle(int sheetIndex, long rowNum, List<Object> r) { |
|
|
|
if(rowNum>=1){ |
|
|
|
for ( ; i < hssfRow.getLastCellNum(); i++) { |
|
|
|
HSSFCell brandIdHSSFCell = hssfRow.getCell(i); |
|
|
|
if(brandIdHSSFCell!=null){ |
|
|
|
if (i == 1) {//类型
|
|
|
|
brandIdHSSFCell.setCellType(CellType.STRING); |
|
|
|
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) { |
|
|
|
String value = brandIdHSSFCell.getStringCellValue(); |
|
|
|
value=value.trim(); |
|
|
|
sd.setType(value); |
|
|
|
} |
|
|
|
} |
|
|
|
if (i == 2) {//销售订单号
|
|
|
|
brandIdHSSFCell.setCellType(CellType.STRING); |
|
|
|
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) { |
|
|
|
String value = brandIdHSSFCell.getStringCellValue(); |
|
|
|
value=value.trim(); |
|
|
|
sd.setCode(value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (i == 3) {//商品代码
|
|
|
|
brandIdHSSFCell.setCellType(CellType.STRING); |
|
|
|
String value = brandIdHSSFCell.getStringCellValue(); |
|
|
|
value=value.trim(); |
|
|
|
sd.setProCode(value); |
|
|
|
} |
|
|
|
if (i == 4) {//商品条码
|
|
|
|
brandIdHSSFCell.setCellType(CellType.STRING); |
|
|
|
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) { |
|
|
|
String value = brandIdHSSFCell.getStringCellValue(); |
|
|
|
value=value.trim(); |
|
|
|
sd.setProBarCode(value); |
|
|
|
} |
|
|
|
} |
|
|
|
if (i == 5) {//商品名称
|
|
|
|
brandIdHSSFCell.setCellType(CellType.STRING); |
|
|
|
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) { |
|
|
|
String value = brandIdHSSFCell.getStringCellValue(); |
|
|
|
value=value.trim(); |
|
|
|
sd.setProName(value); |
|
|
|
} |
|
|
|
} |
|
|
|
if (i == 6) {//品牌代码
|
|
|
|
brandIdHSSFCell.setCellType(CellType.STRING); |
|
|
|
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) { |
|
|
|
String value = brandIdHSSFCell.getStringCellValue(); |
|
|
|
value=value.trim(); |
|
|
|
sd.setBrandCode(value); |
|
|
|
} |
|
|
|
} |
|
|
|
if (i == 7) {//品牌名称
|
|
|
|
brandIdHSSFCell.setCellType(CellType.STRING); |
|
|
|
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) { |
|
|
|
String value = brandIdHSSFCell.getStringCellValue(); |
|
|
|
value=value.trim(); |
|
|
|
sd.setBrandName(value); |
|
|
|
Map<String,Object> sd_map=new HashMap<>(); |
|
|
|
|
|
|
|
try{ |
|
|
|
sd_map.put("type",r.get(1));//类型
|
|
|
|
sd_map.put("code",r.get(2));//销售订单号
|
|
|
|
sd_map.put("proCode",r.get( 3));//商品代码
|
|
|
|
sd_map.put("proBarCode",r.get( 4));//商品条码
|
|
|
|
sd_map.put("proName",r.get( 5));//商品名称
|
|
|
|
sd_map.put("brandCode",r.get( 6));//品牌代码
|
|
|
|
Object brandName=r.get(7); |
|
|
|
if(brandName!=null) |
|
|
|
sd_map.put("brandName",brandName.toString());//品牌名称
|
|
|
|
|
|
|
|
Object dalei=r.get(8);//大类
|
|
|
|
if(dalei!=null) |
|
|
|
sd_map.put("categoryb",dalei.toString()); |
|
|
|
|
|
|
|
Object zhonglei=r.get(9);//中类
|
|
|
|
if(zhonglei!=null) |
|
|
|
sd_map.put("categorym",zhonglei); |
|
|
|
|
|
|
|
Object xiaolei=r.get(10);//小类
|
|
|
|
if(xiaolei!=null) |
|
|
|
sd_map.put("categorys",xiaolei); |
|
|
|
|
|
|
|
sd_map.put("customerCode",r.get( 11));//客户代码
|
|
|
|
sd_map.put("customerName",r.get( 12));//客户名称
|
|
|
|
sd_map.put("saleNum",r.get( 13));//销售数量
|
|
|
|
sd_map.put("storeCode",r.get( 14));//销售渠道
|
|
|
|
sd_map.put("salePrice",r.get( 15));//销售价格
|
|
|
|
sd_map.put("saleCost",r.get( 16));//销售成本
|
|
|
|
sd_map.put("profit",r.get( 17));//利润
|
|
|
|
sd_map.put("dataDate",r.get( 18));//销售日期
|
|
|
|
SalesData sd=new SalesData(); |
|
|
|
BeanUtil.fillBeanWithMap(sd_map, sd, true); |
|
|
|
salesDatas.add(sd); |
|
|
|
i++; |
|
|
|
}catch(Exception e){ |
|
|
|
e.printStackTrace(); |
|
|
|
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
baseMapper.insertIntoImportDataInfo(sdf.format(new Date()),"销售数据导入第"+i+"出现异常"+e.getMessage()); |
|
|
|
System.err.println("i="+i+",value=null"); |
|
|
|
} |
|
|
|
lisss.add(rowNum+""); |
|
|
|
|
|
|
|
//inventoryInformationService.reduceStock(sd.getProCode(),sd.getProName(),sd.getStoreCode(),sd.getSaleNum());
|
|
|
|
log.info("productInformation:{}", JSONObject.toJSONString(sd_map)); |
|
|
|
log.info("rowNum:{}", rowNum); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@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() { |
|
|
|
List<List<SalesData>> listArray = new ArrayList<List<SalesData>>(); |
|
|
|
int listSize = salesDatas.size(); |
|
|
|
int pageSize=5000; |
|
|
|
for (int i = 0; i < listSize; i += pageSize) { |
|
|
|
int toIndex = Math.min(i + pageSize, listSize); |
|
|
|
listArray.add(salesDatas.subList(i, toIndex)); |
|
|
|
} |
|
|
|
Map<String,Object> params=new HashMap<>(); |
|
|
|
params.put("dataDate",salesDatas.get(0).getDataDate()); |
|
|
|
baseMapper.deleteByMap(params); |
|
|
|
for(List<SalesData> l:listArray){ |
|
|
|
log.info("batchInsert-start:{}",l.size()); |
|
|
|
baseMapper.batchInsert(l); |
|
|
|
log.info("batchInsert-end:{}",l.size()); |
|
|
|
} |
|
|
|
List<SalesData> list=baseMapper.selectForBrandAndCategory(salesDatas.get(0).getDataDate()); |
|
|
|
for(SalesData sd:list){ |
|
|
|
BrandInfoVo brandInfoVo = brandInfoService.selectByCode(sd.getBrandCode()); |
|
|
|
if(brandInfoVo==null){ |
|
|
|
BrandInfo brandInfo = new BrandInfo(); |
|
|
|
brandInfo.setName(value); |
|
|
|
brandInfo.setName(sd.getBrandName()); |
|
|
|
brandInfo.setCode(sd.getBrandCode()); |
|
|
|
brandInfoService.insert(brandInfo); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (i == 8) {//大类
|
|
|
|
brandIdHSSFCell.setCellType(CellType.STRING); |
|
|
|
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) { |
|
|
|
String value = brandIdHSSFCell.getStringCellValue(); |
|
|
|
value=value.trim(); |
|
|
|
String[] split = value.split("]"); |
|
|
|
String key = split[0].replace("[","");//key
|
|
|
|
String v=split[1];//类别value
|
|
|
|
sd.setCategoryb(value); |
|
|
|
DictCommonDetailsVo category = dictCommonService.fetchByKeyAndType(key, "category"); |
|
|
|
if(category==null){ |
|
|
|
String dalei=sd.getCategoryb(); |
|
|
|
String[] split_dalei = dalei.split("]"); |
|
|
|
String key_dalei = split_dalei[0].replace("[","");//key
|
|
|
|
String v_dalei=split_dalei[1];//类别value
|
|
|
|
DictCommonDetailsVo category_dalei = dictCommonService.fetchByKeyAndType(key_dalei, "category"); |
|
|
|
if(category_dalei==null){ |
|
|
|
DictCommon dc=new DictCommon(); |
|
|
|
dc.setDictType("category"); |
|
|
|
dc.setDictKey(key); |
|
|
|
dc.setDictValue(v); |
|
|
|
dc.setDictKey(key_dalei); |
|
|
|
dc.setDictValue(v_dalei); |
|
|
|
dictCommonService.insert(dc); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (i == 9) {//中类
|
|
|
|
brandIdHSSFCell.setCellType(CellType.STRING); |
|
|
|
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) { |
|
|
|
String value = brandIdHSSFCell.getStringCellValue(); |
|
|
|
value=value.trim(); |
|
|
|
String[] split = value.split("]"); |
|
|
|
String key = split[0].replace("[","");//key
|
|
|
|
String v=split[1];//类别value
|
|
|
|
sd.setCategorym(value); |
|
|
|
DictCommonDetailsVo category = dictCommonService.fetchByKeyAndType(key, "category"); |
|
|
|
if(category==null){ |
|
|
|
String zhonglei=sd.getCategorym(); |
|
|
|
String[] split_zhonglei = zhonglei.split("]"); |
|
|
|
String key_zhonglei = split_zhonglei[0].replace("[","");//key
|
|
|
|
String v_zhonglei=split_zhonglei[1];//类别value
|
|
|
|
DictCommonDetailsVo category_zhonglei = dictCommonService.fetchByKeyAndType(key_zhonglei, "category"); |
|
|
|
if(category_zhonglei==null){ |
|
|
|
DictCommon dc=new DictCommon(); |
|
|
|
dc.setDictType("category"); |
|
|
|
dc.setDictKey(key); |
|
|
|
dc.setDictValue(v); |
|
|
|
dc.setDictKey(key_zhonglei); |
|
|
|
dc.setDictValue(v_zhonglei); |
|
|
|
dictCommonService.insert(dc); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (i == 10) {//小类
|
|
|
|
brandIdHSSFCell.setCellType(CellType.STRING); |
|
|
|
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) { |
|
|
|
String value = brandIdHSSFCell.getStringCellValue(); |
|
|
|
value=value.trim(); |
|
|
|
String[] split = value.split("]"); |
|
|
|
String key = split[0].replace("[","");//key
|
|
|
|
String v=split[1];//类别value
|
|
|
|
sd.setCategorys(value); |
|
|
|
DictCommonDetailsVo category = dictCommonService.fetchByKeyAndType(key, "category"); |
|
|
|
String xiaolei=sd.getCategorys(); |
|
|
|
String[] split_xiaolei = xiaolei.split("]"); |
|
|
|
String key_xiaolei = split_xiaolei[0].replace("[","");//key
|
|
|
|
String v_xiaolei=split_xiaolei[1];//类别value
|
|
|
|
DictCommonDetailsVo category = dictCommonService.fetchByKeyAndType(key_xiaolei, "category"); |
|
|
|
if(category==null){ |
|
|
|
DictCommon dc=new DictCommon(); |
|
|
|
dc.setDictType("category"); |
|
|
|
dc.setDictKey(key); |
|
|
|
dc.setDictValue(v); |
|
|
|
dc.setDictKey(key_xiaolei); |
|
|
|
dc.setDictValue(v_xiaolei); |
|
|
|
dictCommonService.insert(dc); |
|
|
|
} |
|
|
|
} |
|
|
|
baseMapper.updateStoreName(salesDatas.get(0).getDataDate()); |
|
|
|
baseMapper.deleteSalesDataByDate(salesDatas.get(0).getDataDate()); |
|
|
|
analysisSalesData(salesDatas.get(0).getDataDate(),""); |
|
|
|
RowHandler.super.doAfterAllAnalysed(); |
|
|
|
} |
|
|
|
if (i == 11) {//客户代码
|
|
|
|
brandIdHSSFCell.setCellType(CellType.STRING); |
|
|
|
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) { |
|
|
|
String value = brandIdHSSFCell.getStringCellValue(); |
|
|
|
value=value.trim(); |
|
|
|
sd.setCustomerCode(value); |
|
|
|
} |
|
|
|
} |
|
|
|
if (i == 12) {//客户名称
|
|
|
|
brandIdHSSFCell.setCellType(CellType.STRING); |
|
|
|
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) { |
|
|
|
String value = brandIdHSSFCell.getStringCellValue(); |
|
|
|
value=value.trim(); |
|
|
|
sd.setCustomerName(value); |
|
|
|
} |
|
|
|
} |
|
|
|
if (i == 13) {//销售数量
|
|
|
|
brandIdHSSFCell.setCellType(CellType.STRING); |
|
|
|
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) { |
|
|
|
String value = brandIdHSSFCell.getStringCellValue(); |
|
|
|
value=value.trim(); |
|
|
|
sd.setSaleNum(value); |
|
|
|
} |
|
|
|
} |
|
|
|
if (i == 14) {//销售渠道
|
|
|
|
brandIdHSSFCell.setCellType(CellType.STRING); |
|
|
|
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) { |
|
|
|
String value = brandIdHSSFCell.getStringCellValue(); |
|
|
|
value=value.trim(); |
|
|
|
sd.setStoreCode(value); |
|
|
|
} |
|
|
|
} |
|
|
|
if (i == 15) {//销售价格
|
|
|
|
brandIdHSSFCell.setCellType(CellType.STRING); |
|
|
|
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) { |
|
|
|
String value = brandIdHSSFCell.getStringCellValue(); |
|
|
|
value=value.trim(); |
|
|
|
sd.setSalePrice(value); |
|
|
|
} |
|
|
|
} |
|
|
|
if (i == 16) {//销售成本
|
|
|
|
brandIdHSSFCell.setCellType(CellType.STRING); |
|
|
|
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) { |
|
|
|
String value = brandIdHSSFCell.getStringCellValue(); |
|
|
|
value=value.trim(); |
|
|
|
sd.setSaleCost(value); |
|
|
|
} |
|
|
|
} |
|
|
|
if (i == 17) {//利润
|
|
|
|
brandIdHSSFCell.setCellType(CellType.STRING); |
|
|
|
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) { |
|
|
|
String value = brandIdHSSFCell.getStringCellValue(); |
|
|
|
value=value.trim(); |
|
|
|
sd.setProfit(value); |
|
|
|
} |
|
|
|
} |
|
|
|
if (i == 18) {//销售日期
|
|
|
|
brandIdHSSFCell.setCellType(CellType.STRING); |
|
|
|
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) { |
|
|
|
String value = brandIdHSSFCell.getStringCellValue(); |
|
|
|
value=value.trim(); |
|
|
|
sd.setDataDate(value); |
|
|
|
} |
|
|
|
} |
|
|
|
}else{ |
|
|
|
System.err.println("rowNum="+rowNum+",i="+i+",value=null"); |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
public void readBrandPeriodSorXls1(MultipartFile file) { |
|
|
|
|
|
|
|
ResultBean<FileUploadResult> fub = fileUploadComponent.uploadFile(file, "salesdata"); |
|
|
|
String filePath = fub.getData().getFilePath(); |
|
|
|
String fp = fileUploadComponent.getUploadPath() + filePath; |
|
|
|
long millis = System.currentTimeMillis(); |
|
|
|
ExcelUtil.read07BySax(fp, -1, createRowHandler()); |
|
|
|
|
|
|
|
|
|
|
|
/*HSSFWorkbook hssfWorkbook = null; |
|
|
|
try { |
|
|
|
hssfWorkbook = new HSSFWorkbook(is); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
List<String> lisss=new ArrayList<>(); |
|
|
|
List<SalesData> salesDatas=new ArrayList<>(); |
|
|
|
HSSFSheet hssfSheet = hssfWorkbook.getSheetAt(0); |
|
|
|
// 循环行Row
|
|
|
|
for (int rowNum = 1; rowNum <= hssfSheet.getLastRowNum(); rowNum++) { |
|
|
|
SalesData sd=new SalesData(); |
|
|
|
HSSFRow hssfRow = hssfSheet.getRow(rowNum); |
|
|
|
int i = 0; |
|
|
|
try{ |
|
|
|
sd.setType(ExcelTool.readStringFromHSSFRow(hssfRow, 1));//类型
|
|
|
|
sd.setCode(ExcelTool.readStringFromHSSFRow(hssfRow, 2));//销售订单号
|
|
|
|
sd.setProCode(ExcelTool.readStringFromHSSFRow(hssfRow, 3));//商品代码
|
|
|
|
sd.setProBarCode(ExcelTool.readStringFromHSSFRow(hssfRow, 4));//商品条码
|
|
|
|
sd.setProName(ExcelTool.readStringFromHSSFRow(hssfRow, 5));//商品名称
|
|
|
|
sd.setBrandCode(ExcelTool.readStringFromHSSFRow(hssfRow, 6));//品牌代码
|
|
|
|
String brandName=ExcelTool.readStringFromHSSFRow(hssfRow, 7); |
|
|
|
sd.setBrandName(brandName);//品牌名称
|
|
|
|
|
|
|
|
String dalei=ExcelTool.readStringFromHSSFRow(hssfRow, 8);//大类
|
|
|
|
|
|
|
|
sd.setCategoryb(dalei); |
|
|
|
|
|
|
|
String zhonglei=ExcelTool.readStringFromHSSFRow(hssfRow, 9);//中类
|
|
|
|
sd.setCategorym(zhonglei); |
|
|
|
|
|
|
|
String xiaolei=ExcelTool.readStringFromHSSFRow(hssfRow, 10);//小类
|
|
|
|
sd.setCategorys(xiaolei); |
|
|
|
|
|
|
|
sd.setCustomerCode(ExcelTool.readStringFromHSSFRow(hssfRow, 11));//客户代码
|
|
|
|
sd.setCustomerName(ExcelTool.readStringFromHSSFRow(hssfRow, 12));//客户名称
|
|
|
|
sd.setSaleNum(ExcelTool.readStringFromHSSFRow(hssfRow, 13));//销售数量
|
|
|
|
sd.setStoreCode(ExcelTool.readStringFromHSSFRow(hssfRow, 14));//销售渠道
|
|
|
|
sd.setSalePrice(ExcelTool.readStringFromHSSFRow(hssfRow, 15));//销售价格
|
|
|
|
sd.setSaleCost(ExcelTool.readStringFromHSSFRow(hssfRow, 16));//销售成本
|
|
|
|
sd.setProfit(ExcelTool.readStringFromHSSFRow(hssfRow, 17));//利润
|
|
|
|
sd.setDataDate(ExcelTool.readStringFromHSSFRow(hssfRow, 18));//销售日期
|
|
|
|
salesDatas.add(sd); |
|
|
|
}catch(Exception e){ |
|
|
|
e.printStackTrace(); |
|
|
|
System.err.println("i="+i+",value=null"); |
|
|
|
} |
|
|
|
|
|
|
|
lisss.add(rowNum+""); |
|
|
|
baseMapper.insert(sd); |
|
|
|
inventoryInformationService.reduceStock(sd.getProCode(),sd.getProName(),sd.getStoreCode(),sd.getSaleNum()); |
|
|
|
|
|
|
|
//inventoryInformationService.reduceStock(sd.getProCode(),sd.getProName(),sd.getStoreCode(),sd.getSaleNum());
|
|
|
|
log.info("productInformation:{}", JSONObject.toJSONString(sd)); |
|
|
|
log.info("rowNum:{}", rowNum); |
|
|
|
} |
|
|
|
String x = JSON.toJSONString(lisss); |
|
|
|
System.out.println(x); |
|
|
|
String x1 = JSON.toJSONString(lisss2); |
|
|
|
System.out.println(x1); |
|
|
|
//return message;
|
|
|
|
System.out.println(x);*/ |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* 销售明细表 |
|
|
|
* @param pc |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
/*public HSSFWorkbook analysisSalesData2(String pc){ |
|
|
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* 分析销售数据 |
|
|
@ -408,27 +390,23 @@ public class SalesDataService extends MybatisBaseService<SalesDataMapper, SalesD |
|
|
|
list=baseMapper.selectByStoreCode(storeCode); |
|
|
|
} |
|
|
|
//创建HSSFWorkbook
|
|
|
|
addProductNum(list); |
|
|
|
//addProductNum(list);
|
|
|
|
List<Map<String,String>> listss=new ArrayList<>(); |
|
|
|
int i=0; |
|
|
|
for(SalesData s:list){ |
|
|
|
String proCode = s.getProCode(); |
|
|
|
//List<StoreInfo> storeInfos=storeInfoService.selectLimitStores();
|
|
|
|
List<PurchaseRequisitionPro> lps=purchaseRequisitionProService.selectByCode(proCode); |
|
|
|
if(lps==null||lps.size()==0){ |
|
|
|
if((lps==null||lps.size()==0)){//&&s.getCategorys().indexOf("0811")<0 烟
|
|
|
|
continue; |
|
|
|
} |
|
|
|
if(s.getState()==1){ |
|
|
|
BigDecimal multiply = new BigDecimal(s.getSaleNum()).multiply(new BigDecimal(s.getSalePrice())); |
|
|
|
StoreInfo storeInfo = storeInfoService.selectByCodeAndLimit(s.getStoreCode()); |
|
|
|
if(storeInfo!=null){ |
|
|
|
System.out.println( |
|
|
|
"[" |
|
|
|
+s.getStoreCode()+"]"+storeInfo.getName()+","+s.getType()+"," |
|
|
|
+s.getCode()+","+s.getProCode()+","+s.getProName()+","+s.getSaleNum()+"," |
|
|
|
+s.getSalePrice()+","+multiply.toString()); |
|
|
|
/*StoreInfo storeInfo = storeInfoService.selectByCodeAndLimit(s.getStoreCode()); |
|
|
|
if(storeInfo!=null){*/ |
|
|
|
Map<String,String> map=new HashMap<>(); |
|
|
|
map.put("t1","["+s.getStoreCode()+"]"+storeInfo.getName()); |
|
|
|
map.put("t2",storeInfo.getName()); |
|
|
|
map.put("t1","["+s.getStoreCode()+"]"+s.getStoreName()); |
|
|
|
map.put("t2",s.getStoreName()); |
|
|
|
map.put("t3",s.getType()); |
|
|
|
map.put("t4",s.getCode()); |
|
|
|
map.put("t5",s.getProCode()); |
|
|
@ -438,12 +416,15 @@ public class SalesDataService extends MybatisBaseService<SalesDataMapper, SalesD |
|
|
|
map.put("t9",multiply.toString()); |
|
|
|
map.put("t10",s.getDataDate()); |
|
|
|
listss.add(map); |
|
|
|
} else { |
|
|
|
log.info("i:{}",i++); |
|
|
|
//} else {
|
|
|
|
log.info("SalesData:{}",JSONObject.toJSONString(s)); |
|
|
|
// }
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
baseMapper.insertStoreInfo(listss); |
|
|
|
log.info("开始新增salestest"); |
|
|
|
baseMapper.insertsalestest(listss); |
|
|
|
log.info("结束新增salestest"); |
|
|
|
return null; |
|
|
|
} |
|
|
|
public HSSFWorkbook analysisSalesData2(String pc,String storeCode){ |
|
|
@ -688,7 +669,7 @@ public class SalesDataService extends MybatisBaseService<SalesDataMapper, SalesD |
|
|
|
private List<SalesData> addProductNum( List<SalesData> list) { |
|
|
|
for(int i = 0; i < list.size(); i++){ |
|
|
|
SalesData pr=list.get(i); |
|
|
|
ProductInformationVo productInformation=productInformationService.selectByCode(pr.getProCode()); |
|
|
|
/* ProductInformationVo productInformation=productInformationService.selectByCode(pr.getProCode()); |
|
|
|
log.info("pr:{}",JSONObject.toJSONString(pr)); |
|
|
|
if(productInformation==null) { |
|
|
|
pr.setState(2); |
|
|
@ -697,16 +678,16 @@ public class SalesDataService extends MybatisBaseService<SalesDataMapper, SalesD |
|
|
|
String brandSid = productInformation.getBrandSid(); |
|
|
|
String categoryKey = productInformation.getCategoryKey(); |
|
|
|
List<RestrictedCategory> restrictedCategorys=restrictedCategoryService.limitJudgement(categoryKey,brandSid); |
|
|
|
if("081101,081102,081103".indexOf(categoryKey)>=0||(restrictedCategorys!=null&&restrictedCategorys.size()>0)){ |
|
|
|
if("081101,081102,081103".indexOf(categoryKey)>=0||(restrictedCategorys!=null&&restrictedCategorys.size()>0)){*/ |
|
|
|
pr.setState(1); |
|
|
|
}else{ |
|
|
|
/* }else{ |
|
|
|
pr.setState(0); |
|
|
|
String remarks=""; |
|
|
|
remarks=remarks+productInformation.getCategory()+"["+productInformation.getCategoryKey()+"]品类,"; |
|
|
|
remarks=remarks+productInformation.getBrand()+"["+productInformation.getBrandSid()+"]品牌不符合;"; |
|
|
|
pr.setRemarks(remarks); |
|
|
|
} |
|
|
|
} |
|
|
|
}*/ |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|