|
|
@ -1,6 +1,10 @@ |
|
|
|
package com.yxt.supervise.customer.biz.purchaserequisition; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
import com.alibaba.excel.context.AnalysisContext; |
|
|
|
import com.alibaba.excel.read.builder.ExcelReaderBuilder; |
|
|
|
import com.alibaba.excel.read.listener.ReadListener; |
|
|
|
import com.alibaba.excel.read.metadata.holder.ReadRowHolder; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
@ -8,28 +12,26 @@ import com.yxt.common.base.utils.PagerUtil; |
|
|
|
import com.yxt.common.core.query.PagerQuery; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import com.yxt.common.core.vo.PagerVo; |
|
|
|
import com.yxt.supervise.customer.api.gdwholesalegd.GdWholesaleGd; |
|
|
|
import com.yxt.supervise.customer.api.gdwholesalegd.GdWholesaleGdExcelVo; |
|
|
|
import com.yxt.supervise.customer.api.gdwholesalegd.GdWholesaleGdQuery; |
|
|
|
import com.yxt.supervise.customer.api.purchaserequisition.PurchaseRequisition; |
|
|
|
import com.yxt.supervise.customer.api.purchaserequisition.PurchaseRequisitionExcelVo; |
|
|
|
import com.yxt.supervise.customer.api.purchaserequisition.PurchaseRequisitionQuery; |
|
|
|
import com.yxt.supervise.customer.api.purchaserequisition.PurchaseRequisitionVo; |
|
|
|
import com.yxt.supervise.customer.api.restrictedbrand.RestrictedBrand; |
|
|
|
import com.yxt.supervise.customer.api.restrictedbrand.RestrictedBrandQuery; |
|
|
|
import com.yxt.supervise.customer.api.restrictedbrand.RestrictedBrandVo; |
|
|
|
import com.yxt.supervise.customer.api.purchaserequisitionpro.PurchaseRequisitionPro; |
|
|
|
import com.yxt.supervise.customer.biz.purchaserequisitionpro.PurchaseRequisitionProService; |
|
|
|
import com.yxt.supervise.customer.tools.StrTool; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCell; |
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCellStyle; |
|
|
|
import org.apache.poi.hssf.usermodel.HSSFRow; |
|
|
|
import org.apache.poi.hssf.usermodel.HSSFSheet; |
|
|
|
import org.apache.poi.ss.usermodel.CellType; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.io.IOException; |
|
|
|
import java.text.ParseException; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
@ -40,6 +42,8 @@ import java.util.Map; |
|
|
|
@Service |
|
|
|
public class PurchaseRequisitionService extends MybatisBaseService<PurchaseRequisitionMapper, PurchaseRequisition> { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private PurchaseRequisitionProService purchaseRequisitionProService; |
|
|
|
|
|
|
|
public PagerVo<PurchaseRequisitionVo> listPageVo(PagerQuery<PurchaseRequisitionQuery> pq) { |
|
|
|
PurchaseRequisitionQuery query = pq.getParams(); |
|
|
@ -66,6 +70,7 @@ public class PurchaseRequisitionService extends MybatisBaseService<PurchaseRequi |
|
|
|
PagerVo<PurchaseRequisitionVo> p = PagerUtil.pageToVo(pagging, null); |
|
|
|
return p; |
|
|
|
} |
|
|
|
|
|
|
|
public List<PurchaseRequisitionExcelVo> exportExcel(PagerQuery<PurchaseRequisitionQuery> pq) { |
|
|
|
PurchaseRequisitionQuery query = pq.getParams(); |
|
|
|
QueryWrapper<PurchaseRequisition> qw = new QueryWrapper<>(); |
|
|
@ -90,167 +95,105 @@ public class PurchaseRequisitionService extends MybatisBaseService<PurchaseRequi |
|
|
|
return pagging; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void supplierAnalysis() throws ParseException { |
|
|
|
ztspglhzb(); |
|
|
|
gysddmxb(); |
|
|
|
public ResultBean<String> checkCodeByFileName(String filename) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
if (StringUtils.isBlank(filename)) |
|
|
|
return rb.setMsg("文件名不可为空"); |
|
|
|
if (filename.length() < 15) |
|
|
|
return rb.setMsg("文件名格式错误"); |
|
|
|
String code = filename.substring(0, 14); |
|
|
|
PurchaseRequisition purchaseRequisition = fetchByCode(code); |
|
|
|
if (purchaseRequisition == null) |
|
|
|
return rb.success().setData("nothas"); |
|
|
|
return rb.success().setData("hased"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 在途商品管理汇总表 |
|
|
|
* |
|
|
|
* @throws ParseException |
|
|
|
*/ |
|
|
|
public void ztspglhzb() throws ParseException { |
|
|
|
// Date date = new Date();
|
|
|
|
// SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
// baseMapper.deleteAll();
|
|
|
|
// List<Map<String, Object>> list = baseMapper.ztspglhzb();//--在途商品管理汇总表
|
|
|
|
// for (Map<String, Object> m : list) {
|
|
|
|
// String billTotalPrice = m.get("billTotalPrice") != null ? m.get("billTotalPrice").toString() : "0";//订单总额
|
|
|
|
// String prodValue = m.get("prodValue") != null ? m.get("prodValue").toString() : "0";//实际到货价值
|
|
|
|
// String arrivalDate = m.get("arrivalDate") != null ? m.get("arrivalDate").toString() : "0";//全部到货日期
|
|
|
|
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
|
|
|
|
// m.put("date", sdf.format(date));
|
|
|
|
// m.put("no", sdf1.format(date).toString() + "01");//编号
|
|
|
|
// BigDecimal bigDecimal = new BigDecimal(billTotalPrice); //总金额
|
|
|
|
// BigDecimal bigDecimal1 = new BigDecimal(prodValue);//到货金额
|
|
|
|
// BigDecimal subtract = bigDecimal.subtract(bigDecimal1);//有未到货的货值
|
|
|
|
// Date parse = sdf.parse(arrivalDate);
|
|
|
|
// long nowMillisecond = date.getTime();
|
|
|
|
// long arrivalMillisecond = parse.getTime();//到货日期
|
|
|
|
// if (nowMillisecond > arrivalMillisecond && subtract.compareTo(new BigDecimal("0")) == 1) {//是否延期 大于到货日期 并且在途货值大于0 为延期
|
|
|
|
// m.put("sfyq", "是");
|
|
|
|
// } else {
|
|
|
|
// m.put("sfyq", "否");
|
|
|
|
// }
|
|
|
|
// if (subtract.compareTo(new BigDecimal("0")) == 1) {
|
|
|
|
// m.put("wdhjz", subtract.toString());
|
|
|
|
// m.put("cchjz", "0");
|
|
|
|
// } else {
|
|
|
|
// m.put("wdhjz", "0");
|
|
|
|
// BigDecimal subtract2 = bigDecimal1.subtract(bigDecimal);
|
|
|
|
// m.put("cchjz", subtract2.toString());
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// log.info("ztspglhzb:{}", JSONObject.toJSONString(list));
|
|
|
|
// baseMapper.insertZtspglhzb(list);
|
|
|
|
public PurchaseRequisition fetchByCode(String code) { |
|
|
|
QueryWrapper<PurchaseRequisition> qw = new QueryWrapper<>(); |
|
|
|
qw.eq("code", code); |
|
|
|
List<PurchaseRequisition> list = baseMapper.selectList(qw); |
|
|
|
if (list == null || list.isEmpty()) |
|
|
|
return null; |
|
|
|
return list.get(0); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 供应商订单明细表 |
|
|
|
*/ |
|
|
|
public void gysddmxb() { |
|
|
|
// Date date = new Date();
|
|
|
|
// SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
// List<Map<String, String>> list2 = baseMapper.gysddmxb();//--供应商订单明细表
|
|
|
|
// for (Map<String, String> m : list2) {
|
|
|
|
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
|
|
|
|
// String format = sdf.format(date);
|
|
|
|
// m.put("date", format.toString());
|
|
|
|
// String no = sdf1.format(date).toString() + "01";//编号
|
|
|
|
// m.put("no", no);
|
|
|
|
// }
|
|
|
|
// log.info("gysddmxb:{}", JSONObject.toJSONString(list2));
|
|
|
|
// baseMapper.deleteGysddmxb();
|
|
|
|
// baseMapper.insertGysddmxb(list2);
|
|
|
|
public ResultBean<PurchaseRequisition> uploadXlsxFile(MultipartFile file) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
PurchaseRequisition pr = new PurchaseRequisition(); |
|
|
|
pr.setPurchasingOrgCode("1"); |
|
|
|
pr.setPurchasingOrgName("36524集团"); |
|
|
|
pr.setPurchasingDeptCode("9001"); |
|
|
|
pr.setPurchasingDeptName("365生活通"); |
|
|
|
|
|
|
|
List<PurchaseRequisitionPro> proList = new ArrayList<>(); |
|
|
|
try { |
|
|
|
ExcelReaderBuilder read = EasyExcel.read(file.getInputStream(), createReadListener(pr, proList)); |
|
|
|
read.sheet().doRead(); |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
return rb.setMsg("读取Excel文件异常:" + e.getMessage()); |
|
|
|
} |
|
|
|
baseMapper.insert(pr); |
|
|
|
purchaseRequisitionProService.saveBatch(proList); |
|
|
|
return rb.success().setData(pr); |
|
|
|
} |
|
|
|
|
|
|
|
//
|
|
|
|
// public ResultBean<String> readBrandPeriodSorXls1(InputStream is) {
|
|
|
|
// /* int ii=uddatePrice();
|
|
|
|
// if(ii==1){
|
|
|
|
// return;
|
|
|
|
// }*/
|
|
|
|
// HSSFWorkbook hssfWorkbook = null;
|
|
|
|
// try {
|
|
|
|
// hssfWorkbook = new HSSFWorkbook(is);
|
|
|
|
// } catch (IOException e) {
|
|
|
|
// e.printStackTrace();
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// List<String> lisss=new ArrayList<>();
|
|
|
|
// List<String> lisss2=new ArrayList<>();
|
|
|
|
// HSSFSheet hssfSheet = hssfWorkbook.getSheetAt(0);
|
|
|
|
// PurchaseRequisition pr=new PurchaseRequisition();
|
|
|
|
// List<PurchaseRequisitionPro> prps=new ArrayList<>();
|
|
|
|
// pr.setPurchasingOrgCode("1");
|
|
|
|
// pr.setPurchasingOrgName("36524集团");
|
|
|
|
// pr.setPurchasingDeptCode("9001");
|
|
|
|
// pr.setPurchasingDeptName("365生活通");
|
|
|
|
// // 循环行Row
|
|
|
|
// for (int rowNum = 0; rowNum <=hssfSheet.getLastRowNum(); rowNum++) {
|
|
|
|
// HSSFRow hssfRow = hssfSheet.getRow(rowNum);
|
|
|
|
// int i = 0;
|
|
|
|
// try{
|
|
|
|
// //设置单号 填单人 填单时间
|
|
|
|
// /*if(rowNum==0){
|
|
|
|
// for ( ; i < hssfRow.getLastCellNum(); i++) {
|
|
|
|
// setRow0(pr, hssfRow, i);
|
|
|
|
// }
|
|
|
|
// }*/
|
|
|
|
// //设置单号 填单人 填单时间
|
|
|
|
// if(rowNum==1){
|
|
|
|
// for ( ; i < hssfRow.getLastCellNum(); i++) {
|
|
|
|
// setRow1(pr, hssfRow, i);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// //设置供货单位 仓位 到货日期
|
|
|
|
// if(rowNum==2){
|
|
|
|
// for ( ; i < hssfRow.getLastCellNum(); i++) {
|
|
|
|
// setRow2(pr, hssfRow, i);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// //设置采购员 入库单位 单据到效期
|
|
|
|
// if(rowNum==3){
|
|
|
|
// for ( ; i < hssfRow.getLastCellNum(); i++) {
|
|
|
|
// setRow3(pr, hssfRow, i);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// //设置采购员 入库单位 单据到效期
|
|
|
|
// if(rowNum==4){
|
|
|
|
// for ( ; i < hssfRow.getLastCellNum(); i++) {
|
|
|
|
// setRow4(pr, hssfRow, i);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// if(rowNum>6){
|
|
|
|
// ProductInformation p=new ProductInformation();
|
|
|
|
// PurchaseRequisitionPro prp = new PurchaseRequisitionPro();
|
|
|
|
// prp.setMainSid(pr.getSid());
|
|
|
|
// String hsje="";//含税金额
|
|
|
|
// for ( ; i < hssfRow.getLastCellNum(); i++) {
|
|
|
|
// HSSFCell brandIdHSSFCell = hssfRow.getCell(i);
|
|
|
|
// if(brandIdHSSFCell!=null){
|
|
|
|
// if (i == 1) {//商品代码
|
|
|
|
// brandIdHSSFCell.setCellType(CellType.STRING);
|
|
|
|
// String code = brandIdHSSFCell.getStringCellValue();
|
|
|
|
// ProductInformationVo productInformation=productInformationService.selectByCode(code);
|
|
|
|
// if(productInformation==null){
|
|
|
|
// p.setCode(code);
|
|
|
|
// }else{
|
|
|
|
// prp.setCategory(productInformation.getCategory());
|
|
|
|
// prp.setCategoryKey(productInformation.getCategoryKey());
|
|
|
|
// prp.setBrand(productInformation.getBrand());
|
|
|
|
// prp.setBrandCode(productInformation.getBrandSid());
|
|
|
|
// }
|
|
|
|
// prp.setProCode(code);
|
|
|
|
// prp.setContent("code");//规格型号
|
|
|
|
// }
|
|
|
|
// if (i == 2) {//名称
|
|
|
|
private ReadListener<Map<Integer, String>> createReadListener(PurchaseRequisition pr, List<PurchaseRequisitionPro> proList) { |
|
|
|
return new ReadListener<Map<Integer, String>>() { |
|
|
|
private void full1(Map<Integer, String> map) { |
|
|
|
String code = map.get(1); |
|
|
|
pr.setCode(code); |
|
|
|
pr.setPurchaseDate(map.get(5)); |
|
|
|
} |
|
|
|
|
|
|
|
private void full2(Map<Integer, String> map) { |
|
|
|
String str1 = map.get(1); |
|
|
|
String[] arr1 = StrTool.splitBySquareBrackets(str1); |
|
|
|
pr.setSupplierName(arr1[0]); |
|
|
|
pr.setSupplierCode(arr1[1]); |
|
|
|
pr.setWarehousePosition("供应链仓"); |
|
|
|
pr.setWarehousePositionCode("112"); |
|
|
|
pr.setArrivalDate(map.get(5)); |
|
|
|
} |
|
|
|
|
|
|
|
private void full3(Map<Integer, String> map) { |
|
|
|
String str1 = map.get(1); |
|
|
|
String[] arr1 = StrTool.splitBySquareBrackets(str1); |
|
|
|
pr.setBuyerName(arr1[0]); |
|
|
|
pr.setBuyerCode(arr1[1]); |
|
|
|
pr.setExpiryDate(map.get(5)); |
|
|
|
} |
|
|
|
|
|
|
|
private void full4(Map<Integer, String> map) { |
|
|
|
pr.setCompletionStatus(map.get(5)); |
|
|
|
pr.setCompletionStatusKey("0");//0未完成
|
|
|
|
} |
|
|
|
|
|
|
|
private void addPro(Map<Integer, String> map) { |
|
|
|
PurchaseRequisitionPro prp = new PurchaseRequisitionPro(); |
|
|
|
prp.setMainSid(pr.getSid()); |
|
|
|
String hsje = "";//含税金额
|
|
|
|
prp.setProCode(map.get(1)); |
|
|
|
// prp.setCategory(productInformation.getCategory());
|
|
|
|
// prp.setCategoryKey(productInformation.getCategoryKey());
|
|
|
|
// prp.setBrand(productInformation.getBrand());
|
|
|
|
// prp.setBrandCode(productInformation.getBrandSid());
|
|
|
|
prp.setContent("code");//规格型号
|
|
|
|
prp.setProName(map.get(2)); |
|
|
|
prp.setNumber(map.get(3)); |
|
|
|
prp.setPackageSpec(map.get(4)); |
|
|
|
prp.setPackageNumber(map.get(5)); |
|
|
|
|
|
|
|
// if (i == 7) {//含税单价(元)
|
|
|
|
// brandIdHSSFCell.setCellType(CellType.STRING);
|
|
|
|
// if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) {
|
|
|
|
// String name = brandIdHSSFCell.getStringCellValue();
|
|
|
|
// prp.setProName(name);
|
|
|
|
// p.setName(name);
|
|
|
|
// if(StringUtils.isBlank(prp.getProCode())){
|
|
|
|
// continue;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// if (i == 3) {//数量
|
|
|
|
// brandIdHSSFCell.setCellType(CellType.STRING);
|
|
|
|
// if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) {
|
|
|
|
// String value = brandIdHSSFCell.getStringCellValue();
|
|
|
|
// prp.setNumber(value);
|
|
|
|
// if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) {
|
|
|
|
// hsje= brandIdHSSFCell.getStringCellValue();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (i == 10) {//第二代码
|
|
|
|
// brandIdHSSFCell.setCellType(CellType.STRING);
|
|
|
|
// if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) {
|
|
|
@ -258,13 +201,6 @@ public class PurchaseRequisitionService extends MybatisBaseService<PurchaseRequi |
|
|
|
// prp.setSecondCode(value);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// if (i == 53) {//包装数量
|
|
|
|
// brandIdHSSFCell.setCellType(CellType.STRING);
|
|
|
|
// if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) {
|
|
|
|
// String value = brandIdHSSFCell.getStringCellValue();
|
|
|
|
// prp.setPackageNumber(value);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// if (i == 53) {//包内数量 对应采购订单的规格
|
|
|
|
// brandIdHSSFCell.setCellType(CellType.STRING);
|
|
|
|
// if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) {
|
|
|
@ -313,13 +249,6 @@ public class PurchaseRequisitionService extends MybatisBaseService<PurchaseRequi |
|
|
|
// productInformationService.insert(p);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// if (i == 4) {//包装规格
|
|
|
|
// brandIdHSSFCell.setCellType(CellType.STRING);
|
|
|
|
// if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) {
|
|
|
|
// String value= brandIdHSSFCell.getStringCellValue();
|
|
|
|
// prp.setPackageSpec(value);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// if (i == 11) {//单位
|
|
|
|
// brandIdHSSFCell.setCellType(CellType.STRING);
|
|
|
|
// if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) {
|
|
|
@ -372,15 +301,6 @@ public class PurchaseRequisitionService extends MybatisBaseService<PurchaseRequi |
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (i == 7) {//含税单价(元)
|
|
|
|
// brandIdHSSFCell.setCellType(CellType.STRING);
|
|
|
|
// if(StringUtils.isBlank(prp.getProCode())){
|
|
|
|
// continue;
|
|
|
|
// }
|
|
|
|
// if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) {
|
|
|
|
// hsje= brandIdHSSFCell.getStringCellValue();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }else{
|
|
|
|
// System.err.println("rowNum="+rowNum+",i="+i+",value=null");
|
|
|
|
// }
|
|
|
@ -388,215 +308,33 @@ public class PurchaseRequisitionService extends MybatisBaseService<PurchaseRequi |
|
|
|
// if(StringUtils.isNotBlank(prp.getProCode())){
|
|
|
|
// prps.add(prp);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }catch(Exception e){
|
|
|
|
// e.printStackTrace();
|
|
|
|
// System.err.println("i="+i+",value=null");
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// lisss.add(rowNum+"");
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
// log.info("productInformation:{}", JSONObject.toJSONString(pr));
|
|
|
|
// ResultBean<String> objectResultBean=ResultBean.fireFail();
|
|
|
|
// SupplierInfoVo supplierInfoVo = supplierInfoService.selectByCodeForIndex(pr.getSupplierCode());
|
|
|
|
// if(supplierInfoVo==null){
|
|
|
|
// return objectResultBean.setMsg("供应商不存在!");
|
|
|
|
// }
|
|
|
|
// // List<Map<String,String>> suplierZtyz=baseMapper.suplierZtyz(pr.getSupplierCode()); 临时注释掉 2023-01-16
|
|
|
|
// List<Map<String,String>> suplierZtyz=baseMapper.suplierZtyz2(pr.getSupplierCode());
|
|
|
|
// if(suplierZtyz.size()>0){
|
|
|
|
// return objectResultBean.setMsg("供应商有在途商品!");
|
|
|
|
// }
|
|
|
|
// purchaseRequisitionService.insert(pr);
|
|
|
|
// for (PurchaseRequisitionPro p: prps){
|
|
|
|
// purchaseRequisitionProService.insert(p);
|
|
|
|
// /* String proCode = p.getProCode();*/
|
|
|
|
// /*int row=purchaseRequisitionProService.selectProdCodeTable(proCode);
|
|
|
|
// if(row==0){
|
|
|
|
// purchaseRequisitionProService.insertProdCodeTable(proCode);
|
|
|
|
// }*/
|
|
|
|
// }
|
|
|
|
// GdRescategoryProdService.resetCache();
|
|
|
|
// log.info("x:{}",JSON.toJSONString(lisss));
|
|
|
|
// String x1 = JSON.toJSONString(lisss2);
|
|
|
|
// log.info("x1:{}",JSON.toJSONString(lisss2));
|
|
|
|
// return objectResultBean.success().setData(pr.getCode());
|
|
|
|
// //return message;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// private void setRow0(PurchaseRequisition pr, HSSFRow hssfRow, int i) {
|
|
|
|
// HSSFCell brandIdHSSFCell = hssfRow.getCell(i);
|
|
|
|
// if(brandIdHSSFCell!=null){
|
|
|
|
// if (i == 1) {//单号
|
|
|
|
// brandIdHSSFCell.setCellType(CellType.STRING);
|
|
|
|
// String code = brandIdHSSFCell.getStringCellValue();
|
|
|
|
// if(com.yxt.common.base.utils.StringUtils.isNotBlank(code)){
|
|
|
|
// PurchaseRequisition purchaseRequisition = purchaseRequisitionService.selectByCode(code);
|
|
|
|
// if(purchaseRequisition!=null){
|
|
|
|
// String newCode = purchaseRequisition.getNewCode();
|
|
|
|
// String[] split = newCode.split(",");
|
|
|
|
// split[split.length]=code;
|
|
|
|
// String str="";
|
|
|
|
// for(String s:split){
|
|
|
|
// str=str+","+s;
|
|
|
|
// }
|
|
|
|
// String substring = str.substring(1, str.length());
|
|
|
|
// purchaseRequisition.setNewCode(substring);
|
|
|
|
// purchaseRequisitionService.updateById(purchaseRequisition);
|
|
|
|
// }
|
|
|
|
// pr.setOldCode(code);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// private void setRow1(PurchaseRequisition pr, HSSFRow hssfRow, int i) {
|
|
|
|
// HSSFCell brandIdHSSFCell = hssfRow.getCell(i);
|
|
|
|
// if(brandIdHSSFCell!=null){
|
|
|
|
// if (i == 1) {//单号
|
|
|
|
// brandIdHSSFCell.setCellType(CellType.STRING);
|
|
|
|
// String code = brandIdHSSFCell.getStringCellValue();
|
|
|
|
// PurchaseRequisition purchaseRequisition = baseMapper.selectByCode(code);
|
|
|
|
// Map<String,Object> map=new HashMap<>();
|
|
|
|
// map.put("code",code);
|
|
|
|
// baseMapper.deleteByMap(map);
|
|
|
|
// purchaseRequisition=new PurchaseRequisition();
|
|
|
|
// Map<String,Object> map1=new HashMap<>();
|
|
|
|
// if(purchaseRequisition!=null){
|
|
|
|
// map1.put("mainSid",purchaseRequisition.getSid());
|
|
|
|
// purchaseRequisitionProService.deleteByMap(map1);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// //ProductInformationVo productInformationVo = baseMapper.selectByCode(code);
|
|
|
|
// pr.setCode(code);
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
// if (i == 3) {//填单人
|
|
|
|
// brandIdHSSFCell.setCellType(CellType.STRING);
|
|
|
|
// String value = brandIdHSSFCell.getStringCellValue();
|
|
|
|
// //ProductInformationVo productInformationVo = baseMapper.selectByCode(code);
|
|
|
|
// String[] split = value.split("\\[");
|
|
|
|
// String v = split[0];//类别value
|
|
|
|
// String key=split[1].replace("]","");//key
|
|
|
|
// pr.setBuyerName(v);
|
|
|
|
// pr.setBuyerCode(key);
|
|
|
|
// }
|
|
|
|
// if (i == 5) {//填单时间
|
|
|
|
// brandIdHSSFCell.setCellType(CellType.STRING);
|
|
|
|
// String value = brandIdHSSFCell.getStringCellValue();
|
|
|
|
// //ProductInformationVo productInformationVo = baseMapper.selectByCode(code);
|
|
|
|
// pr.setPurchaseDate(value);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// private void setRow2(PurchaseRequisition pr, HSSFRow hssfRow, int i) {
|
|
|
|
// HSSFCell brandIdHSSFCell = hssfRow.getCell(i);
|
|
|
|
// if(brandIdHSSFCell!=null){
|
|
|
|
// if (i == 1) {//供货单位 供应商
|
|
|
|
// brandIdHSSFCell.setCellType(CellType.STRING);
|
|
|
|
// String value = brandIdHSSFCell.getStringCellValue();
|
|
|
|
// String[] split = value.split("\\[");
|
|
|
|
// String v = split[0];//类别value
|
|
|
|
// String key=split[1].replace("]","");//key
|
|
|
|
// SupplierInfoVo supplierInfoVo = supplierInfoService.selectByCodeForIndex(key);
|
|
|
|
// pr.setSupplierCode(supplierInfoVo.getCodeUnified());
|
|
|
|
// pr.setSupplierName(v);
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
// if (i == 3) {//仓位
|
|
|
|
// brandIdHSSFCell.setCellType(CellType.STRING);
|
|
|
|
// String value = brandIdHSSFCell.getStringCellValue();
|
|
|
|
// String[] split = value.split("\\[");
|
|
|
|
// String v ="供应链仓";// split[0];//类别value
|
|
|
|
// String key="112";//split[1].replace("]","");//key
|
|
|
|
// WarehousePositionVo warehousePositionVo = warehousePositionService.selectByCode(key);
|
|
|
|
// if(warehousePositionVo==null){
|
|
|
|
// WarehousePosition warehousePosition=new WarehousePosition();
|
|
|
|
// warehousePosition.setName(v);
|
|
|
|
// warehousePosition.setCode(key);
|
|
|
|
// warehousePositionService.insert(warehousePosition);
|
|
|
|
// }
|
|
|
|
// pr.setWarehousePosition(v);
|
|
|
|
// pr.setWarehousePositionCode(key);
|
|
|
|
// }
|
|
|
|
// if (i == 5) {//到货日期
|
|
|
|
// brandIdHSSFCell.setCellType(CellType.STRING);
|
|
|
|
// String value = brandIdHSSFCell.getStringCellValue();
|
|
|
|
// //ProductInformationVo productInformationVo = baseMapper.selectByCode(code);
|
|
|
|
// pr.setArrivalDate(value);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
private void setRow3(PurchaseRequisition pr, HSSFRow hssfRow, int i) { |
|
|
|
HSSFCell brandIdHSSFCell = hssfRow.getCell(i); |
|
|
|
if (brandIdHSSFCell != null) { |
|
|
|
if (i == 1) {//采购员
|
|
|
|
brandIdHSSFCell.setCellType(CellType.STRING); |
|
|
|
String value = brandIdHSSFCell.getStringCellValue(); |
|
|
|
//ProductInformationVo productInformationVo = baseMapper.selectByCode(code);
|
|
|
|
String[] split = value.split("\\["); |
|
|
|
String v = split[0];//类别value
|
|
|
|
String key = split[1].replace("]", "");//key
|
|
|
|
pr.setBuyerName(v); |
|
|
|
pr.setBuyerCode(key); |
|
|
|
pr.setLogisticsCompanyCode(key); |
|
|
|
pr.setLogisticsCompanyName(v); |
|
|
|
proList.add(prp); |
|
|
|
} |
|
|
|
|
|
|
|
if (i == 5) {//单据到效期
|
|
|
|
brandIdHSSFCell.setCellType(CellType.STRING); |
|
|
|
String value = brandIdHSSFCell.getStringCellValue(); |
|
|
|
//ProductInformationVo productInformationVo = baseMapper.selectByCode(code);
|
|
|
|
pr.setExpiryDate(value); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void setRow4(PurchaseRequisition pr, HSSFRow hssfRow, int i) { |
|
|
|
HSSFCell brandIdHSSFCell = hssfRow.getCell(i); |
|
|
|
if (brandIdHSSFCell != null) { |
|
|
|
if (i == 5) {//完成状态
|
|
|
|
brandIdHSSFCell.setCellType(CellType.STRING); |
|
|
|
String value = brandIdHSSFCell.getStringCellValue(); |
|
|
|
//ProductInformationVo productInformationVo = baseMapper.selectByCode(code);
|
|
|
|
pr.setCompletionStatus(value); |
|
|
|
pr.setCompletionStatusKey("0");//0未完成
|
|
|
|
@Override |
|
|
|
public void invoke(Map<Integer, String> map, AnalysisContext analysisContext) { |
|
|
|
ReadRowHolder readRowHolder = analysisContext.readRowHolder(); |
|
|
|
int rowIndex = readRowHolder.getRowIndex(); |
|
|
|
if (1 == rowIndex) { |
|
|
|
full1(map); |
|
|
|
} |
|
|
|
if (2 == rowIndex) { |
|
|
|
full2(map); |
|
|
|
} |
|
|
|
if (3 == rowIndex) { |
|
|
|
full3(map); |
|
|
|
} |
|
|
|
if (4 == rowIndex) { |
|
|
|
full4(map); |
|
|
|
} |
|
|
|
if (rowIndex > 6) |
|
|
|
addPro(map); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void createRow3(HSSFSheet sheet, int rownum, String[] col1, HSSFCellStyle style) { |
|
|
|
//声明列对象
|
|
|
|
HSSFCell cell = null; |
|
|
|
//创建标题
|
|
|
|
HSSFRow row2 = sheet.createRow(rownum); |
|
|
|
for (int i = 0; i < col1.length; i++) { |
|
|
|
cell = row2.createCell(i); |
|
|
|
cell.setCellValue(col1[i]); |
|
|
|
cell.setCellStyle(style); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<String> checkCodeByFileName(String filename) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
if (StringUtils.isBlank(filename)) |
|
|
|
return rb.setMsg("文件名不可为空"); |
|
|
|
if (filename.length() < 15) |
|
|
|
return rb.setMsg("文件名格式错误"); |
|
|
|
String code = filename.substring(0, 14); |
|
|
|
PurchaseRequisition purchaseRequisition = fetchByCode(code); |
|
|
|
if (purchaseRequisition == null) |
|
|
|
return rb.success().setData("nothas"); |
|
|
|
return rb.success().setData("hased"); |
|
|
|
} |
|
|
|
@Override |
|
|
|
public void doAfterAllAnalysed(AnalysisContext analysisContext) { |
|
|
|
|
|
|
|
public PurchaseRequisition fetchByCode(String code) { |
|
|
|
QueryWrapper<PurchaseRequisition> qw = new QueryWrapper<>(); |
|
|
|
qw.eq("code", code); |
|
|
|
List<PurchaseRequisition> list = baseMapper.selectList(qw); |
|
|
|
if (list == null || list.isEmpty()) |
|
|
|
return null; |
|
|
|
return list.get(0); |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|