优化首页接口,限制超管用户的统计

This commit is contained in:
jishenghua
2024-10-16 22:34:50 +08:00
parent 9797478a4c
commit 6ff36c1ba7
2 changed files with 78 additions and 69 deletions

View File

@@ -12,8 +12,8 @@ import com.jsh.erp.datasource.vo.DepotHeadVo4List;
import com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount; import com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount;
import com.jsh.erp.service.depot.DepotService; import com.jsh.erp.service.depot.DepotService;
import com.jsh.erp.service.depotHead.DepotHeadService; import com.jsh.erp.service.depotHead.DepotHeadService;
import com.jsh.erp.service.redis.RedisService;
import com.jsh.erp.service.systemConfig.SystemConfigService; import com.jsh.erp.service.systemConfig.SystemConfigService;
import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.*; import com.jsh.erp.utils.*;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@@ -50,6 +50,9 @@ public class DepotHeadController {
@Resource @Resource
private SystemConfigService systemConfigService; private SystemConfigService systemConfigService;
@Resource
private UserService userService;
/** /**
* 批量设置状态-审核或者反审核 * 批量设置状态-审核或者反审核
* @param jsonObject * @param jsonObject
@@ -484,14 +487,17 @@ public class DepotHeadController {
public BaseResponseInfo getBuyAndSaleStatistics(HttpServletRequest request) { public BaseResponseInfo getBuyAndSaleStatistics(HttpServletRequest request) {
BaseResponseInfo res = new BaseResponseInfo(); BaseResponseInfo res = new BaseResponseInfo();
try { try {
String today = Tools.getNow() + BusinessConstants.DAY_FIRST_TIME; Map<String, Object> map = new HashMap<>();
String monthFirstDay = Tools.firstDayOfMonth(Tools.getCurrentMonth()) + BusinessConstants.DAY_FIRST_TIME; String loginName = userService.getCurrentUser().getLoginName();
String yesterdayBegin = Tools.getYesterday() + BusinessConstants.DAY_FIRST_TIME; if(!"admin".equals(loginName)) {
String yesterdayEnd = Tools.getYesterday() + BusinessConstants.DAY_LAST_TIME; String today = Tools.getNow() + BusinessConstants.DAY_FIRST_TIME;
String yearBegin = Tools.getYearBegin() + BusinessConstants.DAY_FIRST_TIME; String monthFirstDay = Tools.firstDayOfMonth(Tools.getCurrentMonth()) + BusinessConstants.DAY_FIRST_TIME;
String yearEnd = Tools.getYearEnd() + BusinessConstants.DAY_LAST_TIME; String yesterdayBegin = Tools.getYesterday() + BusinessConstants.DAY_FIRST_TIME;
Map<String, Object> map = depotHeadService.getBuyAndSaleStatistics(today, monthFirstDay, String yesterdayEnd = Tools.getYesterday() + BusinessConstants.DAY_LAST_TIME;
yesterdayBegin, yesterdayEnd, yearBegin, yearEnd, request); String yearBegin = Tools.getYearBegin() + BusinessConstants.DAY_FIRST_TIME;
String yearEnd = Tools.getYearEnd() + BusinessConstants.DAY_LAST_TIME;
map = depotHeadService.getBuyAndSaleStatistics(today, monthFirstDay, yesterdayBegin, yesterdayEnd, yearBegin, yearEnd, request);
}
res.code = 200; res.code = 200;
res.data = map; res.data = map;
} catch(Exception e){ } catch(Exception e){

View File

@@ -985,77 +985,80 @@ public class DepotItemController {
public BaseResponseInfo buyOrSalePrice(HttpServletRequest request, public BaseResponseInfo buyOrSalePrice(HttpServletRequest request,
HttpServletResponse response)throws Exception { HttpServletResponse response)throws Exception {
BaseResponseInfo res = new BaseResponseInfo(); BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try { try {
Long userId = userService.getUserId(request); Map<String, Object> map = new HashMap<>();
List<String> monthList = Tools.getLastMonths(6); String loginName = userService.getCurrentUser().getLoginName();
String beginTime = Tools.firstDayOfMonth(monthList.get(0)) + BusinessConstants.DAY_FIRST_TIME; if(!"admin".equals(loginName)) {
String endTime = Tools.getNow() + BusinessConstants.DAY_LAST_TIME; Long userId = userService.getUserId(request);
List<InOutPriceVo> inOrOutPriceList = depotItemService.inOrOutPriceList(beginTime, endTime); List<String> monthList = Tools.getLastMonths(6);
String priceLimit = userService.getRoleTypeByUserId(userId).getPriceLimit(); String beginTime = Tools.firstDayOfMonth(monthList.get(0)) + BusinessConstants.DAY_FIRST_TIME;
JSONArray buyPriceList = new JSONArray(); String endTime = Tools.getNow() + BusinessConstants.DAY_LAST_TIME;
for(String month: monthList) { List<InOutPriceVo> inOrOutPriceList = depotItemService.inOrOutPriceList(beginTime, endTime);
JSONObject obj = new JSONObject(); String priceLimit = userService.getRoleTypeByUserId(userId).getPriceLimit();
BigDecimal outPrice = BigDecimal.ZERO; JSONArray buyPriceList = new JSONArray();
BigDecimal inPrice = BigDecimal.ZERO; for (String month : monthList) {
for(InOutPriceVo item: inOrOutPriceList) { JSONObject obj = new JSONObject();
String billOperMonth = Tools.dateToStr(item.getOperTime(), "yyyy-MM"); BigDecimal outPrice = BigDecimal.ZERO;
if(month.equals(billOperMonth)) { BigDecimal inPrice = BigDecimal.ZERO;
if("入库".equals(item.getType()) && "采购".equals(item.getSubType())) { for (InOutPriceVo item : inOrOutPriceList) {
outPrice = outPrice.add(item.getDiscountLastMoney()); String billOperMonth = Tools.dateToStr(item.getOperTime(), "yyyy-MM");
} if (month.equals(billOperMonth)) {
if("".equals(item.getType()) && "采购退货".equals(item.getSubType())) { if ("".equals(item.getType()) && "采购".equals(item.getSubType())) {
inPrice = inPrice.add(item.getDiscountLastMoney()); outPrice = outPrice.add(item.getDiscountLastMoney());
}
if ("出库".equals(item.getType()) && "采购退货".equals(item.getSubType())) {
inPrice = inPrice.add(item.getDiscountLastMoney());
}
} }
} }
obj.put("x", month);
obj.put("y", roleService.parseHomePriceByLimit(outPrice.subtract(inPrice), "buy", priceLimit, "***", request));
buyPriceList.add(obj);
} }
obj.put("x", month); map.put("buyPriceList", buyPriceList);
obj.put("y", roleService.parseHomePriceByLimit(outPrice.subtract(inPrice), "buy", priceLimit, "***", request)); JSONArray salePriceList = new JSONArray();
buyPriceList.add(obj); for (String month : monthList) {
} JSONObject obj = new JSONObject();
map.put("buyPriceList", buyPriceList); BigDecimal outPrice = BigDecimal.ZERO;
JSONArray salePriceList = new JSONArray(); BigDecimal inPrice = BigDecimal.ZERO;
for(String month: monthList) { for (InOutPriceVo item : inOrOutPriceList) {
JSONObject obj = new JSONObject(); String billOperMonth = Tools.dateToStr(item.getOperTime(), "yyyy-MM");
BigDecimal outPrice = BigDecimal.ZERO; if (month.equals(billOperMonth)) {
BigDecimal inPrice = BigDecimal.ZERO; if ("出库".equals(item.getType()) && "销售".equals(item.getSubType())) {
for(InOutPriceVo item: inOrOutPriceList) { outPrice = outPrice.add(item.getDiscountLastMoney());
String billOperMonth = Tools.dateToStr(item.getOperTime(), "yyyy-MM"); }
if(month.equals(billOperMonth)) { if ("入库".equals(item.getType()) && "销售退货".equals(item.getSubType())) {
if("出库".equals(item.getType()) && "销售".equals(item.getSubType())) { inPrice = inPrice.add(item.getDiscountLastMoney());
outPrice = outPrice.add(item.getDiscountLastMoney()); }
}
if("入库".equals(item.getType()) && "销售退货".equals(item.getSubType())) {
inPrice = inPrice.add(item.getDiscountLastMoney());
} }
} }
obj.put("x", month);
obj.put("y", roleService.parseHomePriceByLimit(outPrice.subtract(inPrice), "sale", priceLimit, "***", request));
salePriceList.add(obj);
} }
obj.put("x", month); map.put("salePriceList", salePriceList);
obj.put("y", roleService.parseHomePriceByLimit(outPrice.subtract(inPrice), "sale", priceLimit, "***", request)); JSONArray retailPriceList = new JSONArray();
salePriceList.add(obj); for (String month : monthList) {
} JSONObject obj = new JSONObject();
map.put("salePriceList", salePriceList); BigDecimal outPrice = BigDecimal.ZERO;
JSONArray retailPriceList = new JSONArray(); BigDecimal inPrice = BigDecimal.ZERO;
for(String month: monthList) { for (InOutPriceVo item : inOrOutPriceList) {
JSONObject obj = new JSONObject(); String billOperMonth = Tools.dateToStr(item.getOperTime(), "yyyy-MM");
BigDecimal outPrice = BigDecimal.ZERO; if (month.equals(billOperMonth)) {
BigDecimal inPrice = BigDecimal.ZERO; if ("出库".equals(item.getType()) && "零售".equals(item.getSubType())) {
for(InOutPriceVo item: inOrOutPriceList) { outPrice = outPrice.add(item.getTotalPrice().abs());
String billOperMonth = Tools.dateToStr(item.getOperTime(), "yyyy-MM"); }
if(month.equals(billOperMonth)) { if ("入库".equals(item.getType()) && "零售退货".equals(item.getSubType())) {
if("出库".equals(item.getType()) && "零售".equals(item.getSubType())) { inPrice = inPrice.add(item.getTotalPrice().abs());
outPrice = outPrice.add(item.getTotalPrice().abs()); }
}
if("入库".equals(item.getType()) && "零售退货".equals(item.getSubType())) {
inPrice = inPrice.add(item.getTotalPrice().abs());
} }
} }
obj.put("x", month);
obj.put("y", roleService.parseHomePriceByLimit(outPrice.subtract(inPrice), "retail", priceLimit, "***", request));
retailPriceList.add(obj);
} }
obj.put("x", month); map.put("retailPriceList", retailPriceList);
obj.put("y", roleService.parseHomePriceByLimit(outPrice.subtract(inPrice), "retail", priceLimit, "***", request));
retailPriceList.add(obj);
} }
map.put("retailPriceList", retailPriceList);
res.code = 200; res.code = 200;
res.data = map; res.data = map;
} catch (Exception e) { } catch (Exception e) {