完善首页数据统计接口的数据角色判断

This commit is contained in:
季圣华
2022-08-08 22:46:49 +08:00
parent c42c3b712a
commit 9a496ffa87
8 changed files with 93 additions and 54 deletions

View File

@@ -415,7 +415,8 @@ public class DepotHeadController {
*/ */
@GetMapping(value = "/getBuyAndSaleStatistics") @GetMapping(value = "/getBuyAndSaleStatistics")
@ApiOperation(value = "统计今日采购额、昨日采购额、本月采购额、今年采购额|销售额|零售额") @ApiOperation(value = "统计今日采购额、昨日采购额、本月采购额、今年采购额|销售额|零售额")
public BaseResponseInfo getBuyAndSaleStatistics(HttpServletRequest request) { public BaseResponseInfo getBuyAndSaleStatistics(@RequestParam(value = "roleType", required = false) String roleType,
HttpServletRequest request) {
BaseResponseInfo res = new BaseResponseInfo(); BaseResponseInfo res = new BaseResponseInfo();
try { try {
String today = Tools.getNow() + BusinessConstants.DAY_FIRST_TIME; String today = Tools.getNow() + BusinessConstants.DAY_FIRST_TIME;
@@ -425,7 +426,7 @@ public class DepotHeadController {
String yearBegin = Tools.getYearBegin() + BusinessConstants.DAY_FIRST_TIME; String yearBegin = Tools.getYearBegin() + BusinessConstants.DAY_FIRST_TIME;
String yearEnd = Tools.getYearEnd() + BusinessConstants.DAY_LAST_TIME; String yearEnd = Tools.getYearEnd() + BusinessConstants.DAY_LAST_TIME;
Map<String, Object> map = depotHeadService.getBuyAndSaleStatistics(today, monthFirstDay, Map<String, Object> map = depotHeadService.getBuyAndSaleStatistics(today, monthFirstDay,
yesterdayBegin, yesterdayEnd, yearBegin, yearEnd); yesterdayBegin, yesterdayEnd, yearBegin, yearEnd, roleType);
res.code = 200; res.code = 200;
res.data = map; res.data = map;
} catch(Exception e){ } catch(Exception e){

View File

@@ -633,17 +633,17 @@ public class DepotItemController {
*/ */
@GetMapping(value = "/buyOrSalePrice") @GetMapping(value = "/buyOrSalePrice")
@ApiOperation(value = "统计采购、销售、零售的总金额") @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(); BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
String message = "成功";
try { try {
List<String> list = Tools.getLastMonths(6); List<String> list = Tools.getLastMonths(6);
JSONArray buyPriceList = new JSONArray(); JSONArray buyPriceList = new JSONArray();
for(String month: list) { for(String month: list) {
JSONObject obj = new JSONObject(); JSONObject obj = new JSONObject();
BigDecimal outPrice = depotItemService.inOrOutPrice("入库", "采购", month); BigDecimal outPrice = depotItemService.inOrOutPrice("入库", "采购", month, roleType);
BigDecimal inPrice = depotItemService.inOrOutPrice("出库", "采购退货", month); BigDecimal inPrice = depotItemService.inOrOutPrice("出库", "采购退货", month, roleType);
obj.put("x", month); obj.put("x", month);
obj.put("y", outPrice.subtract(inPrice)); obj.put("y", outPrice.subtract(inPrice));
buyPriceList.add(obj); buyPriceList.add(obj);
@@ -652,8 +652,8 @@ public class DepotItemController {
JSONArray salePriceList = new JSONArray(); JSONArray salePriceList = new JSONArray();
for(String month: list) { for(String month: list) {
JSONObject obj = new JSONObject(); JSONObject obj = new JSONObject();
BigDecimal outPrice = depotItemService.inOrOutPrice("出库", "销售", month); BigDecimal outPrice = depotItemService.inOrOutPrice("出库", "销售", month, roleType);
BigDecimal inPrice = depotItemService.inOrOutPrice("入库", "销售退货", month); BigDecimal inPrice = depotItemService.inOrOutPrice("入库", "销售退货", month, roleType);
obj.put("x", month); obj.put("x", month);
obj.put("y", outPrice.subtract(inPrice)); obj.put("y", outPrice.subtract(inPrice));
salePriceList.add(obj); salePriceList.add(obj);
@@ -662,8 +662,8 @@ public class DepotItemController {
JSONArray retailPriceList = new JSONArray(); JSONArray retailPriceList = new JSONArray();
for(String month: list) { for(String month: list) {
JSONObject obj = new JSONObject(); JSONObject obj = new JSONObject();
BigDecimal outPrice = depotItemService.inOrOutRetailPrice("出库", "零售", month); BigDecimal outPrice = depotItemService.inOrOutRetailPrice("出库", "零售", month, roleType);
BigDecimal inPrice = depotItemService.inOrOutRetailPrice("入库", "零售退货", month); BigDecimal inPrice = depotItemService.inOrOutRetailPrice("入库", "零售退货", month, roleType);
obj.put("x", month); obj.put("x", month);
obj.put("y", outPrice.subtract(inPrice)); obj.put("y", outPrice.subtract(inPrice));
retailPriceList.add(obj); retailPriceList.add(obj);
@@ -673,8 +673,8 @@ public class DepotItemController {
res.data = map; res.data = map;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
message = "统计失败";
res.code = 500; res.code = 500;
res.data = "统计失败";
} }
return res; return res;
} }

View File

@@ -186,13 +186,15 @@ public interface DepotHeadMapperEx {
@Param("subType") String subType, @Param("subType") String subType,
@Param("hasSupplier") Integer hasSupplier, @Param("hasSupplier") Integer hasSupplier,
@Param("beginTime") String beginTime, @Param("beginTime") String beginTime,
@Param("endTime") String endTime); @Param("endTime") String endTime,
@Param("creatorArray") String[] creatorArray);
BigDecimal getBuyAndSaleRetailStatistics( BigDecimal getBuyAndSaleRetailStatistics(
@Param("type") String type, @Param("type") String type,
@Param("subType") String subType, @Param("subType") String subType,
@Param("beginTime") String beginTime, @Param("beginTime") String beginTime,
@Param("endTime") String endTime); @Param("endTime") String endTime,
@Param("creatorArray") String[] creatorArray);
List<DepotHeadVo4List> debtList( List<DepotHeadVo4List> debtList(
@Param("organId") Long organId, @Param("organId") Long organId,

View File

@@ -88,13 +88,15 @@ public interface DepotItemMapperEx {
@Param("type") String type, @Param("type") String type,
@Param("subType") String subType, @Param("subType") String subType,
@Param("beginTime") String beginTime, @Param("beginTime") String beginTime,
@Param("endTime") String endTime); @Param("endTime") String endTime,
@Param("creatorArray") String[] creatorArray);
BigDecimal inOrOutRetailPrice( BigDecimal inOrOutRetailPrice(
@Param("type") String type, @Param("type") String type,
@Param("subType") String subType, @Param("subType") String subType,
@Param("beginTime") String beginTime, @Param("beginTime") String beginTime,
@Param("endTime") String endTime); @Param("endTime") String endTime,
@Param("creatorArray") String[] creatorArray);
BigDecimal getStockCheckSumByDepotList( BigDecimal getStockCheckSumByDepotList(
@Param("depotList") List<Long> depotList, @Param("depotList") List<Long> depotList,

View File

@@ -850,60 +850,62 @@ public class DepotHeadService {
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((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<>(); Map<String, Object> map = new HashMap<>();
//今日 //今日
BigDecimal todayBuy = getBuyAndSaleBasicStatistics("入库", "采购", BigDecimal todayBuy = getBuyAndSaleBasicStatistics("入库", "采购",
1, today, getNow3()); //今日采购入库 1, today, getNow3(), creatorArray); //今日采购入库
BigDecimal todayBuyBack = getBuyAndSaleBasicStatistics("出库", "采购退货", BigDecimal todayBuyBack = getBuyAndSaleBasicStatistics("出库", "采购退货",
1, today, getNow3()); //今日采购退货 1, today, getNow3(), creatorArray); //今日采购退货
BigDecimal todaySale = getBuyAndSaleBasicStatistics("出库", "销售", BigDecimal todaySale = getBuyAndSaleBasicStatistics("出库", "销售",
1, today, getNow3()); //今日销售出库 1, today, getNow3(), creatorArray); //今日销售出库
BigDecimal todaySaleBack = getBuyAndSaleBasicStatistics("入库", "销售退货", BigDecimal todaySaleBack = getBuyAndSaleBasicStatistics("入库", "销售退货",
1, today, getNow3()); //今日销售退货 1, today, getNow3(), creatorArray); //今日销售退货
BigDecimal todayRetailSale = getBuyAndSaleRetailStatistics("出库", "零售", BigDecimal todayRetailSale = getBuyAndSaleRetailStatistics("出库", "零售",
today, getNow3()); //今日零售出库 today, getNow3(), creatorArray); //今日零售出库
BigDecimal todayRetailSaleBack = getBuyAndSaleRetailStatistics("入库", "零售退货", BigDecimal todayRetailSaleBack = getBuyAndSaleRetailStatistics("入库", "零售退货",
today, getNow3()); //今日零售退货 today, getNow3(), creatorArray); //今日零售退货
//本月 //本月
BigDecimal monthBuy = getBuyAndSaleBasicStatistics("入库", "采购", BigDecimal monthBuy = getBuyAndSaleBasicStatistics("入库", "采购",
1, monthFirstDay, getNow3()); //本月采购入库 1, monthFirstDay, getNow3(), creatorArray); //本月采购入库
BigDecimal monthBuyBack = getBuyAndSaleBasicStatistics("出库", "采购退货", BigDecimal monthBuyBack = getBuyAndSaleBasicStatistics("出库", "采购退货",
1, monthFirstDay, getNow3()); //本月采购退货 1, monthFirstDay, getNow3(), creatorArray); //本月采购退货
BigDecimal monthSale = getBuyAndSaleBasicStatistics("出库", "销售", BigDecimal monthSale = getBuyAndSaleBasicStatistics("出库", "销售",
1,monthFirstDay, getNow3()); //本月销售出库 1,monthFirstDay, getNow3(), creatorArray); //本月销售出库
BigDecimal monthSaleBack = getBuyAndSaleBasicStatistics("入库", "销售退货", BigDecimal monthSaleBack = getBuyAndSaleBasicStatistics("入库", "销售退货",
1,monthFirstDay, getNow3()); //本月销售退货 1,monthFirstDay, getNow3(), creatorArray); //本月销售退货
BigDecimal monthRetailSale = getBuyAndSaleRetailStatistics("出库", "零售", BigDecimal monthRetailSale = getBuyAndSaleRetailStatistics("出库", "零售",
monthFirstDay, getNow3()); //本月零售出库 monthFirstDay, getNow3(), creatorArray); //本月零售出库
BigDecimal monthRetailSaleBack = getBuyAndSaleRetailStatistics("入库", "零售退货", BigDecimal monthRetailSaleBack = getBuyAndSaleRetailStatistics("入库", "零售退货",
monthFirstDay, getNow3()); //本月零售退货 monthFirstDay, getNow3(), creatorArray); //本月零售退货
//昨日 //昨日
BigDecimal yesterdayBuy = getBuyAndSaleBasicStatistics("入库", "采购", BigDecimal yesterdayBuy = getBuyAndSaleBasicStatistics("入库", "采购",
1, yesterdayBegin, yesterdayEnd); //昨日采购入库 1, yesterdayBegin, yesterdayEnd, creatorArray); //昨日采购入库
BigDecimal yesterdayBuyBack = getBuyAndSaleBasicStatistics("出库", "采购退货", BigDecimal yesterdayBuyBack = getBuyAndSaleBasicStatistics("出库", "采购退货",
1, yesterdayBegin, yesterdayEnd); //昨日采购退货 1, yesterdayBegin, yesterdayEnd, creatorArray); //昨日采购退货
BigDecimal yesterdaySale = getBuyAndSaleBasicStatistics("出库", "销售", BigDecimal yesterdaySale = getBuyAndSaleBasicStatistics("出库", "销售",
1, yesterdayBegin, yesterdayEnd); //昨日销售出库 1, yesterdayBegin, yesterdayEnd, creatorArray); //昨日销售出库
BigDecimal yesterdaySaleBack = getBuyAndSaleBasicStatistics("入库", "销售退货", BigDecimal yesterdaySaleBack = getBuyAndSaleBasicStatistics("入库", "销售退货",
1, yesterdayBegin, yesterdayEnd); //昨日销售退货 1, yesterdayBegin, yesterdayEnd, creatorArray); //昨日销售退货
BigDecimal yesterdayRetailSale = getBuyAndSaleRetailStatistics("出库", "零售", BigDecimal yesterdayRetailSale = getBuyAndSaleRetailStatistics("出库", "零售",
yesterdayBegin, yesterdayEnd); //昨日零售出库 yesterdayBegin, yesterdayEnd, creatorArray); //昨日零售出库
BigDecimal yesterdayRetailSaleBack = getBuyAndSaleRetailStatistics("入库", "零售退货", BigDecimal yesterdayRetailSaleBack = getBuyAndSaleRetailStatistics("入库", "零售退货",
yesterdayBegin, yesterdayEnd); //昨日零售退货 yesterdayBegin, yesterdayEnd, creatorArray); //昨日零售退货
//今年 //今年
BigDecimal yearBuy = getBuyAndSaleBasicStatistics("入库", "采购", BigDecimal yearBuy = getBuyAndSaleBasicStatistics("入库", "采购",
1, yearBegin, yearEnd); //今年采购入库 1, yearBegin, yearEnd, creatorArray); //今年采购入库
BigDecimal yearBuyBack = getBuyAndSaleBasicStatistics("出库", "采购退货", BigDecimal yearBuyBack = getBuyAndSaleBasicStatistics("出库", "采购退货",
1, yearBegin, yearEnd); //今年采购退货 1, yearBegin, yearEnd, creatorArray); //今年采购退货
BigDecimal yearSale = getBuyAndSaleBasicStatistics("出库", "销售", BigDecimal yearSale = getBuyAndSaleBasicStatistics("出库", "销售",
1, yearBegin, yearEnd); //今年销售出库 1, yearBegin, yearEnd, creatorArray); //今年销售出库
BigDecimal yearSaleBack = getBuyAndSaleBasicStatistics("入库", "销售退货", BigDecimal yearSaleBack = getBuyAndSaleBasicStatistics("入库", "销售退货",
1, yearBegin, yearEnd); //今年销售退货 1, yearBegin, yearEnd, creatorArray); //今年销售退货
BigDecimal yearRetailSale = getBuyAndSaleRetailStatistics("出库", "零售", BigDecimal yearRetailSale = getBuyAndSaleRetailStatistics("出库", "零售",
yearBegin, yearEnd); //今年零售出库 yearBegin, yearEnd, creatorArray); //今年零售出库
BigDecimal yearRetailSaleBack = getBuyAndSaleRetailStatistics("入库", "零售退货", BigDecimal yearRetailSaleBack = getBuyAndSaleRetailStatistics("入库", "零售退货",
yearBegin, yearEnd); //今年零售退货 yearBegin, yearEnd, creatorArray); //今年零售退货
map.put("todayBuy", todayBuy.subtract(todayBuyBack)); map.put("todayBuy", todayBuy.subtract(todayBuyBack));
map.put("todaySale", todaySale.subtract(todaySaleBack)); map.put("todaySale", todaySale.subtract(todaySaleBack));
map.put("todayRetailSale", todayRetailSale.subtract(todayRetailSaleBack)); map.put("todayRetailSale", todayRetailSale.subtract(todayRetailSaleBack));
@@ -919,12 +921,14 @@ public class DepotHeadService {
return map; return map;
} }
public BigDecimal getBuyAndSaleBasicStatistics(String type, String subType, Integer hasSupplier, String beginTime, String endTime) { public BigDecimal getBuyAndSaleBasicStatistics(String type, String subType, Integer hasSupplier,
return depotHeadMapperEx.getBuyAndSaleBasicStatistics(type, subType, hasSupplier, beginTime, endTime); 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) { public BigDecimal getBuyAndSaleRetailStatistics(String type, String subType,
return depotHeadMapperEx.getBuyAndSaleRetailStatistics(type, subType, beginTime, endTime).abs(); String beginTime, String endTime, String[] creatorArray) {
return depotHeadMapperEx.getBuyAndSaleRetailStatistics(type, subType, beginTime, endTime, creatorArray).abs();
} }
public DepotHead getDepotHead(String number)throws Exception { public DepotHead getDepotHead(String number)throws Exception {

View File

@@ -348,12 +348,13 @@ public class DepotItemService {
* @return * @return
* @throws Exception * @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; BigDecimal result= BigDecimal.ZERO;
try{ try{
String [] creatorArray = depotHeadService.getCreatorArray(roleType);
String beginTime = Tools.firstDayOfMonth(month) + BusinessConstants.DAY_FIRST_TIME; String beginTime = Tools.firstDayOfMonth(month) + BusinessConstants.DAY_FIRST_TIME;
String endTime = Tools.lastDayOfMonth(month) + BusinessConstants.DAY_LAST_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){ }catch(Exception e){
JshException.readFail(logger, e); JshException.readFail(logger, e);
} }
@@ -368,12 +369,13 @@ public class DepotItemService {
* @return * @return
* @throws Exception * @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; BigDecimal result= BigDecimal.ZERO;
try{ try{
String [] creatorArray = depotHeadService.getCreatorArray(roleType);
String beginTime = Tools.firstDayOfMonth(month) + BusinessConstants.DAY_FIRST_TIME; String beginTime = Tools.firstDayOfMonth(month) + BusinessConstants.DAY_FIRST_TIME;
String endTime = Tools.lastDayOfMonth(month) + BusinessConstants.DAY_LAST_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(); result = result.abs();
}catch(Exception e){ }catch(Exception e){
JshException.readFail(logger, e); JshException.readFail(logger, e);

View File

@@ -721,6 +721,13 @@
<if test="endTime != null"> <if test="endTime != null">
and oper_time &lt;= #{endTime} and oper_time &lt;= #{endTime}
</if> </if>
<if test="creatorArray != null">
and creator in (
<foreach collection="creatorArray" item="creator" separator=",">
#{creator}
</foreach>
)
</if>
and ifnull(delete_flag,'0') !='1' and ifnull(delete_flag,'0') !='1'
</select> </select>
@@ -741,6 +748,13 @@
<if test="endTime != null"> <if test="endTime != null">
and oper_time &lt;= #{endTime} and oper_time &lt;= #{endTime}
</if> </if>
<if test="creatorArray != null">
and creator in (
<foreach collection="creatorArray" item="creator" separator=",">
#{creator}
</foreach>
)
</if>
and ifnull(delete_flag,'0') !='1' and ifnull(delete_flag,'0') !='1'
</select> </select>

View File

@@ -378,6 +378,13 @@
and dh.type=#{type} and dh.sub_type=#{subType} and dh.type=#{type} and dh.sub_type=#{subType}
and dh.oper_time &gt;= #{beginTime} and dh.oper_time &gt;= #{beginTime}
and dh.oper_time &lt;= #{endTime} and dh.oper_time &lt;= #{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' and ifnull(dh.delete_flag,'0') !='1'
</select> </select>
@@ -387,6 +394,13 @@
and dh.type=#{type} and dh.sub_type=#{subType} and dh.type=#{type} and dh.sub_type=#{subType}
and dh.oper_time &gt;= #{beginTime} and dh.oper_time &gt;= #{beginTime}
and dh.oper_time &lt;= #{endTime} and dh.oper_time &lt;= #{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' and ifnull(dh.delete_flag,'0') !='1'
</select> </select>