优化首页接口,限制超管用户的统计
This commit is contained in:
parent
9797478a4c
commit
6ff36c1ba7
@ -12,8 +12,8 @@ import com.jsh.erp.datasource.vo.DepotHeadVo4List;
|
||||
import com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount;
|
||||
import com.jsh.erp.service.depot.DepotService;
|
||||
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.user.UserService;
|
||||
import com.jsh.erp.utils.*;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -50,6 +50,9 @@ public class DepotHeadController {
|
||||
@Resource
|
||||
private SystemConfigService systemConfigService;
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
/**
|
||||
* 批量设置状态-审核或者反审核
|
||||
* @param jsonObject
|
||||
@ -484,14 +487,17 @@ public class DepotHeadController {
|
||||
public BaseResponseInfo getBuyAndSaleStatistics(HttpServletRequest request) {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
String today = Tools.getNow() + BusinessConstants.DAY_FIRST_TIME;
|
||||
String monthFirstDay = Tools.firstDayOfMonth(Tools.getCurrentMonth()) + BusinessConstants.DAY_FIRST_TIME;
|
||||
String yesterdayBegin = Tools.getYesterday() + BusinessConstants.DAY_FIRST_TIME;
|
||||
String yesterdayEnd = Tools.getYesterday() + BusinessConstants.DAY_LAST_TIME;
|
||||
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, request);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String loginName = userService.getCurrentUser().getLoginName();
|
||||
if(!"admin".equals(loginName)) {
|
||||
String today = Tools.getNow() + BusinessConstants.DAY_FIRST_TIME;
|
||||
String monthFirstDay = Tools.firstDayOfMonth(Tools.getCurrentMonth()) + BusinessConstants.DAY_FIRST_TIME;
|
||||
String yesterdayBegin = Tools.getYesterday() + BusinessConstants.DAY_FIRST_TIME;
|
||||
String yesterdayEnd = Tools.getYesterday() + BusinessConstants.DAY_LAST_TIME;
|
||||
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.data = map;
|
||||
} catch(Exception e){
|
||||
|
||||
@ -985,77 +985,80 @@ public class DepotItemController {
|
||||
public BaseResponseInfo buyOrSalePrice(HttpServletRequest request,
|
||||
HttpServletResponse response)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
try {
|
||||
Long userId = userService.getUserId(request);
|
||||
List<String> monthList = Tools.getLastMonths(6);
|
||||
String beginTime = Tools.firstDayOfMonth(monthList.get(0)) + BusinessConstants.DAY_FIRST_TIME;
|
||||
String endTime = Tools.getNow() + BusinessConstants.DAY_LAST_TIME;
|
||||
List<InOutPriceVo> inOrOutPriceList = depotItemService.inOrOutPriceList(beginTime, endTime);
|
||||
String priceLimit = userService.getRoleTypeByUserId(userId).getPriceLimit();
|
||||
JSONArray buyPriceList = new JSONArray();
|
||||
for(String month: monthList) {
|
||||
JSONObject obj = new JSONObject();
|
||||
BigDecimal outPrice = BigDecimal.ZERO;
|
||||
BigDecimal inPrice = BigDecimal.ZERO;
|
||||
for(InOutPriceVo item: inOrOutPriceList) {
|
||||
String billOperMonth = Tools.dateToStr(item.getOperTime(), "yyyy-MM");
|
||||
if(month.equals(billOperMonth)) {
|
||||
if("入库".equals(item.getType()) && "采购".equals(item.getSubType())) {
|
||||
outPrice = outPrice.add(item.getDiscountLastMoney());
|
||||
}
|
||||
if("出库".equals(item.getType()) && "采购退货".equals(item.getSubType())) {
|
||||
inPrice = inPrice.add(item.getDiscountLastMoney());
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String loginName = userService.getCurrentUser().getLoginName();
|
||||
if(!"admin".equals(loginName)) {
|
||||
Long userId = userService.getUserId(request);
|
||||
List<String> monthList = Tools.getLastMonths(6);
|
||||
String beginTime = Tools.firstDayOfMonth(monthList.get(0)) + BusinessConstants.DAY_FIRST_TIME;
|
||||
String endTime = Tools.getNow() + BusinessConstants.DAY_LAST_TIME;
|
||||
List<InOutPriceVo> inOrOutPriceList = depotItemService.inOrOutPriceList(beginTime, endTime);
|
||||
String priceLimit = userService.getRoleTypeByUserId(userId).getPriceLimit();
|
||||
JSONArray buyPriceList = new JSONArray();
|
||||
for (String month : monthList) {
|
||||
JSONObject obj = new JSONObject();
|
||||
BigDecimal outPrice = BigDecimal.ZERO;
|
||||
BigDecimal inPrice = BigDecimal.ZERO;
|
||||
for (InOutPriceVo item : inOrOutPriceList) {
|
||||
String billOperMonth = Tools.dateToStr(item.getOperTime(), "yyyy-MM");
|
||||
if (month.equals(billOperMonth)) {
|
||||
if ("入库".equals(item.getType()) && "采购".equals(item.getSubType())) {
|
||||
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);
|
||||
obj.put("y", roleService.parseHomePriceByLimit(outPrice.subtract(inPrice), "buy", priceLimit, "***", request));
|
||||
buyPriceList.add(obj);
|
||||
}
|
||||
map.put("buyPriceList", buyPriceList);
|
||||
JSONArray salePriceList = new JSONArray();
|
||||
for(String month: monthList) {
|
||||
JSONObject obj = new JSONObject();
|
||||
BigDecimal outPrice = BigDecimal.ZERO;
|
||||
BigDecimal inPrice = BigDecimal.ZERO;
|
||||
for(InOutPriceVo item: inOrOutPriceList) {
|
||||
String billOperMonth = Tools.dateToStr(item.getOperTime(), "yyyy-MM");
|
||||
if(month.equals(billOperMonth)) {
|
||||
if("出库".equals(item.getType()) && "销售".equals(item.getSubType())) {
|
||||
outPrice = outPrice.add(item.getDiscountLastMoney());
|
||||
}
|
||||
if("入库".equals(item.getType()) && "销售退货".equals(item.getSubType())) {
|
||||
inPrice = inPrice.add(item.getDiscountLastMoney());
|
||||
map.put("buyPriceList", buyPriceList);
|
||||
JSONArray salePriceList = new JSONArray();
|
||||
for (String month : monthList) {
|
||||
JSONObject obj = new JSONObject();
|
||||
BigDecimal outPrice = BigDecimal.ZERO;
|
||||
BigDecimal inPrice = BigDecimal.ZERO;
|
||||
for (InOutPriceVo item : inOrOutPriceList) {
|
||||
String billOperMonth = Tools.dateToStr(item.getOperTime(), "yyyy-MM");
|
||||
if (month.equals(billOperMonth)) {
|
||||
if ("出库".equals(item.getType()) && "销售".equals(item.getSubType())) {
|
||||
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);
|
||||
obj.put("y", roleService.parseHomePriceByLimit(outPrice.subtract(inPrice), "sale", priceLimit, "***", request));
|
||||
salePriceList.add(obj);
|
||||
}
|
||||
map.put("salePriceList", salePriceList);
|
||||
JSONArray retailPriceList = new JSONArray();
|
||||
for(String month: monthList) {
|
||||
JSONObject obj = new JSONObject();
|
||||
BigDecimal outPrice = BigDecimal.ZERO;
|
||||
BigDecimal inPrice = BigDecimal.ZERO;
|
||||
for(InOutPriceVo item: inOrOutPriceList) {
|
||||
String billOperMonth = Tools.dateToStr(item.getOperTime(), "yyyy-MM");
|
||||
if(month.equals(billOperMonth)) {
|
||||
if("出库".equals(item.getType()) && "零售".equals(item.getSubType())) {
|
||||
outPrice = outPrice.add(item.getTotalPrice().abs());
|
||||
}
|
||||
if("入库".equals(item.getType()) && "零售退货".equals(item.getSubType())) {
|
||||
inPrice = inPrice.add(item.getTotalPrice().abs());
|
||||
map.put("salePriceList", salePriceList);
|
||||
JSONArray retailPriceList = new JSONArray();
|
||||
for (String month : monthList) {
|
||||
JSONObject obj = new JSONObject();
|
||||
BigDecimal outPrice = BigDecimal.ZERO;
|
||||
BigDecimal inPrice = BigDecimal.ZERO;
|
||||
for (InOutPriceVo item : inOrOutPriceList) {
|
||||
String billOperMonth = Tools.dateToStr(item.getOperTime(), "yyyy-MM");
|
||||
if (month.equals(billOperMonth)) {
|
||||
if ("出库".equals(item.getType()) && "零售".equals(item.getSubType())) {
|
||||
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);
|
||||
obj.put("y", roleService.parseHomePriceByLimit(outPrice.subtract(inPrice), "retail", priceLimit, "***", request));
|
||||
retailPriceList.add(obj);
|
||||
map.put("retailPriceList", retailPriceList);
|
||||
}
|
||||
map.put("retailPriceList", retailPriceList);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch (Exception e) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user