From 4c91e8cb08a8d289a2840ace307989dcaab6b6be Mon Sep 17 00:00:00 2001 From: jishenghua <752718920@qq.com> Date: Sat, 22 Feb 2025 15:47:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=B4=A6=E6=88=B7=E7=9A=84?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=88=86=E9=A1=B5=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jsh/erp/controller/AccountController.java | 61 +++++-------------- .../jsh/erp/controller/TenantController.java | 4 -- .../datasource/mappers/AccountMapperEx.java | 8 +-- .../erp/service/account/AccountService.java | 40 ++++++------ 4 files changed, 40 insertions(+), 73 deletions(-) diff --git a/jshERP-boot/src/main/java/com/jsh/erp/controller/AccountController.java b/jshERP-boot/src/main/java/com/jsh/erp/controller/AccountController.java index abeb30d7..712758f6 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/controller/AccountController.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/controller/AccountController.java @@ -2,15 +2,17 @@ package com.jsh.erp.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.jsh.erp.constants.BusinessConstants; +import com.jsh.erp.base.BaseController; +import com.jsh.erp.base.TableDataInfo; import com.jsh.erp.datasource.entities.Account; import com.jsh.erp.datasource.vo.AccountVo4InOutList; import com.jsh.erp.datasource.vo.AccountVo4List; import com.jsh.erp.service.account.AccountService; import com.jsh.erp.service.systemConfig.SystemConfigService; -import com.jsh.erp.utils.*; +import com.jsh.erp.utils.BaseResponseInfo; +import com.jsh.erp.utils.Constants; +import com.jsh.erp.utils.ErpInfo; +import com.jsh.erp.utils.StringUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; @@ -20,7 +22,6 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -34,7 +35,7 @@ import static com.jsh.erp.utils.ResponseJsonUtil.returnStr; @RestController @RequestMapping(value = "/account") @Api(tags = {"账户管理"}) -public class AccountController { +public class AccountController extends BaseController { private Logger logger = LoggerFactory.getLogger(AccountController.class); @Resource @@ -59,30 +60,13 @@ public class AccountController { @GetMapping(value = "/list") @ApiOperation(value = "获取信息列表") - public String getList(@RequestParam(value = Constants.PAGE_SIZE, required = false) Integer pageSize, - @RequestParam(value = Constants.CURRENT_PAGE, required = false) Integer currentPage, - @RequestParam(value = Constants.SEARCH, required = false) String search, - HttpServletRequest request)throws Exception { - Map objectMap = new HashMap<>(); - if (pageSize != null && pageSize <= 0) { - pageSize = 10; - } + public TableDataInfo getList(@RequestParam(value = Constants.SEARCH, required = false) String search, + HttpServletRequest request)throws Exception { String name = StringUtil.getInfo(search, "name"); String serialNo = StringUtil.getInfo(search, "serialNo"); String remark = StringUtil.getInfo(search, "remark"); - IPage page = new Page<>(); - page.setCurrent(currentPage); - page.setSize(pageSize); - IPage list = accountService.select(page, name, serialNo, remark); - if (list != null) { - objectMap.put("total", list.getTotal()); - objectMap.put("rows", list.getRecords()); - return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code); - } else { - objectMap.put("total", BusinessConstants.DEFAULT_LIST_NULL_NUMBER); - objectMap.put("rows", new ArrayList()); - return returnJson(objectMap, "查找不到数据", ErpInfo.OK.code); - } + List list = accountService.select(name, serialNo, remark); + return getDataTable(list); } @PostMapping(value = "/add") @@ -267,28 +251,11 @@ public class AccountController { */ @GetMapping(value = "/listWithBalance") @ApiOperation(value = "获取带余额的报表") - public BaseResponseInfo listWithBalance(@RequestParam("name") String name, + public TableDataInfo listWithBalance(@RequestParam("name") String name, @RequestParam("serialNo") String serialNo, - @RequestParam("currentPage") Integer currentPage, - @RequestParam("pageSize") Integer pageSize, HttpServletRequest request) throws Exception { - BaseResponseInfo res = new BaseResponseInfo(); - try { - Map map = new HashMap<>(); - IPage page = new Page<>(); - page.setCurrent(currentPage); - page.setSize(pageSize); - IPage list = accountService.listWithBalance(page, StringUtil.toNull(name), StringUtil.toNull(serialNo)); - map.put("rows", list.getRecords()); - map.put("total", list.getTotal()); - res.code = 200; - res.data = map; - } catch(Exception e){ - logger.error(e.getMessage(), e); - res.code = 500; - res.data = "获取数据失败"; - } - return res; + List list = accountService.listWithBalance(StringUtil.toNull(name), StringUtil.toNull(serialNo)); + return getDataTable(list); } /** diff --git a/jshERP-boot/src/main/java/com/jsh/erp/controller/TenantController.java b/jshERP-boot/src/main/java/com/jsh/erp/controller/TenantController.java index 9f2dfcca..b8bf027f 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/controller/TenantController.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/controller/TenantController.java @@ -1,11 +1,8 @@ package com.jsh.erp.controller; import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.jsh.erp.base.BaseController; import com.jsh.erp.base.TableDataInfo; -import com.jsh.erp.constants.BusinessConstants; import com.jsh.erp.datasource.entities.Tenant; import com.jsh.erp.datasource.entities.TenantEx; import com.jsh.erp.service.tenant.TenantService; @@ -18,7 +15,6 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; diff --git a/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/AccountMapperEx.java b/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/AccountMapperEx.java index efb20e79..0de74043 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/AccountMapperEx.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/datasource/mappers/AccountMapperEx.java @@ -1,6 +1,5 @@ package com.jsh.erp.datasource.mappers; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.jsh.erp.datasource.entities.Account; import com.jsh.erp.datasource.entities.AccountVo4Sum; import com.jsh.erp.datasource.entities.DepotHead; @@ -18,8 +17,7 @@ public interface AccountMapperEx { @Param("name") String name, @Param("serialNo") String serialNo); - IPage selectByConditionAccount( - IPage page, + List selectByConditionAccount( @Param("name") String name, @Param("serialNo") String serialNo, @Param("remark") String remark); @@ -54,8 +52,8 @@ public interface AccountMapperEx { @Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("forceFlag") Boolean forceFlag, - @Param("offset") Long offset, - @Param("rows") Long rows); + @Param("offset") Integer offset, + @Param("rows") Integer rows); List getManyAccountSumByParam( @Param("beginTime") String beginTime, diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/account/AccountService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/account/AccountService.java index f028c0cf..d80f5f64 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/account/AccountService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/account/AccountService.java @@ -1,7 +1,8 @@ package com.jsh.erp.service.account; import com.alibaba.fastjson.JSONObject; -import com.baomidou.mybatisplus.core.metadata.IPage; +import com.jsh.erp.base.PageDomain; +import com.jsh.erp.base.TableSupport; import com.jsh.erp.constants.BusinessConstants; import com.jsh.erp.constants.ExceptionConstants; import com.jsh.erp.datasource.entities.*; @@ -13,6 +14,7 @@ import com.jsh.erp.exception.JshException; import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.systemConfig.SystemConfigService; import com.jsh.erp.service.user.UserService; +import com.jsh.erp.utils.PageUtils; import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.Tools; import org.slf4j.Logger; @@ -99,10 +101,11 @@ public class AccountService { return list; } - public IPage select(IPage page, String name, String serialNo, String remark) throws Exception{ - IPage iPage = null; + public List select(String name, String serialNo, String remark) throws Exception{ + List list = null; try{ - iPage = accountMapperEx.selectByConditionAccount(page, name, serialNo, remark); + PageUtils.startPage(); + list = accountMapperEx.selectByConditionAccount(name, serialNo, remark); String timeStr = Tools.getCurrentMonth(); String bTime = Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME; String eTime = Tools.lastDayOfMonth(timeStr) + BusinessConstants.DAY_LAST_TIME; @@ -113,8 +116,9 @@ public class AccountService { Map currentAccountSumMap = new HashMap<>(); Map currentAccountSumByHeadMap = new HashMap<>(); Map currentAccountSumByDetailMap = new HashMap<>(); - long offset = (page.getCurrent() - 1) * page.getSize(); - long rows = page.getSize(); + PageDomain pageDomain = TableSupport.buildPageRequest(); + int offset = (pageDomain.getCurrentPage() - 1) * pageDomain.getPageSize(); + int rows = pageDomain.getPageSize(); List thisMonthAmountList = accountMapperEx.getAccountSumByParam(name, serialNo, bTime, eTime, forceFlag, offset, rows); List currentAmountList = accountMapperEx.getAccountSumByParam(name, serialNo, null, null, forceFlag, offset, rows); List thisMonthManyAmountList = accountMapperEx.getManyAccountSumByParam(bTime, eTime, forceFlag); @@ -129,8 +133,8 @@ public class AccountService { currentAccountSumByHeadMap.put(currentAmount.getId(), currentAmount.getAccountSumByHead()); currentAccountSumByDetailMap.put(currentAmount.getId(), currentAmount.getAccountSumByDetail()); } - if (null != iPage.getRecords()) { - for (AccountVo4List al : iPage.getRecords()) { + if (null != list) { + for (AccountVo4List al : list) { DecimalFormat df = new DecimalFormat(".##"); BigDecimal thisMonthAmount = thisMonthAccountSumMap.get(al.getId()) .add(thisMonthAccountSumByHeadMap.get(al.getId())) @@ -152,7 +156,7 @@ public class AccountService { } catch(Exception e){ JshException.readFail(logger, e); } - return iPage; + return list; } @Transactional(value = "transactionManager", rollbackFor = Exception.class) @@ -436,10 +440,11 @@ public class AccountService { return sb.toString(); } - public IPage listWithBalance(IPage page, String name, String serialNo) throws Exception { - IPage iPage = null; + public List listWithBalance(String name, String serialNo) throws Exception { + List list = null; try{ - iPage = accountMapperEx.selectByConditionAccount(page, name, serialNo, null); + PageUtils.startPage(); + list = accountMapperEx.selectByConditionAccount(name, serialNo, null); String timeStr = Tools.getCurrentMonth(); String bTime = Tools.firstDayOfMonth(timeStr) + BusinessConstants.DAY_FIRST_TIME; String eTime = Tools.lastDayOfMonth(timeStr) + BusinessConstants.DAY_LAST_TIME; @@ -450,8 +455,9 @@ public class AccountService { Map currentAccountSumMap = new HashMap<>(); Map currentAccountSumByHeadMap = new HashMap<>(); Map currentAccountSumByDetailMap = new HashMap<>(); - long offset = (page.getCurrent() - 1) * page.getSize(); - long rows = page.getSize(); + PageDomain pageDomain = TableSupport.buildPageRequest(); + int offset = (pageDomain.getCurrentPage() - 1) * pageDomain.getPageSize(); + int rows = pageDomain.getPageSize(); List thisMonthAmountList = accountMapperEx.getAccountSumByParam(name, serialNo, bTime, eTime, forceFlag, offset, rows); List currentAmountList = accountMapperEx.getAccountSumByParam(name, serialNo, null, null, forceFlag, offset, rows); List thisMonthManyAmountList = accountMapperEx.getManyAccountSumByParam(bTime, eTime, forceFlag); @@ -466,8 +472,8 @@ public class AccountService { currentAccountSumByHeadMap.put(currentAmount.getId(), currentAmount.getAccountSumByHead()); currentAccountSumByDetailMap.put(currentAmount.getId(), currentAmount.getAccountSumByDetail()); } - if (null != iPage.getRecords()) { - for (AccountVo4List al : iPage.getRecords()) { + if (null != list) { + for (AccountVo4List al : list) { DecimalFormat df = new DecimalFormat(".##"); BigDecimal thisMonthAmount = thisMonthAccountSumMap.get(al.getId()) .add(thisMonthAccountSumByHeadMap.get(al.getId())) @@ -489,7 +495,7 @@ public class AccountService { } catch(Exception e){ JshException.readFail(logger, e); } - return iPage; + return list; } public Map getStatistics(String name, String serialNo) {