vue版本上线
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
package com.jsh.erp.service.accountItem;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.service.ICommonQuery;
|
||||
import com.jsh.erp.utils.Constants;
|
||||
import com.jsh.erp.utils.QueryUtils;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service(value = "accountItem_component")
|
||||
@AccountItemResource
|
||||
public class AccountItemComponent implements ICommonQuery {
|
||||
|
||||
@Resource
|
||||
private AccountItemService accountItemService;
|
||||
|
||||
@Override
|
||||
public Object selectOne(Long id) throws Exception {
|
||||
return accountItemService.getAccountItem(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map)throws Exception {
|
||||
return getAccountItemList(map);
|
||||
}
|
||||
|
||||
private List<?> getAccountItemList(Map<String, String> map) throws Exception{
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type"));
|
||||
String remark = StringUtil.getInfo(search, "remark");
|
||||
String order = QueryUtils.order(map);
|
||||
return accountItemService.select(name, type, remark, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long counts(Map<String, String> map)throws Exception {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
Integer type = StringUtil.parseInteger(StringUtil.getInfo(search, "type"));
|
||||
String remark = StringUtil.getInfo(search, "remark");
|
||||
return accountItemService.countAccountItem(name, type, remark);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(JSONObject obj, HttpServletRequest request) throws Exception{
|
||||
return accountItemService.insertAccountItem(obj, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(JSONObject obj, HttpServletRequest request)throws Exception {
|
||||
return accountItemService.updateAccountItem(obj, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id, HttpServletRequest request)throws Exception {
|
||||
return accountItemService.deleteAccountItem(id, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteBatch(String ids, HttpServletRequest request)throws Exception {
|
||||
return accountItemService.batchDeleteAccountItem(ids, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name)throws Exception {
|
||||
return accountItemService.checkIsNameExist(id, name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.jsh.erp.service.accountItem;
|
||||
|
||||
import com.jsh.erp.service.ResourceInfo;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author jishenghua qq752718920 2018-10-7 15:26:27
|
||||
*/
|
||||
@ResourceInfo(value = "accountItem")
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface AccountItemResource {
|
||||
}
|
||||
@@ -0,0 +1,241 @@
|
||||
package com.jsh.erp.service.accountItem;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.constants.BusinessConstants;
|
||||
import com.jsh.erp.datasource.entities.AccountItem;
|
||||
import com.jsh.erp.datasource.entities.AccountItemExample;
|
||||
import com.jsh.erp.datasource.entities.User;
|
||||
import com.jsh.erp.datasource.mappers.AccountItemMapper;
|
||||
import com.jsh.erp.datasource.mappers.AccountItemMapperEx;
|
||||
import com.jsh.erp.datasource.vo.AccountItemVo4List;
|
||||
import com.jsh.erp.exception.JshException;
|
||||
import com.jsh.erp.service.log.LogService;
|
||||
import com.jsh.erp.service.user.UserService;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class AccountItemService {
|
||||
private Logger logger = LoggerFactory.getLogger(AccountItemService.class);
|
||||
|
||||
@Resource
|
||||
private AccountItemMapper accountItemMapper;
|
||||
|
||||
@Resource
|
||||
private AccountItemMapperEx accountItemMapperEx;
|
||||
@Resource
|
||||
private LogService logService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
public AccountItem getAccountItem(long id)throws Exception {
|
||||
AccountItem result=null;
|
||||
try{
|
||||
result=accountItemMapper.selectByPrimaryKey(id);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<AccountItem> getAccountItem()throws Exception {
|
||||
AccountItemExample example = new AccountItemExample();
|
||||
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||
List<AccountItem> list=null;
|
||||
try{
|
||||
list=accountItemMapper.selectByExample(example);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<AccountItem> select(String name, Integer type, String remark, int offset, int rows)throws Exception {
|
||||
List<AccountItem> list=null;
|
||||
try{
|
||||
list = accountItemMapperEx.selectByConditionAccountItem(name, type, remark, offset, rows);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public Long countAccountItem(String name, Integer type, String remark)throws Exception {
|
||||
Long result=null;
|
||||
try{
|
||||
result = accountItemMapperEx.countsByAccountItem(name, type, remark);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int insertAccountItem(JSONObject obj, HttpServletRequest request) throws Exception{
|
||||
AccountItem accountItem = JSONObject.parseObject(obj.toJSONString(), AccountItem.class);
|
||||
int result=0;
|
||||
try{
|
||||
result = accountItemMapper.insertSelective(accountItem);
|
||||
logService.insertLog("财务明细", BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int updateAccountItem(JSONObject obj, HttpServletRequest request)throws Exception {
|
||||
AccountItem accountItem = JSONObject.parseObject(obj.toJSONString(), AccountItem.class);
|
||||
int result=0;
|
||||
try{
|
||||
result = accountItemMapper.updateByPrimaryKeySelective(accountItem);
|
||||
logService.insertLog("财务明细",
|
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(accountItem.getId()).toString(), request);
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int deleteAccountItem(Long id, HttpServletRequest request)throws Exception {
|
||||
int result=0;
|
||||
try{
|
||||
result = accountItemMapper.deleteByPrimaryKey(id);
|
||||
logService.insertLog("财务明细",
|
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(id).toString(), request);
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int batchDeleteAccountItem(String ids, HttpServletRequest request)throws Exception {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
AccountItemExample example = new AccountItemExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
int result=0;
|
||||
try{
|
||||
result = accountItemMapper.deleteByExample(example);
|
||||
logService.insertLog("财务明细", "批量删除,id集:" + ids, request);
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int checkIsNameExist(Long id, String name)throws Exception {
|
||||
AccountItemExample example = new AccountItemExample();
|
||||
example.createCriteria().andIdNotEqualTo(id).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||
List<AccountItem> list = null;
|
||||
try{
|
||||
list = accountItemMapper.selectByExample(example);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return list==null?0:list.size();
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int insertAccountItemWithObj(AccountItem accountItem)throws Exception {
|
||||
int result=0;
|
||||
try{
|
||||
result = accountItemMapper.insertSelective(accountItem);
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int updateAccountItemWithObj(AccountItem accountItem)throws Exception {
|
||||
int result=0;
|
||||
try{
|
||||
result = accountItemMapper.updateByPrimaryKeySelective(accountItem);
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<AccountItemVo4List> getDetailList(Long headerId) {
|
||||
List<AccountItemVo4List> list=null;
|
||||
try{
|
||||
list = accountItemMapperEx.getDetailList(headerId);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public void saveDetials(String rows, Long headerId, String type, HttpServletRequest request) throws Exception {
|
||||
//删除单据的明细
|
||||
deleteAccountItemHeadId(headerId);
|
||||
JSONArray rowArr = JSONArray.parseArray(rows);
|
||||
if (null != rowArr) {
|
||||
for (int i = 0; i < rowArr.size(); i++) {
|
||||
AccountItem accountItem = new AccountItem();
|
||||
JSONObject tempInsertedJson = JSONObject.parseObject(rowArr.getString(i));
|
||||
accountItem.setHeaderId(headerId);
|
||||
if (tempInsertedJson.get("accountId") != null && !tempInsertedJson.get("accountId").equals("")) {
|
||||
accountItem.setAccountId(tempInsertedJson.getLong("accountId"));
|
||||
}
|
||||
if (tempInsertedJson.get("inOutItemId") != null && !tempInsertedJson.get("inOutItemId").equals("")) {
|
||||
accountItem.setInOutItemId(tempInsertedJson.getLong("inOutItemId"));
|
||||
}
|
||||
if (tempInsertedJson.get("eachAmount") != null && !tempInsertedJson.get("eachAmount").equals("")) {
|
||||
BigDecimal eachAmount = tempInsertedJson.getBigDecimal("eachAmount");
|
||||
if (type.equals("付款")) {
|
||||
eachAmount = BigDecimal.ZERO.subtract(eachAmount);
|
||||
}
|
||||
accountItem.setEachAmount(eachAmount);
|
||||
} else {
|
||||
accountItem.setEachAmount(BigDecimal.ZERO);
|
||||
}
|
||||
accountItem.setRemark(tempInsertedJson.getString("remark"));
|
||||
this.insertAccountItemWithObj(accountItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public void deleteAccountItemHeadId(Long headerId)throws Exception {
|
||||
AccountItemExample example = new AccountItemExample();
|
||||
example.createCriteria().andHeaderIdEqualTo(headerId);
|
||||
try{
|
||||
accountItemMapper.deleteByExample(example);
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int batchDeleteAccountItemByIds(String ids) throws Exception{
|
||||
logService.insertLog("财务明细",
|
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
|
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||
User userInfo=userService.getCurrentUser();
|
||||
String [] idArray=ids.split(",");
|
||||
int result=0;
|
||||
try{
|
||||
result = accountItemMapperEx.batchDeleteAccountItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user