yxt_djz 3 years ago
parent
commit
7a6d4b264d
  1. 5
      yxt_supervise/supervise-portal/supervise-portal-api/src/main/java/com/yxt/supervise/portal/api/purchaserequisitionpro/PurchaseRequisitionPro.java
  2. 5
      yxt_supervise/supervise-portal/supervise-portal-api/src/main/java/com/yxt/supervise/portal/api/purchaserequisitionpro/PurchaseRequisitionProDetailsVo.java
  3. 5
      yxt_supervise/supervise-portal/supervise-portal-api/src/main/java/com/yxt/supervise/portal/api/purchaserequisitionpro/PurchaseRequisitionProDto.java
  4. 5
      yxt_supervise/supervise-portal/supervise-portal-api/src/main/java/com/yxt/supervise/portal/api/purchaserequisitionpro/PurchaseRequisitionProQuery.java
  5. 5
      yxt_supervise/supervise-portal/supervise-portal-api/src/main/java/com/yxt/supervise/portal/api/purchaserequisitionpro/PurchaseRequisitionProVo.java
  6. 59
      yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/inventoryinformation/InventoryInformationRest.java
  7. 76
      yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/inventoryinformation/InventoryInformationService.java
  8. 2
      yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/productnum/ProductNumMapper.java
  9. 61
      yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/productnum/ProductNumRest.java
  10. 295
      yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/productnum/ProductNumService.java
  11. 9
      yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/purchaserequisition/PurchaseRequisitionMapper.java
  12. 71
      yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/purchaserequisition/PurchaseRequisitionService.java
  13. 11
      yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/purchaserequisitionpro/PurchaseRequisitionProMapper.java
  14. 10
      yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/purchaserequisitionpro/PurchaseRequisitionProService.java
  15. 2
      yxt_supervise/supervise-portal/supervise-portal-biz/src/main/resources/application.yml

5
yxt_supervise/supervise-portal/supervise-portal-api/src/main/java/com/yxt/supervise/portal/api/purchaserequisitionpro/PurchaseRequisitionPro.java

@ -90,5 +90,8 @@ public class PurchaseRequisitionPro extends BaseEntity {
private String brandCode; // 品牌编码
@ApiModelProperty("发货日期")
private String issuanceDate; // 发货日期
@ApiModelProperty("第二代码")
private String secondCode;// 第二代码
@ApiModelProperty("零售金额")
private String retailAmount;// 零售金额
}

5
yxt_supervise/supervise-portal/supervise-portal-api/src/main/java/com/yxt/supervise/portal/api/purchaserequisitionpro/PurchaseRequisitionProDetailsVo.java

@ -109,5 +109,8 @@ public class PurchaseRequisitionProDetailsVo implements Vo {
private String brandCode; // 品牌编码
@ApiModelProperty("发货日期")
private String issuanceDate; // 发货日期
@ApiModelProperty("第二代码")
private String secondCode;// 第二代码
@ApiModelProperty("零售金额")
private String retailAmount;// 零售金额
}

5
yxt_supervise/supervise-portal/supervise-portal-api/src/main/java/com/yxt/supervise/portal/api/purchaserequisitionpro/PurchaseRequisitionProDto.java

@ -109,5 +109,8 @@ public class PurchaseRequisitionProDto implements Dto {
private String brandCode; // 品牌编码
@ApiModelProperty("发货日期")
private String issuanceDate; // 发货日期
@ApiModelProperty("第二代码")
private String secondCode;// 第二代码
@ApiModelProperty("零售金额")
private String retailAmount;// 零售金额
}

5
yxt_supervise/supervise-portal/supervise-portal-api/src/main/java/com/yxt/supervise/portal/api/purchaserequisitionpro/PurchaseRequisitionProQuery.java

@ -107,5 +107,8 @@ public class PurchaseRequisitionProQuery implements Query {
private String brandCode; // 品牌编码
@ApiModelProperty("发货日期")
private String issuanceDate; // 发货日期
@ApiModelProperty("第二代码")
private String secondCode;// 第二代码
@ApiModelProperty("零售金额")
private String retailAmount;// 零售金额
}

5
yxt_supervise/supervise-portal/supervise-portal-api/src/main/java/com/yxt/supervise/portal/api/purchaserequisitionpro/PurchaseRequisitionProVo.java

@ -91,5 +91,8 @@ public class PurchaseRequisitionProVo implements Vo {
private String brandCode; // 品牌编码
@ApiModelProperty("发货日期")
private String issuanceDate; // 发货日期
@ApiModelProperty("第二代码")
private String secondCode;// 第二代码
@ApiModelProperty("零售金额")
private String retailAmount;// 零售金额
}

59
yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/inventoryinformation/InventoryInformationRest.java

@ -123,63 +123,4 @@ public class InventoryInformationRest implements InventoryInformationFeign {
inventoryInformationService.readBrandPeriodSorXlsForDictCommon(in,"");
return rb;
}
@ApiOperation(" ")
@RequestMapping(value = "/exportExcel", method = RequestMethod.GET)
public ResultBean exportExcel(HttpServletRequest request, HttpServletResponse response){
ResultBean rb = ResultBean.fireFail(); //excel标题
//excel文件名
String fileName = "采购订单商品明细表"+System.currentTimeMillis()+".xls";
HSSFWorkbook wb = inventoryInformationService.exportExcel( null);
//响应到客户端
try {
this.setResponseHeader(response, fileName);
OutputStream os = response.getOutputStream();
wb.write(os);
os.flush();
os.close();
} catch (Exception e) {
e.printStackTrace();
}
return rb;
}
public void setResponseHeader(HttpServletResponse response, String fileName) {
try {
try {
fileName = new String(fileName.getBytes(),"ISO8859-1");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
response.setContentType("application/octet-stream;charset=ISO8859-1");
response.setHeader("Content-Disposition", "attachment;filename="+ fileName);
response.addHeader("Pargam", "no-cache");
response.addHeader("Cache-Control", "no-cache");
} catch (Exception ex) {
ex.printStackTrace();
}
}
}

76
yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/inventoryinformation/InventoryInformationService.java

@ -303,80 +303,4 @@ public class InventoryInformationService extends MybatisBaseService<InventoryInf
System.out.println(x1);
//return message;
}
@Resource
private ProductNumService productNumService;
public HSSFWorkbook exportExcel( HSSFWorkbook wb) {
String title = "重点品类商品订货明细";
String[] col = {"审核单号","状态","合计金额"};
String[] col1 = {"序号","厂商编码","厂商名称","商品代码","商品条码","商品名称","单位","进价","配价","售价","箱规",
"订货数量","订货金额(元)","合计","税票","降价折扣%","判定结果","备注"};
//sheet名
String sheetName = "重点品类商品订货明细";
//创建HSSFWorkbook
//String [][]content={{"张三","男","12","清华大学","大一"},{"李四","女","14","北京大学","大二"}};
List<ProductNum> productNums=productNumService.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, 18);
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);*/
//声明列对象
HSSFCell cell = null;
//创建标题
HSSFRow row1 = sheet.createRow(1);
for(int i=0;i<col1.length;i++){
cell = row1.createCell(i);
cell.setCellValue(col1[i]);
cell.setCellStyle(style);
}
//创建内容
for(int i=0;i<productNums.size();i++){
row = sheet.createRow(i + 2);
//将内容按顺序赋给对应的列对象
//"序号","厂商编码","厂商名称","商品代码","商品条码","商品名称","单位","进价","售价","箱规","订货数量","订货金额(元)","合计","税票","降价折扣%"
row.createCell(0).setCellValue(i);
row.createCell(1).setCellValue(productNums.get(i).getSupplierCode());
row.createCell(2).setCellValue(productNums.get(i).getSupplierName());
row.createCell(3).setCellValue(productNums.get(i).getCode());
row.createCell(4).setCellValue(productNums.get(i).getBarCode());
row.createCell(5).setCellValue(productNums.get(i).getName());
row.createCell(6).setCellValue(productNums.get(i).getUnit());
row.createCell(7).setCellValue(productNums.get(i).getPurchasePrice());//进价
row.createCell(8).setCellValue(productNums.get(i).getValence());//进价
row.createCell(9).setCellValue(productNums.get(i).getPrice());//售价
row.createCell(10).setCellValue(productNums.get(i).getBoxGauge());
row.createCell(11).setCellValue(productNums.get(i).getNum());
row.createCell(12).setCellValue(productNums.get(i).getOrderAmount());
row.createCell(13).setCellValue("0");
row.createCell(14).setCellValue(productNums.get(i).getTaxReceipt());
row.createCell(15).setCellValue(productNums.get(i).getDiscount());
row.createCell(16).setCellValue(productNums.get(i).getState());
row.createCell(17).setCellValue(productNums.get(i).getRemarks());
}
return wb;
}
}

2
yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/productnum/ProductNumMapper.java

@ -66,4 +66,6 @@ public interface ProductNumMapper extends BaseMapper<ProductNum> {
List<ProductNum> getAll();
@Select("select * from product_num where pc like CONCAT('%',#{pc},'%') group by pc ")
List<String> selectMaxPc(@Param("pc") String pc);
@Select("select * from product_num where pc =#{pc} ")
List<ProductNum> selectByPc(@Param("pc")String pc);
}

61
yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/productnum/ProductNumRest.java

@ -31,15 +31,14 @@ import com.yxt.common.core.vo.PagerVo;
import com.yxt.supervise.portal.api.productnum.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
/**
* Project: com.supervise(宇信通监管) <br/>
@ -119,8 +118,62 @@ public class ProductNumRest implements ProductNumFeign {
} catch (IOException e) {
e.printStackTrace();
}
//inventoryInformationService.readBrandPeriodSorXls1(in,"");
productNumService.readBrandPeriodSorXls1(in,"");
return rb;
}
@ApiOperation(" ")
@RequestMapping(value = "/exportExcel", method = RequestMethod.GET)
public ResultBean exportExcel(HttpServletRequest request, HttpServletResponse response){
ResultBean rb = ResultBean.fireFail(); //excel标题
//excel文件名
String fileName = "采购订单商品明细表"+System.currentTimeMillis()+".xls";
HSSFWorkbook wb = productNumService.exportExcel( null);
//响应到客户端
try {
this.setResponseHeader(response, fileName);
OutputStream os = response.getOutputStream();
wb.write(os);
os.flush();
os.close();
} catch (Exception e) {
e.printStackTrace();
}
return rb;
}
public void setResponseHeader(HttpServletResponse response, String fileName) {
try {
try {
fileName = new String(fileName.getBytes(),"ISO8859-1");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
response.setContentType("application/octet-stream;charset=ISO8859-1");
response.setHeader("Content-Disposition", "attachment;filename="+ fileName);
response.addHeader("Pargam", "no-cache");
response.addHeader("Cache-Control", "no-cache");
} catch (Exception ex) {
ex.printStackTrace();
}
}
@ApiOperation(" ")
@RequestMapping(value = "/products", method = RequestMethod.GET)
public ResultBean products(HttpServletRequest request, HttpServletResponse response){
String pc=request.getParameter("code");
ResultBean rb = ResultBean.fireFail(); //excel标题
//excel文件名
String fileName = pc+"采购订单商品明细表"+System.currentTimeMillis()+".xls";
HSSFWorkbook wb = productNumService.products( pc);
//响应到客户端
try {
this.setResponseHeader(response, fileName);
OutputStream os = response.getOutputStream();
wb.write(os);
os.flush();
os.close();
} catch (Exception e) {
e.printStackTrace();
}
return rb;
}
}

295
yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/productnum/ProductNumService.java

@ -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);
}
}
}

9
yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/purchaserequisition/PurchaseRequisitionMapper.java

@ -3,7 +3,16 @@ package com.yxt.supervise.portal.biz.purchaserequisition;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yxt.supervise.portal.api.purchaserequisition.PurchaseRequisition;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@Mapper
public interface PurchaseRequisitionMapper extends BaseMapper<PurchaseRequisition> {
/**
* 根据单据编号查询采购订单
* @param pc
* @return
*/
@Select("select * from purchase_requisition where code=#{code}")
PurchaseRequisition selectByCode(@Param("code") String pc);
}

71
yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/purchaserequisition/PurchaseRequisitionService.java

@ -44,9 +44,12 @@ 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.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Service
@ -140,6 +143,13 @@ public class PurchaseRequisitionService extends MybatisBaseService<PurchaseRequi
prp.setNumber(value);
}
}
if (i == 9) {//第二代码
brandIdHSSFCell.setCellType(CellType.STRING);
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) {
String value = brandIdHSSFCell.getStringCellValue();
prp.setSecondCode(value);
}
}
if (i == 4) {//包装数量
brandIdHSSFCell.setCellType(CellType.STRING);
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) {
@ -177,16 +187,12 @@ public class PurchaseRequisitionService extends MybatisBaseService<PurchaseRequi
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) {
String value= brandIdHSSFCell.getStringCellValue();
prp.setPackagePrice(value);
/*double v = Double.parseDouble(prp.getPackageInsideNumber());
double v1 = Double.parseDouble(prp.getPackageNumber());
double v2 = v / v1;
int i1 = Integer.parseInt(v2 + "");*/
// prp.setPackageInsideNumber(i1+"");
String packageNumber = prp.getPackageNumber();
Integer v3 = Integer.valueOf(packageNumber);
double v4 = Double.parseDouble(value);
double v5 = v3 * v4;
prp.setTotalPrice(v5+"");
BigDecimal v3 = new BigDecimal(packageNumber);
BigDecimal v4 = new BigDecimal(value);
BigDecimal v5 = v3 .multiply( v4);
prp.setTotalPrice(v5.toString());
}
}
if (i == 37) {//包合计(元)
@ -194,17 +200,48 @@ public class PurchaseRequisitionService extends MybatisBaseService<PurchaseRequi
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) {
String value= brandIdHSSFCell.getStringCellValue();
prp.setPackageTotalPrice(value);
//latestPurchasePrice
String packageTotalPrice = prp.getPackageTotalPrice(); //送货金额
String number = prp.getNumber();//数量
BigDecimal v = new BigDecimal(packageTotalPrice).divide(new BigDecimal(number),4);
ProductInformationVo productInformationVo = productInformationService.selectByCode(prp.getProCode());
productInformationVo.setLatestPurchasePrice(v.toString());
ProductInformation pif=new ProductInformation();
BeanUtil.copyProperties(productInformationVo,pif);
productInformationService.updateById(pif);
}
}
if (i == 10) {//第二代码
brandIdHSSFCell.setCellType(CellType.STRING);
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) {
String value= brandIdHSSFCell.getStringCellValue();
prp.setSecondCode(value);
}
}
if (i == 56) {//零售金额
brandIdHSSFCell.setCellType(CellType.STRING);
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) {
String value= brandIdHSSFCell.getStringCellValue();
prp.setRetailAmount(value);
}
}
if (i == 12) {//配货价格
brandIdHSSFCell.setCellType(CellType.STRING);
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) {
String value= brandIdHSSFCell.getStringCellValue();
prp.setRetailAmount(value);
}
}
if (i == 21) {//含税单价(元)
brandIdHSSFCell.setCellType(CellType.STRING);
if (StringUtils.isNotBlank(brandIdHSSFCell.getStringCellValue())) {
String value= brandIdHSSFCell.getStringCellValue();
double v = Double.parseDouble(value);
double v1 = Double.parseDouble(prp.getPackageNumber());
int v2 = (int) (v / v1);
int i1 = Integer.parseInt(v2 + "");
prp.setUnitPriceTax(i1+"");
BigDecimal v = new BigDecimal(value);
BigDecimal v1 = new BigDecimal(prp.getPackageNumber());
BigDecimal v2 = v.divide( v1,4);
prp.setUnitPriceTax(v2.toString());
}
}
}else{
@ -239,6 +276,9 @@ public class PurchaseRequisitionService extends MybatisBaseService<PurchaseRequi
if (i == 1) {//单号
brandIdHSSFCell.setCellType(CellType.STRING);
String code = brandIdHSSFCell.getStringCellValue();
Map<String,Object> map=new HashMap<>();
map.put("code",code);
baseMapper.deleteByMap(map);
//ProductInformationVo productInformationVo = baseMapper.selectByCode(code);
pr.setCode(code);
@ -322,4 +362,9 @@ public class PurchaseRequisitionService extends MybatisBaseService<PurchaseRequi
}
}
}
public PurchaseRequisition selectByCode(String pc) {
PurchaseRequisition p=baseMapper.selectByCode(pc);
return p;
}
}

11
yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/purchaserequisitionpro/PurchaseRequisitionProMapper.java

@ -3,7 +3,18 @@ package com.yxt.supervise.portal.biz.purchaserequisitionpro;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yxt.supervise.portal.api.purchaserequisitionpro.PurchaseRequisitionPro;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@Mapper
public interface PurchaseRequisitionProMapper extends BaseMapper<PurchaseRequisitionPro> {
/**
* 根据主表的sid查询采购的商品信息
* @param purchaseRequisitionSid
* @return
*/
@Select("select * from purchase_requisition_pro where mainSid=#{mainSid}")
List<PurchaseRequisitionPro> selectByMainSid(@Param("mainSid") String purchaseRequisitionSid);
}

10
yxt_supervise/supervise-portal/supervise-portal-biz/src/main/java/com/yxt/supervise/portal/biz/purchaserequisitionpro/PurchaseRequisitionProService.java

@ -4,6 +4,16 @@ import com.yxt.common.base.service.MybatisBaseService;
import com.yxt.supervise.portal.api.purchaserequisitionpro.PurchaseRequisitionPro;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class PurchaseRequisitionProService extends MybatisBaseService<PurchaseRequisitionProMapper, PurchaseRequisitionPro> {
/**
* 根据主表的sid查询采购的商品信息
* @param purchaseRequisitionSid
* @return
*/
public List<PurchaseRequisitionPro> selectByMainSid(String purchaseRequisitionSid) {
return baseMapper.selectByMainSid(purchaseRequisitionSid);
}
}

2
yxt_supervise/supervise-portal/supervise-portal-biz/src/main/resources/application.yml

@ -2,7 +2,7 @@ spring:
application:
name: supervise-portal
profiles:
active: test
active: devv
messages:
# 国际化资源文件路径
basename: i18n/messages

Loading…
Cancel
Save