|
@@ -1,16 +1,21 @@
|
|
|
package com.usoftchina.saas.storage.service.impl;
|
|
package com.usoftchina.saas.storage.service.impl;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.usoftchina.saas.commons.dto.ListReqDTO;
|
|
import com.usoftchina.saas.commons.dto.ListReqDTO;
|
|
|
import com.usoftchina.saas.context.BaseContextHolder;
|
|
import com.usoftchina.saas.context.BaseContextHolder;
|
|
|
|
|
+import com.usoftchina.saas.page.PageDefault;
|
|
|
import com.usoftchina.saas.page.PageRequest;
|
|
import com.usoftchina.saas.page.PageRequest;
|
|
|
import com.usoftchina.saas.storage.mapper.ProdInOutReportMapper;
|
|
import com.usoftchina.saas.storage.mapper.ProdInOutReportMapper;
|
|
|
import com.usoftchina.saas.storage.service.ProdInOutReportService;
|
|
import com.usoftchina.saas.storage.service.ProdInOutReportService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Created by zdw
|
|
* Created by zdw
|
|
@@ -22,43 +27,59 @@ public class ProdInOutReportServiceImpl implements ProdInOutReportService{
|
|
|
private ProdInOutReportMapper prodInOutReportMapper;
|
|
private ProdInOutReportMapper prodInOutReportMapper;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public PageInfo getProdiodetail(PageRequest page, ListReqDTO req) {
|
|
|
|
|
- return getListDATA(page, req, "Prodiodetail");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public PageInfo getProdinoutCount(PageRequest page, ListReqDTO req) {
|
|
|
|
|
- return getListDATA(page, req, "ProdinoutCount");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- 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> getProdiodetail(@PageDefault(size = 10) PageRequest page, ListReqDTO req) {
|
|
|
PageHelper.startPage(page.getNumber(), page.getSize());
|
|
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 = prodInOutReportMapper.selectProdiodetailByCondition(con, companyId);
|
|
|
//取分页信息
|
|
//取分页信息
|
|
|
- PageInfo pageInfo = new PageInfo(lists);
|
|
|
|
|
- return pageInfo;
|
|
|
|
|
|
|
+ PageInfo pageInfo = new PageInfo(list);
|
|
|
|
|
+ //取对应计算数据
|
|
|
|
|
+ if (!StringUtils.isEmpty(calculateFieldsSql)) {
|
|
|
|
|
+ String res = prodInOutReportMapper.selectProdiodetailCalculateFields(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> getProdinoutCount(@PageDefault(size = 10) PageRequest page, ListReqDTO req) {
|
|
|
|
|
+ PageHelper.startPage(page.getNumber(), page.getSize());
|
|
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
List list = null;
|
|
List list = null;
|
|
|
Long companyId = BaseContextHolder.getCompanyId();
|
|
Long companyId = BaseContextHolder.getCompanyId();
|
|
|
String con = req.getFinalCondition();
|
|
String con = req.getFinalCondition();
|
|
|
|
|
+ String calculateFieldsSql = req.getCalculateFieldsSql();
|
|
|
|
|
+ JSONArray arr = null;
|
|
|
if (null == con) {
|
|
if (null == con) {
|
|
|
con = "1=1";
|
|
con = "1=1";
|
|
|
}
|
|
}
|
|
|
- if ("Prodiodetail".equals(type)) {
|
|
|
|
|
- list = prodInOutReportMapper.selectProdiodetailByCondition(con, companyId);
|
|
|
|
|
- } else if ("ProdinoutCount".equals(type)){
|
|
|
|
|
- list = prodInOutReportMapper.selectProdinoutCountByCondition(con, companyId);
|
|
|
|
|
|
|
+ list = prodInOutReportMapper.selectProdinoutCountByCondition(con, companyId);
|
|
|
|
|
+ //取分页信息
|
|
|
|
|
+ PageInfo pageInfo = new PageInfo(list);
|
|
|
|
|
+ //取对应计算数据
|
|
|
|
|
+ if (!StringUtils.isEmpty(calculateFieldsSql)) {
|
|
|
|
|
+ String res = prodInOutReportMapper.selectProdinoutCountCalculateFields(calculateFieldsSql, con, companyId);
|
|
|
|
|
+ try {
|
|
|
|
|
+ arr = JSONArray.parseArray(res);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- return list;
|
|
|
|
|
|
|
+ map.put("list", pageInfo);
|
|
|
|
|
+ map.put("calculate", arr);
|
|
|
|
|
+ return map;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|