vue版本上线

This commit is contained in:
季圣华
2021-04-07 23:53:57 +08:00
parent 76a0033a4e
commit f4ef5aa067
803 changed files with 171959 additions and 27 deletions

View File

@@ -0,0 +1,75 @@
package com.jsh.erp.service.inOutItem;
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 = "inOutItem_component")
@InOutItemResource
public class InOutItemComponent implements ICommonQuery {
@Resource
private InOutItemService inOutItemService;
@Override
public Object selectOne(Long id) throws Exception {
return inOutItemService.getInOutItem(id);
}
@Override
public List<?> select(Map<String, String> map)throws Exception {
return getFunctionsList(map);
}
private List<?> getFunctionsList(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name");
String type = StringUtil.getInfo(search, "type");
String remark = StringUtil.getInfo(search, "remark");
String order = QueryUtils.order(map);
return inOutItemService.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");
String type = StringUtil.getInfo(search, "type");
String remark = StringUtil.getInfo(search, "remark");
return inOutItemService.countInOutItem(name, type, remark);
}
@Override
public int insert(JSONObject obj, HttpServletRequest request)throws Exception {
return inOutItemService.insertInOutItem(obj, request);
}
@Override
public int update(JSONObject obj, HttpServletRequest request)throws Exception {
return inOutItemService.updateInOutItem(obj, request);
}
@Override
public int delete(Long id, HttpServletRequest request)throws Exception {
return inOutItemService.deleteInOutItem(id, request);
}
@Override
public int deleteBatch(String ids, HttpServletRequest request)throws Exception {
return inOutItemService.batchDeleteInOutItem(ids, request);
}
@Override
public int checkIsNameExist(Long id, String name)throws Exception {
return inOutItemService.checkIsNameExist(id, name);
}
}

View File

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

View File

@@ -0,0 +1,202 @@
package com.jsh.erp.service.inOutItem;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.mappers.AccountItemMapperEx;
import com.jsh.erp.datasource.mappers.InOutItemMapper;
import com.jsh.erp.datasource.mappers.InOutItemMapperEx;
import com.jsh.erp.exception.BusinessRunTimeException;
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.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
public class InOutItemService {
private Logger logger = LoggerFactory.getLogger(InOutItemService.class);
@Resource
private InOutItemMapper inOutItemMapper;
@Resource
private InOutItemMapperEx inOutItemMapperEx;
@Resource
private UserService userService;
@Resource
private LogService logService;
@Resource
private AccountItemMapperEx accountItemMapperEx;
public InOutItem getInOutItem(long id)throws Exception {
InOutItem result=null;
try{
result=inOutItemMapper.selectByPrimaryKey(id);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
public List<InOutItem> getInOutItemListByIds(String ids)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids);
List<InOutItem> list = new ArrayList<>();
try{
InOutItemExample example = new InOutItemExample();
example.createCriteria().andIdIn(idList);
list = inOutItemMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public List<InOutItem> getInOutItem()throws Exception {
InOutItemExample example = new InOutItemExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<InOutItem> list=null;
try{
list=inOutItemMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public List<InOutItem> select(String name, String type, String remark, int offset, int rows)throws Exception {
List<InOutItem> list=null;
try{
list=inOutItemMapperEx.selectByConditionInOutItem(name, type, remark, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public Long countInOutItem(String name, String type, String remark)throws Exception {
Long result=null;
try{
result=inOutItemMapperEx.countsByInOutItem(name, type, remark);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertInOutItem(JSONObject obj, HttpServletRequest request)throws Exception {
InOutItem inOutItem = JSONObject.parseObject(obj.toJSONString(), InOutItem.class);
int result=0;
try{
result=inOutItemMapper.insertSelective(inOutItem);
logService.insertLog("收支项目",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(inOutItem.getName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateInOutItem(JSONObject obj, HttpServletRequest request)throws Exception {
InOutItem inOutItem = JSONObject.parseObject(obj.toJSONString(), InOutItem.class);
int result=0;
try{
result=inOutItemMapper.updateByPrimaryKeySelective(inOutItem);
logService.insertLog("收支项目",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(inOutItem.getName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteInOutItem(Long id, HttpServletRequest request)throws Exception {
return batchDeleteInOutItemByIds(id.toString());
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteInOutItem(String ids, HttpServletRequest request)throws Exception {
return batchDeleteInOutItemByIds(ids);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteInOutItemByIds(String ids)throws Exception {
int result = 0;
String [] idArray=ids.split(",");
//校验财务子表 jsh_accountitem
List<AccountItem> accountItemList=null;
try{
accountItemList=accountItemMapperEx.getAccountItemListByInOutItemIds(idArray);
}catch(Exception e){
JshException.readFail(logger, e);
}
if(accountItemList!=null&&accountItemList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,InOutItemIds[{}]",
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
}
//校验通过执行删除操作
StringBuffer sb = new StringBuffer();
sb.append(BusinessConstants.LOG_OPERATION_TYPE_DELETE);
List<InOutItem> list = getInOutItemListByIds(ids);
for(InOutItem inOutItem: list){
sb.append("[").append(inOutItem.getName()).append("]");
}
logService.insertLog("收支项目", sb.toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
try{
result=inOutItemMapperEx.batchDeleteInOutItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
public int checkIsNameExist(Long id, String name)throws Exception {
InOutItemExample example = new InOutItemExample();
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<InOutItem> list = null;
try{
list=inOutItemMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list==null?0:list.size();
}
public List<InOutItem> findBySelect(String type)throws Exception {
InOutItemExample example = new InOutItemExample();
if (type.equals("in")) {
example.createCriteria().andTypeEqualTo("收入").andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
} else if (type.equals("out")) {
example.createCriteria().andTypeEqualTo("支出").andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
}
example.setOrderByClause("id desc");
List<InOutItem> list = null;
try{
list=inOutItemMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
}