|
|
@ -33,8 +33,10 @@ import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.yxt.anrui.portal.api.purchaserequisitionstore.PurchaseRequisitionStore; |
|
|
|
import com.yxt.anrui.portal.api.purchaserequisitionstore.PurchaseRequisitionStoreVo; |
|
|
|
import com.yxt.anrui.portal.api.purchaserequisitiontobacco.PurchaseRequisitionTobacco; |
|
|
|
import com.yxt.anrui.portal.api.purchaserequisitiontobacco.PurchaseRequisitionTobaccoQuery; |
|
|
|
import com.yxt.anrui.portal.api.purchaserequisitiontobacco.PurchaseRequisitionTobaccoVo; |
|
|
|
import com.yxt.common.base.config.component.FileUploadComponent; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
|
import com.yxt.common.base.utils.PagerUtil; |
|
|
@ -42,6 +44,7 @@ import com.yxt.common.core.query.PagerQuery; |
|
|
|
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.portal.biz.purchaserequisitionstore.PurchaseRequisitionStoreService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
|
@ -69,8 +72,11 @@ import java.util.*; |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
public class PurchaseRequisitionTobaccoService extends MybatisBaseService<PurchaseRequisitionTobaccoMapper, PurchaseRequisitionTobacco> { |
|
|
|
@Autowired |
|
|
|
private FileUploadComponent fileUploadComponent; |
|
|
|
@Autowired |
|
|
|
private FileUploadComponent fileUploadComponent; |
|
|
|
@Autowired |
|
|
|
private PurchaseRequisitionStoreService purchaseRequisitionStoreService; |
|
|
|
|
|
|
|
public PagerVo<PurchaseRequisitionTobacco> listPage(PagerQuery<PurchaseRequisitionTobaccoQuery> pq) { |
|
|
|
PurchaseRequisitionTobaccoQuery query = pq.getParams(); |
|
|
|
QueryWrapper<PurchaseRequisitionTobacco> qw = createQueryWrapper(query); |
|
|
@ -86,244 +92,401 @@ public class PurchaseRequisitionTobaccoService extends MybatisBaseService<Purcha |
|
|
|
QueryWrapper<PurchaseRequisitionTobacco> qw = new QueryWrapper<>(); |
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getCreateSid())) { |
|
|
|
qw.eq("createSid", query.getCreateSid()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getCreateSid())) { |
|
|
|
qw.eq("createSid", query.getCreateSid()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getModifySid())) { |
|
|
|
qw.eq("modifySid", query.getModifySid()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getModifySid())) { |
|
|
|
qw.eq("modifySid", query.getModifySid()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getCode())) { |
|
|
|
qw.eq("code", query.getCode()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getCode())) { |
|
|
|
qw.eq("code", query.getCode()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getBuyerName())) { |
|
|
|
qw.eq("buyerName", query.getBuyerName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getBuyerName())) { |
|
|
|
qw.eq("buyerName", query.getBuyerName()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getBuyerCode())) { |
|
|
|
qw.eq("buyerCode", query.getBuyerCode()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getBuyerCode())) { |
|
|
|
qw.eq("buyerCode", query.getBuyerCode()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getPurchaseDate())) { |
|
|
|
qw.eq("purchaseDate", query.getPurchaseDate()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getPurchaseDate())) { |
|
|
|
qw.eq("purchaseDate", query.getPurchaseDate()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getArrivalDate())) { |
|
|
|
qw.eq("arrivalDate", query.getArrivalDate()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getArrivalDate())) { |
|
|
|
qw.eq("arrivalDate", query.getArrivalDate()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getPurchasingOrgName())) { |
|
|
|
qw.eq("purchasingOrgName", query.getPurchasingOrgName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getPurchasingOrgName())) { |
|
|
|
qw.eq("purchasingOrgName", query.getPurchasingOrgName()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getPurchasingOrgCode())) { |
|
|
|
qw.eq("purchasingOrgCode", query.getPurchasingOrgCode()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getPurchasingOrgCode())) { |
|
|
|
qw.eq("purchasingOrgCode", query.getPurchasingOrgCode()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getPurchasingDeptCode())) { |
|
|
|
qw.eq("purchasingDeptCode", query.getPurchasingDeptCode()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getPurchasingDeptCode())) { |
|
|
|
qw.eq("purchasingDeptCode", query.getPurchasingDeptCode()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getPurchasingDeptName())) { |
|
|
|
qw.eq("purchasingDeptName", query.getPurchasingDeptName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getPurchasingDeptName())) { |
|
|
|
qw.eq("purchasingDeptName", query.getPurchasingDeptName()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getSupplierName())) { |
|
|
|
qw.eq("supplierName", query.getSupplierName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getSupplierName())) { |
|
|
|
qw.eq("supplierName", query.getSupplierName()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getSupplierCode())) { |
|
|
|
qw.eq("supplierCode", query.getSupplierCode()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getSupplierCode())) { |
|
|
|
qw.eq("supplierCode", query.getSupplierCode()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getSupplierOnlyCode())) { |
|
|
|
qw.eq("supplierOnlyCode", query.getSupplierOnlyCode()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getSupplierOnlyCode())) { |
|
|
|
qw.eq("supplierOnlyCode", query.getSupplierOnlyCode()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getLogisticsCompanyName())) { |
|
|
|
qw.eq("logisticsCompanyName", query.getLogisticsCompanyName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getLogisticsCompanyName())) { |
|
|
|
qw.eq("logisticsCompanyName", query.getLogisticsCompanyName()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getLogisticsCompanyCode())) { |
|
|
|
qw.eq("logisticsCompanyCode", query.getLogisticsCompanyCode()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getLogisticsCompanyCode())) { |
|
|
|
qw.eq("logisticsCompanyCode", query.getLogisticsCompanyCode()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getExpiryDate())) { |
|
|
|
qw.eq("expiryDate", query.getExpiryDate()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getExpiryDate())) { |
|
|
|
qw.eq("expiryDate", query.getExpiryDate()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getWarehousePosition())) { |
|
|
|
qw.eq("warehousePosition", query.getWarehousePosition()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getWarehousePosition())) { |
|
|
|
qw.eq("warehousePosition", query.getWarehousePosition()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getWarehousePositionCode())) { |
|
|
|
qw.eq("warehousePositionCode", query.getWarehousePositionCode()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getWarehousePositionCode())) { |
|
|
|
qw.eq("warehousePositionCode", query.getWarehousePositionCode()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getPurchaseState())) { |
|
|
|
qw.eq("purchaseState", query.getPurchaseState()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getPurchaseState())) { |
|
|
|
qw.eq("purchaseState", query.getPurchaseState()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getPurchaseRemarks())) { |
|
|
|
qw.eq("purchaseRemarks", query.getPurchaseRemarks()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getPurchaseRemarks())) { |
|
|
|
qw.eq("purchaseRemarks", query.getPurchaseRemarks()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getBankState())) { |
|
|
|
qw.eq("bankState", query.getBankState()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getBankState())) { |
|
|
|
qw.eq("bankState", query.getBankState()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getBankRemarks())) { |
|
|
|
qw.eq("bankRemarks", query.getBankRemarks()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getBankRemarks())) { |
|
|
|
qw.eq("bankRemarks", query.getBankRemarks()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getCompletionStatus())) { |
|
|
|
qw.eq("completionStatus", query.getCompletionStatus()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getCompletionStatus())) { |
|
|
|
qw.eq("completionStatus", query.getCompletionStatus()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getCompletionStatusKey())) { |
|
|
|
qw.eq("completionStatusKey", query.getCompletionStatusKey()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getCompletionStatusKey())) { |
|
|
|
qw.eq("completionStatusKey", query.getCompletionStatusKey()); |
|
|
|
} |
|
|
|
return qw; |
|
|
|
} |
|
|
|
|
|
|
|
public void yczt(String date) { |
|
|
|
// 在途商品统计条件:207家报烟店范围、审核通过的烟草采购订单(230105开始)中商品明细有未入库的记录。
|
|
|
|
List<Map<String,String>> list=baseMapper.selectDdinfo(date); |
|
|
|
Map<String,String> zje=baseMapper.selectDdzje(date); |
|
|
|
log.info("list:{}",JSONObject.toJSONString(list)); |
|
|
|
log.info("zje:{}",JSONObject.toJSONString(zje)); |
|
|
|
} |
|
|
|
public void readBrandPeriodSorXls1(MultipartFile file) { |
|
|
|
|
|
|
|
ResultBean<FileUploadResult> fub = fileUploadComponent.uploadFile(file, "PurchaseRequisitionTobacco"); |
|
|
|
String filePath = fub.getData().getFilePath(); |
|
|
|
String fp = fileUploadComponent.getUploadPath() + filePath; |
|
|
|
long millis = System.currentTimeMillis(); |
|
|
|
ExcelUtil.read07BySax(fp, -1, createRowHandler()); |
|
|
|
} |
|
|
|
private RowHandler createRowHandler( ) { |
|
|
|
return new RowHandler() { |
|
|
|
|
|
|
|
List<String> lisss=new ArrayList<>(); |
|
|
|
List<PurchaseRequisitionStore> salesDatas=new ArrayList<>(); |
|
|
|
|
|
|
|
String sid=UUID.randomUUID().toString(); |
|
|
|
Map<String,Object> map=new HashMap<>(); |
|
|
|
int i = 0; |
|
|
|
int j = 0; |
|
|
|
@Override |
|
|
|
public void handle(int sheetIndex, long rowNum, List<Object> r) { |
|
|
|
map.put("sid",sid); |
|
|
|
if(rowNum==1){ |
|
|
|
map.put("code",r.get(2)); |
|
|
|
String tdrCode_s = r.get(4).toString(); |
|
|
|
String[] split = tdrCode_s.split("\\["); |
|
|
|
String s = split[1]; |
|
|
|
String replace = s.replace("]", ""); |
|
|
|
map.put("tdrCode",replace);//填单人
|
|
|
|
map.put("tdrName",split[0]);//填单人
|
|
|
|
map.put("purchaseDate",r.get(6));//填单时间
|
|
|
|
map.put("supplierName",r.get(6));//
|
|
|
|
map.put("supplierCode",r.get(6));//
|
|
|
|
} |
|
|
|
if(rowNum==2){ |
|
|
|
String s = r.get(2).toString(); |
|
|
|
String[] split = s.split("]"); |
|
|
|
map.put("supplierName",split[1]);//
|
|
|
|
String s1 = split[0]; |
|
|
|
String replace = s1.replace("[", ""); |
|
|
|
map.put("supplierCode",replace);//
|
|
|
|
String o = r.get(4).toString(); |
|
|
|
String[] split1 = o.split("]"); |
|
|
|
map.put("warehousePosition",split1[1]); |
|
|
|
String s2 = split1[0]; |
|
|
|
String replace1 = s2.replace("[", ""); |
|
|
|
map.put("warehousePositionCode",replace1); |
|
|
|
map.put("arrivalDate",r.get(6)); |
|
|
|
} |
|
|
|
if(rowNum==3){ |
|
|
|
String s = r.get(2).toString(); |
|
|
|
String[] split = s.split("\\["); |
|
|
|
map.put("buyerName",split[0]);//
|
|
|
|
String s1 = split[1]; |
|
|
|
String replace = s1.replace("]", ""); |
|
|
|
map.put("buyerCode",replace);//
|
|
|
|
String s3 = r.get(4).toString(); |
|
|
|
String substring = s3.substring(s3.indexOf("[")+1, s3.indexOf("]")); |
|
|
|
String substring1 = s3.substring(s3.indexOf("]")+1, s3.length()); |
|
|
|
map.put("purchasingOrgName",substring); |
|
|
|
map.put("purchasingOrgCode",substring1); |
|
|
|
String expiryDate=r.get(6)==null?"":r.get(6).toString(); |
|
|
|
map.put("expiryDate",expiryDate); |
|
|
|
} |
|
|
|
if(rowNum==4){ |
|
|
|
String completionStatus=r.get(6)==null?"":r.get(6).toString(); |
|
|
|
map.put("completionStatus", completionStatus); |
|
|
|
map.put("completionStatus", "0"); |
|
|
|
} |
|
|
|
|
|
|
|
if(rowNum>5){ |
|
|
|
Map<String,Object> sd_map=new HashMap<>(); |
|
|
|
try{ |
|
|
|
sd_map.put("yCode",r.get(2));//卷烟代码
|
|
|
|
String o = r.get(3).toString(); |
|
|
|
String[] split = o.split("]"); |
|
|
|
String substring = split[0].substring(split[0].indexOf("[")+1, split[0].length()); |
|
|
|
sd_map.put("storeCode",substring);//门店代码
|
|
|
|
sd_map.put("storeName",split[1]);//门店名称
|
|
|
|
sd_map.put("price",r.get( 4));//金额
|
|
|
|
sd_map.put("pc",r.get( 5));//批次
|
|
|
|
sd_map.put("mainSid",sid);//关联sid
|
|
|
|
PurchaseRequisitionStore sd=new PurchaseRequisitionStore(); |
|
|
|
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+""); |
|
|
|
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<PurchaseRequisitionStore>> listArray = new ArrayList<List<PurchaseRequisitionStore>>(); |
|
|
|
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)); |
|
|
|
} |
|
|
|
PurchaseRequisitionTobacco sd=new PurchaseRequisitionTobacco(); |
|
|
|
BeanUtil.fillBeanWithMap(map, sd, true); |
|
|
|
SimpleDateFormat sdf =new SimpleDateFormat("yyyyMMdd"); |
|
|
|
String format = sdf.format(new Date()); |
|
|
|
List<PurchaseRequisitionTobacco> list= baseMapper.selectByDateForCode(format); |
|
|
|
int size = list.size(); |
|
|
|
int r=size+1; |
|
|
|
String purchaseDate=sd.getPurchaseDate(); |
|
|
|
purchaseDate=purchaseDate.replace(".",""); |
|
|
|
sd.setCode(purchaseDate); |
|
|
|
baseMapper.insert(sd); |
|
|
|
for(List<PurchaseRequisitionStore> l:listArray){ |
|
|
|
log.info("batchInsert-start:{}",l.size()); |
|
|
|
baseMapper.batchInsert(l); |
|
|
|
log.info("batchInsert-end:{}",l.size()); |
|
|
|
} |
|
|
|
RowHandler.super.doAfterAllAnalysed(); |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
public void yczt(String date) { |
|
|
|
// 在途商品统计条件:207家报烟店范围、审核通过的烟草采购订单(230105开始)中商品明细有未入库的记录。
|
|
|
|
List<Map<String, String>> list = baseMapper.selectDdinfo(date); |
|
|
|
Map<String, String> zje = baseMapper.selectDdzje(date); |
|
|
|
log.info("list:{}", JSONObject.toJSONString(list)); |
|
|
|
log.info("zje:{}", JSONObject.toJSONString(zje)); |
|
|
|
} |
|
|
|
|
|
|
|
public void readBrandPeriodSorXls1(MultipartFile file) { |
|
|
|
|
|
|
|
ResultBean<FileUploadResult> fub = fileUploadComponent.uploadFile(file, "PurchaseRequisitionTobacco"); |
|
|
|
String filePath = fub.getData().getFilePath(); |
|
|
|
String fp = fileUploadComponent.getUploadPath() + filePath; |
|
|
|
long millis = System.currentTimeMillis(); |
|
|
|
ExcelUtil.read07BySax(fp, -1, createRowHandler()); |
|
|
|
} |
|
|
|
|
|
|
|
private RowHandler createRowHandler() { |
|
|
|
return new RowHandler() { |
|
|
|
|
|
|
|
List<String> lisss = new ArrayList<>(); |
|
|
|
List<PurchaseRequisitionStore> salesDatas = new ArrayList<>(); |
|
|
|
|
|
|
|
String sid = UUID.randomUUID().toString(); |
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
int i = 0; |
|
|
|
int j = 0; |
|
|
|
|
|
|
|
@Override |
|
|
|
public void handle(int sheetIndex, long rowNum, List<Object> r) { |
|
|
|
map.put("sid", sid); |
|
|
|
if (rowNum == 1) { |
|
|
|
map.put("code", r.get(2)); |
|
|
|
String tdrCode_s = r.get(4).toString(); |
|
|
|
String[] split = tdrCode_s.split("\\["); |
|
|
|
String s = split[1]; |
|
|
|
String replace = s.replace("]", ""); |
|
|
|
map.put("tdrCode", replace);//填单人
|
|
|
|
map.put("tdrName", split[0]);//填单人
|
|
|
|
map.put("purchaseDate", r.get(6));//填单时间
|
|
|
|
map.put("supplierName", r.get(6));//
|
|
|
|
map.put("supplierCode", r.get(6));//
|
|
|
|
} |
|
|
|
if (rowNum == 2) { |
|
|
|
String s = r.get(2).toString(); |
|
|
|
String[] split = s.split("]"); |
|
|
|
map.put("supplierName", split[1]);//
|
|
|
|
String s1 = split[0]; |
|
|
|
String replace = s1.replace("[", ""); |
|
|
|
map.put("supplierCode", replace);//
|
|
|
|
String o = r.get(4).toString(); |
|
|
|
String[] split1 = o.split("]"); |
|
|
|
map.put("warehousePosition", split1[1]); |
|
|
|
String s2 = split1[0]; |
|
|
|
String replace1 = s2.replace("[", ""); |
|
|
|
map.put("warehousePositionCode", replace1); |
|
|
|
map.put("arrivalDate", r.get(6)); |
|
|
|
} |
|
|
|
if (rowNum == 3) { |
|
|
|
String s = r.get(2).toString(); |
|
|
|
String[] split = s.split("\\["); |
|
|
|
map.put("buyerName", split[0]);//
|
|
|
|
String s1 = split[1]; |
|
|
|
String replace = s1.replace("]", ""); |
|
|
|
map.put("buyerCode", replace);//
|
|
|
|
String s3 = r.get(4).toString(); |
|
|
|
String substring = s3.substring(s3.indexOf("[") + 1, s3.indexOf("]")); |
|
|
|
String substring1 = s3.substring(s3.indexOf("]") + 1, s3.length()); |
|
|
|
map.put("purchasingOrgName", substring); |
|
|
|
map.put("purchasingOrgCode", substring1); |
|
|
|
String expiryDate = r.get(6) == null ? "" : r.get(6).toString(); |
|
|
|
map.put("expiryDate", expiryDate); |
|
|
|
} |
|
|
|
if (rowNum == 4) { |
|
|
|
String completionStatus = r.get(6) == null ? "" : r.get(6).toString(); |
|
|
|
map.put("completionStatus", completionStatus); |
|
|
|
map.put("completionStatus", "0"); |
|
|
|
} |
|
|
|
|
|
|
|
if (rowNum > 5) { |
|
|
|
Map<String, Object> sd_map = new HashMap<>(); |
|
|
|
try { |
|
|
|
sd_map.put("yCode", r.get(2));//卷烟代码
|
|
|
|
String o = r.get(3).toString(); |
|
|
|
String[] split = o.split("]"); |
|
|
|
String substring = split[0].substring(split[0].indexOf("[") + 1, split[0].length()); |
|
|
|
sd_map.put("storeCode", substring);//门店代码
|
|
|
|
sd_map.put("storeName", split[1]);//门店名称
|
|
|
|
sd_map.put("price", r.get(4));//金额
|
|
|
|
sd_map.put("pc", r.get(5));//批次
|
|
|
|
sd_map.put("mainSid", sid);//关联sid
|
|
|
|
PurchaseRequisitionStore sd = new PurchaseRequisitionStore(); |
|
|
|
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 + ""); |
|
|
|
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<PurchaseRequisitionStore>> listArray = new ArrayList<List<PurchaseRequisitionStore>>(); |
|
|
|
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)); |
|
|
|
} |
|
|
|
PurchaseRequisitionTobacco sd = new PurchaseRequisitionTobacco(); |
|
|
|
BeanUtil.fillBeanWithMap(map, sd, true); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); |
|
|
|
String format = sdf.format(new Date()); |
|
|
|
List<PurchaseRequisitionTobacco> list = baseMapper.selectByDateForCode(format); |
|
|
|
int size = list.size(); |
|
|
|
int r = size + 1; |
|
|
|
String purchaseDate = sd.getPurchaseDate(); |
|
|
|
purchaseDate = purchaseDate.replace(".", ""); |
|
|
|
sd.setCode(purchaseDate); |
|
|
|
baseMapper.insert(sd); |
|
|
|
for (List<PurchaseRequisitionStore> l : listArray) { |
|
|
|
log.info("batchInsert-start:{}", l.size()); |
|
|
|
baseMapper.batchInsert(l); |
|
|
|
log.info("batchInsert-end:{}", l.size()); |
|
|
|
} |
|
|
|
RowHandler.super.doAfterAllAnalysed(); |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
public String readOrderXlsx(MultipartFile file) { |
|
|
|
ResultBean<FileUploadResult> fub = fileUploadComponent.uploadFile(file, "PurchaseRequisitionTobacco"); |
|
|
|
String filePath = fub.getData().getFilePath(); |
|
|
|
String fp = fileUploadComponent.getUploadPath() + filePath; |
|
|
|
String orderSid = UUID.randomUUID().toString(); |
|
|
|
ExcelUtil.read07BySax(fp, 0, createRowHandlerWithSid(orderSid)); |
|
|
|
return orderSid; |
|
|
|
} |
|
|
|
|
|
|
|
private RowHandler createRowHandlerWithSid(String orderSid) { |
|
|
|
return new RowHandler() { |
|
|
|
List<PurchaseRequisitionStore> toInsertList = new ArrayList<>(); |
|
|
|
Map<String, Object> orderMap = new HashMap<>(); |
|
|
|
|
|
|
|
@Override |
|
|
|
public void handle(int sheetIndex, long rowNum, List<Object> r) { |
|
|
|
orderMap.put("sid", orderSid); |
|
|
|
if (rowNum == 1) { |
|
|
|
orderMap.put("code", r.get(2)); |
|
|
|
String tdrCode_s = r.get(4).toString(); |
|
|
|
String[] split = tdrCode_s.split("\\["); |
|
|
|
String s = split[1]; |
|
|
|
String replace = s.replace("]", ""); |
|
|
|
orderMap.put("tdrCode", replace);//填单人
|
|
|
|
orderMap.put("tdrName", split[0]);//填单人
|
|
|
|
orderMap.put("purchaseDate", r.get(6));//填单时间
|
|
|
|
orderMap.put("supplierName", r.get(6));//
|
|
|
|
orderMap.put("supplierCode", r.get(6));//
|
|
|
|
} |
|
|
|
if (rowNum == 2) { |
|
|
|
String s = r.get(2).toString(); |
|
|
|
String[] split = s.split("]"); |
|
|
|
orderMap.put("supplierName", split[1]);//
|
|
|
|
String s1 = split[0]; |
|
|
|
String replace = s1.replace("[", ""); |
|
|
|
orderMap.put("supplierCode", replace);//
|
|
|
|
String o = r.get(4).toString(); |
|
|
|
// String[] split1 = o.split("]");
|
|
|
|
orderMap.put("warehousePosition", o.substring(3)); |
|
|
|
// String s2 = split1[0];
|
|
|
|
// String replace1 = s2.replace("[", "");
|
|
|
|
orderMap.put("warehousePositionCode", o.substring(0, 3)); |
|
|
|
orderMap.put("arrivalDate", r.get(6)); |
|
|
|
} |
|
|
|
if (rowNum == 3) { |
|
|
|
String s = r.get(2).toString(); |
|
|
|
String[] split = s.split("\\["); |
|
|
|
orderMap.put("buyerName", split[0]);//
|
|
|
|
String s1 = split[1]; |
|
|
|
String replace = s1.replace("]", ""); |
|
|
|
orderMap.put("buyerCode", replace);//
|
|
|
|
String s3 = r.get(4).toString(); |
|
|
|
String substring = s3.substring(s3.indexOf("[") + 1, s3.indexOf("]")); |
|
|
|
String substring1 = s3.substring(s3.indexOf("]") + 1, s3.length()); |
|
|
|
orderMap.put("purchasingOrgCode", substring); |
|
|
|
orderMap.put("purchasingOrgName", substring1); |
|
|
|
String expiryDate = r.get(6) == null ? "" : r.get(6).toString(); |
|
|
|
orderMap.put("expiryDate", expiryDate); |
|
|
|
} |
|
|
|
if (rowNum == 4) { |
|
|
|
String completionStatus = r.get(6) == null ? "" : r.get(6).toString(); |
|
|
|
orderMap.put("completionStatus", completionStatus); |
|
|
|
orderMap.put("completionStatus", "0"); |
|
|
|
} |
|
|
|
|
|
|
|
if (rowNum > 5) { |
|
|
|
Map<String, Object> sd_map = new HashMap<>(); |
|
|
|
String o = "" + r.get(3); |
|
|
|
if (StringUtils.isNotBlank(o) && o.length() > 9) { |
|
|
|
try { |
|
|
|
sd_map.put("yCode", r.get(2));//卷烟代码
|
|
|
|
String[] split = o.split("]"); |
|
|
|
String substring = split[0].substring(split[0].indexOf("[") + 1, split[0].length()); |
|
|
|
sd_map.put("storeCode", substring);//门店代码
|
|
|
|
sd_map.put("storeName", split[1]);//门店名称
|
|
|
|
sd_map.put("price", r.get(4));//金额
|
|
|
|
sd_map.put("pc", r.get(5));//批次
|
|
|
|
sd_map.put("mainSid", orderSid);//关联sid
|
|
|
|
PurchaseRequisitionStore sd = new PurchaseRequisitionStore(); |
|
|
|
BeanUtil.fillBeanWithMap(sd_map, sd, true); |
|
|
|
toInsertList.add(sd); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
baseMapper.insertIntoImportDataInfo(sdf.format(new Date()), "烟草数据导入第" + rowNum + "出现异常" + e.getMessage()); |
|
|
|
System.err.println("i=" + rowNum + ",value=null"); |
|
|
|
} |
|
|
|
} |
|
|
|
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() { |
|
|
|
if (orderMap != null && !orderMap.isEmpty()) { |
|
|
|
String orderCode = ("" + orderMap.get("purchaseDate")).replace(".", ""); |
|
|
|
PurchaseRequisitionTobaccoService.this.clearAllByCode(orderCode); |
|
|
|
PurchaseRequisitionTobacco sd = new PurchaseRequisitionTobacco(); |
|
|
|
BeanUtil.fillBeanWithMap(orderMap, sd, true); |
|
|
|
sd.setCode(orderCode); |
|
|
|
baseMapper.insert(sd); |
|
|
|
} |
|
|
|
if (toInsertList != null && !toInsertList.isEmpty()) { |
|
|
|
purchaseRequisitionStoreService.saveBatch(toInsertList); |
|
|
|
} |
|
|
|
RowHandler.super.doAfterAllAnalysed(); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void clearAllByCode(String orderCode) { |
|
|
|
PurchaseRequisitionTobacco tt = fetchByCode(orderCode); |
|
|
|
if (tt == null) |
|
|
|
return; |
|
|
|
purchaseRequisitionStoreService.clearAllByMainSid(tt.getSid()); |
|
|
|
baseMapper.clearByCode(orderCode); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 通过单号查找订单信息 |
|
|
|
* |
|
|
|
* @param orderCode |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public PurchaseRequisitionTobacco fetchByCode(String orderCode) { |
|
|
|
QueryWrapper<PurchaseRequisitionTobacco> qw = new QueryWrapper<>(); |
|
|
|
qw.eq("code", orderCode); |
|
|
|
List<PurchaseRequisitionTobacco> list = baseMapper.selectList(qw); |
|
|
|
if (list == null || list.isEmpty()) |
|
|
|
return null; |
|
|
|
return list.get(0); |
|
|
|
} |
|
|
|
|
|
|
|
public PurchaseRequisitionTobaccoVo fetchVoBySid(String sid) { |
|
|
|
QueryWrapper<PurchaseRequisitionTobacco> qw = new QueryWrapper<>(); |
|
|
|
qw.eq("sid", sid); |
|
|
|
List<PurchaseRequisitionTobacco> list = baseMapper.selectList(qw); |
|
|
|
if (list == null || list.isEmpty()) |
|
|
|
return null; |
|
|
|
PurchaseRequisitionTobacco entity = list.get(0); |
|
|
|
PurchaseRequisitionTobaccoVo vo = new PurchaseRequisitionTobaccoVo(); |
|
|
|
BeanUtil.copyProperties(entity, vo, true); |
|
|
|
List<PurchaseRequisitionStoreVo> storeVoList = purchaseRequisitionStoreService.listVoByMainSid(sid); |
|
|
|
vo.setStoreList(storeVoList); |
|
|
|
return vo; |
|
|
|
} |
|
|
|
} |
|
|
|