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

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

@ -2,14 +2,15 @@ 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.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.AccountService;
import com.jsh.erp.service.systemConfig.SystemConfigService;
import com.jsh.erp.utils.BaseResponseInfo;
import com.jsh.erp.utils.ErpInfo;
import com.jsh.erp.utils.StringUtil;
import com.jsh.erp.utils.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
@ -19,11 +20,13 @@ 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;
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
import static com.jsh.erp.utils.ResponseJsonUtil.returnStr;
/**
* @author jishenghua 75271*8920
@ -40,6 +43,94 @@ public class AccountController {
@Resource
private SystemConfigService systemConfigService;
@GetMapping(value = "/info")
@ApiOperation(value = "根据id获取信息")
public String getList(@RequestParam("id") Long id,
HttpServletRequest request) throws Exception {
Account account = accountService.getAccount(id);
Map<String, Object> objectMap = new HashMap<>();
if(account != null) {
objectMap.put("info", account);
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
} else {
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
}
}
@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<String, Object> objectMap = new HashMap<>();
if (pageSize != null && pageSize <= 0) {
pageSize = 10;
}
String name = StringUtil.getInfo(search, "name");
String serialNo = StringUtil.getInfo(search, "serialNo");
String remark = StringUtil.getInfo(search, "remark");
IPage<AccountVo4List> page = new Page<>();
page.setCurrent(currentPage);
page.setSize(pageSize);
IPage<AccountVo4List> 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<Object>());
return returnJson(objectMap, "查找不到数据", ErpInfo.OK.code);
}
}
@PostMapping(value = "/add")
@ApiOperation(value = "新增")
public String addResource(@RequestBody JSONObject obj, HttpServletRequest request)throws Exception {
Map<String, Object> objectMap = new HashMap<>();
int insert = accountService.insertAccount(obj, request);
return returnStr(objectMap, insert);
}
@PutMapping(value = "/update")
@ApiOperation(value = "修改")
public String updateResource(@RequestBody JSONObject obj, HttpServletRequest request)throws Exception {
Map<String, Object> objectMap = new HashMap<>();
int update = accountService.updateAccount(obj, request);
return returnStr(objectMap, update);
}
@DeleteMapping(value = "/delete")
@ApiOperation(value = "删除")
public String deleteResource(@RequestParam("id") Long id, HttpServletRequest request)throws Exception {
Map<String, Object> objectMap = new HashMap<>();
int delete = accountService.deleteAccount(id, request);
return returnStr(objectMap, delete);
}
@DeleteMapping(value = "/deleteBatch")
@ApiOperation(value = "批量删除")
public String batchDeleteResource(@RequestParam("ids") String ids, HttpServletRequest request)throws Exception {
Map<String, Object> objectMap = new HashMap<>();
int delete = accountService.batchDeleteAccount(ids, request);
return returnStr(objectMap, delete);
}
@GetMapping(value = "/checkIsNameExist")
@ApiOperation(value = "检查名称是否存在")
public String checkIsNameExist(@RequestParam Long id, @RequestParam(value ="name", required = false) String name,
HttpServletRequest request)throws Exception {
Map<String, Object> objectMap = new HashMap<>();
int exist = accountService.checkIsNameExist(id, name);
if(exist > 0) {
objectMap.put("status", true);
} else {
objectMap.put("status", false);
}
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
}
/**
* 查找结算账户信息-下拉框
* @param request
@ -184,10 +275,12 @@ public class AccountController {
BaseResponseInfo res = new BaseResponseInfo();
try {
Map<String, Object> map = new HashMap<>();
List<AccountVo4List> list = accountService.listWithBalance(StringUtil.toNull(name), StringUtil.toNull(serialNo), (currentPage-1)*pageSize, pageSize);
Long count = accountService.listWithBalanceCount(StringUtil.toNull(name), StringUtil.toNull(serialNo));
map.put("rows", list);
map.put("total", count);
IPage<AccountVo4List> page = new Page<>();
page.setCurrent(currentPage);
page.setSize(pageSize);
IPage<AccountVo4List> 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){

View File

@ -3,11 +3,12 @@ package com.jsh.erp.controller;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.service.CommonQueryManager;
import com.jsh.erp.utils.*;
import com.jsh.erp.utils.Constants;
import com.jsh.erp.utils.ErpInfo;
import com.jsh.erp.utils.ParamUtils;
import com.jsh.erp.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -18,6 +19,7 @@ import java.util.List;
import java.util.Map;
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
import static com.jsh.erp.utils.ResponseJsonUtil.returnStr;
/**
* by jishenghua 2018-9-12 23:58:10 管伊佳erp
@ -79,13 +81,7 @@ public class ResourceController {
@RequestBody JSONObject obj, HttpServletRequest request)throws Exception {
Map<String, Object> objectMap = new HashMap<String, Object>();
int insert = configResourceManager.insert(apiName, obj, request);
if(insert > 0) {
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
} else if(insert == -1) {
return returnJson(objectMap, ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code);
} else {
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
}
return returnStr(objectMap, insert);
}
@PutMapping(value = "/{apiName}/update", produces = {"application/javascript", "application/json"})
@ -94,13 +90,7 @@ public class ResourceController {
@RequestBody JSONObject obj, HttpServletRequest request)throws Exception {
Map<String, Object> objectMap = new HashMap<String, Object>();
int update = configResourceManager.update(apiName, obj, request);
if(update > 0) {
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
} else if(update == -1) {
return returnJson(objectMap, ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code);
} else {
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
}
return returnStr(objectMap, update);
}
@DeleteMapping(value = "/{apiName}/delete", produces = {"application/javascript", "application/json"})
@ -109,13 +99,7 @@ public class ResourceController {
@RequestParam("id") Long id, HttpServletRequest request)throws Exception {
Map<String, Object> objectMap = new HashMap<String, Object>();
int delete = configResourceManager.delete(apiName, id, request);
if(delete > 0) {
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
} else if(delete == -1) {
return returnJson(objectMap, ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code);
} else {
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
}
return returnStr(objectMap, delete);
}
@DeleteMapping(value = "/{apiName}/deleteBatch", produces = {"application/javascript", "application/json"})
@ -124,13 +108,7 @@ public class ResourceController {
@RequestParam("ids") String ids, HttpServletRequest request)throws Exception {
Map<String, Object> objectMap = new HashMap<String, Object>();
int delete = configResourceManager.deleteBatch(apiName, ids, request);
if(delete > 0) {
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
} else if(delete == -1) {
return returnJson(objectMap, ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code);
} else {
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
}
return returnStr(objectMap, delete);
}
@GetMapping(value = "/{apiName}/checkIsNameExist")

View File

@ -7,7 +7,6 @@ import com.jsh.erp.service.depotHead.DepotHeadService;
import com.jsh.erp.service.depotItem.DepotItemService;
import com.jsh.erp.service.serialNumber.SerialNumberService;
import com.jsh.erp.utils.BaseResponseInfo;
import com.jsh.erp.utils.ErpInfo;
import com.jsh.erp.utils.Tools;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -21,7 +20,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
import static com.jsh.erp.utils.ResponseJsonUtil.returnStr;
/**
* Description
@ -62,13 +61,7 @@ public class SerialNumberController {
Integer batAddTotal = jsonObject.getInteger("batAddTotal");
String remark = jsonObject.getString("remark");
int insert = serialNumberService.batAddSerialNumber(materialCode,serialNumberPrefix,batAddTotal,remark);
if(insert > 0) {
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
} else if(insert == -1) {
return returnJson(objectMap, ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code);
} else {
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
}
return returnStr(objectMap, insert);
}
/**

View File

@ -1,23 +1,27 @@
package com.jsh.erp.controller;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.service.tenant.TenantService;
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.datasource.entities.Tenant;
import com.jsh.erp.datasource.entities.TenantEx;
import com.jsh.erp.service.TenantService;
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;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
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.Map;
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
import static com.jsh.erp.utils.ResponseJsonUtil.returnStr;
/**
* @author ji_sheng_hua 管伊佳erp
@ -26,11 +30,99 @@ import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
@RequestMapping(value = "/tenant")
@Api(tags = {"租户管理"})
public class TenantController {
private Logger logger = LoggerFactory.getLogger(TenantController.class);
@Resource
private TenantService tenantService;
@GetMapping(value = "/info")
@ApiOperation(value = "根据id获取信息")
public String getList(@RequestParam("id") Long id,
HttpServletRequest request) throws Exception {
Tenant tenant = tenantService.getTenant(id);
Map<String, Object> objectMap = new HashMap<>();
if(tenant != null) {
objectMap.put("info", tenant);
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
} else {
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
}
}
@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<String, Object> objectMap = new HashMap<>();
if (pageSize != null && pageSize <= 0) {
pageSize = 10;
}
String loginName = StringUtil.getInfo(search, "loginName");
String type = StringUtil.getInfo(search, "type");
String enabled = StringUtil.getInfo(search, "enabled");
String remark = StringUtil.getInfo(search, "remark");
IPage<TenantEx> page = new Page<>();
page.setCurrent(currentPage);
page.setSize(pageSize);
IPage<TenantEx> list = tenantService.select(page, loginName, type, enabled, remark);
if (list != null) {
objectMap.put("rows", list.getRecords());
objectMap.put("total", list.getTotal());
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
} else {
objectMap.put("rows", new ArrayList<Object>());
objectMap.put("total", BusinessConstants.DEFAULT_LIST_NULL_NUMBER);
return returnJson(objectMap, "查找不到数据", ErpInfo.OK.code);
}
}
@PostMapping(value = "/add")
@ApiOperation(value = "新增")
public String addResource(@RequestBody JSONObject obj, HttpServletRequest request)throws Exception {
Map<String, Object> objectMap = new HashMap<>();
int insert = tenantService.insertTenant(obj, request);
return returnStr(objectMap, insert);
}
@PutMapping(value = "/update")
@ApiOperation(value = "修改")
public String updateResource(@RequestBody JSONObject obj, HttpServletRequest request)throws Exception {
Map<String, Object> objectMap = new HashMap<>();
int update = tenantService.updateTenant(obj, request);
return returnStr(objectMap, update);
}
@DeleteMapping(value = "/delete")
@ApiOperation(value = "删除")
public String deleteResource(@RequestParam("id") Long id, HttpServletRequest request)throws Exception {
Map<String, Object> objectMap = new HashMap<>();
int delete = tenantService.deleteTenant(id, request);
return returnStr(objectMap, delete);
}
@DeleteMapping(value = "/deleteBatch")
@ApiOperation(value = "批量删除")
public String batchDeleteResource(@RequestParam("ids") String ids, HttpServletRequest request)throws Exception {
Map<String, Object> objectMap = new HashMap<>();
int delete = tenantService.batchDeleteTenant(ids, request);
return returnStr(objectMap, delete);
}
@GetMapping(value = "/checkIsNameExist")
@ApiOperation(value = "检查名称是否存在")
public String checkIsNameExist(@RequestParam Long id, @RequestParam(value ="name", required = false) String name,
HttpServletRequest request)throws Exception {
Map<String, Object> objectMap = new HashMap<>();
int exist = tenantService.checkIsNameExist(id, name);
if(exist > 0) {
objectMap.put("status", true);
} else {
objectMap.put("status", false);
}
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
}
/**
* 批量设置状态-启用或者禁用
* @param jsonObject

View File

@ -13,7 +13,7 @@ import com.jsh.erp.exception.BusinessParamCheckingException;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.redis.RedisService;
import com.jsh.erp.service.role.RoleService;
import com.jsh.erp.service.tenant.TenantService;
import com.jsh.erp.service.TenantService;
import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.BaseResponseInfo;
import com.jsh.erp.utils.ErpInfo;

View File

@ -1,5 +1,6 @@
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;
@ -17,14 +18,8 @@ public interface AccountMapperEx {
@Param("name") String name,
@Param("serialNo") String serialNo);
List<AccountVo4List> selectByConditionAccount(
@Param("name") String name,
@Param("serialNo") String serialNo,
@Param("remark") String remark,
@Param("offset") Integer offset,
@Param("rows") Integer rows);
Long countsByAccount(
IPage<AccountVo4List> selectByConditionAccount(
IPage<AccountVo4List> page,
@Param("name") String name,
@Param("serialNo") String serialNo,
@Param("remark") String remark);
@ -59,8 +54,8 @@ public interface AccountMapperEx {
@Param("beginTime") String beginTime,
@Param("endTime") String endTime,
@Param("forceFlag") Boolean forceFlag,
@Param("offset") Integer offset,
@Param("rows") Integer rows);
@Param("offset") Long offset,
@Param("rows") Long rows);
List<DepotHead> getManyAccountSumByParam(
@Param("beginTime") String beginTime,

View File

@ -1,6 +1,6 @@
package com.jsh.erp.datasource.mappers;
import com.jsh.erp.datasource.entities.Tenant;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jsh.erp.datasource.entities.TenantEx;
import org.apache.ibatis.annotations.Param;
@ -8,15 +8,8 @@ import java.util.List;
public interface TenantMapperEx {
List<TenantEx> selectByConditionTenant(
@Param("loginName") String loginName,
@Param("type") String type,
@Param("enabled") String enabled,
@Param("remark") String remark,
@Param("offset") Integer offset,
@Param("rows") Integer rows);
Long countsByTenant(
IPage<TenantEx> selectByConditionTenant(
IPage<TenantEx> page,
@Param("loginName") String loginName,
@Param("type") String type,
@Param("enabled") String enabled,

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;

View File

@ -33,35 +33,6 @@ public class ResponseJsonUtil {
}
}
/**
*
* @param responseCode
* @return
*/
public static String backJson4HttpApi(ResponseCode responseCode) {
if (responseCode != null) {
String result = JSON.toJSONString(responseCode, new ResponseFilter(),
SerializerFeature.DisableCircularReferenceDetect,
SerializerFeature.WriteNonStringKeyAsString);
result = result.replaceFirst("\"data\":\\{", "");
return result.substring(0, result.length() - 1);
}
return null;
}
/**
* 验证失败的json串
* @param code
* @return
*/
public static String backJson4VerifyFailure(int code) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("message", "未通过验证");
return JSON.toJSONString(new ResponseCode(code, map), new ResponseFilter(),
SerializerFeature.DisableCircularReferenceDetect,
SerializerFeature.WriteNonStringKeyAsString);
}
/**
* 成功的json串
* @param responseCode
@ -80,4 +51,14 @@ public class ResponseJsonUtil {
map.put("message", message);
return backJson(new ResponseCode(code, map));
}
public static String returnStr(Map<String, Object> objectMap, int res) {
if(res > 0) {
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
} else if(res == -1) {
return returnJson(objectMap, ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code);
} else {
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
}
}
}

View File

@ -28,6 +28,9 @@ public class StringUtil {
"| grant | grant|grant | execute | execute|execute | exec | exec|exec | xp_cmdshell | xp_cmdshell|xp_cmdshell " +
"| call | call|call | declare | declare|declare | source | source|source | sql | sql|sql ";
/** 下划线 */
private static final char SEPARATOR = '_';
public static String filterNull(String str) {
if (str == null) {
return "";

View File

@ -49,29 +49,6 @@
</if>
and ifnull(delete_flag,'0') !='1'
order by sort asc, id desc
<if test="offset != null and rows != null">
limit #{offset},#{rows}
</if>
</select>
<select id="countsByAccount" resultType="java.lang.Long">
SELECT
COUNT(id)
FROM jsh_account
WHERE 1=1
<if test="name != null">
<bind name="bindName" value="'%'+name+'%'"/>
and name like #{bindName}
</if>
<if test="serialNo != null and serialNo !=''">
<bind name="bindSerialNo" value="'%'+serialNo+'%'"/>
and serial_no like #{bindSerialNo}
</if>
<if test="remark != null">
<bind name="bindRemark" value="'%'+remark+'%'"/>
and remark like #{bindRemark}
</if>
and ifnull(delete_flag,'0') !='1'
</select>
<select id="getAccountSum" resultType="java.math.BigDecimal">

View File

@ -35,30 +35,6 @@
</if>
and ifnull(t.delete_flag,'0') !='1'
order by t.id desc
<if test="offset != null and rows != null">
limit #{offset},#{rows}
</if>
</select>
<select id="countsByTenant" resultType="java.lang.Long">
select
count(t.id)
from jsh_tenant t
where 1=1
<if test="loginName != null">
<bind name="bindLoginName" value="'%'+loginName+'%'"/>
and t.login_name like #{bindLoginName}
</if>
<if test="type != null and type != ''">
and t.type = #{type}
</if>
<if test="enabled != null and enabled != ''">
and t.enabled = #{enabled}
</if>
<if test="remark != null">
<bind name="bindRemark" value="'%'+remark+'%'"/>
and t.remark like #{bindRemark}
</if>
and ifnull(t.delete_flag,'0') !='1'
</select>
</mapper>