|
|
@ -46,23 +46,23 @@ import com.yxt.supervise.portal.api.restrictedcategory.RestrictedCategory; |
|
|
|
import com.yxt.supervise.portal.biz.brandinfo.BrandInfoService; |
|
|
|
import com.yxt.supervise.portal.biz.dictcommon.DictCommonService; |
|
|
|
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 lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCell; |
|
|
|
import org.apache.poi.hssf.usermodel.HSSFRow; |
|
|
|
import org.apache.poi.hssf.usermodel.HSSFSheet; |
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
|
|
|
import org.apache.poi.hssf.usermodel.*; |
|
|
|
import org.apache.poi.ss.usermodel.CellType; |
|
|
|
import org.apache.poi.ss.usermodel.HorizontalAlignment; |
|
|
|
import org.apache.poi.ss.util.CellRangeAddress; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
/** |
|
|
|
* Project: com.supervise(宇信通监管) <br/> |
|
|
@ -310,4 +310,285 @@ public class ProductNumService extends MybatisBaseService<ProductNumMapper, Prod |
|
|
|
public List<ProductNum> getAll() { |
|
|
|
return baseMapper.getAll(); |
|
|
|
} |
|
|
|
public HSSFWorkbook exportExcel( HSSFWorkbook wb) { |
|
|
|
String title = "重点品类商品订货明细"; |
|
|
|
String[] col = {"审核单号","状态","合计金额"}; |
|
|
|
String[] col1 = {"序号","采购订单编号","厂商编码","厂商名称","商品代码","商品条码","商品名称","单位","进价","配价","售价","箱规", |
|
|
|
"订货数量","订货金额(元)","合计","税票","降价折扣%","判定结果","备注"}; |
|
|
|
//sheet名
|
|
|
|
String sheetName = "重点品类商品订货明细"; |
|
|
|
//创建HSSFWorkbook
|
|
|
|
//String [][]content={{"张三","男","12","清华大学","大一"},{"李四","女","14","北京大学","大二"}};
|
|
|
|
List<ProductNum> productNums=getAll(); |
|
|
|
// 第一步,创建一个HSSFWorkbook,对应一个Excel文件
|
|
|
|
if(wb == null){ |
|
|
|
wb = new HSSFWorkbook(); |
|
|
|
} |
|
|
|
// 第二步,在workbook中添加一个sheet,对应Excel文件中的sheet
|
|
|
|
HSSFSheet sheet = wb.createSheet(sheetName); |
|
|
|
// 合并单元格:参数:起始行, 终止行, 起始列, 终止列
|
|
|
|
CellRangeAddress cra = new CellRangeAddress(0, 0, 0, 19); |
|
|
|
sheet.addMergedRegion(cra); |
|
|
|
// 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制
|
|
|
|
|
|
|
|
HSSFRow row = sheet.createRow(0); |
|
|
|
// 第四步,创建单元格,并设置值表头 设置表头居中
|
|
|
|
HSSFCellStyle style = wb.createCellStyle(); |
|
|
|
style.setAlignment(HorizontalAlignment.CENTER); // 创建一个居中格式
|
|
|
|
HSSFCell titleRow = row.createCell(0); |
|
|
|
titleRow.setCellValue(title); |
|
|
|
titleRow.setCellStyle(style); |
|
|
|
|
|
|
|
/*HSSFCell titleRow1 = row.createCell(1); |
|
|
|
titleRow1.setCellValue("审核单号:123456789 状态:已通过审核 合计金额:12345678"); |
|
|
|
titleRow1.setCellStyle(style);*/ |
|
|
|
|
|
|
|
//声明列对象
|
|
|
|
|
|
|
|
createRow3(sheet, 1, col1, style); |
|
|
|
|
|
|
|
//创建内容
|
|
|
|
for(int i=0;i<productNums.size();i++){ |
|
|
|
row = sheet.createRow(i + 2); |
|
|
|
//将内容按顺序赋给对应的列对象
|
|
|
|
//"序号","厂商编码","厂商名称","商品代码","商品条码","商品名称","单位","进价","售价","箱规","订货数量","订货金额(元)","合计","税票","降价折扣%"
|
|
|
|
row.createCell(0).setCellValue(i+1); |
|
|
|
row.createCell(1).setCellValue(""); |
|
|
|
row.createCell(2).setCellValue(productNums.get(i).getSupplierCode()); |
|
|
|
row.createCell(3).setCellValue(productNums.get(i).getSupplierName()); |
|
|
|
row.createCell(4).setCellValue(productNums.get(i).getCode()); |
|
|
|
row.createCell(5).setCellValue(productNums.get(i).getBarCode()); |
|
|
|
row.createCell(6).setCellValue(productNums.get(i).getName()); |
|
|
|
row.createCell(7).setCellValue(productNums.get(i).getUnit()); |
|
|
|
row.createCell(8).setCellValue(productNums.get(i).getPurchasePrice());//进价
|
|
|
|
row.createCell(9).setCellValue(productNums.get(i).getValence());//进价
|
|
|
|
row.createCell(10).setCellValue(productNums.get(i).getPrice());//售价
|
|
|
|
row.createCell(11).setCellValue(productNums.get(i).getBoxGauge()); |
|
|
|
row.createCell(12).setCellValue(productNums.get(i).getNum()); |
|
|
|
row.createCell(13).setCellValue(productNums.get(i).getOrderAmount()); |
|
|
|
row.createCell(14).setCellValue("0"); |
|
|
|
row.createCell(15).setCellValue(productNums.get(i).getTaxReceipt()); |
|
|
|
row.createCell(16).setCellValue(productNums.get(i).getDiscount()); |
|
|
|
row.createCell(17).setCellValue(productNums.get(i).getState()==1?"符合":"不符合"); |
|
|
|
row.createCell(18).setCellValue(productNums.get(i).getRemarks()); |
|
|
|
} |
|
|
|
return wb; |
|
|
|
} |
|
|
|
|
|
|
|
public HSSFWorkbook refuseProducts(HSSFWorkbook wb,String pc) { |
|
|
|
String title = "采购订单商品明细表(拒绝)"; |
|
|
|
String[] col = {"审核单号:"+pc,"状态:拒绝","合计金额:"}; |
|
|
|
String[] col1 = {"序号","采购订单编号","商品代码","商品名称","规格型号","数量","单位","单价(元)","含税单价(元)","合计(元)","包内数量","包代码", |
|
|
|
"包数量","包单价","包合计(元)","商品品类","品牌名称","拒绝原因"}; |
|
|
|
//sheet名
|
|
|
|
String sheetName = "采购订单商品明细表(拒绝)"; |
|
|
|
//创建HSSFWorkbook
|
|
|
|
List<ProductNum> productNums=getAll(); |
|
|
|
// 第一步,创建一个HSSFWorkbook,对应一个Excel文件
|
|
|
|
if(wb == null){ |
|
|
|
wb = new HSSFWorkbook(); |
|
|
|
} |
|
|
|
// 第二步,在workbook中添加一个sheet,对应Excel文件中的sheet
|
|
|
|
HSSFSheet sheet = wb.createSheet(sheetName); |
|
|
|
// 合并单元格:参数:起始行, 终止行, 起始列, 终止列
|
|
|
|
CellRangeAddress cra = new CellRangeAddress(0, 0, 0, 19); |
|
|
|
CellRangeAddress cra2 = new CellRangeAddress(1, 1, 0, 19); |
|
|
|
sheet.addMergedRegion(cra); |
|
|
|
sheet.addMergedRegion(cra2); |
|
|
|
// 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制
|
|
|
|
|
|
|
|
HSSFRow row = sheet.createRow(0); |
|
|
|
// 第四步,创建单元格,并设置值表头 设置表头居中
|
|
|
|
HSSFCellStyle style = wb.createCellStyle(); |
|
|
|
style.setAlignment(HorizontalAlignment.CENTER); // 创建一个居中格式
|
|
|
|
HSSFCell titleRow = row.createCell(0); |
|
|
|
titleRow.setCellValue(title); |
|
|
|
titleRow.setCellStyle(style); |
|
|
|
BigDecimal price=new BigDecimal("0"); |
|
|
|
for(int i=0;i<productNums.size();i++){ |
|
|
|
ProductNum p = productNums.get(i); |
|
|
|
price= price.add(new BigDecimal(p.getOrderAmount())); |
|
|
|
} |
|
|
|
col[2]=col[2]+price; |
|
|
|
//第二行
|
|
|
|
createRow2(col, sheet); |
|
|
|
createRow3(sheet, 2, col1, style); |
|
|
|
|
|
|
|
//创建内容
|
|
|
|
for(int i=0;i<productNums.size();i++){ |
|
|
|
row = sheet.createRow(i + 2); |
|
|
|
//将内容按顺序赋给对应的列对象
|
|
|
|
//"序号","商品代码","商品名称","规格型号","数量","单位","单价(元)","含税单价(元)","合计(元)","包内数量","包代码","包数量","包单价","包合计(元)","商品品类","品牌名称","拒绝原因"
|
|
|
|
row.createCell(0).setCellValue(i+1); |
|
|
|
row.createCell(1).setCellValue(pc); |
|
|
|
row.createCell(2).setCellValue(productNums.get(i).getSupplierCode()); |
|
|
|
row.createCell(3).setCellValue(productNums.get(i).getSupplierName()); |
|
|
|
row.createCell(4).setCellValue(productNums.get(i).getCode()); |
|
|
|
row.createCell(5).setCellValue(productNums.get(i).getBarCode()); |
|
|
|
row.createCell(6).setCellValue(productNums.get(i).getName()); |
|
|
|
row.createCell(7).setCellValue(productNums.get(i).getUnit()); |
|
|
|
row.createCell(8).setCellValue(productNums.get(i).getPurchasePrice());//进价
|
|
|
|
row.createCell(9).setCellValue(productNums.get(i).getValence());//进价
|
|
|
|
row.createCell(10).setCellValue(productNums.get(i).getPrice());//售价
|
|
|
|
row.createCell(11).setCellValue(productNums.get(i).getBoxGauge()); |
|
|
|
row.createCell(12).setCellValue(productNums.get(i).getNum()); |
|
|
|
row.createCell(13).setCellValue(productNums.get(i).getOrderAmount()); |
|
|
|
row.createCell(14).setCellValue("0"); |
|
|
|
row.createCell(15).setCellValue(productNums.get(i).getTaxReceipt()); |
|
|
|
row.createCell(16).setCellValue(productNums.get(i).getDiscount()); |
|
|
|
row.createCell(17).setCellValue(productNums.get(i).getState()==1?"符合":"不符合"); |
|
|
|
row.createCell(18).setCellValue(productNums.get(i).getRemarks()); |
|
|
|
} |
|
|
|
return wb; |
|
|
|
} |
|
|
|
|
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void createRow2(String[] col, HSSFSheet sheet) { |
|
|
|
HSSFCell c = null; |
|
|
|
HSSFRow row1 = sheet.createRow(1); |
|
|
|
c = row1.createCell(0); |
|
|
|
c.setCellValue(col[0]+" "+ col[1]+" "+ col[2]); |
|
|
|
} |
|
|
|
@Resource |
|
|
|
private PurchaseRequisitionService purchaseRequisitionService; |
|
|
|
@Resource |
|
|
|
private PurchaseRequisitionProService purchaseRequisitionProService; |
|
|
|
/** |
|
|
|
* |
|
|
|
* 带批次导出采购订单的商品审批结果 |
|
|
|
* @param pc |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public HSSFWorkbook products(String pc){ |
|
|
|
String title = "重点品类商品订货明细限定情况"; |
|
|
|
String[] col = {"审核单号","状态","合计金额"}; |
|
|
|
String[] col1 = {"序号","采购订单编号","厂商编码","厂商名称","商品代码","商品条码","商品名称","单位","进价","配价","售价","箱规", |
|
|
|
"订货数量","订货金额(元)","合计","税票","降价折扣%","判定结果","备注"}; |
|
|
|
//sheet名
|
|
|
|
String sheetName = pc+"重点品类商品订货明细限定情况"; |
|
|
|
//创建HSSFWorkbook
|
|
|
|
PurchaseRequisition purchaseRequisition=purchaseRequisitionService.selectByCode(pc); |
|
|
|
String purchaseRequisitionSid = purchaseRequisition.getSid(); |
|
|
|
List<PurchaseRequisitionPro> list=purchaseRequisitionProService.selectByMainSid(purchaseRequisitionSid); |
|
|
|
addProductNum(purchaseRequisition,list); |
|
|
|
|
|
|
|
List<ProductNum> productNums=baseMapper.selectByPc(pc); |
|
|
|
// 第一步,创建一个HSSFWorkbook,对应一个Excel文件
|
|
|
|
HSSFWorkbook wb = new HSSFWorkbook(); |
|
|
|
// 第二步,在workbook中添加一个sheet,对应Excel文件中的sheet
|
|
|
|
HSSFSheet sheet = wb.createSheet(sheetName); |
|
|
|
// 合并单元格:参数:起始行, 终止行, 起始列, 终止列
|
|
|
|
CellRangeAddress cra = new CellRangeAddress(0, 0, 0, 19); |
|
|
|
sheet.addMergedRegion(cra); |
|
|
|
// 第三步,在sheet中添加表头第0行,注意老版本poi对Excel的行数列数有限制
|
|
|
|
|
|
|
|
HSSFRow row = sheet.createRow(0); |
|
|
|
// 第四步,创建单元格,并设置值表头 设置表头居中
|
|
|
|
HSSFCellStyle style = wb.createCellStyle(); |
|
|
|
style.setAlignment(HorizontalAlignment.CENTER); // 创建一个居中格式
|
|
|
|
HSSFCell titleRow = row.createCell(0); |
|
|
|
titleRow.setCellValue(title); |
|
|
|
titleRow.setCellStyle(style); |
|
|
|
|
|
|
|
/*HSSFCell titleRow1 = row.createCell(1); |
|
|
|
titleRow1.setCellValue("审核单号:123456789 状态:已通过审核 合计金额:12345678"); |
|
|
|
titleRow1.setCellStyle(style);*/ |
|
|
|
|
|
|
|
//声明列对象
|
|
|
|
|
|
|
|
createRow3(sheet, 1, col1, style); |
|
|
|
|
|
|
|
//创建内容
|
|
|
|
for(int i=0;i<productNums.size();i++){ |
|
|
|
row = sheet.createRow(i + 2); |
|
|
|
//将内容按顺序赋给对应的列对象
|
|
|
|
//"序号","厂商编码","厂商名称","商品代码","商品条码","商品名称","单位","进价","售价","箱规","订货数量","订货金额(元)","合计","税票","降价折扣%"
|
|
|
|
row.createCell(0).setCellValue(i+1); |
|
|
|
row.createCell(1).setCellValue(pc); |
|
|
|
row.createCell(2).setCellValue(productNums.get(i).getSupplierCode()); |
|
|
|
row.createCell(3).setCellValue(productNums.get(i).getSupplierName()); |
|
|
|
row.createCell(4).setCellValue(productNums.get(i).getCode()); |
|
|
|
row.createCell(5).setCellValue(productNums.get(i).getBarCode()); |
|
|
|
row.createCell(6).setCellValue(productNums.get(i).getName()); |
|
|
|
row.createCell(7).setCellValue(productNums.get(i).getUnit()); |
|
|
|
row.createCell(8).setCellValue(productNums.get(i).getPurchasePrice());//进价
|
|
|
|
row.createCell(9).setCellValue(productNums.get(i).getValence());//进价
|
|
|
|
row.createCell(10).setCellValue(productNums.get(i).getPrice());//售价
|
|
|
|
row.createCell(11).setCellValue(productNums.get(i).getBoxGauge()); |
|
|
|
row.createCell(12).setCellValue(productNums.get(i).getNum()); |
|
|
|
row.createCell(13).setCellValue(productNums.get(i).getOrderAmount()); |
|
|
|
row.createCell(14).setCellValue("0"); |
|
|
|
row.createCell(15).setCellValue(productNums.get(i).getTaxReceipt()); |
|
|
|
row.createCell(16).setCellValue(productNums.get(i).getDiscount()); |
|
|
|
row.createCell(17).setCellValue(productNums.get(i).getState()==1?"符合":"不符合"); |
|
|
|
row.createCell(18).setCellValue(productNums.get(i).getRemarks()); |
|
|
|
} |
|
|
|
return wb; |
|
|
|
} |
|
|
|
|
|
|
|
private void addProductNum(PurchaseRequisition pu,List<PurchaseRequisitionPro> list) { |
|
|
|
Map<String,Object> map=new HashMap<String,Object>(); |
|
|
|
map.put("pc",pu.getCode()); |
|
|
|
baseMapper.deleteByMap(map); |
|
|
|
for(int i = 0; i < list.size(); i++){ |
|
|
|
PurchaseRequisitionPro p=list.get(i); |
|
|
|
ProductNum pr=new ProductNum(); |
|
|
|
pr.setPc(pu.getCode()); |
|
|
|
pr.setSupplierCode(pu.getSupplierCode());//供应商代码
|
|
|
|
pr.setSupplierName(pu.getSupplierName());//供应商名称
|
|
|
|
ProductInformationVo productInformation=productInformationService.selectByCode(p.getProCode()); |
|
|
|
///ProductInformationVo b=productInformationService.limitJudgement(code);
|
|
|
|
ProductInformationVo b=productInformationService.selectByCode(p.getProCode()); |
|
|
|
String brandSid = b.getBrandSid(); |
|
|
|
String categoryKey = b.getCategoryKey(); |
|
|
|
|
|
|
|
List<RestrictedCategory> restrictedCategorys=restrictedCategoryService.limitJudgement(categoryKey,brandSid); |
|
|
|
if("081101,081102,081103".indexOf(categoryKey)>=0||(restrictedCategorys!=null&&restrictedCategorys.size()>0)){ |
|
|
|
pr.setState(1); |
|
|
|
}else{ |
|
|
|
pr.setState(0); |
|
|
|
String remarks=""; |
|
|
|
remarks=remarks+productInformation.getCategory()+"["+productInformation.getCategoryKey()+"]品类,"; |
|
|
|
remarks=remarks+productInformation.getBrand()+"["+productInformation.getBrandSid()+"]品牌不符合;"; |
|
|
|
pr.setRemarks(remarks); |
|
|
|
} |
|
|
|
pr.setCode(p.getProCode()); |
|
|
|
if(productInformation!=null){ |
|
|
|
pr.setBrand(productInformation.getBrand()); |
|
|
|
pr.setCategory(productInformation.getCategory()); |
|
|
|
} |
|
|
|
pr.setBarCode(p.getSecondCode());//商品条码
|
|
|
|
pr.setName(p.getProName());//商品名称
|
|
|
|
pr.setUnit(p.getUnit());//单位
|
|
|
|
String packageTotalPrice = p.getPackageTotalPrice(); |
|
|
|
String number = p.getNumber(); |
|
|
|
BigDecimal v = new BigDecimal(packageTotalPrice).divide(new BigDecimal(number),4,BigDecimal.ROUND_HALF_UP); |
|
|
|
pr.setPurchasePrice(v.toString());//进价 送货金额/数量=进价
|
|
|
|
pr.setValence(productInformation.getRationingPrice());//配价
|
|
|
|
String retailAmount = p.getRetailAmount();//零售金额
|
|
|
|
String packageSpec = p.getPackageInsideNumber();//包装规格
|
|
|
|
String packageNumber = p.getPackageNumber();//包装数量
|
|
|
|
BigDecimal v1 = new BigDecimal(retailAmount).divide(new BigDecimal(packageSpec)).divide(new BigDecimal(packageNumber)); |
|
|
|
//double v1 = Double.parseDouble(retailAmount) / Double.parseDouble(packageSpec) / Double.parseDouble(packageNumber);
|
|
|
|
pr.setPrice(v1.toString());//售价 零售金额/规格/包装数量=单价
|
|
|
|
pr.setBoxGauge(packageSpec);//箱规
|
|
|
|
pr.setNum(p.getNumber());//订货数量
|
|
|
|
pr.setOrderAmount(p.getPackageTotalPrice());//订货金额
|
|
|
|
pr.setTaxReceipt("");//税票
|
|
|
|
pr.setDiscount("");//折扣
|
|
|
|
|
|
|
|
baseMapper.insert(pr); |
|
|
|
} |
|
|
|
} |
|
|
|
} |