@ -121,6 +121,7 @@ public class PurchaseRequisitionService extends MybatisBaseService<PurchaseRequi
public void ztspglhzb ( ) throws ParseException {
public void ztspglhzb ( ) throws ParseException {
Date date = new Date ( ) ;
Date date = new Date ( ) ;
SimpleDateFormat sdf1 = new SimpleDateFormat ( "yyyyMMdd" ) ;
SimpleDateFormat sdf1 = new SimpleDateFormat ( "yyyyMMdd" ) ;
baseMapper . deleteAll ( ) ;
List < Map < String , Object > > list = baseMapper . ztspglhzb ( ) ; //--在途商品管理汇总表
List < Map < String , Object > > list = baseMapper . ztspglhzb ( ) ; //--在途商品管理汇总表
for ( Map < String , Object > m : list ) {
for ( Map < String , Object > m : list ) {
String billTotalPrice = m . get ( "billTotalPrice" ) ! = null ? m . get ( "billTotalPrice" ) . toString ( ) : "0" ; //订单总额
String billTotalPrice = m . get ( "billTotalPrice" ) ! = null ? m . get ( "billTotalPrice" ) . toString ( ) : "0" ; //订单总额
@ -299,20 +300,7 @@ public class PurchaseRequisitionService extends MybatisBaseService<PurchaseRequi
productInformationVo . setNewestPurchasePrice ( divide . toString ( ) ) ;
productInformationVo . setNewestPurchasePrice ( divide . toString ( ) ) ;
ProductInformation pif = new ProductInformation ( ) ;
ProductInformation pif = new ProductInformation ( ) ;
BeanUtil . copyProperties ( productInformationVo , pif ) ;
BeanUtil . copyProperties ( productInformationVo , pif ) ;
productInformationService . updateById ( pif ) ;
productInformationService . updateById ( pif ) ;
String brandSid = pif . getBrandSid ( ) ;
String categoryKey = pif . 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(2);
/ * RestrictedCategory restrictedCategory = new RestrictedCategory ( ) ;
restrictedCategory . setCategorys ( "[" + categoryKey + "]" ) ;
restrictedCategory . setBrands ( "[" + brandSid + "]" ) ;
restrictedCategoryService . insert ( restrictedCategory ) ; * /
// }
}
}
if ( StringUtils . isNotBlank ( p . getCode ( ) ) ) {
if ( StringUtils . isNotBlank ( p . getCode ( ) ) ) {
@ -329,13 +317,6 @@ public class PurchaseRequisitionService extends MybatisBaseService<PurchaseRequi
BeanUtil . copyProperties ( category , dictCommon ) ;
BeanUtil . copyProperties ( category , dictCommon ) ;
dictCommonService . insert ( dictCommon ) ;
dictCommonService . insert ( dictCommon ) ;
}
}
List < RestrictedCategory > supervise = restrictedCategoryService . limitJudgement ( category . getDictKey ( ) , "supervise" ) ;
if ( supervise = = null | | supervise . size ( ) = = 0 ) {
RestrictedCategory restrictedCategory = new RestrictedCategory ( ) ;
restrictedCategory . setCategorys ( category . getDictKey ( ) ) ;
restrictedCategory . setCategorys ( "supervise" ) ;
restrictedCategoryService . insert ( restrictedCategory ) ;
}
p . setCategoryKey ( category . getDictKey ( ) ) ;
p . setCategoryKey ( category . getDictKey ( ) ) ;
p . setCategory ( category . getDictValue ( ) ) ;
p . setCategory ( category . getDictValue ( ) ) ;
productInformationService . insert ( p ) ;
productInformationService . insert ( p ) ;
@ -395,6 +376,17 @@ public class PurchaseRequisitionService extends MybatisBaseService<PurchaseRequi
prp . setRetailAmount ( value ) ;
prp . setRetailAmount ( value ) ;
}
}
}
}
if ( i = = 51 ) { //品类
brandIdHSSFCell . setCellType ( CellType . STRING ) ;
if ( StringUtils . isNotBlank ( brandIdHSSFCell . getStringCellValue ( ) ) ) {
String value = brandIdHSSFCell . getStringCellValue ( ) ;
String [ ] split = value . split ( "\\[" ) ;
String v = split [ 0 ] ; //类别value
String key = split [ 1 ] . replace ( "]" , "" ) ; //key
prp . setCategory ( v ) ;
prp . setCategoryKey ( key ) ;
}
}
if ( i = = 12 ) { //配货价格
if ( i = = 12 ) { //配货价格
brandIdHSSFCell . setCellType ( CellType . STRING ) ;
brandIdHSSFCell . setCellType ( CellType . STRING ) ;
if ( StringUtils . isNotBlank ( brandIdHSSFCell . getStringCellValue ( ) ) ) {
if ( StringUtils . isNotBlank ( brandIdHSSFCell . getStringCellValue ( ) ) ) {
@ -437,11 +429,11 @@ public class PurchaseRequisitionService extends MybatisBaseService<PurchaseRequi
purchaseRequisitionService . insert ( pr ) ;
purchaseRequisitionService . insert ( pr ) ;
for ( PurchaseRequisitionPro p : prps ) {
for ( PurchaseRequisitionPro p : prps ) {
purchaseRequisitionProService . insert ( p ) ;
purchaseRequisitionProService . insert ( p ) ;
String proCode = p . getProCode ( ) ;
/* String proCode = p.getProCode();*/
int row = purchaseRequisitionProService . selectProdCodeTable ( proCode ) ;
/ * int row = purchaseRequisitionProService . selectProdCodeTable ( proCode ) ;
if ( row = = 0 ) {
if ( row = = 0 ) {
purchaseRequisitionProService . insertProdCodeTable ( proCode ) ;
purchaseRequisitionProService . insertProdCodeTable ( proCode ) ;
}
} * /
}
}
GdRescategoryProdService . resetCache ( ) ;
GdRescategoryProdService . resetCache ( ) ;
String x = JSON . toJSONString ( lisss ) ;
String x = JSON . toJSONString ( lisss ) ;
@ -611,78 +603,7 @@ public class PurchaseRequisitionService extends MybatisBaseService<PurchaseRequi
public PurchaseRequisition selectBySid ( String sid ) {
public PurchaseRequisition selectBySid ( String sid ) {
return baseMapper . selectBySid ( sid ) ;
return baseMapper . selectBySid ( sid ) ;
}
}
/ * *
*
* 带批次导出采购订单的商品审批结果
* @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 < PurchaseRequisitionProDto > 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 , 17 ) ;
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 ( 9 ) . setCellValue ( productNums . get ( i ) . getBoxGauge ( ) ) ;
row . createCell ( 10 ) . setCellValue ( productNums . get ( i ) . getNum ( ) ) ;
row . createCell ( 11 ) . setCellValue ( productNums . get ( i ) . getOrderAmount ( ) ) ;
row . createCell ( 12 ) . setCellValue ( "0" ) ;
row . createCell ( 13 ) . setCellValue ( productNums . get ( i ) . getTaxReceipt ( ) ) ;
row . createCell ( 14 ) . setCellValue ( productNums . get ( i ) . getDiscount ( ) ) ;
row . createCell ( 15 ) . setCellValue ( productNums . get ( i ) . getState ( ) = = 1 ? "符合" : "不符合" ) ;
row . createCell ( 16 ) . setCellValue ( productNums . get ( i ) . getRemarks ( ) ) ;
}
return wb ;
}
private void createRow3 ( HSSFSheet sheet , int rownum , String [ ] col1 , HSSFCellStyle style ) {
private void createRow3 ( HSSFSheet sheet , int rownum , String [ ] col1 , HSSFCellStyle style ) {
//声明列对象
//声明列对象
@ -696,58 +617,4 @@ public class PurchaseRequisitionService extends MybatisBaseService<PurchaseRequi
}
}
}
}
private void addProductNum ( PurchaseRequisition pu , List < PurchaseRequisitionProDto > 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 + + ) {
PurchaseRequisitionProDto 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 ) , 2 , 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),4,BigDecimal.ROUND_HALF_UP).divide(new BigDecimal(packageNumber),4,BigDecimal.ROUND_HALF_UP);
//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 ( "" ) ; //折扣
productNumService . insert ( pr ) ;
}
}
}
}