|
|
@@ -1,18 +1,23 @@
|
|
|
package com.usoftchina.saas.sale.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.sale.mapper.SaleListMapper;
|
|
|
import com.usoftchina.saas.sale.mapper.SaleProfitViewMapper;
|
|
|
import com.usoftchina.saas.sale.mapper.SalerecViewMapper;
|
|
|
import com.usoftchina.saas.sale.service.SaleReportService;
|
|
|
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
|
|
|
@@ -25,38 +30,90 @@ public class SaleReportServiceImpl implements SaleReportService{
|
|
|
private SaleProfitViewMapper saleProfitViewMapper;
|
|
|
@Autowired
|
|
|
private SalerecViewMapper salerecViewMapper;
|
|
|
+ @Autowired
|
|
|
+ private SaleListMapper saleListMapper;
|
|
|
|
|
|
@Override
|
|
|
- public PageInfo getSaleProfitData(PageRequest page, ListReqDTO req) {
|
|
|
- return getListDATA(page, req, "SaleProfit");
|
|
|
+ public Map<String, Object> getSaleProfitData(@PageDefault(size = 10) PageRequest page, ListReqDTO req) {
|
|
|
+ PageHelper.startPage(page.getNumber(), page.getSize());
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+ 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 = saleProfitViewMapper.selectByCondition(con, companyId);
|
|
|
+ //取分页信息
|
|
|
+ PageInfo pageInfo = new PageInfo(list);
|
|
|
+ //取对应计算数据
|
|
|
+ if (!StringUtils.isEmpty(calculateFieldsSql)) {
|
|
|
+ String res = saleProfitViewMapper.selectCalculateFields(calculateFieldsSql, con, companyId);
|
|
|
+ try {
|
|
|
+ arr = JSONArray.parseArray(res);
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("list", pageInfo);
|
|
|
+ map.put("calculate", arr);
|
|
|
+ return map;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public PageInfo getSaleRecData(PageRequest page, ListReqDTO req) {
|
|
|
- return getListDATA(page, req, "SaleRec");
|
|
|
- }
|
|
|
-
|
|
|
- private PageInfo getListDATA(@PageDefault(size = 10) PageRequest page, ListReqDTO req, String type) {
|
|
|
+ public Map<String, Object> getSaleRecData(@PageDefault(size = 10) PageRequest page, ListReqDTO req) {
|
|
|
PageHelper.startPage(page.getNumber(), page.getSize());
|
|
|
- //查询数据
|
|
|
- List lists = getListByType(req, type);
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+ 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 = salerecViewMapper.selectByCondition(con, companyId);
|
|
|
//取分页信息
|
|
|
- PageInfo pageInfo = new PageInfo(lists);
|
|
|
- return pageInfo;
|
|
|
+ PageInfo pageInfo = new PageInfo(list);
|
|
|
+ //取对应计算数据
|
|
|
+ if (!StringUtils.isEmpty(calculateFieldsSql)) {
|
|
|
+ String res = salerecViewMapper.selectCalculateFields(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> getSaleDetail(@PageDefault(size = 10) PageRequest page, ListReqDTO req) {
|
|
|
+ PageHelper.startPage(page.getNumber(), page.getSize());
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
List list = null;
|
|
|
Long companyId = BaseContextHolder.getCompanyId();
|
|
|
String con = req.getFinalCondition();
|
|
|
+ String calculateFieldsSql = req.getCalculateFieldsSql();
|
|
|
+ JSONArray arr = null;
|
|
|
if (null == con) {
|
|
|
con = "1=1";
|
|
|
}
|
|
|
- if ("SaleProfit".equals(type)) {
|
|
|
- list = saleProfitViewMapper.selectByCondition(con, companyId);
|
|
|
- } else if ("SaleRec".equals(type)){
|
|
|
- list = salerecViewMapper.selectByCondition(con, companyId);
|
|
|
+ list = saleListMapper.selectSaleListByCondition(con, companyId);
|
|
|
+ //取分页信息
|
|
|
+ PageInfo pageInfo = new PageInfo(list);
|
|
|
+ //取对应计算数据
|
|
|
+ if (!StringUtils.isEmpty(calculateFieldsSql)) {
|
|
|
+ String res = saleListMapper.selectCalculateFields(calculateFieldsSql, con, companyId);
|
|
|
+ try {
|
|
|
+ arr = JSONArray.parseArray(res);
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
}
|
|
|
- return list;
|
|
|
+ map.put("list", pageInfo);
|
|
|
+ map.put("calculate", arr);
|
|
|
+ return map;
|
|
|
}
|
|
|
}
|