完善首页数据统计接口的数据角色判断
This commit is contained in:
parent
c42c3b712a
commit
9a496ffa87
@ -103,12 +103,12 @@ public class DepotHeadController {
|
||||
public BaseResponseInfo findInDetail(@RequestParam("currentPage") Integer currentPage,
|
||||
@RequestParam("pageSize") Integer pageSize,
|
||||
@RequestParam(value = "organId", required = false) Integer oId,
|
||||
@RequestParam("number") String number,
|
||||
@RequestParam("number") String number,
|
||||
@RequestParam("materialParam") String materialParam,
|
||||
@RequestParam(value = "depotId", required = false) Long depotId,
|
||||
@RequestParam("beginTime") String beginTime,
|
||||
@RequestParam("endTime") String endTime,
|
||||
@RequestParam(value = "roleType", required = false) String roleType,
|
||||
@RequestParam(value = "roleType", required = false) String roleType,
|
||||
@RequestParam("type") String type,
|
||||
@RequestParam("remark") String remark,
|
||||
HttpServletRequest request)throws Exception {
|
||||
@ -415,7 +415,8 @@ public class DepotHeadController {
|
||||
*/
|
||||
@GetMapping(value = "/getBuyAndSaleStatistics")
|
||||
@ApiOperation(value = "统计今日采购额、昨日采购额、本月采购额、今年采购额|销售额|零售额")
|
||||
public BaseResponseInfo getBuyAndSaleStatistics(HttpServletRequest request) {
|
||||
public BaseResponseInfo getBuyAndSaleStatistics(@RequestParam(value = "roleType", required = false) String roleType,
|
||||
HttpServletRequest request) {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
String today = Tools.getNow() + BusinessConstants.DAY_FIRST_TIME;
|
||||
@ -425,7 +426,7 @@ public class DepotHeadController {
|
||||
String yearBegin = Tools.getYearBegin() + BusinessConstants.DAY_FIRST_TIME;
|
||||
String yearEnd = Tools.getYearEnd() + BusinessConstants.DAY_LAST_TIME;
|
||||
Map<String, Object> map = depotHeadService.getBuyAndSaleStatistics(today, monthFirstDay,
|
||||
yesterdayBegin, yesterdayEnd, yearBegin, yearEnd);
|
||||
yesterdayBegin, yesterdayEnd, yearBegin, yearEnd, roleType);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch(Exception e){
|
||||
|
||||
@ -633,17 +633,17 @@ public class DepotItemController {
|
||||
*/
|
||||
@GetMapping(value = "/buyOrSalePrice")
|
||||
@ApiOperation(value = "统计采购、销售、零售的总金额")
|
||||
public BaseResponseInfo buyOrSalePrice(HttpServletRequest request, HttpServletResponse response)throws Exception {
|
||||
public BaseResponseInfo buyOrSalePrice(@RequestParam(value = "roleType", required = false) String roleType,
|
||||
HttpServletRequest request, HttpServletResponse response)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String message = "成功";
|
||||
try {
|
||||
List<String> list = Tools.getLastMonths(6);
|
||||
JSONArray buyPriceList = new JSONArray();
|
||||
for(String month: list) {
|
||||
JSONObject obj = new JSONObject();
|
||||
BigDecimal outPrice = depotItemService.inOrOutPrice("入库", "采购", month);
|
||||
BigDecimal inPrice = depotItemService.inOrOutPrice("出库", "采购退货", month);
|
||||
BigDecimal outPrice = depotItemService.inOrOutPrice("入库", "采购", month, roleType);
|
||||
BigDecimal inPrice = depotItemService.inOrOutPrice("出库", "采购退货", month, roleType);
|
||||
obj.put("x", month);
|
||||
obj.put("y", outPrice.subtract(inPrice));
|
||||
buyPriceList.add(obj);
|
||||
@ -652,8 +652,8 @@ public class DepotItemController {
|
||||
JSONArray salePriceList = new JSONArray();
|
||||
for(String month: list) {
|
||||
JSONObject obj = new JSONObject();
|
||||
BigDecimal outPrice = depotItemService.inOrOutPrice("出库", "销售", month);
|
||||
BigDecimal inPrice = depotItemService.inOrOutPrice("入库", "销售退货", month);
|
||||
BigDecimal outPrice = depotItemService.inOrOutPrice("出库", "销售", month, roleType);
|
||||
BigDecimal inPrice = depotItemService.inOrOutPrice("入库", "销售退货", month, roleType);
|
||||
obj.put("x", month);
|
||||
obj.put("y", outPrice.subtract(inPrice));
|
||||
salePriceList.add(obj);
|
||||
@ -662,8 +662,8 @@ public class DepotItemController {
|
||||
JSONArray retailPriceList = new JSONArray();
|
||||
for(String month: list) {
|
||||
JSONObject obj = new JSONObject();
|
||||
BigDecimal outPrice = depotItemService.inOrOutRetailPrice("出库", "零售", month);
|
||||
BigDecimal inPrice = depotItemService.inOrOutRetailPrice("入库", "零售退货", month);
|
||||
BigDecimal outPrice = depotItemService.inOrOutRetailPrice("出库", "零售", month, roleType);
|
||||
BigDecimal inPrice = depotItemService.inOrOutRetailPrice("入库", "零售退货", month, roleType);
|
||||
obj.put("x", month);
|
||||
obj.put("y", outPrice.subtract(inPrice));
|
||||
retailPriceList.add(obj);
|
||||
@ -673,8 +673,8 @@ public class DepotItemController {
|
||||
res.data = map;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
message = "统计失败";
|
||||
res.code = 500;
|
||||
res.data = "统计失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -186,13 +186,15 @@ public interface DepotHeadMapperEx {
|
||||
@Param("subType") String subType,
|
||||
@Param("hasSupplier") Integer hasSupplier,
|
||||
@Param("beginTime") String beginTime,
|
||||
@Param("endTime") String endTime);
|
||||
@Param("endTime") String endTime,
|
||||
@Param("creatorArray") String[] creatorArray);
|
||||
|
||||
BigDecimal getBuyAndSaleRetailStatistics(
|
||||
@Param("type") String type,
|
||||
@Param("subType") String subType,
|
||||
@Param("beginTime") String beginTime,
|
||||
@Param("endTime") String endTime);
|
||||
@Param("endTime") String endTime,
|
||||
@Param("creatorArray") String[] creatorArray);
|
||||
|
||||
List<DepotHeadVo4List> debtList(
|
||||
@Param("organId") Long organId,
|
||||
|
||||
@ -88,13 +88,15 @@ public interface DepotItemMapperEx {
|
||||
@Param("type") String type,
|
||||
@Param("subType") String subType,
|
||||
@Param("beginTime") String beginTime,
|
||||
@Param("endTime") String endTime);
|
||||
@Param("endTime") String endTime,
|
||||
@Param("creatorArray") String[] creatorArray);
|
||||
|
||||
BigDecimal inOrOutRetailPrice(
|
||||
@Param("type") String type,
|
||||
@Param("subType") String subType,
|
||||
@Param("beginTime") String beginTime,
|
||||
@Param("endTime") String endTime);
|
||||
@Param("endTime") String endTime,
|
||||
@Param("creatorArray") String[] creatorArray);
|
||||
|
||||
BigDecimal getStockCheckSumByDepotList(
|
||||
@Param("depotList") List<Long> depotList,
|
||||
|
||||
@ -850,60 +850,62 @@ public class DepotHeadService {
|
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||
}
|
||||
|
||||
public Map<String, Object> getBuyAndSaleStatistics(String today, String monthFirstDay, String yesterdayBegin, String yesterdayEnd, String yearBegin, String yearEnd) {
|
||||
public Map<String, Object> getBuyAndSaleStatistics(String today, String monthFirstDay, String yesterdayBegin, String yesterdayEnd,
|
||||
String yearBegin, String yearEnd, String roleType) throws Exception {
|
||||
String [] creatorArray = getCreatorArray(roleType);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
//今日
|
||||
BigDecimal todayBuy = getBuyAndSaleBasicStatistics("入库", "采购",
|
||||
1, today, getNow3()); //今日采购入库
|
||||
1, today, getNow3(), creatorArray); //今日采购入库
|
||||
BigDecimal todayBuyBack = getBuyAndSaleBasicStatistics("出库", "采购退货",
|
||||
1, today, getNow3()); //今日采购退货
|
||||
1, today, getNow3(), creatorArray); //今日采购退货
|
||||
BigDecimal todaySale = getBuyAndSaleBasicStatistics("出库", "销售",
|
||||
1, today, getNow3()); //今日销售出库
|
||||
1, today, getNow3(), creatorArray); //今日销售出库
|
||||
BigDecimal todaySaleBack = getBuyAndSaleBasicStatistics("入库", "销售退货",
|
||||
1, today, getNow3()); //今日销售退货
|
||||
1, today, getNow3(), creatorArray); //今日销售退货
|
||||
BigDecimal todayRetailSale = getBuyAndSaleRetailStatistics("出库", "零售",
|
||||
today, getNow3()); //今日零售出库
|
||||
today, getNow3(), creatorArray); //今日零售出库
|
||||
BigDecimal todayRetailSaleBack = getBuyAndSaleRetailStatistics("入库", "零售退货",
|
||||
today, getNow3()); //今日零售退货
|
||||
today, getNow3(), creatorArray); //今日零售退货
|
||||
//本月
|
||||
BigDecimal monthBuy = getBuyAndSaleBasicStatistics("入库", "采购",
|
||||
1, monthFirstDay, getNow3()); //本月采购入库
|
||||
1, monthFirstDay, getNow3(), creatorArray); //本月采购入库
|
||||
BigDecimal monthBuyBack = getBuyAndSaleBasicStatistics("出库", "采购退货",
|
||||
1, monthFirstDay, getNow3()); //本月采购退货
|
||||
1, monthFirstDay, getNow3(), creatorArray); //本月采购退货
|
||||
BigDecimal monthSale = getBuyAndSaleBasicStatistics("出库", "销售",
|
||||
1,monthFirstDay, getNow3()); //本月销售出库
|
||||
1,monthFirstDay, getNow3(), creatorArray); //本月销售出库
|
||||
BigDecimal monthSaleBack = getBuyAndSaleBasicStatistics("入库", "销售退货",
|
||||
1,monthFirstDay, getNow3()); //本月销售退货
|
||||
1,monthFirstDay, getNow3(), creatorArray); //本月销售退货
|
||||
BigDecimal monthRetailSale = getBuyAndSaleRetailStatistics("出库", "零售",
|
||||
monthFirstDay, getNow3()); //本月零售出库
|
||||
monthFirstDay, getNow3(), creatorArray); //本月零售出库
|
||||
BigDecimal monthRetailSaleBack = getBuyAndSaleRetailStatistics("入库", "零售退货",
|
||||
monthFirstDay, getNow3()); //本月零售退货
|
||||
monthFirstDay, getNow3(), creatorArray); //本月零售退货
|
||||
//昨日
|
||||
BigDecimal yesterdayBuy = getBuyAndSaleBasicStatistics("入库", "采购",
|
||||
1, yesterdayBegin, yesterdayEnd); //昨日采购入库
|
||||
1, yesterdayBegin, yesterdayEnd, creatorArray); //昨日采购入库
|
||||
BigDecimal yesterdayBuyBack = getBuyAndSaleBasicStatistics("出库", "采购退货",
|
||||
1, yesterdayBegin, yesterdayEnd); //昨日采购退货
|
||||
1, yesterdayBegin, yesterdayEnd, creatorArray); //昨日采购退货
|
||||
BigDecimal yesterdaySale = getBuyAndSaleBasicStatistics("出库", "销售",
|
||||
1, yesterdayBegin, yesterdayEnd); //昨日销售出库
|
||||
1, yesterdayBegin, yesterdayEnd, creatorArray); //昨日销售出库
|
||||
BigDecimal yesterdaySaleBack = getBuyAndSaleBasicStatistics("入库", "销售退货",
|
||||
1, yesterdayBegin, yesterdayEnd); //昨日销售退货
|
||||
1, yesterdayBegin, yesterdayEnd, creatorArray); //昨日销售退货
|
||||
BigDecimal yesterdayRetailSale = getBuyAndSaleRetailStatistics("出库", "零售",
|
||||
yesterdayBegin, yesterdayEnd); //昨日零售出库
|
||||
yesterdayBegin, yesterdayEnd, creatorArray); //昨日零售出库
|
||||
BigDecimal yesterdayRetailSaleBack = getBuyAndSaleRetailStatistics("入库", "零售退货",
|
||||
yesterdayBegin, yesterdayEnd); //昨日零售退货
|
||||
yesterdayBegin, yesterdayEnd, creatorArray); //昨日零售退货
|
||||
//今年
|
||||
BigDecimal yearBuy = getBuyAndSaleBasicStatistics("入库", "采购",
|
||||
1, yearBegin, yearEnd); //今年采购入库
|
||||
1, yearBegin, yearEnd, creatorArray); //今年采购入库
|
||||
BigDecimal yearBuyBack = getBuyAndSaleBasicStatistics("出库", "采购退货",
|
||||
1, yearBegin, yearEnd); //今年采购退货
|
||||
1, yearBegin, yearEnd, creatorArray); //今年采购退货
|
||||
BigDecimal yearSale = getBuyAndSaleBasicStatistics("出库", "销售",
|
||||
1, yearBegin, yearEnd); //今年销售出库
|
||||
1, yearBegin, yearEnd, creatorArray); //今年销售出库
|
||||
BigDecimal yearSaleBack = getBuyAndSaleBasicStatistics("入库", "销售退货",
|
||||
1, yearBegin, yearEnd); //今年销售退货
|
||||
1, yearBegin, yearEnd, creatorArray); //今年销售退货
|
||||
BigDecimal yearRetailSale = getBuyAndSaleRetailStatistics("出库", "零售",
|
||||
yearBegin, yearEnd); //今年零售出库
|
||||
yearBegin, yearEnd, creatorArray); //今年零售出库
|
||||
BigDecimal yearRetailSaleBack = getBuyAndSaleRetailStatistics("入库", "零售退货",
|
||||
yearBegin, yearEnd); //今年零售退货
|
||||
yearBegin, yearEnd, creatorArray); //今年零售退货
|
||||
map.put("todayBuy", todayBuy.subtract(todayBuyBack));
|
||||
map.put("todaySale", todaySale.subtract(todaySaleBack));
|
||||
map.put("todayRetailSale", todayRetailSale.subtract(todayRetailSaleBack));
|
||||
@ -919,12 +921,14 @@ public class DepotHeadService {
|
||||
return map;
|
||||
}
|
||||
|
||||
public BigDecimal getBuyAndSaleBasicStatistics(String type, String subType, Integer hasSupplier, String beginTime, String endTime) {
|
||||
return depotHeadMapperEx.getBuyAndSaleBasicStatistics(type, subType, hasSupplier, beginTime, endTime);
|
||||
public BigDecimal getBuyAndSaleBasicStatistics(String type, String subType, Integer hasSupplier,
|
||||
String beginTime, String endTime, String[] creatorArray) {
|
||||
return depotHeadMapperEx.getBuyAndSaleBasicStatistics(type, subType, hasSupplier, beginTime, endTime, creatorArray);
|
||||
}
|
||||
|
||||
public BigDecimal getBuyAndSaleRetailStatistics(String type, String subType, String beginTime, String endTime) {
|
||||
return depotHeadMapperEx.getBuyAndSaleRetailStatistics(type, subType, beginTime, endTime).abs();
|
||||
public BigDecimal getBuyAndSaleRetailStatistics(String type, String subType,
|
||||
String beginTime, String endTime, String[] creatorArray) {
|
||||
return depotHeadMapperEx.getBuyAndSaleRetailStatistics(type, subType, beginTime, endTime, creatorArray).abs();
|
||||
}
|
||||
|
||||
public DepotHead getDepotHead(String number)throws Exception {
|
||||
|
||||
@ -348,12 +348,13 @@ public class DepotItemService {
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public BigDecimal inOrOutPrice(String type, String subType, String month) throws Exception{
|
||||
public BigDecimal inOrOutPrice(String type, String subType, String month, String roleType) throws Exception{
|
||||
BigDecimal result= BigDecimal.ZERO;
|
||||
try{
|
||||
String [] creatorArray = depotHeadService.getCreatorArray(roleType);
|
||||
String beginTime = Tools.firstDayOfMonth(month) + BusinessConstants.DAY_FIRST_TIME;
|
||||
String endTime = Tools.lastDayOfMonth(month) + BusinessConstants.DAY_LAST_TIME;
|
||||
result = depotItemMapperEx.inOrOutPrice(type, subType, beginTime, endTime);
|
||||
result = depotItemMapperEx.inOrOutPrice(type, subType, beginTime, endTime, creatorArray);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
@ -368,12 +369,13 @@ public class DepotItemService {
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public BigDecimal inOrOutRetailPrice(String type, String subType, String month) throws Exception{
|
||||
public BigDecimal inOrOutRetailPrice(String type, String subType, String month, String roleType) throws Exception{
|
||||
BigDecimal result= BigDecimal.ZERO;
|
||||
try{
|
||||
String [] creatorArray = depotHeadService.getCreatorArray(roleType);
|
||||
String beginTime = Tools.firstDayOfMonth(month) + BusinessConstants.DAY_FIRST_TIME;
|
||||
String endTime = Tools.lastDayOfMonth(month) + BusinessConstants.DAY_LAST_TIME;
|
||||
result = depotItemMapperEx.inOrOutRetailPrice(type, subType, beginTime, endTime);
|
||||
result = depotItemMapperEx.inOrOutRetailPrice(type, subType, beginTime, endTime, creatorArray);
|
||||
result = result.abs();
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
|
||||
@ -721,6 +721,13 @@
|
||||
<if test="endTime != null">
|
||||
and oper_time <= #{endTime}
|
||||
</if>
|
||||
<if test="creatorArray != null">
|
||||
and creator in (
|
||||
<foreach collection="creatorArray" item="creator" separator=",">
|
||||
#{creator}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
and ifnull(delete_flag,'0') !='1'
|
||||
</select>
|
||||
|
||||
@ -741,6 +748,13 @@
|
||||
<if test="endTime != null">
|
||||
and oper_time <= #{endTime}
|
||||
</if>
|
||||
<if test="creatorArray != null">
|
||||
and creator in (
|
||||
<foreach collection="creatorArray" item="creator" separator=",">
|
||||
#{creator}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
and ifnull(delete_flag,'0') !='1'
|
||||
</select>
|
||||
|
||||
|
||||
@ -378,16 +378,30 @@
|
||||
and dh.type=#{type} and dh.sub_type=#{subType}
|
||||
and dh.oper_time >= #{beginTime}
|
||||
and dh.oper_time <= #{endTime}
|
||||
<if test="creatorArray != null">
|
||||
and dh.creator in (
|
||||
<foreach collection="creatorArray" item="creator" separator=",">
|
||||
#{creator}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
and ifnull(dh.delete_flag,'0') !='1'
|
||||
</select>
|
||||
|
||||
<select id="inOrOutRetailPrice" resultType="java.math.BigDecimal">
|
||||
select ifnull(sum(total_price),0) as allMoney from jsh_depot_head dh
|
||||
where 1=1
|
||||
and dh.type=#{type} and dh.sub_type=#{subType}
|
||||
and dh.oper_time >= #{beginTime}
|
||||
and dh.oper_time <= #{endTime}
|
||||
and ifnull(dh.delete_flag,'0') !='1'
|
||||
and dh.type=#{type} and dh.sub_type=#{subType}
|
||||
and dh.oper_time >= #{beginTime}
|
||||
and dh.oper_time <= #{endTime}
|
||||
<if test="creatorArray != null">
|
||||
and dh.creator in (
|
||||
<foreach collection="creatorArray" item="creator" separator=",">
|
||||
#{creator}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
and ifnull(dh.delete_flag,'0') !='1'
|
||||
</select>
|
||||
|
||||
<select id="getStockCheckSumByDepotList" resultType="java.math.BigDecimal">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user