新增三张报表-销售统计、进货统计、结算账户
This commit is contained in:
@@ -17,6 +17,7 @@ import com.jsh.model.vo.basic.AccountModel;
|
||||
import com.jsh.service.basic.AccountIService;
|
||||
import com.jsh.service.materials.DepotHeadIService;
|
||||
import com.jsh.util.PageUtil;
|
||||
import com.jsh.util.Tools;
|
||||
/**
|
||||
* 结算账户
|
||||
* @author ji sheng hua qq752718920
|
||||
@@ -293,7 +294,9 @@ public class AccountAction extends BaseAction<AccountModel>
|
||||
item.put("name", account.getName());
|
||||
item.put("serialNo", account.getSerialNo());
|
||||
item.put("initialAmount", account.getInitialAmount());
|
||||
item.put("currentAmount", getAccountSum(account.getId()) + account.getInitialAmount());
|
||||
String monthTime = Tools.getCurrentMonth();
|
||||
item.put("thisMonthAmount", getAccountSum(account.getId(),monthTime)); //本月发生额
|
||||
item.put("currentAmount", getAccountSum(account.getId(),"") + account.getInitialAmount()); //当前余额
|
||||
item.put("remark", account.getRemark());
|
||||
item.put("op", 1);
|
||||
dataArray.add(item);
|
||||
@@ -317,13 +320,13 @@ public class AccountAction extends BaseAction<AccountModel>
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public Double getAccountSum(Long id){
|
||||
public Double getAccountSum(Long id,String monthTime){
|
||||
Double accountSum = 0.0;
|
||||
try{
|
||||
PageUtil<DepotHead> pageUtil = new PageUtil<DepotHead>();
|
||||
pageUtil.setPageSize(0);
|
||||
pageUtil.setCurPage(0);
|
||||
pageUtil.setAdvSearch(getCondition_getSum(id));
|
||||
pageUtil.setAdvSearch(getCondition_getSum(id,monthTime));
|
||||
depotHeadService.find(pageUtil);
|
||||
List<DepotHead> dataList = pageUtil.getPageList();
|
||||
if(dataList!= null){
|
||||
@@ -413,13 +416,17 @@ public class AccountAction extends BaseAction<AccountModel>
|
||||
* 拼接搜索条件-结算账户当前余额求和
|
||||
* @return
|
||||
*/
|
||||
private Map<String,Object> getCondition_getSum(Long id)
|
||||
private Map<String,Object> getCondition_getSum(Long id,String monthTime)
|
||||
{
|
||||
/**
|
||||
* 拼接搜索条件
|
||||
*/
|
||||
Map<String,Object> condition = new HashMap<String,Object>();
|
||||
condition.put("AccountId_n_eq", id);
|
||||
if(!monthTime.equals("")){
|
||||
condition.put("OperTime_s_gteq", monthTime + "-01 00:00:00");
|
||||
condition.put("OperTime_s_lteq", monthTime + "-31 00:00:00");
|
||||
}
|
||||
return condition;
|
||||
}
|
||||
|
||||
|
||||
@@ -233,7 +233,112 @@ public class DepotItemAction extends BaseAction<DepotItemModel>
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 进货统计
|
||||
* @return
|
||||
*/
|
||||
public void buyIn()
|
||||
{
|
||||
try
|
||||
{
|
||||
PageUtil<DepotItem> pageUtil = new PageUtil<DepotItem>();
|
||||
pageUtil.setPageSize(model.getPageSize());
|
||||
pageUtil.setCurPage(model.getPageNo());
|
||||
pageUtil.setAdvSearch(getConditionALL());
|
||||
depotItemService.find(pageUtil);
|
||||
List<DepotItem> dataList = pageUtil.getPageList();
|
||||
|
||||
JSONObject outer = new JSONObject();
|
||||
outer.put("total", pageUtil.getTotalCount());
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if(null != dataList)
|
||||
{
|
||||
for(DepotItem depotItem:dataList)
|
||||
{
|
||||
JSONObject item = new JSONObject();
|
||||
Integer InSum = sumNumberBuyOrSale("入库","采购",depotItem.getMaterialId().getId(),model.getMonthTime());
|
||||
Integer OutSum = sumNumberBuyOrSale("出库","采购退货",depotItem.getMaterialId().getId(),model.getMonthTime());
|
||||
Double InSumPrice = sumPriceBuyOrSale("入库","采购",depotItem.getMaterialId().getId(),model.getMonthTime());
|
||||
Double OutSumPrice = sumPriceBuyOrSale("出库","采购退货",depotItem.getMaterialId().getId(),model.getMonthTime());
|
||||
item.put("Id", depotItem.getId());
|
||||
item.put("MaterialId", depotItem.getMaterialId()==null?"":depotItem.getMaterialId().getId());
|
||||
item.put("MaterialName", depotItem.getMaterialId().getName());
|
||||
item.put("MaterialModel", depotItem.getMaterialId().getModel());
|
||||
item.put("MaterialColor", depotItem.getMaterialId().getColor());
|
||||
item.put("InSum", InSum);
|
||||
item.put("OutSum", OutSum);
|
||||
item.put("InSumPrice", InSumPrice);
|
||||
item.put("OutSumPrice", OutSumPrice);
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
outer.put("rows", dataArray);
|
||||
//回写查询结果
|
||||
toClient(outer.toString());
|
||||
}
|
||||
catch (DataAccessException e)
|
||||
{
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找信息异常", e);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 销售统计
|
||||
* @return
|
||||
*/
|
||||
public void saleOut()
|
||||
{
|
||||
try
|
||||
{
|
||||
PageUtil<DepotItem> pageUtil = new PageUtil<DepotItem>();
|
||||
pageUtil.setPageSize(model.getPageSize());
|
||||
pageUtil.setCurPage(model.getPageNo());
|
||||
pageUtil.setAdvSearch(getConditionALL());
|
||||
depotItemService.find(pageUtil);
|
||||
List<DepotItem> dataList = pageUtil.getPageList();
|
||||
|
||||
JSONObject outer = new JSONObject();
|
||||
outer.put("total", pageUtil.getTotalCount());
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if(null != dataList)
|
||||
{
|
||||
for(DepotItem depotItem:dataList)
|
||||
{
|
||||
JSONObject item = new JSONObject();
|
||||
Integer OutSum = sumNumberBuyOrSale("出库","销售",depotItem.getMaterialId().getId(),model.getMonthTime());
|
||||
Integer InSum = sumNumberBuyOrSale("入库","销售退货",depotItem.getMaterialId().getId(),model.getMonthTime());
|
||||
Double OutSumPrice = sumPriceBuyOrSale("出库","销售",depotItem.getMaterialId().getId(),model.getMonthTime());
|
||||
Double InSumPrice = sumPriceBuyOrSale("入库","销售退货",depotItem.getMaterialId().getId(),model.getMonthTime());
|
||||
item.put("Id", depotItem.getId());
|
||||
item.put("MaterialId", depotItem.getMaterialId()==null?"":depotItem.getMaterialId().getId());
|
||||
item.put("MaterialName", depotItem.getMaterialId().getName());
|
||||
item.put("MaterialModel", depotItem.getMaterialId().getModel());
|
||||
item.put("MaterialColor", depotItem.getMaterialId().getColor());
|
||||
item.put("OutSum", OutSum);
|
||||
item.put("InSum", InSum);
|
||||
item.put("OutSumPrice", OutSumPrice);
|
||||
item.put("InSumPrice", InSumPrice);
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
outer.put("rows", dataArray);
|
||||
//回写查询结果
|
||||
toClient(outer.toString());
|
||||
}
|
||||
catch (DataAccessException e)
|
||||
{
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找信息异常", e);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 统计总计金额
|
||||
* @return
|
||||
@@ -350,6 +455,52 @@ public class DepotItemAction extends BaseAction<DepotItemModel>
|
||||
}
|
||||
sumNumber = Integer.parseInt(allNumber);
|
||||
return sumNumber;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public Integer sumNumberBuyOrSale(String type,String subType,Long MId,String MonthTime) {
|
||||
Integer sumNumber = 0;
|
||||
String allNumber = "";
|
||||
String sumType = "Number";
|
||||
PageUtil pageUtil = new PageUtil();
|
||||
pageUtil.setPageSize(0);
|
||||
pageUtil.setCurPage(0);
|
||||
try {
|
||||
depotItemService.buyOrSale(pageUtil, type, subType, MId, MonthTime, sumType);
|
||||
allNumber = pageUtil.getPageList().toString();
|
||||
allNumber = allNumber.substring(1,allNumber.length()-1);
|
||||
if(allNumber.equals("null")){
|
||||
allNumber = "0";
|
||||
}
|
||||
allNumber = allNumber.replace(".0", "");
|
||||
} catch (JshException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
sumNumber = Integer.parseInt(allNumber);
|
||||
return sumNumber;
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
public Double sumPriceBuyOrSale(String type,String subType,Long MId,String MonthTime) {
|
||||
Double sumPrice = 0.0;
|
||||
String allPrice = "";
|
||||
String sumType = "Price";
|
||||
PageUtil pageUtil = new PageUtil();
|
||||
pageUtil.setPageSize(0);
|
||||
pageUtil.setCurPage(0);
|
||||
try {
|
||||
depotItemService.buyOrSale(pageUtil, type, subType, MId, MonthTime, sumType);
|
||||
allPrice = pageUtil.getPageList().toString();
|
||||
allPrice = allPrice.substring(1,allPrice.length()-1);
|
||||
if(allPrice.equals("null")){
|
||||
allPrice = "0";
|
||||
}
|
||||
allPrice = allPrice.replace(".0", "");
|
||||
} catch (JshException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
sumPrice = Double.parseDouble(allPrice);
|
||||
return sumPrice;
|
||||
}
|
||||
/**
|
||||
* 拼接搜索条件
|
||||
|
||||
@@ -36,4 +36,23 @@ public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO
|
||||
pageUtil.setTotalCount(query.list().size());
|
||||
pageUtil.setPageList(query.list());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void buyOrSale(PageUtil<DepotItem> pageUtil,String type, String subType,Long MId,String MonthTime, String sumType) throws JshException
|
||||
{
|
||||
//多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便
|
||||
Query query;
|
||||
if(sumType.equals("Number")) {
|
||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"' and subType='" + subType +"' and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 00:00:00' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
||||
}
|
||||
else {
|
||||
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(AllPrice) as AllPrice from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"' and subType='" + subType +"' and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 00:00:00' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
||||
}
|
||||
pageUtil.setTotalCount(query.list().size());
|
||||
pageUtil.setPageList(query.list());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,4 +9,6 @@ import com.jsh.util.PageUtil;
|
||||
public interface DepotItemIDAO extends BaseIDAO<DepotItem>
|
||||
{
|
||||
void findByType(PageUtil<DepotItem> pageUtil,String type,Long MId, String MonthTime,Boolean isPrev) throws JshException;
|
||||
|
||||
void buyOrSale(PageUtil<DepotItem> pageUtil,String type, String subType,Long MId, String MonthTime, String sumType) throws JshException;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ public interface DepotItemIService extends BaseIService<DepotItem>
|
||||
{
|
||||
void findByType(PageUtil<DepotItem> depotItem, String type, Long MId, String MonthTime,Boolean isPrev)throws JshException;
|
||||
|
||||
void buyOrSale(PageUtil<DepotItem> depotItem, String type, String subType, Long MId, String MonthTime, String sumType)throws JshException;
|
||||
|
||||
/**
|
||||
* 导出信息
|
||||
* @return
|
||||
|
||||
@@ -50,6 +50,12 @@ public class DepotItemService extends BaseService<DepotItem> implements DepotIte
|
||||
depotItemDao.findByType(pageUtil, type, MId, MonthTime,isPrev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buyOrSale(PageUtil<DepotItem> pageUtil, String type,String subType, Long MId, String MonthTime, String sumType) throws JshException
|
||||
{
|
||||
depotItemDao.buyOrSale(pageUtil, type, subType, MId, MonthTime, sumType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出Excel表格
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user