优化账户和租户两个模块的接口

This commit is contained in:
jishenghua
2025-02-21 01:28:44 +08:00
parent 20b100b5e2
commit 53004b1fa5
19 changed files with 263 additions and 392 deletions

View File

@@ -1,6 +1,7 @@
package com.jsh.erp.service.account;
package com.jsh.erp.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.*;
@@ -98,10 +99,10 @@ public class AccountService {
return list;
}
public List<AccountVo4List> select(String name, String serialNo, String remark, int offset, int rows) throws Exception{
List<AccountVo4List> resList = new ArrayList<>();
public IPage<AccountVo4List> select(IPage<AccountVo4List> page, String name, String serialNo, String remark) throws Exception{
IPage<AccountVo4List> iPage = null;
try{
List<AccountVo4List> list = accountMapperEx.selectByConditionAccount(name, serialNo, remark, offset, rows);
iPage = accountMapperEx.selectByConditionAccount(page, 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;
@@ -112,6 +113,8 @@ public class AccountService {
Map<Long, BigDecimal> currentAccountSumMap = new HashMap<>();
Map<Long, BigDecimal> currentAccountSumByHeadMap = new HashMap<>();
Map<Long, BigDecimal> currentAccountSumByDetailMap = new HashMap<>();
long offset = (page.getCurrent() - 1) * page.getSize();
long rows = page.getSize();
List<AccountVo4Sum> thisMonthAmountList = accountMapperEx.getAccountSumByParam(name, serialNo, bTime, eTime, forceFlag, offset, rows);
List<AccountVo4Sum> currentAmountList = accountMapperEx.getAccountSumByParam(name, serialNo, null, null, forceFlag, offset, rows);
List<DepotHead> thisMonthManyAmountList = accountMapperEx.getManyAccountSumByParam(bTime, eTime, forceFlag);
@@ -126,8 +129,8 @@ public class AccountService {
currentAccountSumByHeadMap.put(currentAmount.getId(), currentAmount.getAccountSumByHead());
currentAccountSumByDetailMap.put(currentAmount.getId(), currentAmount.getAccountSumByDetail());
}
if (null != list) {
for (AccountVo4List al : list) {
if (null != iPage.getRecords()) {
for (AccountVo4List al : iPage.getRecords()) {
DecimalFormat df = new DecimalFormat(".##");
BigDecimal thisMonthAmount = thisMonthAccountSumMap.get(al.getId())
.add(thisMonthAccountSumByHeadMap.get(al.getId()))
@@ -144,23 +147,12 @@ public class AccountService {
.add(getManyAccountSumParse(al.getId(), currentManyAmountList))
.add(al.getInitialAmount()) ;
al.setCurrentAmount(currentAmount);
resList.add(al);
}
}
} catch(Exception e){
JshException.readFail(logger, e);
}
return resList;
}
public Long countAccount(String name, String serialNo, String remark)throws Exception {
Long result = null;
try{
result = accountMapperEx.countsByAccount(name, serialNo, remark);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
return iPage;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
@@ -444,10 +436,10 @@ public class AccountService {
return sb.toString();
}
public List<AccountVo4List> listWithBalance(String name, String serialNo, Integer offset, Integer rows) throws Exception {
List<AccountVo4List> resList = new ArrayList<>();
public IPage<AccountVo4List> listWithBalance(IPage<AccountVo4List> page, String name, String serialNo) throws Exception {
IPage<AccountVo4List> iPage = null;
try{
List<AccountVo4List> list = accountMapperEx.selectByConditionAccount(name, serialNo, null, offset, rows);
iPage = accountMapperEx.selectByConditionAccount(page, 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;
@@ -458,6 +450,8 @@ public class AccountService {
Map<Long, BigDecimal> currentAccountSumMap = new HashMap<>();
Map<Long, BigDecimal> currentAccountSumByHeadMap = new HashMap<>();
Map<Long, BigDecimal> currentAccountSumByDetailMap = new HashMap<>();
long offset = (page.getCurrent() - 1) * page.getSize();
long rows = page.getSize();
List<AccountVo4Sum> thisMonthAmountList = accountMapperEx.getAccountSumByParam(name, serialNo, bTime, eTime, forceFlag, offset, rows);
List<AccountVo4Sum> currentAmountList = accountMapperEx.getAccountSumByParam(name, serialNo, null, null, forceFlag, offset, rows);
List<DepotHead> thisMonthManyAmountList = accountMapperEx.getManyAccountSumByParam(bTime, eTime, forceFlag);
@@ -472,8 +466,8 @@ public class AccountService {
currentAccountSumByHeadMap.put(currentAmount.getId(), currentAmount.getAccountSumByHead());
currentAccountSumByDetailMap.put(currentAmount.getId(), currentAmount.getAccountSumByDetail());
}
if (null != list) {
for (AccountVo4List al : list) {
if (null != iPage.getRecords()) {
for (AccountVo4List al : iPage.getRecords()) {
DecimalFormat df = new DecimalFormat(".##");
BigDecimal thisMonthAmount = thisMonthAccountSumMap.get(al.getId())
.add(thisMonthAccountSumByHeadMap.get(al.getId()))
@@ -490,23 +484,12 @@ public class AccountService {
.add(getManyAccountSumParse(al.getId(), currentManyAmountList))
.add(al.getInitialAmount());
al.setCurrentAmount(currentAmount);
resList.add(al);
}
}
} catch(Exception e){
JshException.readFail(logger, e);
}
return resList;
}
public Long listWithBalanceCount(String name, String serialNo) {
Long result = null;
try{
result = accountMapperEx.countsByAccount(name, serialNo, null);
} catch(Exception e){
JshException.readFail(logger, e);
}
return result;
return iPage;
}
public Map<String, Object> getStatistics(String name, String serialNo) {

View File

@@ -1,6 +1,7 @@
package com.jsh.erp.service.tenant;
package com.jsh.erp.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.datasource.entities.Tenant;
import com.jsh.erp.datasource.entities.TenantEx;
@@ -10,6 +11,7 @@ import com.jsh.erp.datasource.mappers.TenantMapper;
import com.jsh.erp.datasource.mappers.TenantMapperEx;
import com.jsh.erp.datasource.mappers.UserBusinessMapperEx;
import com.jsh.erp.datasource.mappers.UserMapperEx;
import com.jsh.erp.datasource.vo.AccountVo4List;
import com.jsh.erp.exception.JshException;
import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.user.UserService;
@@ -75,13 +77,13 @@ public class TenantService {
return list;
}
public List<TenantEx> select(String loginName, String type, String enabled, String remark, int offset, int rows)throws Exception {
List<TenantEx> list= new ArrayList<>();
public IPage<TenantEx> select(IPage<TenantEx> page, String loginName, String type, String enabled, String remark)throws Exception {
IPage<TenantEx> iPage = null;
try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
list = tenantMapperEx.selectByConditionTenant(loginName, type, enabled, remark, offset, rows);
if (null != list) {
for (TenantEx tenantEx : list) {
iPage = tenantMapperEx.selectByConditionTenant(page, loginName, type, enabled, remark);
if (null != iPage.getRecords()) {
for (TenantEx tenantEx : iPage.getRecords()) {
tenantEx.setCreateTimeStr(Tools.getCenternTime(tenantEx.getCreateTime()));
tenantEx.setExpireTimeStr(Tools.getCenternTime(tenantEx.getExpireTime()));
}
@@ -90,19 +92,7 @@ public class TenantService {
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public Long countTenant(String loginName, String type, String enabled, String remark)throws Exception {
Long result=null;
try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
result = tenantMapperEx.countsByTenant(loginName, type, enabled, remark);
}
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
return iPage;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)

View File

@@ -1,75 +0,0 @@
package com.jsh.erp.service.account;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.service.ICommonQuery;
import com.jsh.erp.utils.Constants;
import com.jsh.erp.utils.QueryUtils;
import com.jsh.erp.utils.StringUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@Service(value = "account_component")
@AccountResource
public class AccountComponent implements ICommonQuery {
@Resource
private AccountService accountService;
@Override
public Object selectOne(Long id) throws Exception {
return accountService.getAccount(id);
}
@Override
public List<?> select(Map<String, String> map)throws Exception {
return getAccountList(map);
}
private List<?> getAccountList(Map<String, String> map) throws Exception{
String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name");
String serialNo = StringUtil.getInfo(search, "serialNo");
String remark = StringUtil.getInfo(search, "remark");
String order = QueryUtils.order(map);
return accountService.select(name, serialNo, remark, QueryUtils.offset(map), QueryUtils.rows(map));
}
@Override
public Long counts(Map<String, String> map) throws Exception{
String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name");
String serialNo = StringUtil.getInfo(search, "serialNo");
String remark = StringUtil.getInfo(search, "remark");
return accountService.countAccount(name, serialNo, remark);
}
@Override
public int insert(JSONObject obj, HttpServletRequest request) throws Exception{
return accountService.insertAccount(obj, request);
}
@Override
public int update(JSONObject obj, HttpServletRequest request)throws Exception {
return accountService.updateAccount(obj, request);
}
@Override
public int delete(Long id, HttpServletRequest request)throws Exception {
return accountService.deleteAccount(id, request);
}
@Override
public int deleteBatch(String ids, HttpServletRequest request)throws Exception {
return accountService.batchDeleteAccount(ids, request);
}
@Override
public int checkIsNameExist(Long id, String name)throws Exception {
return accountService.checkIsNameExist(id, name);
}
}

View File

@@ -1,15 +0,0 @@
package com.jsh.erp.service.account;
import com.jsh.erp.service.ResourceInfo;
import java.lang.annotation.*;
/**
* @author jishenghua qq752718920 2018-10-7 15:26:27
*/
@ResourceInfo(value = "account")
@Inherited
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface AccountResource {
}

View File

@@ -11,7 +11,7 @@ import com.jsh.erp.datasource.mappers.DepotItemMapperEx;
import com.jsh.erp.datasource.vo.*;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.exception.JshException;
import com.jsh.erp.service.account.AccountService;
import com.jsh.erp.service.AccountService;
import com.jsh.erp.service.accountHead.AccountHeadService;
import com.jsh.erp.service.accountItem.AccountItemService;
import com.jsh.erp.service.depot.DepotService;

View File

@@ -1,78 +0,0 @@
package com.jsh.erp.service.tenant;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.service.ICommonQuery;
import com.jsh.erp.service.user.UserResource;
import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.Constants;
import com.jsh.erp.utils.QueryUtils;
import com.jsh.erp.utils.StringUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@Service(value = "tenant_component")
@TenantResource
public class TenantComponent implements ICommonQuery {
@Resource
private TenantService tenantService;
@Override
public Object selectOne(Long id) throws Exception {
return tenantService.getTenant(id);
}
@Override
public List<?> select(Map<String, String> map)throws Exception {
return getTenantList(map);
}
private List<?> getTenantList(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH);
String loginName = StringUtil.getInfo(search, "loginName");
String type = StringUtil.getInfo(search, "type");
String enabled = StringUtil.getInfo(search, "enabled");
String remark = StringUtil.getInfo(search, "remark");
return tenantService.select(loginName, type, enabled, remark, QueryUtils.offset(map), QueryUtils.rows(map));
}
@Override
public Long counts(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH);
String loginName = StringUtil.getInfo(search, "loginName");
String type = StringUtil.getInfo(search, "type");
String enabled = StringUtil.getInfo(search, "enabled");
String remark = StringUtil.getInfo(search, "remark");
return tenantService.countTenant(loginName, type, enabled, remark);
}
@Override
public int insert(JSONObject obj, HttpServletRequest request)throws Exception {
return tenantService.insertTenant(obj, request);
}
@Override
public int update(JSONObject obj, HttpServletRequest request)throws Exception {
return tenantService.updateTenant(obj, request);
}
@Override
public int delete(Long id, HttpServletRequest request)throws Exception {
return tenantService.deleteTenant(id, request);
}
@Override
public int deleteBatch(String ids, HttpServletRequest request)throws Exception {
return tenantService.batchDeleteTenant(ids, request);
}
@Override
public int checkIsNameExist(Long id, String name)throws Exception {
return tenantService.checkIsNameExist(id, name);
}
}

View File

@@ -1,15 +0,0 @@
package com.jsh.erp.service.tenant;
import com.jsh.erp.service.ResourceInfo;
import java.lang.annotation.*;
/**
* @author jishenghua qq752718920 2019-6-27 22:56:56
*/
@ResourceInfo(value = "tenant")
@Inherited
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface TenantResource {
}

View File

@@ -20,7 +20,7 @@ import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.exception.JshException;
import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.orgaUserRel.OrgaUserRelService;
import com.jsh.erp.service.tenant.TenantService;
import com.jsh.erp.service.TenantService;
import com.jsh.erp.service.userBusiness.UserBusinessService;
import com.jsh.erp.utils.ExceptionCodeConstants;
import com.jsh.erp.utils.StringUtil;