Commit 42835c94 authored by 乾坤平台's avatar 乾坤平台 Committed by 季圣华
Browse files

!50 异常封装

Merge pull request !50 from 乾坤平台/master
parents 7ce3af46 8a831229
...@@ -35,6 +35,14 @@ public class GlobalExceptionHandler { ...@@ -35,6 +35,14 @@ public class GlobalExceptionHandler {
status.put(ExceptionConstants.GLOBAL_RETURNS_CODE, ExceptionConstants.SERVICE_SYSTEM_ERROR_CODE); status.put(ExceptionConstants.GLOBAL_RETURNS_CODE, ExceptionConstants.SERVICE_SYSTEM_ERROR_CODE);
status.put(ExceptionConstants.GLOBAL_RETURNS_MESSAGE, ExceptionConstants.SERVICE_SYSTEM_ERROR_MSG); status.put(ExceptionConstants.GLOBAL_RETURNS_MESSAGE, ExceptionConstants.SERVICE_SYSTEM_ERROR_MSG);
log.error("Global Exception Occured => url : {}, msg : {}", request.getRequestURL(), e.getMessage()); log.error("Global Exception Occured => url : {}, msg : {}", request.getRequestURL(), e.getMessage());
/**
* create by: qiankunpingtai
* create time: 2019/4/18 17:41
* website:https://qiankunpingtai.cn
* description:
* 这里输出完整的堆栈信息,否则有些异常完全不知道哪里出错了。
*/
log.error("Global Exception Occured => url : {}", request.getRequestURL(), e);
e.printStackTrace(); e.printStackTrace();
return status; return status;
} }
......
package com.jsh.erp.service; package com.jsh.erp.service;
import com.jsh.erp.constants.BusinessConstants; import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.datasource.entities.Log;
import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.mappers.LogMapper;
import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.log.LogService;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -12,12 +9,9 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -12,12 +9,9 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static com.jsh.erp.utils.Tools.getLocalIp;
/** /**
* @author jishenghua 752718920 2018-10-7 15:25:58 * @author jishenghua 752718920 2018-10-7 15:25:58
*/ */
...@@ -36,7 +30,7 @@ public class CommonQueryManager { ...@@ -36,7 +30,7 @@ public class CommonQueryManager {
* @param apiName 接口名称 * @param apiName 接口名称
* @param id ID * @param id ID
*/ */
public Object selectOne(String apiName, String id) { public Object selectOne(String apiName, String id) throws Exception{
if (StringUtil.isNotEmpty(apiName) && StringUtil.isNotEmpty(id)) { if (StringUtil.isNotEmpty(apiName) && StringUtil.isNotEmpty(id)) {
return container.getCommonQuery(apiName).selectOne(id); return container.getCommonQuery(apiName).selectOne(id);
} }
...@@ -49,7 +43,7 @@ public class CommonQueryManager { ...@@ -49,7 +43,7 @@ public class CommonQueryManager {
* @param parameterMap * @param parameterMap
* @return * @return
*/ */
public List<?> select(String apiName, Map<String, String> parameterMap) { public List<?> select(String apiName, Map<String, String> parameterMap)throws Exception {
if (StringUtil.isNotEmpty(apiName)) { if (StringUtil.isNotEmpty(apiName)) {
return container.getCommonQuery(apiName).select(parameterMap); return container.getCommonQuery(apiName).select(parameterMap);
} }
...@@ -62,7 +56,7 @@ public class CommonQueryManager { ...@@ -62,7 +56,7 @@ public class CommonQueryManager {
* @param parameterMap * @param parameterMap
* @return * @return
*/ */
public Long counts(String apiName, Map<String, String> parameterMap) { public Long counts(String apiName, Map<String, String> parameterMap)throws Exception {
if (StringUtil.isNotEmpty(apiName)) { if (StringUtil.isNotEmpty(apiName)) {
return container.getCommonQuery(apiName).counts(parameterMap); return container.getCommonQuery(apiName).counts(parameterMap);
} }
...@@ -76,7 +70,7 @@ public class CommonQueryManager { ...@@ -76,7 +70,7 @@ public class CommonQueryManager {
* @return * @return
*/ */
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insert(String apiName, String beanJson, HttpServletRequest request) { public int insert(String apiName, String beanJson, HttpServletRequest request) throws Exception{
if (StringUtil.isNotEmpty(apiName)) { if (StringUtil.isNotEmpty(apiName)) {
logService.insertLog(apiName, BusinessConstants.LOG_OPERATION_TYPE_ADD, request); logService.insertLog(apiName, BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
return container.getCommonQuery(apiName).insert(beanJson, request); return container.getCommonQuery(apiName).insert(beanJson, request);
...@@ -92,7 +86,7 @@ public class CommonQueryManager { ...@@ -92,7 +86,7 @@ public class CommonQueryManager {
* @return * @return
*/ */
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int update(String apiName, String beanJson, Long id, HttpServletRequest request) { public int update(String apiName, String beanJson, Long id, HttpServletRequest request)throws Exception {
if (StringUtil.isNotEmpty(apiName)) { if (StringUtil.isNotEmpty(apiName)) {
logService.insertLog(apiName, logService.insertLog(apiName,
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request); new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
...@@ -108,7 +102,7 @@ public class CommonQueryManager { ...@@ -108,7 +102,7 @@ public class CommonQueryManager {
* @return * @return
*/ */
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int delete(String apiName, Long id, HttpServletRequest request) { public int delete(String apiName, Long id, HttpServletRequest request)throws Exception {
if (StringUtil.isNotEmpty(apiName)) { if (StringUtil.isNotEmpty(apiName)) {
logService.insertLog(apiName, logService.insertLog(apiName,
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(id).toString(), request); new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(id).toString(), request);
...@@ -124,7 +118,7 @@ public class CommonQueryManager { ...@@ -124,7 +118,7 @@ public class CommonQueryManager {
* @return * @return
*/ */
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDelete(String apiName, String ids, HttpServletRequest request) { public int batchDelete(String apiName, String ids, HttpServletRequest request)throws Exception {
if (StringUtil.isNotEmpty(apiName)) { if (StringUtil.isNotEmpty(apiName)) {
logService.insertLog(apiName, "批量删除,id集:" + ids, request); logService.insertLog(apiName, "批量删除,id集:" + ids, request);
return container.getCommonQuery(apiName).batchDelete(ids); return container.getCommonQuery(apiName).batchDelete(ids);
...@@ -139,7 +133,7 @@ public class CommonQueryManager { ...@@ -139,7 +133,7 @@ public class CommonQueryManager {
* @param name * @param name
* @return * @return
*/ */
public int checkIsNameExist(String apiName, Long id, String name) { public int checkIsNameExist(String apiName, Long id, String name) throws Exception{
if (StringUtil.isNotEmpty(apiName)) { if (StringUtil.isNotEmpty(apiName)) {
return container.getCommonQuery(apiName).checkIsNameExist(id, name); return container.getCommonQuery(apiName).checkIsNameExist(id, name);
} }
......
...@@ -18,7 +18,7 @@ public interface ICommonQuery { ...@@ -18,7 +18,7 @@ public interface ICommonQuery {
* @param condition 资源id * @param condition 资源id
* @return 资源 * @return 资源
*/ */
Object selectOne(String condition); Object selectOne(String condition) throws Exception;
/** /**
* 自定义查询 * 自定义查询
...@@ -26,7 +26,7 @@ public interface ICommonQuery { ...@@ -26,7 +26,7 @@ public interface ICommonQuery {
* @param parameterMap 查询参数 * @param parameterMap 查询参数
* @return 查询结果 * @return 查询结果
*/ */
List<?> select(Map<String, String> parameterMap); List<?> select(Map<String, String> parameterMap) throws Exception;
/** /**
* 查询数量 * 查询数量
...@@ -34,7 +34,7 @@ public interface ICommonQuery { ...@@ -34,7 +34,7 @@ public interface ICommonQuery {
* @param parameterMap 查询参数 * @param parameterMap 查询参数
* @return 查询结果 * @return 查询结果
*/ */
Long counts(Map<String, String> parameterMap); Long counts(Map<String, String> parameterMap) throws Exception;
/** /**
* 新增数据 * 新增数据
...@@ -42,7 +42,7 @@ public interface ICommonQuery { ...@@ -42,7 +42,7 @@ public interface ICommonQuery {
* @param beanJson * @param beanJson
* @return * @return
*/ */
int insert(String beanJson, HttpServletRequest request); int insert(String beanJson, HttpServletRequest request) throws Exception;
/** /**
* 更新数据 * 更新数据
...@@ -50,7 +50,7 @@ public interface ICommonQuery { ...@@ -50,7 +50,7 @@ public interface ICommonQuery {
* @param beanJson * @param beanJson
* @return * @return
*/ */
int update(String beanJson, Long id); int update(String beanJson, Long id) throws Exception;
/** /**
* 删除数据 * 删除数据
...@@ -58,7 +58,7 @@ public interface ICommonQuery { ...@@ -58,7 +58,7 @@ public interface ICommonQuery {
* @param id * @param id
* @return * @return
*/ */
int delete(Long id); int delete(Long id) throws Exception;
/** /**
* 批量删除数据 * 批量删除数据
...@@ -66,7 +66,7 @@ public interface ICommonQuery { ...@@ -66,7 +66,7 @@ public interface ICommonQuery {
* @param ids * @param ids
* @return * @return
*/ */
int batchDelete(String ids); int batchDelete(String ids) throws Exception;
/** /**
* 查询名称是否存在 * 查询名称是否存在
...@@ -74,5 +74,5 @@ public interface ICommonQuery { ...@@ -74,5 +74,5 @@ public interface ICommonQuery {
* @param id * @param id
* @return * @return
*/ */
int checkIsNameExist(Long id, String name); int checkIsNameExist(Long id, String name) throws Exception;
} }
\ No newline at end of file
package com.jsh.erp.service.account; package com.jsh.erp.service.account;
import com.jsh.erp.service.ICommonQuery; import com.jsh.erp.service.ICommonQuery;
import com.jsh.erp.service.depot.DepotResource;
import com.jsh.erp.service.depot.DepotService;
import com.jsh.erp.utils.Constants; import com.jsh.erp.utils.Constants;
import com.jsh.erp.utils.QueryUtils; import com.jsh.erp.utils.QueryUtils;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
...@@ -26,11 +24,11 @@ public class AccountComponent implements ICommonQuery { ...@@ -26,11 +24,11 @@ public class AccountComponent implements ICommonQuery {
} }
@Override @Override
public List<?> select(Map<String, String> map) { public List<?> select(Map<String, String> map)throws Exception {
return getAccountList(map); return getAccountList(map);
} }
private List<?> getAccountList(Map<String, String> map) { private List<?> getAccountList(Map<String, String> map) throws Exception{
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name"); String name = StringUtil.getInfo(search, "name");
String serialNo = StringUtil.getInfo(search, "serialNo"); String serialNo = StringUtil.getInfo(search, "serialNo");
...@@ -40,7 +38,7 @@ public class AccountComponent implements ICommonQuery { ...@@ -40,7 +38,7 @@ public class AccountComponent implements ICommonQuery {
} }
@Override @Override
public Long counts(Map<String, String> map) { public Long counts(Map<String, String> map) throws Exception{
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name"); String name = StringUtil.getInfo(search, "name");
String serialNo = StringUtil.getInfo(search, "serialNo"); String serialNo = StringUtil.getInfo(search, "serialNo");
...@@ -49,27 +47,27 @@ public class AccountComponent implements ICommonQuery { ...@@ -49,27 +47,27 @@ public class AccountComponent implements ICommonQuery {
} }
@Override @Override
public int insert(String beanJson, HttpServletRequest request) { public int insert(String beanJson, HttpServletRequest request) throws Exception{
return accountService.insertAccount(beanJson, request); return accountService.insertAccount(beanJson, request);
} }
@Override @Override
public int update(String beanJson, Long id) { public int update(String beanJson, Long id)throws Exception {
return accountService.updateAccount(beanJson, id); return accountService.updateAccount(beanJson, id);
} }
@Override @Override
public int delete(Long id) { public int delete(Long id)throws Exception {
return accountService.deleteAccount(id); return accountService.deleteAccount(id);
} }
@Override @Override
public int batchDelete(String ids) { public int batchDelete(String ids)throws Exception {
return accountService.batchDeleteAccount(ids); return accountService.batchDeleteAccount(ids);
} }
@Override @Override
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
return accountService.checkIsNameExist(id, name); return accountService.checkIsNameExist(id, name);
} }
......
...@@ -19,16 +19,16 @@ public class AccountHeadComponent implements ICommonQuery { ...@@ -19,16 +19,16 @@ public class AccountHeadComponent implements ICommonQuery {
private AccountHeadService accountHeadService; private AccountHeadService accountHeadService;
@Override @Override
public Object selectOne(String condition) { public Object selectOne(String condition) throws Exception {
return null; return null;
} }
@Override @Override
public List<?> select(Map<String, String> map) { public List<?> select(Map<String, String> map)throws Exception {
return getAccountHeadList(map); return getAccountHeadList(map);
} }
private List<?> getAccountHeadList(Map<String, String> map) { private List<?> getAccountHeadList(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String type = StringUtil.getInfo(search, "type"); String type = StringUtil.getInfo(search, "type");
String billNo = StringUtil.getInfo(search, "billNo"); String billNo = StringUtil.getInfo(search, "billNo");
...@@ -39,7 +39,7 @@ public class AccountHeadComponent implements ICommonQuery { ...@@ -39,7 +39,7 @@ public class AccountHeadComponent implements ICommonQuery {
} }
@Override @Override
public Long counts(Map<String, String> map) { public Long counts(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String type = StringUtil.getInfo(search, "type"); String type = StringUtil.getInfo(search, "type");
String billNo = StringUtil.getInfo(search, "billNo"); String billNo = StringUtil.getInfo(search, "billNo");
...@@ -49,27 +49,27 @@ public class AccountHeadComponent implements ICommonQuery { ...@@ -49,27 +49,27 @@ public class AccountHeadComponent implements ICommonQuery {
} }
@Override @Override
public int insert(String beanJson, HttpServletRequest request) { public int insert(String beanJson, HttpServletRequest request) throws Exception{
return accountHeadService.insertAccountHead(beanJson, request); return accountHeadService.insertAccountHead(beanJson, request);
} }
@Override @Override
public int update(String beanJson, Long id) { public int update(String beanJson, Long id)throws Exception {
return accountHeadService.updateAccountHead(beanJson, id); return accountHeadService.updateAccountHead(beanJson, id);
} }
@Override @Override
public int delete(Long id) { public int delete(Long id)throws Exception {
return accountHeadService.deleteAccountHead(id); return accountHeadService.deleteAccountHead(id);
} }
@Override @Override
public int batchDelete(String ids) { public int batchDelete(String ids)throws Exception {
return accountHeadService.batchDeleteAccountHead(ids); return accountHeadService.batchDeleteAccountHead(ids);
} }
@Override @Override
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
return accountHeadService.checkIsNameExist(id, name); return accountHeadService.checkIsNameExist(id, name);
} }
......
...@@ -42,18 +42,44 @@ public class AccountHeadService { ...@@ -42,18 +42,44 @@ public class AccountHeadService {
@Resource @Resource
private AccountItemMapperEx accountItemMapperEx; private AccountItemMapperEx accountItemMapperEx;
public AccountHead getAccountHead(long id) { public AccountHead getAccountHead(long id) throws Exception {
return accountHeadMapper.selectByPrimaryKey(id); AccountHead result=null;
try{
result=accountHeadMapper.selectByPrimaryKey(id);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return result;
} }
public List<AccountHead> getAccountHead() { public List<AccountHead> getAccountHead() throws Exception{
AccountHeadExample example = new AccountHeadExample(); AccountHeadExample example = new AccountHeadExample();
return accountHeadMapper.selectByExample(example); List<AccountHead> list=null;
try{
list=accountHeadMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list;
} }
public List<AccountHeadVo4ListEx> select(String type, String billNo, String beginTime, String endTime, int offset, int rows) { public List<AccountHeadVo4ListEx> select(String type, String billNo, String beginTime, String endTime, int offset, int rows) throws Exception{
List<AccountHeadVo4ListEx> resList = new ArrayList<AccountHeadVo4ListEx>(); List<AccountHeadVo4ListEx> resList = new ArrayList<AccountHeadVo4ListEx>();
List<AccountHeadVo4ListEx> list = accountHeadMapperEx.selectByConditionAccountHead(type, billNo, beginTime, endTime, offset, rows); List<AccountHeadVo4ListEx> list=null;
try{
list = accountHeadMapperEx.selectByConditionAccountHead(type, billNo, beginTime, endTime, offset, rows);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
if (null != list) { if (null != list) {
for (AccountHeadVo4ListEx ah : list) { for (AccountHeadVo4ListEx ah : list) {
if(ah.getChangeamount() != null) { if(ah.getChangeamount() != null) {
...@@ -68,45 +94,107 @@ public class AccountHeadService { ...@@ -68,45 +94,107 @@ public class AccountHeadService {
return resList; return resList;
} }
public Long countAccountHead(String type, String billNo, String beginTime, String endTime) { public Long countAccountHead(String type, String billNo, String beginTime, String endTime) throws Exception{
return accountHeadMapperEx.countsByAccountHead(type, billNo, beginTime, endTime); Long result=null;
try{
result = accountHeadMapperEx.countsByAccountHead(type, billNo, beginTime, endTime);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertAccountHead(String beanJson, HttpServletRequest request) { public int insertAccountHead(String beanJson, HttpServletRequest request) throws Exception{
AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class); AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class);
return accountHeadMapper.insertSelective(accountHead); int result=0;
try{
result = accountHeadMapper.insertSelective(accountHead);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateAccountHead(String beanJson, Long id) { public int updateAccountHead(String beanJson, Long id)throws Exception {
AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class); AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class);
accountHead.setId(id); accountHead.setId(id);
return accountHeadMapper.updateByPrimaryKeySelective(accountHead); int result=0;
try{
result = accountHeadMapper.updateByPrimaryKeySelective(accountHead);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteAccountHead(Long id) { public int deleteAccountHead(Long id)throws Exception {
return accountHeadMapper.deleteByPrimaryKey(id); int result=0;
try{
result = accountHeadMapper.deleteByPrimaryKey(id);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteAccountHead(String ids) { public int batchDeleteAccountHead(String ids)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids); List<Long> idList = StringUtil.strToLongList(ids);
AccountHeadExample example = new AccountHeadExample(); AccountHeadExample example = new AccountHeadExample();
example.createCriteria().andIdIn(idList); example.createCriteria().andIdIn(idList);
return accountHeadMapper.deleteByExample(example); int result=0;
try{
result = accountHeadMapper.deleteByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
AccountHeadExample example = new AccountHeadExample(); AccountHeadExample example = new AccountHeadExample();
example.createCriteria().andIdNotEqualTo(id).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andIdNotEqualTo(id).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<AccountHead> list = accountHeadMapper.selectByExample(example); List<AccountHead> list = null;
return list.size(); try{
list = accountHeadMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list==null?0:list.size();
} }
public Long getMaxId() { public Long getMaxId()throws Exception {
return accountHeadMapperEx.getMaxId(); Long result = null;
try{
result = accountHeadMapperEx.getMaxId();
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return result;
} }
public BigDecimal findAllMoney(Integer supplierId, String type, String mode, String endTime) { public BigDecimal findAllMoney(Integer supplierId, String type, String mode, String endTime) {
...@@ -116,12 +204,29 @@ public class AccountHeadService { ...@@ -116,12 +204,29 @@ public class AccountHeadService {
} else if (mode.equals("合计")) { } else if (mode.equals("合计")) {
modeName = "TotalPrice"; modeName = "TotalPrice";
} }
return accountHeadMapperEx.findAllMoney(supplierId, type, modeName, endTime); BigDecimal result = null;
try{
result = accountHeadMapperEx.findAllMoney(supplierId, type, modeName, endTime);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return result;
} }
public List<AccountHeadVo4ListEx> getDetailByNumber(String billNo) { public List<AccountHeadVo4ListEx> getDetailByNumber(String billNo)throws Exception {
List<AccountHeadVo4ListEx> resList = new ArrayList<AccountHeadVo4ListEx>(); List<AccountHeadVo4ListEx> resList = new ArrayList<AccountHeadVo4ListEx>();
List<AccountHeadVo4ListEx> list = accountHeadMapperEx.getDetailByNumber(billNo); List<AccountHeadVo4ListEx> list = null;
try{
list = accountHeadMapperEx.getDetailByNumber(billNo);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
if (null != list) { if (null != list) {
for (AccountHeadVo4ListEx ah : list) { for (AccountHeadVo4ListEx ah : list) {
if(ah.getChangeamount() != null) { if(ah.getChangeamount() != null) {
...@@ -136,13 +241,22 @@ public class AccountHeadService { ...@@ -136,13 +241,22 @@ public class AccountHeadService {
return resList; return resList;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteAccountHeadByIds(String ids) { public int batchDeleteAccountHeadByIds(String ids)throws Exception {
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_ACCOUNT_HEAD, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_ACCOUNT_HEAD,
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser(); User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(","); String [] idArray=ids.split(",");
return accountHeadMapperEx.batchDeleteAccountHeadByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); int result = 0;
try{
result = accountHeadMapperEx.batchDeleteAccountHeadByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
/** /**
* create by: qiankunpingtai * create by: qiankunpingtai
...@@ -168,7 +282,15 @@ public class AccountHeadService { ...@@ -168,7 +282,15 @@ public class AccountHeadService {
/** /**
* 校验财务子表 jsh_accountitem * 校验财务子表 jsh_accountitem
* */ * */
List<AccountItem> accountItemList=accountItemMapperEx.getAccountItemListByHeaderIds(idArray); List<AccountItem> accountItemList = null;
try{
accountItemList = accountItemMapperEx.getAccountItemListByHeaderIds(idArray);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
if(accountItemList!=null&&accountItemList.size()>0){ if(accountItemList!=null&&accountItemList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,HeaderIds[{}]", logger.error("异常码[{}],异常提示[{}],参数,HeaderIds[{}]",
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
......
...@@ -19,16 +19,16 @@ public class AccountItemComponent implements ICommonQuery { ...@@ -19,16 +19,16 @@ public class AccountItemComponent implements ICommonQuery {
private AccountItemService accountItemService; private AccountItemService accountItemService;
@Override @Override
public Object selectOne(String condition) { public Object selectOne(String condition)throws Exception {
return null; return null;
} }
@Override @Override
public List<?> select(Map<String, String> map) { public List<?> select(Map<String, String> map)throws Exception {
return getAccountItemList(map); return getAccountItemList(map);
} }
private List<?> getAccountItemList(Map<String, String> map) { private List<?> getAccountItemList(Map<String, String> map) throws Exception{
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name"); String name = StringUtil.getInfo(search, "name");
Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type")); Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type"));
...@@ -38,7 +38,7 @@ public class AccountItemComponent implements ICommonQuery { ...@@ -38,7 +38,7 @@ public class AccountItemComponent implements ICommonQuery {
} }
@Override @Override
public Long counts(Map<String, String> map) { public Long counts(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name"); String name = StringUtil.getInfo(search, "name");
Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type")); Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type"));
...@@ -47,27 +47,27 @@ public class AccountItemComponent implements ICommonQuery { ...@@ -47,27 +47,27 @@ public class AccountItemComponent implements ICommonQuery {
} }
@Override @Override
public int insert(String beanJson, HttpServletRequest request) { public int insert(String beanJson, HttpServletRequest request) throws Exception{
return accountItemService.insertAccountItem(beanJson, request); return accountItemService.insertAccountItem(beanJson, request);
} }
@Override @Override
public int update(String beanJson, Long id) { public int update(String beanJson, Long id)throws Exception {
return accountItemService.updateAccountItem(beanJson, id); return accountItemService.updateAccountItem(beanJson, id);
} }
@Override @Override
public int delete(Long id) { public int delete(Long id)throws Exception {
return accountItemService.deleteAccountItem(id); return accountItemService.deleteAccountItem(id);
} }
@Override @Override
public int batchDelete(String ids) { public int batchDelete(String ids)throws Exception {
return accountItemService.batchDeleteAccountItem(ids); return accountItemService.batchDeleteAccountItem(ids);
} }
@Override @Override
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
return accountItemService.checkIsNameExist(id, name); return accountItemService.checkIsNameExist(id, name);
} }
......
...@@ -3,12 +3,15 @@ package com.jsh.erp.service.accountItem; ...@@ -3,12 +3,15 @@ package com.jsh.erp.service.accountItem;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants; import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.AccountHead;
import com.jsh.erp.datasource.entities.AccountItem; import com.jsh.erp.datasource.entities.AccountItem;
import com.jsh.erp.datasource.entities.AccountItemExample; import com.jsh.erp.datasource.entities.AccountItemExample;
import com.jsh.erp.datasource.entities.User; import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.mappers.AccountItemMapper; import com.jsh.erp.datasource.mappers.AccountItemMapper;
import com.jsh.erp.datasource.mappers.AccountItemMapperEx; import com.jsh.erp.datasource.mappers.AccountItemMapperEx;
import com.jsh.erp.datasource.vo.AccountItemVo4List; import com.jsh.erp.datasource.vo.AccountItemVo4List;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.user.UserService; import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.ErpInfo; import com.jsh.erp.utils.ErpInfo;
...@@ -43,72 +46,179 @@ public class AccountItemService { ...@@ -43,72 +46,179 @@ public class AccountItemService {
@Resource @Resource
private UserService userService; private UserService userService;
public AccountItem getAccountItem(long id) { public AccountItem getAccountItem(long id)throws Exception {
return accountItemMapper.selectByPrimaryKey(id); AccountItem result=null;
try{
result=accountItemMapper.selectByPrimaryKey(id);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return result;
} }
public List<AccountItem> getAccountItem() { public List<AccountItem> getAccountItem()throws Exception {
AccountItemExample example = new AccountItemExample(); AccountItemExample example = new AccountItemExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
return accountItemMapper.selectByExample(example); List<AccountItem> list=null;
try{
list=accountItemMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list;
} }
public List<AccountItem> select(String name, Integer type, String remark, int offset, int rows) { public List<AccountItem> select(String name, Integer type, String remark, int offset, int rows)throws Exception {
return accountItemMapperEx.selectByConditionAccountItem(name, type, remark, offset, rows); List<AccountItem> list=null;
try{
list = accountItemMapperEx.selectByConditionAccountItem(name, type, remark, offset, rows);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list;
} }
public Long countAccountItem(String name, Integer type, String remark) { public Long countAccountItem(String name, Integer type, String remark)throws Exception {
return accountItemMapperEx.countsByAccountItem(name, type, remark); Long result=null;
try{
result = accountItemMapperEx.countsByAccountItem(name, type, remark);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertAccountItem(String beanJson, HttpServletRequest request) { public int insertAccountItem(String beanJson, HttpServletRequest request) throws Exception{
AccountItem accountItem = JSONObject.parseObject(beanJson, AccountItem.class); AccountItem accountItem = JSONObject.parseObject(beanJson, AccountItem.class);
return accountItemMapper.insertSelective(accountItem); int result=0;
try{
result = accountItemMapper.insertSelective(accountItem);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateAccountItem(String beanJson, Long id) { public int updateAccountItem(String beanJson, Long id)throws Exception {
AccountItem accountItem = JSONObject.parseObject(beanJson, AccountItem.class); AccountItem accountItem = JSONObject.parseObject(beanJson, AccountItem.class);
accountItem.setId(id); accountItem.setId(id);
return accountItemMapper.updateByPrimaryKeySelective(accountItem); int result=0;
try{
result = accountItemMapper.updateByPrimaryKeySelective(accountItem);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteAccountItem(Long id) { public int deleteAccountItem(Long id)throws Exception {
return accountItemMapper.deleteByPrimaryKey(id); int result=0;
try{
result = accountItemMapper.deleteByPrimaryKey(id);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteAccountItem(String ids) { public int batchDeleteAccountItem(String ids)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids); List<Long> idList = StringUtil.strToLongList(ids);
AccountItemExample example = new AccountItemExample(); AccountItemExample example = new AccountItemExample();
example.createCriteria().andIdIn(idList); example.createCriteria().andIdIn(idList);
return accountItemMapper.deleteByExample(example); int result=0;
try{
result = accountItemMapper.deleteByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
AccountItemExample example = new AccountItemExample(); AccountItemExample example = new AccountItemExample();
example.createCriteria().andIdNotEqualTo(id).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andIdNotEqualTo(id).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<AccountItem> list = accountItemMapper.selectByExample(example); List<AccountItem> list = null;
return list.size(); try{
list = accountItemMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list==null?0:list.size();
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertAccountItemWithObj(AccountItem accountItem) { public int insertAccountItemWithObj(AccountItem accountItem)throws Exception {
return accountItemMapper.insertSelective(accountItem); int result=0;
try{
result = accountItemMapper.insertSelective(accountItem);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateAccountItemWithObj(AccountItem accountItem) { public int updateAccountItemWithObj(AccountItem accountItem)throws Exception {
return accountItemMapper.updateByPrimaryKeySelective(accountItem); int result=0;
try{
result = accountItemMapper.updateByPrimaryKeySelective(accountItem);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
public List<AccountItemVo4List> getDetailList(Long headerId) { public List<AccountItemVo4List> getDetailList(Long headerId) {
return accountItemMapperEx.getDetailList(headerId); List<AccountItemVo4List> list=null;
try{
list = accountItemMapperEx.getDetailList(headerId);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public String saveDetials(String inserted, String deleted, String updated, Long headerId, String listType) throws DataAccessException { public String saveDetials(String inserted, String deleted, String updated, Long headerId, String listType) throws Exception {
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_ACCOUNT_ITEM, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_ACCOUNT_ITEM,
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(",headerId:").append(headerId).toString(), new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(",headerId:").append(headerId).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
...@@ -181,12 +291,21 @@ public class AccountItemService { ...@@ -181,12 +291,21 @@ public class AccountItemService {
return null; return null;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteAccountItemByIds(String ids) { public int batchDeleteAccountItemByIds(String ids) throws Exception{
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_ACCOUNT_ITEM, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_ACCOUNT_ITEM,
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser(); User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(","); String [] idArray=ids.split(",");
return accountItemMapperEx.batchDeleteAccountItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); int result=0;
try{
result = accountItemMapperEx.batchDeleteAccountItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
} }
...@@ -19,16 +19,16 @@ public class AppComponent implements ICommonQuery { ...@@ -19,16 +19,16 @@ public class AppComponent implements ICommonQuery {
private AppService appService; private AppService appService;
@Override @Override
public Object selectOne(String condition) { public Object selectOne(String condition)throws Exception {
return null; return null;
} }
@Override @Override
public List<?> select(Map<String, String> map) { public List<?> select(Map<String, String> map)throws Exception {
return getAppList(map); return getAppList(map);
} }
private List<?> getAppList(Map<String, String> map) { private List<?> getAppList(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name"); String name = StringUtil.getInfo(search, "name");
String type = StringUtil.getInfo(search, "type"); String type = StringUtil.getInfo(search, "type");
...@@ -37,7 +37,7 @@ public class AppComponent implements ICommonQuery { ...@@ -37,7 +37,7 @@ public class AppComponent implements ICommonQuery {
} }
@Override @Override
public Long counts(Map<String, String> map) { public Long counts(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name"); String name = StringUtil.getInfo(search, "name");
String type = StringUtil.getInfo(search, "type"); String type = StringUtil.getInfo(search, "type");
...@@ -45,27 +45,27 @@ public class AppComponent implements ICommonQuery { ...@@ -45,27 +45,27 @@ public class AppComponent implements ICommonQuery {
} }
@Override @Override
public int insert(String beanJson, HttpServletRequest request) { public int insert(String beanJson, HttpServletRequest request)throws Exception {
return appService.insertApp(beanJson, request); return appService.insertApp(beanJson, request);
} }
@Override @Override
public int update(String beanJson, Long id) { public int update(String beanJson, Long id)throws Exception {
return appService.updateApp(beanJson, id); return appService.updateApp(beanJson, id);
} }
@Override @Override
public int delete(Long id) { public int delete(Long id)throws Exception {
return appService.deleteApp(id); return appService.deleteApp(id);
} }
@Override @Override
public int batchDelete(String ids) { public int batchDelete(String ids)throws Exception {
return appService.batchDeleteApp(ids); return appService.batchDeleteApp(ids);
} }
@Override @Override
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
return 0; return 0;
} }
......
...@@ -2,12 +2,14 @@ package com.jsh.erp.service.app; ...@@ -2,12 +2,14 @@ package com.jsh.erp.service.app;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants; import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.App; import com.jsh.erp.datasource.entities.App;
import com.jsh.erp.datasource.entities.AppExample; import com.jsh.erp.datasource.entities.AppExample;
import com.jsh.erp.datasource.entities.User; import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.entities.UserBusiness; import com.jsh.erp.datasource.entities.UserBusiness;
import com.jsh.erp.datasource.mappers.AppMapper; import com.jsh.erp.datasource.mappers.AppMapper;
import com.jsh.erp.datasource.mappers.AppMapperEx; import com.jsh.erp.datasource.mappers.AppMapperEx;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.user.UserService; import com.jsh.erp.service.user.UserService;
import com.jsh.erp.service.userBusiness.UserBusinessService; import com.jsh.erp.service.userBusiness.UserBusinessService;
...@@ -40,11 +42,19 @@ public class AppService { ...@@ -40,11 +42,19 @@ public class AppService {
@Resource @Resource
private UserBusinessService userBusinessService; private UserBusinessService userBusinessService;
public List<App> findDock(){ public List<App> findDock()throws Exception{
AppExample example = new AppExample(); AppExample example = new AppExample();
example.createCriteria().andZlEqualTo("dock").andEnabledEqualTo(true).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andZlEqualTo("dock").andEnabledEqualTo(true).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("Sort"); example.setOrderByClause("Sort");
List<App> list = appMapper.selectByExample(example); List<App> list=null;
try{
list=appMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list; return list;
} }
/** /**
...@@ -55,86 +65,191 @@ public class AppService { ...@@ -55,86 +65,191 @@ public class AppService {
* @Param: null * @Param: null
* @return * @return
*/ */
public List<App> findDesk(){ public List<App> findDesk()throws Exception{
AppExample example = new AppExample(); AppExample example = new AppExample();
example.createCriteria().andZlEqualTo("desk").andEnabledEqualTo(true).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andZlEqualTo("desk").andEnabledEqualTo(true).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("Sort"); example.setOrderByClause("Sort");
List<App> list = appMapper.selectByExample(example); List<App> list=null;
try{
list=appMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list; return list;
} }
public App getApp(long id) { public App getApp(long id)throws Exception {
return appMapper.selectByPrimaryKey(id); App result=null;
try{
result=appMapper.selectByPrimaryKey(id);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return result;
} }
public List<App> getApp() { public List<App> getApp()throws Exception {
AppExample example = new AppExample(); AppExample example = new AppExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
return appMapper.selectByExample(example); List<App> list=null;
try{
list=appMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list;
} }
public List<App> select(String name, String type, int offset, int rows) { public List<App> select(String name, String type, int offset, int rows)throws Exception {
return appMapperEx.selectByConditionApp(name, type, offset, rows); List<App> list=null;
try{
list=appMapperEx.selectByConditionApp(name, type, offset, rows);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list;
} }
public Long countApp(String name, String type) { public Long countApp(String name, String type)throws Exception {
return appMapperEx.countsByApp(name, type); Long result=null;
try{
result=appMapperEx.countsByApp(name, type);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertApp(String beanJson, HttpServletRequest request) { public int insertApp(String beanJson, HttpServletRequest request)throws Exception {
App app = JSONObject.parseObject(beanJson, App.class); App app = JSONObject.parseObject(beanJson, App.class);
return appMapper.insertSelective(app); int result=0;
try{
result=appMapper.insertSelective(app);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateApp(String beanJson, Long id) { public int updateApp(String beanJson, Long id) throws Exception{
App app = JSONObject.parseObject(beanJson, App.class); App app = JSONObject.parseObject(beanJson, App.class);
app.setId(id); app.setId(id);
return appMapper.updateByPrimaryKeySelective(app); int result=0;
try{
result=appMapper.updateByPrimaryKeySelective(app);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteApp(Long id) { public int deleteApp(Long id)throws Exception {
return appMapper.deleteByPrimaryKey(id); int result=0;
try{
result=appMapper.deleteByPrimaryKey(id);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteApp(String ids) { public int batchDeleteApp(String ids)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids); List<Long> idList = StringUtil.strToLongList(ids);
AppExample example = new AppExample(); AppExample example = new AppExample();
example.createCriteria().andIdIn(idList); example.createCriteria().andIdIn(idList);
return appMapper.deleteByExample(example); int result=0;
try{
result=appMapper.deleteByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
public List<App> findRoleAPP(){ public List<App> findRoleAPP()throws Exception{
AppExample example = new AppExample(); AppExample example = new AppExample();
example.createCriteria().andEnabledEqualTo(true).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andEnabledEqualTo(true).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("Sort"); example.setOrderByClause("Sort");
List<App> list = appMapper.selectByExample(example); List<App> list=null;
try{
list=appMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list; return list;
} }
public List<App> findAppInIds(String ids, String type){ public List<App> findAppInIds(String ids, String type)throws Exception{
List<Long> idList = StringUtil.strToLongList(ids); List<Long> idList = StringUtil.strToLongList(ids);
AppExample example = new AppExample(); AppExample example = new AppExample();
example.createCriteria().andZlEqualTo(type).andEnabledEqualTo(true).andIdIn(idList) example.createCriteria().andZlEqualTo(type).andEnabledEqualTo(true).andIdIn(idList)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("Sort"); example.setOrderByClause("Sort");
List<App> list = appMapper.selectByExample(example); List<App> list=null;
try{
list=appMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list; return list;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteAppByIds(String ids) { public int batchDeleteAppByIds(String ids) throws Exception{
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_APP, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_APP,
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser(); User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(","); String [] idArray=ids.split(",");
return appMapperEx.batchDeleteAppByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); int result=0;
try{
result=appMapperEx.batchDeleteAppByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
public List<App> findAppByUserId(String userId) { public List<App> findAppByUserId(String userId)throws Exception {
List<UserBusiness> roleList = userBusinessService.findRoleByUserId(userId); List<UserBusiness> roleList = userBusinessService.findRoleByUserId(userId);
String roles = null; String roles = null;
if(roleList!=null && roleList.size()>0 && roleList.get(0)!=null){ if(roleList!=null && roleList.size()>0 && roleList.get(0)!=null){
...@@ -162,10 +277,19 @@ public class AppService { ...@@ -162,10 +277,19 @@ public class AppService {
* @param numberList * @param numberList
* @return * @return
*/ */
public List<App> findAppByNumber(List<String> numberList) { public List<App> findAppByNumber(List<String> numberList) throws Exception{
AppExample example = new AppExample(); AppExample example = new AppExample();
example.createCriteria().andEnabledEqualTo(true).andNumberIn(numberList); example.createCriteria().andEnabledEqualTo(true).andNumberIn(numberList);
return appMapper.selectByExample(example); List<App> list=null;
try{
list=appMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list;
} }
} }
...@@ -20,16 +20,16 @@ public class DepotComponent implements ICommonQuery { ...@@ -20,16 +20,16 @@ public class DepotComponent implements ICommonQuery {
private DepotService depotService; private DepotService depotService;
@Override @Override
public Object selectOne(String condition) { public Object selectOne(String condition)throws Exception {
return null; return null;
} }
@Override @Override
public List<?> select(Map<String, String> map) { public List<?> select(Map<String, String> map)throws Exception {
return getDepotList(map); return getDepotList(map);
} }
private List<?> getDepotList(Map<String, String> map) { private List<?> getDepotList(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name"); String name = StringUtil.getInfo(search, "name");
Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type")); Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type"));
...@@ -39,7 +39,7 @@ public class DepotComponent implements ICommonQuery { ...@@ -39,7 +39,7 @@ public class DepotComponent implements ICommonQuery {
} }
@Override @Override
public Long counts(Map<String, String> map) { public Long counts(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name"); String name = StringUtil.getInfo(search, "name");
Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type")); Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type"));
...@@ -48,27 +48,27 @@ public class DepotComponent implements ICommonQuery { ...@@ -48,27 +48,27 @@ public class DepotComponent implements ICommonQuery {
} }
@Override @Override
public int insert(String beanJson, HttpServletRequest request) { public int insert(String beanJson, HttpServletRequest request) throws Exception{
return depotService.insertDepot(beanJson, request); return depotService.insertDepot(beanJson, request);
} }
@Override @Override
public int update(String beanJson, Long id) { public int update(String beanJson, Long id)throws Exception {
return depotService.updateDepot(beanJson, id); return depotService.updateDepot(beanJson, id);
} }
@Override @Override
public int delete(Long id) { public int delete(Long id)throws Exception {
return depotService.deleteDepot(id); return depotService.deleteDepot(id);
} }
@Override @Override
public int batchDelete(String ids) { public int batchDelete(String ids)throws Exception {
return depotService.batchDeleteDepot(ids); return depotService.batchDeleteDepot(ids);
} }
@Override @Override
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
return depotService.checkIsNameExist(id, name); return depotService.checkIsNameExist(id, name);
} }
......
...@@ -41,91 +41,214 @@ public class DepotService { ...@@ -41,91 +41,214 @@ public class DepotService {
@Resource @Resource
private DepotItemMapperEx depotItemMapperEx; private DepotItemMapperEx depotItemMapperEx;
public Depot getDepot(long id) { public Depot getDepot(long id)throws Exception {
return depotMapper.selectByPrimaryKey(id); Depot result=null;
try{
result=depotMapper.selectByPrimaryKey(id);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return result;
} }
public List<Depot> getDepot() { public List<Depot> getDepot()throws Exception {
DepotExample example = new DepotExample(); DepotExample example = new DepotExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
return depotMapper.selectByExample(example); List<Depot> list=null;
try{
list=depotMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list;
} }
public List<Depot> getAllList() { public List<Depot> getAllList()throws Exception {
DepotExample example = new DepotExample(); DepotExample example = new DepotExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("sort"); example.setOrderByClause("sort");
return depotMapper.selectByExample(example); List<Depot> list=null;
try{
list=depotMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list;
} }
public List<Depot> select(String name, Integer type, String remark, int offset, int rows) { public List<Depot> select(String name, Integer type, String remark, int offset, int rows)throws Exception {
return depotMapperEx.selectByConditionDepot(name, type, remark, offset, rows); List<Depot> list=null;
try{
list=depotMapperEx.selectByConditionDepot(name, type, remark, offset, rows);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list;
} }
public Long countDepot(String name, Integer type, String remark) { public Long countDepot(String name, Integer type, String remark)throws Exception {
return depotMapperEx.countsByDepot(name, type, remark); Long result=null;
try{
result=depotMapperEx.countsByDepot(name, type, remark);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertDepot(String beanJson, HttpServletRequest request) { public int insertDepot(String beanJson, HttpServletRequest request)throws Exception {
Depot depot = JSONObject.parseObject(beanJson, Depot.class); Depot depot = JSONObject.parseObject(beanJson, Depot.class);
return depotMapper.insertSelective(depot); int result=0;
try{
result=depotMapper.insertSelective(depot);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateDepot(String beanJson, Long id) { public int updateDepot(String beanJson, Long id) throws Exception{
Depot depot = JSONObject.parseObject(beanJson, Depot.class); Depot depot = JSONObject.parseObject(beanJson, Depot.class);
depot.setId(id); depot.setId(id);
return depotMapper.updateByPrimaryKeySelective(depot); int result=0;
try{
result= depotMapper.updateByPrimaryKeySelective(depot);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteDepot(Long id) { public int deleteDepot(Long id)throws Exception {
return depotMapper.deleteByPrimaryKey(id); int result=0;
try{
result= depotMapper.deleteByPrimaryKey(id);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteDepot(String ids) { public int batchDeleteDepot(String ids) throws Exception{
List<Long> idList = StringUtil.strToLongList(ids); List<Long> idList = StringUtil.strToLongList(ids);
DepotExample example = new DepotExample(); DepotExample example = new DepotExample();
example.createCriteria().andIdIn(idList); example.createCriteria().andIdIn(idList);
return depotMapper.deleteByExample(example); int result=0;
try{
result= depotMapper.deleteByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
DepotExample example = new DepotExample(); DepotExample example = new DepotExample();
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Depot> list = depotMapper.selectByExample(example); List<Depot> list=null;
return list.size(); try{
list= depotMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list==null?0:list.size();
} }
public List<Depot> findUserDepot(){ public List<Depot> findUserDepot()throws Exception{
DepotExample example = new DepotExample(); DepotExample example = new DepotExample();
example.createCriteria().andTypeEqualTo(0).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andTypeEqualTo(0).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("Sort"); example.setOrderByClause("Sort");
List<Depot> list = depotMapper.selectByExample(example); List<Depot> list=null;
try{
list= depotMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list; return list;
} }
public List<Depot> findGiftByType(Integer type){ public List<Depot> findGiftByType(Integer type)throws Exception{
DepotExample example = new DepotExample(); DepotExample example = new DepotExample();
example.createCriteria().andTypeEqualTo(type); example.createCriteria().andTypeEqualTo(type);
example.setOrderByClause("Sort"); example.setOrderByClause("Sort");
List<Depot> list = depotMapper.selectByExample(example); List<Depot> list=null;
try{
list= depotMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list; return list;
} }
public List<DepotEx> getDepotList(Map<String, Object> parameterMap) { public List<DepotEx> getDepotList(Map<String, Object> parameterMap)throws Exception {
return depotMapperEx.getDepotList(parameterMap); List<DepotEx> list=null;
try{
list= depotMapperEx.getDepotList(parameterMap);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteDepotByIds(String ids) { public int batchDeleteDepotByIds(String ids)throws Exception {
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_DEPOT,
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser(); User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(","); String [] idArray=ids.split(",");
return depotMapperEx.batchDeleteDepotByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); int result=0;
try{
result= depotMapperEx.batchDeleteDepotByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
/** /**
* create by: qiankunpingtai * create by: qiankunpingtai
...@@ -153,7 +276,15 @@ public class DepotService { ...@@ -153,7 +276,15 @@ public class DepotService {
/** /**
* 校验单据主表 jsh_depothead * 校验单据主表 jsh_depothead
* */ * */
List<DepotHead> depotHeadList=depotHeadMapperEx.getDepotHeadListByDepotIds(idArray); List<DepotHead> depotHeadList=null;
try{
depotHeadList= depotHeadMapperEx.getDepotHeadListByDepotIds(idArray);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
if(depotHeadList!=null&&depotHeadList.size()>0){ if(depotHeadList!=null&&depotHeadList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,DepotIds[{}]", logger.error("异常码[{}],异常提示[{}],参数,DepotIds[{}]",
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
...@@ -163,7 +294,15 @@ public class DepotService { ...@@ -163,7 +294,15 @@ public class DepotService {
/** /**
* 校验单据子表 jsh_depotitem * 校验单据子表 jsh_depotitem
* */ * */
List<DepotItem> depotItemList=depotItemMapperEx.getDepotItemListListByDepotIds(idArray); List<DepotItem> depotItemList=null;
try{
depotItemList= depotItemMapperEx.getDepotItemListListByDepotIds(idArray);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
if(depotItemList!=null&&depotItemList.size()>0){ if(depotItemList!=null&&depotItemList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,DepotIds[{}]", logger.error("异常码[{}],异常提示[{}],参数,DepotIds[{}]",
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids); ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
......
...@@ -19,16 +19,16 @@ public class DepotHeadComponent implements ICommonQuery { ...@@ -19,16 +19,16 @@ public class DepotHeadComponent implements ICommonQuery {
private DepotHeadService depotHeadService; private DepotHeadService depotHeadService;
@Override @Override
public Object selectOne(String condition) { public Object selectOne(String condition)throws Exception {
return null; return null;
} }
@Override @Override
public List<?> select(Map<String, String> map) { public List<?> select(Map<String, String> map)throws Exception {
return getDepotHeadList(map); return getDepotHeadList(map);
} }
private List<?> getDepotHeadList(Map<String, String> map) { private List<?> getDepotHeadList(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String type = StringUtil.getInfo(search, "type"); String type = StringUtil.getInfo(search, "type");
String subType = StringUtil.getInfo(search, "subType"); String subType = StringUtil.getInfo(search, "subType");
...@@ -41,7 +41,7 @@ public class DepotHeadComponent implements ICommonQuery { ...@@ -41,7 +41,7 @@ public class DepotHeadComponent implements ICommonQuery {
} }
@Override @Override
public Long counts(Map<String, String> map) { public Long counts(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String type = StringUtil.getInfo(search, "type"); String type = StringUtil.getInfo(search, "type");
String subType = StringUtil.getInfo(search, "subType"); String subType = StringUtil.getInfo(search, "subType");
...@@ -53,27 +53,27 @@ public class DepotHeadComponent implements ICommonQuery { ...@@ -53,27 +53,27 @@ public class DepotHeadComponent implements ICommonQuery {
} }
@Override @Override
public int insert(String beanJson, HttpServletRequest request) { public int insert(String beanJson, HttpServletRequest request) throws Exception{
return depotHeadService.insertDepotHead(beanJson, request); return depotHeadService.insertDepotHead(beanJson, request);
} }
@Override @Override
public int update(String beanJson, Long id) { public int update(String beanJson, Long id)throws Exception {
return depotHeadService.updateDepotHead(beanJson, id); return depotHeadService.updateDepotHead(beanJson, id);
} }
@Override @Override
public int delete(Long id) { public int delete(Long id)throws Exception {
return depotHeadService.deleteDepotHead(id); return depotHeadService.deleteDepotHead(id);
} }
@Override @Override
public int batchDelete(String ids) { public int batchDelete(String ids)throws Exception {
return depotHeadService.batchDeleteDepotHead(ids); return depotHeadService.batchDeleteDepotHead(ids);
} }
@Override @Override
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
return depotHeadService.checkIsNameExist(id, name); return depotHeadService.checkIsNameExist(id, name);
} }
......
...@@ -19,16 +19,16 @@ public class DepotItemComponent implements ICommonQuery { ...@@ -19,16 +19,16 @@ public class DepotItemComponent implements ICommonQuery {
private DepotItemService depotItemService; private DepotItemService depotItemService;
@Override @Override
public Object selectOne(String condition) { public Object selectOne(String condition)throws Exception {
return null; return null;
} }
@Override @Override
public List<?> select(Map<String, String> map) { public List<?> select(Map<String, String> map)throws Exception {
return getDepotItemList(map); return getDepotItemList(map);
} }
private List<?> getDepotItemList(Map<String, String> map) { private List<?> getDepotItemList(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name"); String name = StringUtil.getInfo(search, "name");
Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type")); Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type"));
...@@ -38,7 +38,7 @@ public class DepotItemComponent implements ICommonQuery { ...@@ -38,7 +38,7 @@ public class DepotItemComponent implements ICommonQuery {
} }
@Override @Override
public Long counts(Map<String, String> map) { public Long counts(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name"); String name = StringUtil.getInfo(search, "name");
Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type")); Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type"));
...@@ -47,27 +47,27 @@ public class DepotItemComponent implements ICommonQuery { ...@@ -47,27 +47,27 @@ public class DepotItemComponent implements ICommonQuery {
} }
@Override @Override
public int insert(String beanJson, HttpServletRequest request) { public int insert(String beanJson, HttpServletRequest request)throws Exception {
return depotItemService.insertDepotItem(beanJson, request); return depotItemService.insertDepotItem(beanJson, request);
} }
@Override @Override
public int update(String beanJson, Long id) { public int update(String beanJson, Long id)throws Exception {
return depotItemService.updateDepotItem(beanJson, id); return depotItemService.updateDepotItem(beanJson, id);
} }
@Override @Override
public int delete(Long id) { public int delete(Long id)throws Exception {
return depotItemService.deleteDepotItem(id); return depotItemService.deleteDepotItem(id);
} }
@Override @Override
public int batchDelete(String ids) { public int batchDelete(String ids)throws Exception {
return depotItemService.batchDeleteDepotItem(ids); return depotItemService.batchDeleteDepotItem(ids);
} }
@Override @Override
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
return depotItemService.checkIsNameExist(id, name); return depotItemService.checkIsNameExist(id, name);
} }
......
...@@ -21,16 +21,16 @@ public class FunctionsComponent implements ICommonQuery { ...@@ -21,16 +21,16 @@ public class FunctionsComponent implements ICommonQuery {
private FunctionsService functionsService; private FunctionsService functionsService;
@Override @Override
public Object selectOne(String condition) { public Object selectOne(String condition)throws Exception {
return null; return null;
} }
@Override @Override
public List<?> select(Map<String, String> map) { public List<?> select(Map<String, String> map)throws Exception {
return getFunctionsList(map); return getFunctionsList(map);
} }
private List<?> getFunctionsList(Map<String, String> map) { private List<?> getFunctionsList(Map<String, String> map) throws Exception{
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name"); String name = StringUtil.getInfo(search, "name");
String type = StringUtil.getInfo(search, "type"); String type = StringUtil.getInfo(search, "type");
...@@ -39,7 +39,7 @@ public class FunctionsComponent implements ICommonQuery { ...@@ -39,7 +39,7 @@ public class FunctionsComponent implements ICommonQuery {
} }
@Override @Override
public Long counts(Map<String, String> map) { public Long counts(Map<String, String> map) throws Exception{
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name"); String name = StringUtil.getInfo(search, "name");
String type = StringUtil.getInfo(search, "type"); String type = StringUtil.getInfo(search, "type");
...@@ -47,27 +47,27 @@ public class FunctionsComponent implements ICommonQuery { ...@@ -47,27 +47,27 @@ public class FunctionsComponent implements ICommonQuery {
} }
@Override @Override
public int insert(String beanJson, HttpServletRequest request) { public int insert(String beanJson, HttpServletRequest request)throws Exception {
return functionsService.insertFunctions(beanJson, request); return functionsService.insertFunctions(beanJson, request);
} }
@Override @Override
public int update(String beanJson, Long id) { public int update(String beanJson, Long id)throws Exception {
return functionsService.updateFunctions(beanJson, id); return functionsService.updateFunctions(beanJson, id);
} }
@Override @Override
public int delete(Long id) { public int delete(Long id)throws Exception {
return functionsService.deleteFunctions(id); return functionsService.deleteFunctions(id);
} }
@Override @Override
public int batchDelete(String ids) { public int batchDelete(String ids)throws Exception {
return functionsService.batchDeleteFunctions(ids); return functionsService.batchDeleteFunctions(ids);
} }
@Override @Override
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
return functionsService.checkIsNameExist(id, name); return functionsService.checkIsNameExist(id, name);
} }
......
...@@ -2,11 +2,14 @@ package com.jsh.erp.service.functions; ...@@ -2,11 +2,14 @@ package com.jsh.erp.service.functions;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants; import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.DepotItem;
import com.jsh.erp.datasource.entities.Functions; import com.jsh.erp.datasource.entities.Functions;
import com.jsh.erp.datasource.entities.FunctionsExample; import com.jsh.erp.datasource.entities.FunctionsExample;
import com.jsh.erp.datasource.entities.User; import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.mappers.FunctionsMapper; import com.jsh.erp.datasource.mappers.FunctionsMapper;
import com.jsh.erp.datasource.mappers.FunctionsMapperEx; import com.jsh.erp.datasource.mappers.FunctionsMapperEx;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.user.UserService; import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
...@@ -36,92 +39,205 @@ public class FunctionsService { ...@@ -36,92 +39,205 @@ public class FunctionsService {
@Resource @Resource
private LogService logService; private LogService logService;
public Functions getFunctions(long id) { public Functions getFunctions(long id)throws Exception {
return functionsMapper.selectByPrimaryKey(id); Functions result=null;
try{
result=functionsMapper.selectByPrimaryKey(id);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return result;
} }
public List<Functions> getFunctions() { public List<Functions> getFunctions()throws Exception {
FunctionsExample example = new FunctionsExample(); FunctionsExample example = new FunctionsExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
return functionsMapper.selectByExample(example); List<Functions> list=null;
try{
list=functionsMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list;
} }
public List<Functions> select(String name, String type, int offset, int rows) { public List<Functions> select(String name, String type, int offset, int rows)throws Exception {
return functionsMapperEx.selectByConditionFunctions(name, type, offset, rows); List<Functions> list=null;
try{
list=functionsMapperEx.selectByConditionFunctions(name, type, offset, rows);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list;
} }
public Long countFunctions(String name, String type) { public Long countFunctions(String name, String type)throws Exception {
return functionsMapperEx.countsByFunctions(name, type); Long result=null;
try{
result=functionsMapperEx.countsByFunctions(name, type);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertFunctions(String beanJson, HttpServletRequest request) { public int insertFunctions(String beanJson, HttpServletRequest request)throws Exception {
Functions depot = JSONObject.parseObject(beanJson, Functions.class); Functions depot = JSONObject.parseObject(beanJson, Functions.class);
return functionsMapper.insertSelective(depot); int result=0;
try{
result=functionsMapper.insertSelective(depot);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateFunctions(String beanJson, Long id) { public int updateFunctions(String beanJson, Long id) throws Exception{
Functions depot = JSONObject.parseObject(beanJson, Functions.class); Functions depot = JSONObject.parseObject(beanJson, Functions.class);
depot.setId(id); depot.setId(id);
return functionsMapper.updateByPrimaryKeySelective(depot); int result=0;
try{
result=functionsMapper.updateByPrimaryKeySelective(depot);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteFunctions(Long id) { public int deleteFunctions(Long id)throws Exception {
return functionsMapper.deleteByPrimaryKey(id); int result=0;
try{
result=functionsMapper.deleteByPrimaryKey(id);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteFunctions(String ids) { public int batchDeleteFunctions(String ids)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids); List<Long> idList = StringUtil.strToLongList(ids);
FunctionsExample example = new FunctionsExample(); FunctionsExample example = new FunctionsExample();
example.createCriteria().andIdIn(idList); example.createCriteria().andIdIn(idList);
return functionsMapper.deleteByExample(example); int result=0;
try{
result=functionsMapper.deleteByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
FunctionsExample example = new FunctionsExample(); FunctionsExample example = new FunctionsExample();
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Functions> list = functionsMapper.selectByExample(example); List<Functions> list=null;
return list.size(); try{
list = functionsMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list==null?0:list.size();
} }
public List<Functions> getRoleFunctions(String pNumber) { public List<Functions> getRoleFunctions(String pNumber)throws Exception {
FunctionsExample example = new FunctionsExample(); FunctionsExample example = new FunctionsExample();
example.createCriteria().andEnabledEqualTo(true).andPnumberEqualTo(pNumber) example.createCriteria().andEnabledEqualTo(true).andPnumberEqualTo(pNumber)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("Sort"); example.setOrderByClause("Sort");
List<Functions> list = functionsMapper.selectByExample(example); List<Functions> list=null;
try{
list = functionsMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list; return list;
} }
public List<Functions> findRoleFunctions(String pnumber){ public List<Functions> findRoleFunctions(String pnumber)throws Exception{
FunctionsExample example = new FunctionsExample(); FunctionsExample example = new FunctionsExample();
example.createCriteria().andEnabledEqualTo(true).andPnumberEqualTo(pnumber) example.createCriteria().andEnabledEqualTo(true).andPnumberEqualTo(pnumber)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("Sort"); example.setOrderByClause("Sort");
List<Functions> list = functionsMapper.selectByExample(example); List<Functions> list=null;
try{
list =functionsMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list; return list;
} }
public List<Functions> findByIds(String functionsIds){ public List<Functions> findByIds(String functionsIds)throws Exception{
List<Long> idList = StringUtil.strToLongList(functionsIds); List<Long> idList = StringUtil.strToLongList(functionsIds);
FunctionsExample example = new FunctionsExample(); FunctionsExample example = new FunctionsExample();
example.createCriteria().andEnabledEqualTo(true).andIdIn(idList) example.createCriteria().andEnabledEqualTo(true).andIdIn(idList)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("Sort asc"); example.setOrderByClause("Sort asc");
List<Functions> list = functionsMapper.selectByExample(example); List<Functions> list=null;
try{
list =functionsMapper.selectByExample(example);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
ExceptionConstants.DATA_READ_FAIL_MSG);
}
return list; return list;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteFunctionsByIds(String ids) { public int batchDeleteFunctionsByIds(String ids)throws Exception {
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_FUNCTIONS, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_FUNCTIONS,
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(), new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser(); User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(","); String [] idArray=ids.split(",");
return functionsMapperEx.batchDeleteFunctionsByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); int result=0;
try{
result =functionsMapperEx.batchDeleteFunctionsByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
return result;
} }
} }
...@@ -19,16 +19,16 @@ public class InOutItemComponent implements ICommonQuery { ...@@ -19,16 +19,16 @@ public class InOutItemComponent implements ICommonQuery {
private InOutItemService inOutItemService; private InOutItemService inOutItemService;
@Override @Override
public Object selectOne(String condition) { public Object selectOne(String condition)throws Exception {
return null; return null;
} }
@Override @Override
public List<?> select(Map<String, String> map) { public List<?> select(Map<String, String> map)throws Exception {
return getFunctionsList(map); return getFunctionsList(map);
} }
private List<?> getFunctionsList(Map<String, String> map) { private List<?> getFunctionsList(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name"); String name = StringUtil.getInfo(search, "name");
String type = StringUtil.getInfo(search, "type"); String type = StringUtil.getInfo(search, "type");
...@@ -38,7 +38,7 @@ public class InOutItemComponent implements ICommonQuery { ...@@ -38,7 +38,7 @@ public class InOutItemComponent implements ICommonQuery {
} }
@Override @Override
public Long counts(Map<String, String> map) { public Long counts(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH); String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name"); String name = StringUtil.getInfo(search, "name");
String type = StringUtil.getInfo(search, "type"); String type = StringUtil.getInfo(search, "type");
...@@ -47,27 +47,27 @@ public class InOutItemComponent implements ICommonQuery { ...@@ -47,27 +47,27 @@ public class InOutItemComponent implements ICommonQuery {
} }
@Override @Override
public int insert(String beanJson, HttpServletRequest request) { public int insert(String beanJson, HttpServletRequest request)throws Exception {
return inOutItemService.insertInOutItem(beanJson, request); return inOutItemService.insertInOutItem(beanJson, request);
} }
@Override @Override
public int update(String beanJson, Long id) { public int update(String beanJson, Long id)throws Exception {
return inOutItemService.updateInOutItem(beanJson, id); return inOutItemService.updateInOutItem(beanJson, id);
} }
@Override @Override
public int delete(Long id) { public int delete(Long id)throws Exception {
return inOutItemService.deleteInOutItem(id); return inOutItemService.deleteInOutItem(id);
} }
@Override @Override
public int batchDelete(String ids) { public int batchDelete(String ids)throws Exception {
return inOutItemService.batchDeleteInOutItem(ids); return inOutItemService.batchDeleteInOutItem(ids);
} }
@Override @Override
public int checkIsNameExist(Long id, String name) { public int checkIsNameExist(Long id, String name)throws Exception {
return inOutItemService.checkIsNameExist(id, name); return inOutItemService.checkIsNameExist(id, name);
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment