|
|
@@ -1,16 +1,21 @@
|
|
|
package com.usoftchina.saas.purchase.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.usoftchina.saas.commons.dto.ListReqDTO;
|
|
|
import com.usoftchina.saas.context.BaseContextHolder;
|
|
|
+import com.usoftchina.saas.page.PageDefault;
|
|
|
import com.usoftchina.saas.page.PageRequest;
|
|
|
import com.usoftchina.saas.purchase.mapper.PurchaseReportMapper;
|
|
|
import com.usoftchina.saas.purchase.service.PurchaseReportService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author: guq
|
|
|
@@ -23,43 +28,59 @@ public class PurchaseReportServiceImpl implements PurchaseReportService{
|
|
|
private PurchaseReportMapper purchaseReportMapper;
|
|
|
|
|
|
@Override
|
|
|
- public PageInfo getPurchasePayData(PageRequest page, ListReqDTO req) {
|
|
|
- return getListDATA(page, req, "PurchasePay");
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public PageInfo getPurchaseDetailData(PageRequest page, ListReqDTO req) {
|
|
|
- return getListDATA(page, req, "PurchaseReportDetail");
|
|
|
- }
|
|
|
-
|
|
|
- private PageInfo getListDATA(PageRequest page, ListReqDTO req, String type) {
|
|
|
- //设置默认分页
|
|
|
- if (null == page || page.getSize() == 0 || page.getNumber() == 0) {
|
|
|
- page = new PageRequest();
|
|
|
- page.setNumber(1);
|
|
|
- page.setSize(10);
|
|
|
- }
|
|
|
+ public Map<String, Object> getPurchasePayData(@PageDefault(size = 10)PageRequest page, ListReqDTO req) {
|
|
|
PageHelper.startPage(page.getNumber(), page.getSize());
|
|
|
- //查询数据
|
|
|
- List lists = getListByType(req, type);
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ List list = null;
|
|
|
+ Long companyId = BaseContextHolder.getCompanyId();
|
|
|
+ String con = req.getFinalCondition();
|
|
|
+ String calculateFieldsSql = req.getCalculateFieldsSql();
|
|
|
+ JSONArray arr = null;
|
|
|
+ if (null == con) {
|
|
|
+ con = "1=1";
|
|
|
+ }
|
|
|
+ list = purchaseReportMapper.selectPurchasePayByCondition(con, companyId);
|
|
|
//取分页信息
|
|
|
- PageInfo pageInfo = new PageInfo(lists);
|
|
|
- return pageInfo;
|
|
|
+ PageInfo pageInfo = new PageInfo(list);
|
|
|
+ //取对应计算数据
|
|
|
+ if (!StringUtils.isEmpty(calculateFieldsSql)) {
|
|
|
+ String res = purchaseReportMapper.selectPurchasePayCalculateFields(calculateFieldsSql, con, companyId);
|
|
|
+ try {
|
|
|
+ arr = JSONArray.parseArray(res);
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("list", pageInfo);
|
|
|
+ map.put("calculate", arr);
|
|
|
+ return map;
|
|
|
}
|
|
|
|
|
|
- private List getListByType(ListReqDTO req, String type) {
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getPurchaseDetailData(@PageDefault(size = 10)PageRequest page, ListReqDTO req) {
|
|
|
+ PageHelper.startPage(page.getNumber(), page.getSize());
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
List list = null;
|
|
|
Long companyId = BaseContextHolder.getCompanyId();
|
|
|
- companyId = 1l;
|
|
|
String con = req.getFinalCondition();
|
|
|
+ String calculateFieldsSql = req.getCalculateFieldsSql();
|
|
|
+ JSONArray arr = null;
|
|
|
if (null == con) {
|
|
|
con = "1=1";
|
|
|
}
|
|
|
- if ("PurchasePay".equals(type)) {
|
|
|
- list = purchaseReportMapper.selectByCondition(con, companyId);
|
|
|
- } else if ("PurchaseReportDetail".equals(type)){
|
|
|
- list = purchaseReportMapper.selectDetailByCondition(con, companyId);
|
|
|
+ list = purchaseReportMapper.selectDetailByCondition(con, companyId);
|
|
|
+ //取分页信息
|
|
|
+ PageInfo pageInfo = new PageInfo(list);
|
|
|
+ //取对应计算数据
|
|
|
+ if (!StringUtils.isEmpty(calculateFieldsSql)) {
|
|
|
+ String res = purchaseReportMapper.selectDetailCalculateFields(calculateFieldsSql, con, companyId);
|
|
|
+ try {
|
|
|
+ arr = JSONArray.parseArray(res);
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
}
|
|
|
- return list;
|
|
|
+ map.put("list", pageInfo);
|
|
|
+ map.put("calculate", arr);
|
|
|
+ return map;
|
|
|
}
|
|
|
+
|
|
|
}
|