|
|
|
@ -8,22 +8,33 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import jnpf.mobilePort.entity.PurchaseOrderVO;
|
|
|
|
|
import jnpf.mobilePort.utils.ExportPdf;
|
|
|
|
|
import jnpf.permission.model.authorize.AuthorizeConditionModel;
|
|
|
|
|
import jnpf.permission.service.AuthorizeService;
|
|
|
|
|
import jnpf.purchaseorder.entity.*;
|
|
|
|
|
import jnpf.purchaseorder.mapper.PurchaseorderitemMapper;
|
|
|
|
|
import jnpf.purchaseorder.model.purchaseorder.PurchaseorderPagination;
|
|
|
|
|
import jnpf.purchaseorder.model.purchaseorder.Purchaseorder_item0Model;
|
|
|
|
|
import jnpf.purchaseorder.service.*;
|
|
|
|
|
import jnpf.util.ServletUtil;
|
|
|
|
|
import jnpf.util.StringUtil;
|
|
|
|
|
import jnpf.util.UserProvider;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
@ -62,6 +73,75 @@ public class PurchaseorderitemServiceImpl extends ServiceImpl<PurchaseorderitemM
|
|
|
|
|
@Resource
|
|
|
|
|
private PurchaseorderitemMapper purchaseorderitemMapper;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ResponseEntity<byte[]> getPdfInfo(){
|
|
|
|
|
PurchaseorderPagination pagination = new PurchaseorderPagination();
|
|
|
|
|
pagination.setDocumentNo("cgdj2023020300000001");
|
|
|
|
|
List<PurchaseOrderVO> pMap = this.getPMap(pagination);
|
|
|
|
|
if (pMap!=null&&pMap.size()>0){
|
|
|
|
|
PurchaseOrderVO pVO = pMap.get(0);
|
|
|
|
|
byte[] bytes = null;
|
|
|
|
|
HttpHeaders headers = null;
|
|
|
|
|
ByteArrayOutputStream out=null;
|
|
|
|
|
try {
|
|
|
|
|
ExportPdf exportPdf = new ExportPdf();
|
|
|
|
|
//渲染模板参数
|
|
|
|
|
Map map=new HashMap();
|
|
|
|
|
map.put("title","济钢城市矿产科技有限公司");
|
|
|
|
|
map.put("name", "城市矿产再生资源事业部");
|
|
|
|
|
map.put("creatorTime", pVO.getCreatorTime());
|
|
|
|
|
map.put("contractNo", pVO.getContractNo());
|
|
|
|
|
map.put("contractCode",pVO.getContractCode());
|
|
|
|
|
map.put("supplierName", pVO.getSupplierName());
|
|
|
|
|
|
|
|
|
|
List<Purchaseorder_item0Model> list = pVO.getPurchaseorder_item0List();
|
|
|
|
|
Integer settlement=0;
|
|
|
|
|
BigDecimal settlementSum = new BigDecimal(settlement);
|
|
|
|
|
Integer amount=0;
|
|
|
|
|
BigDecimal amountSum = new BigDecimal(amount);
|
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
Purchaseorder_item0Model model = list.get(i);
|
|
|
|
|
settlementSum=settlementSum.add(new BigDecimal(model.getSettlement())) ;
|
|
|
|
|
amountSum=amountSum.add(new BigDecimal(model.getAmount()));
|
|
|
|
|
model.setSettlement(new BigDecimal(model.getSettlement()).setScale(2,BigDecimal.ROUND_HALF_DOWN).toString());
|
|
|
|
|
model.setPrice(new BigDecimal(model.getPrice()).setScale(2,BigDecimal.ROUND_HALF_DOWN).toString());
|
|
|
|
|
model.setAmount(new BigDecimal(model.getAmount()).setScale(2,BigDecimal.ROUND_HALF_DOWN).toString());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
map.put("settlementSum",settlementSum.setScale(2,BigDecimal.ROUND_HALF_DOWN).toString());
|
|
|
|
|
map.put("amountSum",amountSum.setScale(2,BigDecimal.ROUND_HALF_DOWN).toString() );
|
|
|
|
|
map.put("reportList", list);
|
|
|
|
|
System.out.println(map.toString());
|
|
|
|
|
System.out.println("AAAAAAAAAAAAAAAAAAAAAA ");
|
|
|
|
|
//repotData自己加测试数据
|
|
|
|
|
|
|
|
|
|
out= exportPdf.createPdf(map, "test.ftl", "/templates/export");
|
|
|
|
|
bytes = out.toByteArray();
|
|
|
|
|
String fileName="测试.pdf";
|
|
|
|
|
fileName = URLEncoder.encode(fileName, "utf-8");
|
|
|
|
|
headers = new HttpHeaders();
|
|
|
|
|
headers.add("Content-Disposition",
|
|
|
|
|
"attachment; filename=" + fileName);
|
|
|
|
|
//"attachment; filename=" + new String(fileName.getBytes("gbk"), StandardCharsets.ISO_8859_1));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("导出pdf失败:{}", e);
|
|
|
|
|
// throw new SubBusinessException(ErrorCode.FILE_DOWNLOAD_ERROR, "导出pdf失败!");
|
|
|
|
|
|
|
|
|
|
}finally {
|
|
|
|
|
if (null!=out){
|
|
|
|
|
try {
|
|
|
|
|
out.close();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
log.error("out close error:{}", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return new ResponseEntity<>(bytes, headers, HttpStatus.OK);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<PurchaseOrderVO> getPMap(PurchaseorderPagination purchaseorderPagination) {
|
|
|
|
|
// QueryWrapper<PurchaseorderitemEntity> wrapper = new QueryWrapper<>();
|
|
|
|
@ -417,24 +497,28 @@ public class PurchaseorderitemServiceImpl extends ServiceImpl<PurchaseorderitemM
|
|
|
|
|
queryWrapper.lambda().eq(Purchaseorder_item0Entity::getPurchaseorderId, id);
|
|
|
|
|
return purchaseorder_item0Service.list(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<Invoices_item0itemEntity> GetInvoices_item0itemList(String id){
|
|
|
|
|
QueryWrapper<Invoices_item0itemEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(Invoices_item0itemEntity::getInvoicesId, id);
|
|
|
|
|
return invoices_item0itemService.list(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<PaymentitemEntity> GetPaymentitemList(String id){
|
|
|
|
|
QueryWrapper<PaymentitemEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(PaymentitemEntity::getPaymentno, id);
|
|
|
|
|
return paymentitemService.list(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<PurchasebackitemEntity> GetPurchasebackitemList(String id){
|
|
|
|
|
QueryWrapper<PurchasebackitemEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
queryWrapper.lambda().eq(PurchasebackitemEntity::getPurchaseOrderId, id);
|
|
|
|
|
return purchasebackitemService.list(queryWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<CollectionpoEntity> GetCollectionitemList(String id){
|
|
|
|
|
QueryWrapper<CollectionpoEntity> queryWrapper = new QueryWrapper<>();
|
|
|
|
|