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.person;
import com.alibaba.fastjson.JSONObject;
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.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 = "person_component")
@PersonResource
public class PersonComponent implements ICommonQuery {
@Resource
private PersonService personService;
@Override
public Object selectOne(Long id) throws Exception {
return personService.getPerson(id);
}
@Override
public List<?> select(Map<String, String> map)throws Exception {
return getPersonList(map);
}
private List<?> getPersonList(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 order = QueryUtils.order(map);
return personService.select(name, type, 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");
return personService.countPerson(name, type);
}
@Override
public int insert(JSONObject obj, HttpServletRequest request)throws Exception {
return personService.insertPerson(obj, request);
}
@Override
public int update(JSONObject obj, HttpServletRequest request)throws Exception {
return personService.updatePerson(obj, request);
}
@Override
public int delete(Long id, HttpServletRequest request)throws Exception {
return personService.deletePerson(id, request);
}
@Override
public int deleteBatch(String ids, HttpServletRequest request)throws Exception {
return personService.batchDeletePerson(ids, request);
}
@Override
public int checkIsNameExist(Long id, String name)throws Exception {
return personService.checkIsNameExist(id, name);
}
}

View File

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

View File

@@ -0,0 +1,233 @@
package com.jsh.erp.service.person;
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.AccountHeadMapperEx;
import com.jsh.erp.datasource.mappers.DepotHeadMapperEx;
import com.jsh.erp.datasource.mappers.PersonMapper;
import com.jsh.erp.datasource.mappers.PersonMapperEx;
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 PersonService {
private Logger logger = LoggerFactory.getLogger(PersonService.class);
@Resource
private PersonMapper personMapper;
@Resource
private PersonMapperEx personMapperEx;
@Resource
private UserService userService;
@Resource
private LogService logService;
@Resource
private AccountHeadMapperEx accountHeadMapperEx;
@Resource
private DepotHeadMapperEx depotHeadMapperEx;
public Person getPerson(long id)throws Exception {
Person result=null;
try{
result=personMapper.selectByPrimaryKey(id);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
public List<Person> getPersonListByIds(String ids)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids);
List<Person> list = new ArrayList<>();
try{
PersonExample example = new PersonExample();
example.createCriteria().andIdIn(idList);
list = personMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public List<Person> getPerson()throws Exception {
PersonExample example = new PersonExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Person> list=null;
try{
list=personMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public List<Person> select(String name, String type, int offset, int rows)throws Exception {
List<Person> list=null;
try{
list=personMapperEx.selectByConditionPerson(name, type, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public Long countPerson(String name, String type)throws Exception {
Long result=null;
try{
result=personMapperEx.countsByPerson(name, type);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertPerson(JSONObject obj, HttpServletRequest request)throws Exception {
Person person = JSONObject.parseObject(obj.toJSONString(), Person.class);
int result=0;
try{
result=personMapper.insertSelective(person);
logService.insertLog("经手人",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(person.getName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updatePerson(JSONObject obj, HttpServletRequest request)throws Exception {
Person person = JSONObject.parseObject(obj.toJSONString(), Person.class);
int result=0;
try{
result=personMapper.updateByPrimaryKeySelective(person);
logService.insertLog("经手人",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(person.getName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deletePerson(Long id, HttpServletRequest request)throws Exception {
return batchDeletePersonByIds(id.toString());
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeletePerson(String ids, HttpServletRequest request) throws Exception{
return batchDeletePersonByIds(ids);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeletePersonByIds(String ids)throws Exception {
int result =0;
String [] idArray=ids.split(",");
//校验财务主表 jsh_accounthead
List<AccountHead> accountHeadList =null;
try{
accountHeadList=accountHeadMapperEx.getAccountHeadListByHandsPersonIds(idArray);
}catch(Exception e){
JshException.readFail(logger, e);
}
if(accountHeadList!=null&&accountHeadList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,HandsPersonIds[{}]",
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
}
//校验单据主表 jsh_depot_head
List<DepotHead> depotHeadList =null;
try{
depotHeadList=depotHeadMapperEx.getDepotHeadListByCreator(idArray);
}catch(Exception e){
JshException.readFail(logger, e);
}
if(depotHeadList!=null&&depotHeadList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,HandsPersonIds[{}]",
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<Person> list = getPersonListByIds(ids);
for(Person person: list){
sb.append("[").append(person.getName()).append("]");
}
logService.insertLog("经手人", sb.toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
//删除经手人
try{
result=personMapperEx.batchDeletePersonByIds(idArray);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
public int checkIsNameExist(Long id, String name) throws Exception{
PersonExample example = new PersonExample();
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Person> list =null;
try{
list=personMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list==null?0:list.size();
}
public String getPersonByIds(String personIDs)throws Exception {
List<Long> ids = StringUtil.strToLongList(personIDs);
PersonExample example = new PersonExample();
example.createCriteria().andIdIn(ids).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("id asc");
List<Person> list =null;
try{
list=personMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
StringBuffer sb = new StringBuffer();
if (null != list) {
for (Person person : list) {
sb.append(person.getName() + " ");
}
}
return sb.toString();
}
public List<Person> getPersonByType(String type)throws Exception {
PersonExample example = new PersonExample();
example.createCriteria().andTypeEqualTo(type).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("id asc");
List<Person> list =null;
try{
list=personMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
}