优化进销存统计报表的查询接口

This commit is contained in:
季圣华
2022-04-22 23:47:08 +08:00
parent e441473220
commit 0c33e0cba8
2 changed files with 34 additions and 4 deletions

View File

@@ -445,6 +445,10 @@ public class ExceptionConstants {
public static final int ORGA_USER_REL_EDIT_FAILED_CODE = 11500002; public static final int ORGA_USER_REL_EDIT_FAILED_CODE = 11500002;
public static final String ORGA_USER_REL_EDIT_FAILED_MSG = "修改机构用户关联关系失败"; public static final String ORGA_USER_REL_EDIT_FAILED_MSG = "修改机构用户关联关系失败";
//进销存统计,如果有权限的仓库数量太多则提示要选择仓库
public static final int REPORT_TWO_MANY_DEPOT_FAILED_CODE = 510;
public static final String REPORT_TWO_MANY_DEPOT_FAILED_MSG = "请选择仓库,再进行查询";
//演示用户禁止操作 //演示用户禁止操作
public static final int SYSTEM_CONFIG_TEST_USER_CODE = -1; public static final int SYSTEM_CONFIG_TEST_USER_CODE = -1;
public static final String SYSTEM_CONFIG_TEST_USER_MSG = "演示用户禁止操作"; public static final String SYSTEM_CONFIG_TEST_USER_MSG = "演示用户禁止操作";

View File

@@ -280,7 +280,7 @@ public class DepotItemController {
@ApiOperation(value = "查找所有的明细") @ApiOperation(value = "查找所有的明细")
public BaseResponseInfo findByAll(@RequestParam("currentPage") Integer currentPage, public BaseResponseInfo findByAll(@RequestParam("currentPage") Integer currentPage,
@RequestParam("pageSize") Integer pageSize, @RequestParam("pageSize") Integer pageSize,
@RequestParam("depotIds") String depotIds, @RequestParam(value = "depotIds",required = false) String depotIds,
@RequestParam("monthTime") String monthTime, @RequestParam("monthTime") String monthTime,
@RequestParam("materialParam") String materialParam, @RequestParam("materialParam") String materialParam,
@RequestParam("mpList") String mpList, @RequestParam("mpList") String mpList,
@@ -290,7 +290,7 @@ public class DepotItemController {
try { try {
String timeA = Tools.firstDayOfMonth(monthTime) + BusinessConstants.DAY_FIRST_TIME; String timeA = Tools.firstDayOfMonth(monthTime) + BusinessConstants.DAY_FIRST_TIME;
String timeB = Tools.lastDayOfMonth(monthTime) + BusinessConstants.DAY_LAST_TIME; String timeB = Tools.lastDayOfMonth(monthTime) + BusinessConstants.DAY_LAST_TIME;
List<Long> depotList = StringUtil.strToLongList(depotIds); List<Long> depotList = parseListByDepotIds(depotIds);
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(StringUtil.toNull(materialParam), List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(StringUtil.toNull(materialParam),
timeB,(currentPage-1)*pageSize, pageSize); timeB,(currentPage-1)*pageSize, pageSize);
String[] mpArr = mpList.split(","); String[] mpArr = mpList.split(",");
@@ -339,6 +339,9 @@ public class DepotItemController {
map.put("rows", dataArray); map.put("rows", dataArray);
res.code = 200; res.code = 200;
res.data = map; res.data = map;
} catch (BusinessRunTimeException e) {
res.code = e.getCode();
res.data = e.getData().get("message");
} catch(Exception e){ } catch(Exception e){
e.printStackTrace(); e.printStackTrace();
res.code = 500; res.code = 500;
@@ -357,7 +360,7 @@ public class DepotItemController {
*/ */
@GetMapping(value = "/totalCountMoney") @GetMapping(value = "/totalCountMoney")
@ApiOperation(value = "统计总计金额") @ApiOperation(value = "统计总计金额")
public BaseResponseInfo totalCountMoney(@RequestParam("depotIds") String depotIds, public BaseResponseInfo totalCountMoney(@RequestParam(value = "depotIds",required = false) String depotIds,
@RequestParam("monthTime") String monthTime, @RequestParam("monthTime") String monthTime,
@RequestParam("materialParam") String materialParam, @RequestParam("materialParam") String materialParam,
HttpServletRequest request) throws Exception{ HttpServletRequest request) throws Exception{
@@ -365,7 +368,7 @@ public class DepotItemController {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
try { try {
String endTime = Tools.lastDayOfMonth(monthTime) + BusinessConstants.DAY_LAST_TIME; String endTime = Tools.lastDayOfMonth(monthTime) + BusinessConstants.DAY_LAST_TIME;
List<Long> depotList = StringUtil.strToLongList(depotIds); List<Long> depotList = parseListByDepotIds(depotIds);
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(StringUtil.toNull(materialParam), List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(StringUtil.toNull(materialParam),
endTime, null, null); endTime, null, null);
BigDecimal thisAllPrice = BigDecimal.ZERO; BigDecimal thisAllPrice = BigDecimal.ZERO;
@@ -383,6 +386,9 @@ public class DepotItemController {
map.put("totalCount", thisAllPrice); map.put("totalCount", thisAllPrice);
res.code = 200; res.code = 200;
res.data = map; res.data = map;
} catch (BusinessRunTimeException e) {
res.code = e.getCode();
res.data = e.getData().get("message");
} catch(Exception e){ } catch(Exception e){
e.printStackTrace(); e.printStackTrace();
res.code = 500; res.code = 500;
@@ -391,6 +397,26 @@ public class DepotItemController {
return res; return res;
} }
private List<Long> parseListByDepotIds(@RequestParam("depotIds") String depotIds) throws Exception {
List<Long> depotList = new ArrayList<>();
if(StringUtil.isNotEmpty(depotIds)) {
depotList = StringUtil.strToLongList(depotIds);
} else {
//未选择仓库时默认为当前用户有权限的仓库
JSONArray depotArr = depotService.findDepotByCurrentUser();
for(Object obj: depotArr) {
JSONObject object = JSONObject.parseObject(obj.toString());
depotList.add(object.getLong("id"));
}
//如果有权限的仓库数量太多则提示要选择仓库
if(depotList.size()>10) {
throw new BusinessRunTimeException(ExceptionConstants.REPORT_TWO_MANY_DEPOT_FAILED_CODE,
ExceptionConstants.REPORT_TWO_MANY_DEPOT_FAILED_MSG);
}
}
return depotList;
}
/** /**
* 进货统计 * 进货统计
* @param currentPage * @param currentPage