给首页增加统计折线图的功能

This commit is contained in:
季圣华
2019-10-24 22:16:22 +08:00
parent 028b87a701
commit 7ea85d4f6e
10 changed files with 729 additions and 377 deletions

View File

@@ -21,10 +21,8 @@ import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.text.SimpleDateFormat;
import java.util.*;
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
@@ -665,4 +663,46 @@ public class DepotItemController {
}
return res;
}
/**
* 统计采购或销售的总金额
* @param request
* @param response
* @return
* @throws Exception
*/
@GetMapping(value = "/buyOrSalePrice")
public BaseResponseInfo buyOrSalePrice(HttpServletRequest request, HttpServletResponse response)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
String message = "成功";
try {
Date date = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM");
String dateString = formatter.format(date);
List<String> list = Tools.getSixMonth(dateString);
map.put("monthList", list);
List<BigDecimal> buyPriceList = new ArrayList<BigDecimal>();
for(String month: list) {
BigDecimal outPrice = depotItemService.inOrOutPrice("入库", "采购", month);
BigDecimal inPrice = depotItemService.inOrOutPrice("出库", "采购退货", month);
buyPriceList.add(outPrice.subtract(inPrice));
}
map.put("buyPriceList", buyPriceList);
List<BigDecimal> salePriceList = new ArrayList<BigDecimal>();
for(String month: list) {
BigDecimal outPrice = depotItemService.inOrOutPrice("出库", "销售", month);
BigDecimal inPrice = depotItemService.inOrOutPrice("入库", "销售退货", month);
salePriceList.add(outPrice.subtract(inPrice));
}
map.put("salePriceList", salePriceList);
res.code = 200;
res.data = map;
} catch (Exception e) {
e.printStackTrace();
message = "统计失败";
res.code = 500;
}
return res;
}
}

View File

@@ -63,6 +63,11 @@ public interface DepotItemMapperEx {
@Param("MonthTime") String MonthTime,
@Param("sumType") String sumType);
BigDecimal inOrOutPrice(
@Param("type") String type,
@Param("subType") String subType,
@Param("MonthTime") String MonthTime);
DepotItemVo4Stock getStockByParam(
@Param("depotId") Long depotId,
@Param("mId") Long mId,

View File

@@ -260,6 +260,24 @@ public class DepotItemService {
}
/**
* 统计采购或销售的总金额
* @param type
* @param subType
* @param MonthTime
* @return
* @throws Exception
*/
public BigDecimal inOrOutPrice(String type, String subType, String MonthTime) throws Exception{
BigDecimal result= BigDecimal.ZERO;
try{
result = depotItemMapperEx.inOrOutPrice(type, subType, MonthTime);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
/**
* 2019-02-02修改
* 我之前对操作数量的理解有偏差

View File

@@ -156,6 +156,41 @@ public class Tools {
return new SimpleDateFormat("yyyy-MM").format(cal.getTime());
}
/**
* 获取当前月份的前6个月(含当前月)
* @param date
* @return
*/
public static List<String> getSixMonth(String date) {
List<String> list = new ArrayList<String>();
int month = Integer.parseInt(date.substring(5, 7));
int year = Integer.parseInt(date.substring(0, 4));
for (int i = 5; i >= 0; i--) {
if (month > 6) {
if (month - i >= 10) {
list.add(year + "-" + String.valueOf(month - i));
} else {
list.add(year + "-0" + String.valueOf(month - i));
}
} else {
if (month - i <= 0) {
if (month - i + 12 >= 10) {
list.add(String.valueOf(year - 1) + "-" + String.valueOf(month - i + 12));
} else {
list.add(String.valueOf(year - 1) + "-0" + String.valueOf(month - i + 12));
}
} else {
if (month - i >= 10) {
list.add(String.valueOf(year) + "-" + String.valueOf(month - i));
} else {
list.add(String.valueOf(year) + "-0" + String.valueOf(month - i));
}
}
}
}
return list;
}
/**
* 截取字符串长度
*

View File

@@ -202,6 +202,15 @@
and ifnull(di.delete_Flag,'0') !='1'
</select>
<select id="inOrOutPrice" resultType="java.math.BigDecimal">
select ifnull(sum(DiscountLastMoney),0) as allMoney from jsh_depothead dh
where 1=1
and dh.type='${type}' and dh.subType='${subType}'
and dh.OperTime &gt;= '${MonthTime}-01 00:00:00'
and dh.OperTime &lt;= '${MonthTime}-31 23:59:59'
and ifnull(dh.delete_Flag,'0') !='1'
</select>
<select id="getStockByParam" resultMap="StockMap">
select ifnull((curep.inTotal+curep.transfInTotal+curep.assemInTotal+curep.disAssemInTotal),0) as in_stock,
ifnull((curep.transfOutTotal+curep.outTotal+curep.assemOutTotal+curep.disAssemOutTotal),0) out_stock