更新后端,采用Springboot+mybatis
This commit is contained in:
127
src/main/java/com/jsh/erp/service/CommonQueryManager.java
Normal file
127
src/main/java/com/jsh/erp/service/CommonQueryManager.java
Normal file
@@ -0,0 +1,127 @@
|
||||
package com.jsh.erp.service;
|
||||
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author jishenghua 752718920 2018-10-7 15:25:58
|
||||
*/
|
||||
@Service
|
||||
public class CommonQueryManager {
|
||||
|
||||
@Resource
|
||||
private InterfaceContainer container;
|
||||
|
||||
/**
|
||||
* 查询单条
|
||||
*
|
||||
* @param apiName 接口名称
|
||||
* @param id ID
|
||||
*/
|
||||
public Object selectOne(String apiName, String id) {
|
||||
if (StringUtil.isNotEmpty(apiName) && StringUtil.isNotEmpty(id)) {
|
||||
return container.getCommonQuery(apiName).selectOne(id);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询
|
||||
* @param apiName
|
||||
* @param parameterMap
|
||||
* @return
|
||||
*/
|
||||
public List<?> select(String apiName, Map<String, String> parameterMap) {
|
||||
if (StringUtil.isNotEmpty(apiName)) {
|
||||
return container.getCommonQuery(apiName).select(parameterMap);
|
||||
}
|
||||
return new ArrayList<Object>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 计数
|
||||
* @param apiName
|
||||
* @param parameterMap
|
||||
* @return
|
||||
*/
|
||||
public int counts(String apiName, Map<String, String> parameterMap) {
|
||||
if (StringUtil.isNotEmpty(apiName)) {
|
||||
return container.getCommonQuery(apiName).counts(parameterMap);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入
|
||||
* @param apiName
|
||||
* @param beanJson
|
||||
* @return
|
||||
*/
|
||||
public int insert(String apiName, String beanJson, HttpServletRequest request) {
|
||||
if (StringUtil.isNotEmpty(apiName)) {
|
||||
return container.getCommonQuery(apiName).insert(beanJson, request);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
* @param apiName
|
||||
* @param beanJson
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public int update(String apiName, String beanJson, Long id) {
|
||||
if (StringUtil.isNotEmpty(apiName)) {
|
||||
return container.getCommonQuery(apiName).update(beanJson, id);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param apiName
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public int delete(String apiName, Long id) {
|
||||
if (StringUtil.isNotEmpty(apiName)) {
|
||||
return container.getCommonQuery(apiName).delete(id);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
* @param apiName
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
public int batchDelete(String apiName, String ids) {
|
||||
if (StringUtil.isNotEmpty(apiName)) {
|
||||
return container.getCommonQuery(apiName).batchDelete(ids);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否存在
|
||||
* @param apiName
|
||||
* @param id
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public int checkIsNameExist(String apiName, Long id, String name) {
|
||||
if (StringUtil.isNotEmpty(apiName)) {
|
||||
return container.getCommonQuery(apiName).checkIsNameExist(id, name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
78
src/main/java/com/jsh/erp/service/ICommonQuery.java
Normal file
78
src/main/java/com/jsh/erp/service/ICommonQuery.java
Normal file
@@ -0,0 +1,78 @@
|
||||
package com.jsh.erp.service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 通用查询接口
|
||||
* 功能:1、单条查询 2、分页+搜索 3、查询数量
|
||||
*
|
||||
* @author jishenghua
|
||||
* @version 1.0
|
||||
*/
|
||||
public interface ICommonQuery {
|
||||
/**
|
||||
* 查询:解析JSON,查询资源。
|
||||
*
|
||||
* @param condition 资源id
|
||||
* @return 资源
|
||||
*/
|
||||
Object selectOne(String condition);
|
||||
|
||||
/**
|
||||
* 自定义查询
|
||||
*
|
||||
* @param parameterMap 查询参数
|
||||
* @return 查询结果
|
||||
*/
|
||||
List<?> select(Map<String, String> parameterMap);
|
||||
|
||||
/**
|
||||
* 查询数量
|
||||
*
|
||||
* @param parameterMap 查询参数
|
||||
* @return 查询结果
|
||||
*/
|
||||
int counts(Map<String, String> parameterMap);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param beanJson
|
||||
* @return
|
||||
*/
|
||||
int insert(String beanJson, HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
*
|
||||
* @param beanJson
|
||||
* @return
|
||||
*/
|
||||
int update(String beanJson, Long id);
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
int delete(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除数据
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
int batchDelete(String ids);
|
||||
|
||||
/**
|
||||
* 查询名称是否存在
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
int checkIsNameExist(Long id, String name);
|
||||
}
|
||||
59
src/main/java/com/jsh/erp/service/InterfaceContainer.java
Normal file
59
src/main/java/com/jsh/erp/service/InterfaceContainer.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package com.jsh.erp.service;
|
||||
|
||||
import com.jsh.erp.utils.AnnotationUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author jishenghua 2018-10-7 15:25:09
|
||||
*/
|
||||
@Service
|
||||
public class InterfaceContainer {
|
||||
private final Map<String, Integer> nameTypeMap;
|
||||
private final Map<Integer, ICommonQuery> configComponentMap;
|
||||
|
||||
public InterfaceContainer() {
|
||||
nameTypeMap = new HashMap<>();
|
||||
configComponentMap = new HashMap<>();
|
||||
}
|
||||
|
||||
|
||||
@Autowired(required = false)
|
||||
private void init(ICommonQuery[] configComponents) {
|
||||
for (ICommonQuery configComponent : configComponents) {
|
||||
ResourceInfo info = AnnotationUtils.getAnnotation(configComponent, ResourceInfo.class);
|
||||
if (info != null) {
|
||||
initResourceInfo(info);
|
||||
configComponentMap.put(info.type(), configComponent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getResourceType(String apiName) {
|
||||
if (!nameTypeMap.containsKey(apiName))
|
||||
throw new RuntimeException("资源:" + apiName + "的组件不存在");
|
||||
return nameTypeMap.get(apiName);
|
||||
}
|
||||
|
||||
public ICommonQuery getCommonQuery(String apiName) {
|
||||
return getCommonQuery(this.getResourceType(apiName));
|
||||
}
|
||||
|
||||
private ICommonQuery getCommonQuery(int resourceType) {
|
||||
Assert.isTrue(configComponentMap.containsKey(resourceType));
|
||||
return configComponentMap.get(resourceType);
|
||||
}
|
||||
|
||||
private synchronized void initResourceInfo(ResourceInfo info) {
|
||||
if (nameTypeMap.containsKey(info.value())) {
|
||||
Assert.isTrue(nameTypeMap.get(info.value()).equals(info.type()));
|
||||
} else {
|
||||
nameTypeMap.put(info.value(), info.type());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
35
src/main/java/com/jsh/erp/service/ResourceInfo.java
Normal file
35
src/main/java/com/jsh/erp/service/ResourceInfo.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package com.jsh.erp.service;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author jishenghua 2018-10-7 15:25:39
|
||||
* user-5
|
||||
* role-10
|
||||
* app-15
|
||||
* depot-20
|
||||
* log-25
|
||||
* functions-30
|
||||
* inOutItem-35
|
||||
* unit-40
|
||||
* person-45
|
||||
* userBusiness-50
|
||||
* systemConfig-55
|
||||
* materialProperty-60
|
||||
* account-65
|
||||
* supplier-70
|
||||
* materialCategory-75
|
||||
* material-80
|
||||
* depotHead-85
|
||||
* depotItem-90
|
||||
* accountHead-95
|
||||
* accountItem-100
|
||||
*/
|
||||
@Target({ElementType.TYPE, ElementType.ANNOTATION_TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Inherited
|
||||
@Documented
|
||||
public @interface ResourceInfo {
|
||||
String value();
|
||||
int type();
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.jsh.erp.service.account;
|
||||
|
||||
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 = "account_component")
|
||||
@AccountResource
|
||||
public class AccountComponent implements ICommonQuery {
|
||||
|
||||
@Resource
|
||||
private AccountService accountService;
|
||||
|
||||
@Override
|
||||
public Object selectOne(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map) {
|
||||
return getAccountList(map);
|
||||
}
|
||||
|
||||
private List<?> getAccountList(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
String serialNo = StringUtil.getInfo(search, "serialNo");
|
||||
String remark = StringUtil.getInfo(search, "remark");
|
||||
String order = QueryUtils.order(map);
|
||||
return accountService.select(name, serialNo, remark, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int counts(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
String serialNo = StringUtil.getInfo(search, "serialNo");
|
||||
String remark = StringUtil.getInfo(search, "remark");
|
||||
return accountService.countAccount(name, serialNo, remark);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(String beanJson, HttpServletRequest request) {
|
||||
return accountService.insertAccount(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return accountService.updateAccount(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return accountService.deleteAccount(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return accountService.batchDeleteAccount(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return accountService.checkIsNameExist(id, name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.jsh.erp.service.account;
|
||||
|
||||
import com.jsh.erp.service.ResourceInfo;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author jishenghua qq752718920 2018-10-7 15:26:27
|
||||
*/
|
||||
@ResourceInfo(value = "account", type = 65)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface AccountResource {
|
||||
}
|
||||
295
src/main/java/com/jsh/erp/service/account/AccountService.java
Normal file
295
src/main/java/com/jsh/erp/service/account/AccountService.java
Normal file
@@ -0,0 +1,295 @@
|
||||
package com.jsh.erp.service.account;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.*;
|
||||
import com.jsh.erp.datasource.mappers.AccountHeadMapper;
|
||||
import com.jsh.erp.datasource.mappers.AccountItemMapper;
|
||||
import com.jsh.erp.datasource.mappers.AccountMapper;
|
||||
import com.jsh.erp.datasource.mappers.DepotHeadMapper;
|
||||
import com.jsh.erp.datasource.vo.AccountVo4InOutList;
|
||||
import com.jsh.erp.datasource.vo.AccountVo4List;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import com.jsh.erp.utils.Tools;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class AccountService {
|
||||
private Logger logger = LoggerFactory.getLogger(AccountService.class);
|
||||
|
||||
@Resource
|
||||
private AccountMapper accountMapper;
|
||||
|
||||
@Resource
|
||||
private DepotHeadMapper depotHeadMapper;
|
||||
|
||||
@Resource
|
||||
private AccountHeadMapper accountHeadMapper;
|
||||
|
||||
@Resource
|
||||
private AccountItemMapper accountItemMapper;
|
||||
|
||||
public Account getAccount(long id) {
|
||||
return accountMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<Account> getAccount() {
|
||||
AccountExample example = new AccountExample();
|
||||
return accountMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<AccountVo4List> select(String name, String serialNo, String remark, int offset, int rows) {
|
||||
List<AccountVo4List> resList = new ArrayList<AccountVo4List>();
|
||||
List<AccountVo4List> list = accountMapper.selectByConditionAccount(name, serialNo, remark, offset, rows);
|
||||
String timeStr = Tools.getCurrentMonth();
|
||||
if (null != list && null !=timeStr) {
|
||||
for (AccountVo4List al : list) {
|
||||
DecimalFormat df = new DecimalFormat(".##");
|
||||
Double thisMonthAmount = getAccountSum(al.getId(), timeStr, "month") + getAccountSumByHead(al.getId(), timeStr, "month") + getAccountSumByDetail(al.getId(), timeStr, "month") + getManyAccountSum(al.getId(), timeStr, "month");
|
||||
String thisMonthAmountFmt = "0";
|
||||
if (thisMonthAmount != 0) {
|
||||
thisMonthAmountFmt = df.format(thisMonthAmount);
|
||||
}
|
||||
al.setThismonthamount(thisMonthAmountFmt); //本月发生额
|
||||
Double currentAmount = getAccountSum(al.getId(), "", "month") + getAccountSumByHead(al.getId(), "", "month") + getAccountSumByDetail(al.getId(), "", "month") + getManyAccountSum(al.getId(), "", "month") + al.getInitialamount();
|
||||
al.setCurrentamount(currentAmount);
|
||||
resList.add(al);
|
||||
}
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
public int countAccount(String name, String serialNo, String remark) {
|
||||
return accountMapper.countsByAccount(name, serialNo, remark);
|
||||
}
|
||||
|
||||
public int insertAccount(String beanJson, HttpServletRequest request) {
|
||||
Account account = JSONObject.parseObject(beanJson, Account.class);
|
||||
return accountMapper.insertSelective(account);
|
||||
}
|
||||
|
||||
public int updateAccount(String beanJson, Long id) {
|
||||
Account account = JSONObject.parseObject(beanJson, Account.class);
|
||||
account.setId(id);
|
||||
return accountMapper.updateByPrimaryKeySelective(account);
|
||||
}
|
||||
|
||||
public int deleteAccount(Long id) {
|
||||
return accountMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int batchDeleteAccount(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
AccountExample example = new AccountExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return accountMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
AccountExample example = new AccountExample();
|
||||
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name);
|
||||
List<Account> list = accountMapper.selectByExample(example);
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public List<Account> findBySelect() {
|
||||
AccountExample example = new AccountExample();
|
||||
example.setOrderByClause("id desc");
|
||||
return accountMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
/**
|
||||
* 单个账户的金额求和-入库和出库
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public Double getAccountSum(Long id, String timeStr, String type) {
|
||||
Double accountSum = 0.0;
|
||||
try {
|
||||
DepotHeadExample example = new DepotHeadExample();
|
||||
if (!timeStr.equals("")) {
|
||||
Date bTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
|
||||
Date eTime = StringUtil.getDateByString(timeStr + "-31 00:00:00", null);
|
||||
Date mTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
|
||||
if (type.equals("month")) {
|
||||
example.createCriteria().andAccountidEqualTo(id).andPaytypeNotEqualTo("预付款")
|
||||
.andOpertimeGreaterThanOrEqualTo(bTime).andOpertimeLessThanOrEqualTo(eTime);
|
||||
} else if (type.equals("date")) {
|
||||
example.createCriteria().andAccountidEqualTo(id).andPaytypeNotEqualTo("预付款")
|
||||
.andOpertimeLessThanOrEqualTo(mTime);
|
||||
}
|
||||
} else {
|
||||
example.createCriteria().andAccountidEqualTo(id).andPaytypeNotEqualTo("预付款");
|
||||
}
|
||||
List<DepotHead> dataList = depotHeadMapper.selectByExample(example);
|
||||
if (dataList != null) {
|
||||
for (DepotHead depotHead : dataList) {
|
||||
if(depotHead.getChangeamount()!=null) {
|
||||
accountSum = accountSum + depotHead.getChangeamount();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (DataAccessException e) {
|
||||
logger.error(">>>>>>>>>查找进销存信息异常", e);
|
||||
}
|
||||
return accountSum;
|
||||
}
|
||||
|
||||
/**
|
||||
* 单个账户的金额求和-收入、支出、转账的单据表头的合计
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public Double getAccountSumByHead(Long id, String timeStr, String type) {
|
||||
Double accountSum = 0.0;
|
||||
try {
|
||||
AccountHeadExample example = new AccountHeadExample();
|
||||
if (!timeStr.equals("")) {
|
||||
Date bTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
|
||||
Date eTime = StringUtil.getDateByString(timeStr + "-31 00:00:00", null);
|
||||
Date mTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
|
||||
if (type.equals("month")) {
|
||||
example.createCriteria().andAccountidEqualTo(id)
|
||||
.andBilltimeGreaterThanOrEqualTo(bTime).andBilltimeLessThanOrEqualTo(eTime);
|
||||
} else if (type.equals("date")) {
|
||||
example.createCriteria().andAccountidEqualTo(id)
|
||||
.andBilltimeLessThanOrEqualTo(mTime);
|
||||
}
|
||||
} else {
|
||||
example.createCriteria().andAccountidEqualTo(id);
|
||||
}
|
||||
List<AccountHead> dataList = accountHeadMapper.selectByExample(example);
|
||||
if (dataList != null) {
|
||||
for (AccountHead accountHead : dataList) {
|
||||
if(accountHead.getChangeamount()!=null) {
|
||||
accountSum = accountSum + accountHead.getChangeamount();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (DataAccessException e) {
|
||||
logger.error(">>>>>>>>>查找进销存信息异常", e);
|
||||
}
|
||||
return accountSum;
|
||||
}
|
||||
|
||||
/**
|
||||
* 单个账户的金额求和-收款、付款、转账、收预付款的单据明细的合计
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public Double getAccountSumByDetail(Long id, String timeStr, String type) {
|
||||
Double accountSum = 0.0;
|
||||
try {
|
||||
AccountHeadExample example = new AccountHeadExample();
|
||||
if (!timeStr.equals("")) {
|
||||
Date bTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
|
||||
Date eTime = StringUtil.getDateByString(timeStr + "-31 00:00:00", null);
|
||||
Date mTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
|
||||
if (type.equals("month")) {
|
||||
example.createCriteria().andBilltimeGreaterThanOrEqualTo(bTime).andBilltimeLessThanOrEqualTo(eTime);
|
||||
} else if (type.equals("date")) {
|
||||
example.createCriteria().andBilltimeLessThanOrEqualTo(mTime);
|
||||
}
|
||||
}
|
||||
List<AccountHead> dataList = accountHeadMapper.selectByExample(example);
|
||||
if (dataList != null) {
|
||||
String ids = "";
|
||||
for (AccountHead accountHead : dataList) {
|
||||
ids = ids + accountHead.getId() + ",";
|
||||
}
|
||||
if (!ids.equals("")) {
|
||||
ids = ids.substring(0, ids.length() - 1);
|
||||
}
|
||||
|
||||
AccountItemExample exampleAi = new AccountItemExample();
|
||||
if (!ids.equals("")) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
exampleAi.createCriteria().andAccountidEqualTo(id).andHeaderidIn(idList);
|
||||
} else {
|
||||
exampleAi.createCriteria().andAccountidEqualTo(id);
|
||||
}
|
||||
List<AccountItem> dataListOne = accountItemMapper.selectByExample(exampleAi);
|
||||
if (dataListOne != null) {
|
||||
for (AccountItem accountItem : dataListOne) {
|
||||
if(accountItem.getEachamount()!=null) {
|
||||
accountSum = accountSum + accountItem.getEachamount();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (DataAccessException e) {
|
||||
logger.error(">>>>>>>>>查找进销存信息异常", e);
|
||||
} catch (Exception e) {
|
||||
logger.error(">>>>>>>>>异常信息:", e);
|
||||
}
|
||||
return accountSum;
|
||||
}
|
||||
|
||||
/**
|
||||
* 单个账户的金额求和-多账户的明细合计
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public Double getManyAccountSum(Long id, String timeStr, String type) {
|
||||
Double accountSum = 0.0;
|
||||
try {
|
||||
DepotHeadExample example = new DepotHeadExample();
|
||||
if (!timeStr.equals("")) {
|
||||
Date bTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
|
||||
Date eTime = StringUtil.getDateByString(timeStr + "-31 00:00:00", null);
|
||||
Date mTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
|
||||
if (type.equals("month")) {
|
||||
example.createCriteria().andAccountidlistLike("%" +id.toString() + "%")
|
||||
.andOpertimeGreaterThanOrEqualTo(bTime).andOpertimeLessThanOrEqualTo(eTime);
|
||||
} else if (type.equals("date")) {
|
||||
example.createCriteria().andAccountidlistLike("%" +id.toString() + "%")
|
||||
.andOpertimeLessThanOrEqualTo(mTime);
|
||||
}
|
||||
} else {
|
||||
example.createCriteria().andAccountidlistLike("%" +id.toString() + "%");
|
||||
}
|
||||
List<DepotHead> dataList = depotHeadMapper.selectByExample(example);
|
||||
if (dataList != null) {
|
||||
for (DepotHead depotHead : dataList) {
|
||||
String accountIdList = depotHead.getAccountidlist();
|
||||
String accountMoneyList = depotHead.getAccountmoneylist();
|
||||
accountIdList = accountIdList.replace("[", "").replace("]", "").replace("\"", "");
|
||||
accountMoneyList = accountMoneyList.replace("[", "").replace("]", "").replace("\"", "");
|
||||
String[] aList = accountIdList.split(",");
|
||||
String[] amList = accountMoneyList.split(",");
|
||||
for (int i = 0; i < aList.length; i++) {
|
||||
if (aList[i].toString().equals(id.toString())) {
|
||||
accountSum = accountSum + Double.parseDouble(amList[i].toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (DataAccessException e) {
|
||||
logger.error(">>>>>>>>>查找信息异常", e);
|
||||
}
|
||||
return accountSum;
|
||||
}
|
||||
|
||||
public List<AccountVo4InOutList> findAccountInOutList(Long accountId, Integer offset, Integer rows) {
|
||||
return accountMapper.findAccountInOutList(accountId, offset, rows);
|
||||
}
|
||||
|
||||
public int findAccountInOutListCount(Long accountId) {
|
||||
return accountMapper.findAccountInOutListCount(accountId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.jsh.erp.service.accountHead;
|
||||
|
||||
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 = "accountHead_component")
|
||||
@AccountHeadResource
|
||||
public class AccountHeadComponent implements ICommonQuery {
|
||||
|
||||
@Resource
|
||||
private AccountHeadService accountHeadService;
|
||||
|
||||
@Override
|
||||
public Object selectOne(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map) {
|
||||
return getAccountHeadList(map);
|
||||
}
|
||||
|
||||
private List<?> getAccountHeadList(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String type = StringUtil.getInfo(search, "type");
|
||||
String billNo = StringUtil.getInfo(search, "billNo");
|
||||
String beginTime = StringUtil.getInfo(search, "beginTime");
|
||||
String endTime = StringUtil.getInfo(search, "endTime");
|
||||
String order = QueryUtils.order(map);
|
||||
return accountHeadService.select(type, billNo, beginTime, endTime, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int counts(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String type = StringUtil.getInfo(search, "type");
|
||||
String billNo = StringUtil.getInfo(search, "billNo");
|
||||
String beginTime = StringUtil.getInfo(search, "beginTime");
|
||||
String endTime = StringUtil.getInfo(search, "endTime");
|
||||
return accountHeadService.countAccountHead(type, billNo, beginTime, endTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(String beanJson, HttpServletRequest request) {
|
||||
return accountHeadService.insertAccountHead(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return accountHeadService.updateAccountHead(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return accountHeadService.deleteAccountHead(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return accountHeadService.batchDeleteAccountHead(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return accountHeadService.checkIsNameExist(id, name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.jsh.erp.service.accountHead;
|
||||
|
||||
import com.jsh.erp.service.ResourceInfo;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author jishenghua qq752718920 2018-10-7 15:26:27
|
||||
*/
|
||||
@ResourceInfo(value = "accountHead", type = 95)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface AccountHeadResource {
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.jsh.erp.service.accountHead;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.AccountHead;
|
||||
import com.jsh.erp.datasource.entities.AccountHeadExample;
|
||||
import com.jsh.erp.datasource.entities.AccountHeadVo4ListEx;
|
||||
import com.jsh.erp.datasource.mappers.AccountHeadMapper;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import com.jsh.erp.utils.Tools;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class AccountHeadService {
|
||||
private Logger logger = LoggerFactory.getLogger(AccountHeadService.class);
|
||||
|
||||
@Resource
|
||||
private AccountHeadMapper accountHeadMapper;
|
||||
|
||||
public AccountHead getAccountHead(long id) {
|
||||
return accountHeadMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<AccountHead> getAccountHead() {
|
||||
AccountHeadExample example = new AccountHeadExample();
|
||||
return accountHeadMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<AccountHeadVo4ListEx> select(String type, String billNo, String beginTime, String endTime, int offset, int rows) {
|
||||
List<AccountHeadVo4ListEx> resList = new ArrayList<AccountHeadVo4ListEx>();
|
||||
List<AccountHeadVo4ListEx> list = accountHeadMapper.selectByConditionAccountHead(type, billNo, beginTime, endTime, offset, rows);
|
||||
if (null != list) {
|
||||
for (AccountHeadVo4ListEx ah : list) {
|
||||
if(ah.getChangeamount() != null) {
|
||||
ah.setChangeamount(Math.abs(ah.getChangeamount()));
|
||||
}
|
||||
if(ah.getTotalprice() != null) {
|
||||
ah.setTotalprice(Math.abs(ah.getTotalprice()));
|
||||
}
|
||||
resList.add(ah);
|
||||
}
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
public int countAccountHead(String type, String billNo, String beginTime, String endTime) {
|
||||
return accountHeadMapper.countsByAccountHead(type, billNo, beginTime, endTime);
|
||||
}
|
||||
|
||||
public int insertAccountHead(String beanJson, HttpServletRequest request) {
|
||||
AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class);
|
||||
return accountHeadMapper.insertSelective(accountHead);
|
||||
}
|
||||
|
||||
public int updateAccountHead(String beanJson, Long id) {
|
||||
AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class);
|
||||
accountHead.setId(id);
|
||||
return accountHeadMapper.updateByPrimaryKeySelective(accountHead);
|
||||
}
|
||||
|
||||
public int deleteAccountHead(Long id) {
|
||||
return accountHeadMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int batchDeleteAccountHead(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
AccountHeadExample example = new AccountHeadExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return accountHeadMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
AccountHeadExample example = new AccountHeadExample();
|
||||
example.createCriteria().andIdNotEqualTo(id);
|
||||
List<AccountHead> list = accountHeadMapper.selectByExample(example);
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public Long getMaxId() {
|
||||
return accountHeadMapper.getMaxId();
|
||||
}
|
||||
|
||||
public Double findAllMoney(Integer supplierId, String type, String mode, String endTime) {
|
||||
String modeName = "";
|
||||
if (mode.equals("实际")) {
|
||||
modeName = "ChangeAmount";
|
||||
} else if (mode.equals("合计")) {
|
||||
modeName = "TotalPrice";
|
||||
}
|
||||
return accountHeadMapper.findAllMoney(supplierId, type, modeName, endTime);
|
||||
}
|
||||
|
||||
public List<AccountHeadVo4ListEx> getDetailByNumber(String billNo) {
|
||||
List<AccountHeadVo4ListEx> resList = new ArrayList<AccountHeadVo4ListEx>();
|
||||
List<AccountHeadVo4ListEx> list = accountHeadMapper.getDetailByNumber(billNo);
|
||||
if (null != list) {
|
||||
for (AccountHeadVo4ListEx ah : list) {
|
||||
if(ah.getChangeamount() != null) {
|
||||
ah.setChangeamount(Math.abs(ah.getChangeamount()));
|
||||
}
|
||||
if(ah.getTotalprice() != null) {
|
||||
ah.setTotalprice(Math.abs(ah.getTotalprice()));
|
||||
}
|
||||
resList.add(ah);
|
||||
}
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.jsh.erp.service.accountItem;
|
||||
|
||||
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(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map) {
|
||||
return getAccountItemList(map);
|
||||
}
|
||||
|
||||
private List<?> getAccountItemList(Map<String, String> map) {
|
||||
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 int counts(Map<String, String> map) {
|
||||
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(String beanJson, HttpServletRequest request) {
|
||||
return accountItemService.insertAccountItem(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return accountItemService.updateAccountItem(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return accountItemService.deleteAccountItem(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return accountItemService.batchDeleteAccountItem(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
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", type = 100)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface AccountItemResource {
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.jsh.erp.service.accountItem;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.AccountItem;
|
||||
import com.jsh.erp.datasource.entities.AccountItemExample;
|
||||
import com.jsh.erp.datasource.mappers.AccountItemMapper;
|
||||
import com.jsh.erp.datasource.vo.AccountItemVo4List;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class AccountItemService {
|
||||
private Logger logger = LoggerFactory.getLogger(AccountItemService.class);
|
||||
|
||||
@Resource
|
||||
private AccountItemMapper accountItemMapper;
|
||||
|
||||
public AccountItem getAccountItem(long id) {
|
||||
return accountItemMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<AccountItem> getAccountItem() {
|
||||
AccountItemExample example = new AccountItemExample();
|
||||
return accountItemMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<AccountItem> select(String name, Integer type, String remark, int offset, int rows) {
|
||||
return accountItemMapper.selectByConditionAccountItem(name, type, remark, offset, rows);
|
||||
}
|
||||
|
||||
public int countAccountItem(String name, Integer type, String remark) {
|
||||
return accountItemMapper.countsByAccountItem(name, type, remark);
|
||||
}
|
||||
|
||||
public int insertAccountItem(String beanJson, HttpServletRequest request) {
|
||||
AccountItem accountItem = JSONObject.parseObject(beanJson, AccountItem.class);
|
||||
return accountItemMapper.insertSelective(accountItem);
|
||||
}
|
||||
|
||||
public int updateAccountItem(String beanJson, Long id) {
|
||||
AccountItem accountItem = JSONObject.parseObject(beanJson, AccountItem.class);
|
||||
accountItem.setId(id);
|
||||
return accountItemMapper.updateByPrimaryKeySelective(accountItem);
|
||||
}
|
||||
|
||||
public int deleteAccountItem(Long id) {
|
||||
return accountItemMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int batchDeleteAccountItem(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
AccountItemExample example = new AccountItemExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return accountItemMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
AccountItemExample example = new AccountItemExample();
|
||||
example.createCriteria().andIdNotEqualTo(id);
|
||||
List<AccountItem> list = accountItemMapper.selectByExample(example);
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public int insertAccountItemWithObj(AccountItem accountItem) {
|
||||
return accountItemMapper.insertSelective(accountItem);
|
||||
}
|
||||
|
||||
public int updateAccountItemWithObj(AccountItem accountItem) {
|
||||
return accountItemMapper.updateByPrimaryKeySelective(accountItem);
|
||||
}
|
||||
|
||||
public List<AccountItemVo4List> getDetailList(Long headerId) {
|
||||
return accountItemMapper.getDetailList(headerId);
|
||||
}
|
||||
}
|
||||
72
src/main/java/com/jsh/erp/service/app/AppComponent.java
Normal file
72
src/main/java/com/jsh/erp/service/app/AppComponent.java
Normal file
@@ -0,0 +1,72 @@
|
||||
package com.jsh.erp.service.app;
|
||||
|
||||
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 = "app_component")
|
||||
@AppResource
|
||||
public class AppComponent implements ICommonQuery {
|
||||
|
||||
@Resource
|
||||
private AppService appService;
|
||||
|
||||
@Override
|
||||
public Object selectOne(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map) {
|
||||
return getAppList(map);
|
||||
}
|
||||
|
||||
private List<?> getAppList(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
String type = StringUtil.getInfo(search, "type");
|
||||
String order = QueryUtils.order(map);
|
||||
return appService.select(name, type, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int counts(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
String type = StringUtil.getInfo(search, "type");
|
||||
return appService.countApp(name, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(String beanJson, HttpServletRequest request) {
|
||||
return appService.insertApp(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return appService.updateApp(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return appService.deleteApp(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return appService.batchDeleteApp(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
15
src/main/java/com/jsh/erp/service/app/AppResource.java
Normal file
15
src/main/java/com/jsh/erp/service/app/AppResource.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.jsh.erp.service.app;
|
||||
|
||||
import com.jsh.erp.service.ResourceInfo;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author jishenghua qq752718920 2018-10-7 15:26:27
|
||||
*/
|
||||
@ResourceInfo(value = "app", type = 15)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface AppResource {
|
||||
}
|
||||
85
src/main/java/com/jsh/erp/service/app/AppService.java
Normal file
85
src/main/java/com/jsh/erp/service/app/AppService.java
Normal file
@@ -0,0 +1,85 @@
|
||||
package com.jsh.erp.service.app;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.App;
|
||||
import com.jsh.erp.datasource.entities.AppExample;
|
||||
import com.jsh.erp.datasource.mappers.AppMapper;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class AppService {
|
||||
private Logger logger = LoggerFactory.getLogger(AppService.class);
|
||||
|
||||
@Resource
|
||||
private AppMapper appMapper;
|
||||
|
||||
public List<App> findDock(){
|
||||
AppExample example = new AppExample();
|
||||
example.createCriteria().andZlEqualTo("dock").andEnabledEqualTo(true);
|
||||
example.setOrderByClause("Sort");
|
||||
List<App> list = appMapper.selectByExample(example);
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<App> findDesk(){
|
||||
AppExample example = new AppExample();
|
||||
example.createCriteria().andZlEqualTo("desk").andEnabledEqualTo(true);
|
||||
example.setOrderByClause("Sort");
|
||||
List<App> list = appMapper.selectByExample(example);
|
||||
return list;
|
||||
}
|
||||
|
||||
public App getApp(long id) {
|
||||
return appMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<App> getApp() {
|
||||
AppExample example = new AppExample();
|
||||
return appMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<App> select(String name, String type, int offset, int rows) {
|
||||
return appMapper.selectByConditionApp(name, type, offset, rows);
|
||||
}
|
||||
|
||||
public int countApp(String name, String type) {
|
||||
return appMapper.countsByApp(name, type);
|
||||
}
|
||||
|
||||
public int insertApp(String beanJson, HttpServletRequest request) {
|
||||
App app = JSONObject.parseObject(beanJson, App.class);
|
||||
return appMapper.insertSelective(app);
|
||||
}
|
||||
|
||||
public int updateApp(String beanJson, Long id) {
|
||||
App app = JSONObject.parseObject(beanJson, App.class);
|
||||
app.setId(id);
|
||||
return appMapper.updateByPrimaryKeySelective(app);
|
||||
}
|
||||
|
||||
public int deleteApp(Long id) {
|
||||
return appMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int batchDeleteApp(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
AppExample example = new AppExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return appMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public List<App> findRoleAPP(){
|
||||
AppExample example = new AppExample();
|
||||
example.createCriteria().andEnabledEqualTo(true);
|
||||
example.setOrderByClause("Sort");
|
||||
List<App> list = appMapper.selectByExample(example);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
75
src/main/java/com/jsh/erp/service/depot/DepotComponent.java
Normal file
75
src/main/java/com/jsh/erp/service/depot/DepotComponent.java
Normal file
@@ -0,0 +1,75 @@
|
||||
package com.jsh.erp.service.depot;
|
||||
|
||||
import com.jsh.erp.service.ICommonQuery;
|
||||
import com.jsh.erp.service.app.AppResource;
|
||||
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 = "depot_component")
|
||||
@DepotResource
|
||||
public class DepotComponent implements ICommonQuery {
|
||||
|
||||
@Resource
|
||||
private DepotService depotService;
|
||||
|
||||
@Override
|
||||
public Object selectOne(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map) {
|
||||
return getDepotList(map);
|
||||
}
|
||||
|
||||
private List<?> getDepotList(Map<String, String> map) {
|
||||
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 depotService.select(name, type, remark, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int counts(Map<String, String> map) {
|
||||
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 depotService.countDepot(name, type, remark);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(String beanJson, HttpServletRequest request) {
|
||||
return depotService.insertDepot(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return depotService.updateDepot(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return depotService.deleteDepot(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return depotService.batchDeleteDepot(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return depotService.checkIsNameExist(id, name);
|
||||
}
|
||||
|
||||
}
|
||||
15
src/main/java/com/jsh/erp/service/depot/DepotResource.java
Normal file
15
src/main/java/com/jsh/erp/service/depot/DepotResource.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.jsh.erp.service.depot;
|
||||
|
||||
import com.jsh.erp.service.ResourceInfo;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author jishenghua qq752718920 2018-10-7 15:26:27
|
||||
*/
|
||||
@ResourceInfo(value = "depot", type = 20)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface DepotResource {
|
||||
}
|
||||
91
src/main/java/com/jsh/erp/service/depot/DepotService.java
Normal file
91
src/main/java/com/jsh/erp/service/depot/DepotService.java
Normal file
@@ -0,0 +1,91 @@
|
||||
package com.jsh.erp.service.depot;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.Depot;
|
||||
import com.jsh.erp.datasource.entities.DepotExample;
|
||||
import com.jsh.erp.datasource.mappers.DepotMapper;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class DepotService {
|
||||
private Logger logger = LoggerFactory.getLogger(DepotService.class);
|
||||
|
||||
@Resource
|
||||
private DepotMapper depotMapper;
|
||||
|
||||
public Depot getDepot(long id) {
|
||||
return depotMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<Depot> getDepot() {
|
||||
DepotExample example = new DepotExample();
|
||||
return depotMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<Depot> getAllList() {
|
||||
DepotExample example = new DepotExample();
|
||||
example.setOrderByClause("sort");
|
||||
return depotMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<Depot> select(String name, Integer type, String remark, int offset, int rows) {
|
||||
return depotMapper.selectByConditionDepot(name, type, remark, offset, rows);
|
||||
}
|
||||
|
||||
public int countDepot(String name, Integer type, String remark) {
|
||||
return depotMapper.countsByDepot(name, type, remark);
|
||||
}
|
||||
|
||||
public int insertDepot(String beanJson, HttpServletRequest request) {
|
||||
Depot depot = JSONObject.parseObject(beanJson, Depot.class);
|
||||
return depotMapper.insertSelective(depot);
|
||||
}
|
||||
|
||||
public int updateDepot(String beanJson, Long id) {
|
||||
Depot depot = JSONObject.parseObject(beanJson, Depot.class);
|
||||
depot.setId(id);
|
||||
return depotMapper.updateByPrimaryKeySelective(depot);
|
||||
}
|
||||
|
||||
public int deleteDepot(Long id) {
|
||||
return depotMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int batchDeleteDepot(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
DepotExample example = new DepotExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return depotMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
DepotExample example = new DepotExample();
|
||||
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name);
|
||||
List<Depot> list = depotMapper.selectByExample(example);
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public List<Depot> findUserDepot(){
|
||||
DepotExample example = new DepotExample();
|
||||
example.createCriteria().andTypeEqualTo(0);
|
||||
example.setOrderByClause("Sort");
|
||||
List<Depot> list = depotMapper.selectByExample(example);
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<Depot> findGiftByType(Integer type){
|
||||
DepotExample example = new DepotExample();
|
||||
example.createCriteria().andTypeEqualTo(type);
|
||||
example.setOrderByClause("Sort");
|
||||
List<Depot> list = depotMapper.selectByExample(example);
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.jsh.erp.service.depotHead;
|
||||
|
||||
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 = "depotHead_component")
|
||||
@DepotHeadResource
|
||||
public class DepotHeadComponent implements ICommonQuery {
|
||||
|
||||
@Resource
|
||||
private DepotHeadService depotHeadService;
|
||||
|
||||
@Override
|
||||
public Object selectOne(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map) {
|
||||
return getDepotHeadList(map);
|
||||
}
|
||||
|
||||
private List<?> getDepotHeadList(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String type = StringUtil.getInfo(search, "type");
|
||||
String subType = StringUtil.getInfo(search, "subType");
|
||||
String number = StringUtil.getInfo(search, "number");
|
||||
String beginTime = StringUtil.getInfo(search, "beginTime");
|
||||
String endTime = StringUtil.getInfo(search, "endTime");
|
||||
String dhIds = StringUtil.getInfo(search, "dhIds");
|
||||
String order = QueryUtils.order(map);
|
||||
return depotHeadService.select(type, subType, number, beginTime, endTime, dhIds, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int counts(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String type = StringUtil.getInfo(search, "type");
|
||||
String subType = StringUtil.getInfo(search, "subType");
|
||||
String number = StringUtil.getInfo(search, "number");
|
||||
String beginTime = StringUtil.getInfo(search, "beginTime");
|
||||
String endTime = StringUtil.getInfo(search, "endTime");
|
||||
String dhIds = StringUtil.getInfo(search, "dhIds");
|
||||
return depotHeadService.countDepotHead(type, subType, number, beginTime, endTime, dhIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(String beanJson, HttpServletRequest request) {
|
||||
return depotHeadService.insertDepotHead(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return depotHeadService.updateDepotHead(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return depotHeadService.deleteDepotHead(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return depotHeadService.batchDeleteDepotHead(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return depotHeadService.checkIsNameExist(id, name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.jsh.erp.service.depotHead;
|
||||
|
||||
import com.jsh.erp.service.ResourceInfo;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author jishenghua qq752718920 2018-10-7 15:26:27
|
||||
*/
|
||||
@ResourceInfo(value = "depotHead", type = 85)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface DepotHeadResource {
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
package com.jsh.erp.service.depotHead;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.DepotHead;
|
||||
import com.jsh.erp.datasource.entities.DepotHeadExample;
|
||||
import com.jsh.erp.datasource.entities.User;
|
||||
import com.jsh.erp.datasource.mappers.DepotHeadMapper;
|
||||
import com.jsh.erp.datasource.vo.DepotHeadVo4InDetail;
|
||||
import com.jsh.erp.datasource.vo.DepotHeadVo4InOutMCount;
|
||||
import com.jsh.erp.datasource.vo.DepotHeadVo4List;
|
||||
import com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class DepotHeadService {
|
||||
private Logger logger = LoggerFactory.getLogger(DepotHeadService.class);
|
||||
|
||||
@Resource
|
||||
private DepotHeadMapper depotHeadMapper;
|
||||
|
||||
public DepotHead getDepotHead(long id) {
|
||||
return depotHeadMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<DepotHead> getDepotHead() {
|
||||
DepotHeadExample example = new DepotHeadExample();
|
||||
return depotHeadMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<DepotHeadVo4List> select(String type, String subType, String number, String beginTime, String endTime, String dhIds, int offset, int rows) {
|
||||
List<DepotHeadVo4List> resList = new ArrayList<DepotHeadVo4List>();
|
||||
List<DepotHeadVo4List> list = depotHeadMapper.selectByConditionDepotHead(type, subType, number, beginTime, endTime, dhIds, offset, rows);
|
||||
if (null != list) {
|
||||
for (DepotHeadVo4List dh : list) {
|
||||
if(dh.getOthermoneylist() != null) {
|
||||
String otherMoneyListStr = dh.getOthermoneylist().replace("[", "").replace("]", "").replaceAll("\"", "");
|
||||
dh.setOthermoneylist(otherMoneyListStr);
|
||||
}
|
||||
if(dh.getOthermoneyitem() != null) {
|
||||
String otherMoneyItemStr = dh.getOthermoneyitem().replace("[", "").replace("]", "").replaceAll("\"", "");
|
||||
dh.setOthermoneyitem(otherMoneyItemStr);
|
||||
}
|
||||
if(dh.getChangeamount() != null) {
|
||||
dh.setChangeamount(Math.abs(dh.getChangeamount()));
|
||||
}
|
||||
if(dh.getTotalprice() != null) {
|
||||
dh.setTotalprice(Math.abs(dh.getTotalprice()));
|
||||
}
|
||||
dh.setMaterialsList(findMaterialsListByHeaderId(dh.getId()));
|
||||
resList.add(dh);
|
||||
}
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int countDepotHead(String type, String subType, String number, String beginTime, String endTime, String dhIds) {
|
||||
return depotHeadMapper.countsByDepotHead(type, subType, number, beginTime, endTime, dhIds);
|
||||
}
|
||||
|
||||
public int insertDepotHead(String beanJson, HttpServletRequest request) {
|
||||
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
|
||||
//判断用户是否已经登录过,登录过不再处理
|
||||
Object userInfo = request.getSession().getAttribute("user");
|
||||
if (userInfo != null) {
|
||||
User sessionUser = (User) userInfo;
|
||||
String uName = sessionUser.getUsername();
|
||||
depotHead.setOperpersonname(uName);
|
||||
}
|
||||
depotHead.setCreatetime(new Timestamp(System.currentTimeMillis()));
|
||||
depotHead.setStatus(false);
|
||||
return depotHeadMapper.insertSelective(depotHead);
|
||||
}
|
||||
|
||||
public int updateDepotHead(String beanJson, Long id) {
|
||||
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
|
||||
depotHead.setId(id);
|
||||
return depotHeadMapper.updateByPrimaryKeySelective(depotHead);
|
||||
}
|
||||
|
||||
public int deleteDepotHead(Long id) {
|
||||
return depotHeadMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int batchDeleteDepotHead(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
DepotHeadExample example = new DepotHeadExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return depotHeadMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
DepotHeadExample example = new DepotHeadExample();
|
||||
example.createCriteria().andIdNotEqualTo(id);
|
||||
List<DepotHead> list = depotHeadMapper.selectByExample(example);
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public int batchSetStatus(Boolean status, String depotHeadIDs) {
|
||||
List<Long> ids = StringUtil.strToLongList(depotHeadIDs);
|
||||
DepotHead depotHead = new DepotHead();
|
||||
depotHead.setStatus(status);
|
||||
DepotHeadExample example = new DepotHeadExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
return depotHeadMapper.updateByExampleSelective(depotHead, example);
|
||||
}
|
||||
|
||||
public String buildNumber(String type, String subType, String beginTime, String endTime) {
|
||||
String newNumber = "0001"; //新编号
|
||||
try {
|
||||
DepotHeadExample example = new DepotHeadExample();
|
||||
example.createCriteria().andTypeEqualTo(type).andSubtypeEqualTo(subType)
|
||||
.andOpertimeGreaterThanOrEqualTo(StringUtil.getDateByString(beginTime,null))
|
||||
.andOpertimeLessThanOrEqualTo(StringUtil.getDateByString(endTime,null));
|
||||
example.setOrderByClause("Id desc");
|
||||
List<DepotHead> dataList = depotHeadMapper.selectByExample(example);
|
||||
//存放数据json数组
|
||||
if (null != dataList && dataList.size() > 0) {
|
||||
DepotHead depotHead = dataList.get(0);
|
||||
if (depotHead != null) {
|
||||
String number = depotHead.getDefaultnumber(); //最大的单据编号
|
||||
if (number != null) {
|
||||
Integer lastNumber = Integer.parseInt(number.substring(12, 16)); //末四尾
|
||||
lastNumber = lastNumber + 1;
|
||||
Integer nLen = lastNumber.toString().length();
|
||||
if (nLen == 1) {
|
||||
newNumber = "000" + lastNumber.toString();
|
||||
} else if (nLen == 2) {
|
||||
newNumber = "00" + lastNumber.toString();
|
||||
} else if (nLen == 3) {
|
||||
newNumber = "0" + lastNumber.toString();
|
||||
} else if (nLen == 4) {
|
||||
newNumber = lastNumber.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (DataAccessException e) {
|
||||
logger.error(">>>>>>>>>>>>>>>>>>>单据编号生成异常", e);
|
||||
}
|
||||
return newNumber;
|
||||
}
|
||||
|
||||
public Long getMaxId() {
|
||||
return depotHeadMapper.getMaxId();
|
||||
}
|
||||
|
||||
public String findMaterialsListByHeaderId(Long id) {
|
||||
String allReturn = depotHeadMapper.findMaterialsListByHeaderId(id);
|
||||
return allReturn;
|
||||
}
|
||||
|
||||
public List<DepotHead> findByMonth(String monthTime) {
|
||||
DepotHeadExample example = new DepotHeadExample();
|
||||
monthTime = monthTime + "-31 00:00:00";
|
||||
Date month = StringUtil.getDateByString(monthTime, null);
|
||||
example.createCriteria().andOpertimeLessThanOrEqualTo(month);
|
||||
return depotHeadMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<DepotHead> getDepotHeadGiftOut(String projectId) {
|
||||
DepotHeadExample example = new DepotHeadExample();
|
||||
if (projectId != null) {
|
||||
example.createCriteria().andProjectidEqualTo(Long.parseLong(projectId));
|
||||
}
|
||||
return depotHeadMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<DepotHeadVo4InDetail> findByAll(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId, Integer offset, Integer rows) {
|
||||
return depotHeadMapper.findByAll(beginTime, endTime, type, pid, dids, oId, offset, rows);
|
||||
}
|
||||
|
||||
public int findByAllCount(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId) {
|
||||
return depotHeadMapper.findByAllCount(beginTime, endTime, type, pid, dids, oId);
|
||||
}
|
||||
|
||||
public List<DepotHeadVo4InOutMCount> findInOutMaterialCount(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId, Integer offset, Integer rows) {
|
||||
return depotHeadMapper.findInOutMaterialCount(beginTime, endTime, type, pid, dids, oId, offset, rows);
|
||||
}
|
||||
|
||||
public int findInOutMaterialCountTotal(String beginTime, String endTime, String type, Integer pid, String dids, Integer oId) {
|
||||
return depotHeadMapper.findInOutMaterialCountTotal(beginTime, endTime, type, pid, dids, oId);
|
||||
}
|
||||
|
||||
public List<DepotHeadVo4StatementAccount> findStatementAccount(String beginTime, String endTime, Integer organId, String supType, Integer offset, Integer rows) {
|
||||
return depotHeadMapper.findStatementAccount(beginTime, endTime, organId, supType, offset, rows);
|
||||
}
|
||||
|
||||
public int findStatementAccountCount(String beginTime, String endTime, Integer organId, String supType) {
|
||||
return depotHeadMapper.findStatementAccountCount(beginTime, endTime, organId, supType);
|
||||
}
|
||||
|
||||
public Double findAllMoney(Integer supplierId, String type, String subType, String mode, String endTime) {
|
||||
String modeName = "";
|
||||
if (mode.equals("实际")) {
|
||||
modeName = "ChangeAmount";
|
||||
} else if (mode.equals("合计")) {
|
||||
modeName = "DiscountLastMoney";
|
||||
}
|
||||
return depotHeadMapper.findAllMoney(supplierId, type, subType, modeName, endTime);
|
||||
}
|
||||
|
||||
public List<DepotHeadVo4List> getDetailByNumber(String number) {
|
||||
List<DepotHeadVo4List> resList = new ArrayList<DepotHeadVo4List>();
|
||||
List<DepotHeadVo4List> list = depotHeadMapper.getDetailByNumber(number);
|
||||
if (null != list) {
|
||||
for (DepotHeadVo4List dh : list) {
|
||||
if(dh.getOthermoneylist() != null) {
|
||||
String otherMoneyListStr = dh.getOthermoneylist().replace("[", "").replace("]", "").replaceAll("\"", "");
|
||||
dh.setOthermoneylist(otherMoneyListStr);
|
||||
}
|
||||
if(dh.getOthermoneyitem() != null) {
|
||||
String otherMoneyItemStr = dh.getOthermoneyitem().replace("[", "").replace("]", "").replaceAll("\"", "");
|
||||
dh.setOthermoneyitem(otherMoneyItemStr);
|
||||
}
|
||||
if(dh.getChangeamount() != null) {
|
||||
dh.setChangeamount(Math.abs(dh.getChangeamount()));
|
||||
}
|
||||
if(dh.getTotalprice() != null) {
|
||||
dh.setTotalprice(Math.abs(dh.getTotalprice()));
|
||||
}
|
||||
dh.setMaterialsList(findMaterialsListByHeaderId(dh.getId()));
|
||||
resList.add(dh);
|
||||
}
|
||||
}
|
||||
return resList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.jsh.erp.service.depotItem;
|
||||
|
||||
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 = "depotItem_component")
|
||||
@DepotItemResource
|
||||
public class DepotItemComponent implements ICommonQuery {
|
||||
|
||||
@Resource
|
||||
private DepotItemService depotItemService;
|
||||
|
||||
@Override
|
||||
public Object selectOne(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map) {
|
||||
return getDepotItemList(map);
|
||||
}
|
||||
|
||||
private List<?> getDepotItemList(Map<String, String> map) {
|
||||
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 depotItemService.select(name, type, remark, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int counts(Map<String, String> map) {
|
||||
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 depotItemService.countDepotItem(name, type, remark);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(String beanJson, HttpServletRequest request) {
|
||||
return depotItemService.insertDepotItem(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return depotItemService.updateDepotItem(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return depotItemService.deleteDepotItem(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return depotItemService.batchDeleteDepotItem(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return depotItemService.checkIsNameExist(id, name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.jsh.erp.service.depotItem;
|
||||
|
||||
import com.jsh.erp.service.ResourceInfo;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author jishenghua qq752718920 2018-10-7 15:26:27
|
||||
*/
|
||||
@ResourceInfo(value = "depotItem", type = 90)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface DepotItemResource {
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package com.jsh.erp.service.depotItem;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.*;
|
||||
import com.jsh.erp.datasource.mappers.DepotItemMapper;
|
||||
import com.jsh.erp.utils.QueryUtils;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class DepotItemService {
|
||||
private Logger logger = LoggerFactory.getLogger(DepotItemService.class);
|
||||
|
||||
private final static String TYPE = "入库";
|
||||
private final static String SUM_TYPE = "Number";
|
||||
private final static String IN = "in";
|
||||
private final static String OUT = "out";
|
||||
|
||||
@Resource
|
||||
private DepotItemMapper depotItemMapper;
|
||||
|
||||
public DepotItem getDepotItem(long id) {
|
||||
return depotItemMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<DepotItem> getDepotItem() {
|
||||
DepotItemExample example = new DepotItemExample();
|
||||
return depotItemMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<DepotItem> select(String name, Integer type, String remark, int offset, int rows) {
|
||||
return depotItemMapper.selectByConditionDepotItem(name, type, remark, offset, rows);
|
||||
}
|
||||
|
||||
public int countDepotItem(String name, Integer type, String remark) {
|
||||
return depotItemMapper.countsByDepotItem(name, type, remark);
|
||||
}
|
||||
|
||||
public int insertDepotItem(String beanJson, HttpServletRequest request) {
|
||||
DepotItem depotItem = JSONObject.parseObject(beanJson, DepotItem.class);
|
||||
return depotItemMapper.insertSelective(depotItem);
|
||||
}
|
||||
|
||||
public int updateDepotItem(String beanJson, Long id) {
|
||||
DepotItem depotItem = JSONObject.parseObject(beanJson, DepotItem.class);
|
||||
depotItem.setId(id);
|
||||
return depotItemMapper.updateByPrimaryKeySelective(depotItem);
|
||||
}
|
||||
|
||||
public int deleteDepotItem(Long id) {
|
||||
return depotItemMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int batchDeleteDepotItem(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
DepotItemExample example = new DepotItemExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return depotItemMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
DepotItemExample example = new DepotItemExample();
|
||||
example.createCriteria().andIdNotEqualTo(id);
|
||||
List<DepotItem> list = depotItemMapper.selectByExample(example);
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public List<DepotItemVo4HeaderId> getHeaderIdByMaterial(String materialParam, String depotIds) {
|
||||
return depotItemMapper.getHeaderIdByMaterial(materialParam, depotIds);
|
||||
}
|
||||
|
||||
public List<DepotItemVo4DetailByTypeAndMId> findDetailByTypeAndMaterialIdList(Map<String, String> map) {
|
||||
String mIdStr = map.get("mId");
|
||||
Long mId = null;
|
||||
if(!StringUtil.isEmpty(mIdStr)) {
|
||||
mId = Long.parseLong(mIdStr);
|
||||
}
|
||||
return depotItemMapper.findDetailByTypeAndMaterialIdList(mId, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
public int findDetailByTypeAndMaterialIdCounts(Map<String, String> map) {
|
||||
String mIdStr = map.get("mId");
|
||||
Long mId = null;
|
||||
if(!StringUtil.isEmpty(mIdStr)) {
|
||||
mId = Long.parseLong(mIdStr);
|
||||
}
|
||||
return depotItemMapper.findDetailByTypeAndMaterialIdCounts(mId);
|
||||
}
|
||||
|
||||
public List<DepotItemVo4Material> findStockNumByMaterialIdList(Map<String, String> map) {
|
||||
String mIdStr = map.get("mId");
|
||||
Long mId = null;
|
||||
if(!StringUtil.isEmpty(mIdStr)) {
|
||||
mId = Long.parseLong(mIdStr);
|
||||
}
|
||||
String monthTime = map.get("monthTime");
|
||||
return depotItemMapper.findStockNumByMaterialIdList(mId, monthTime, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
public int findStockNumByMaterialIdCounts(Map<String, String> map) {
|
||||
String mIdStr = map.get("mId");
|
||||
Long mId = null;
|
||||
if(!StringUtil.isEmpty(mIdStr)) {
|
||||
mId = Long.parseLong(mIdStr);
|
||||
}
|
||||
String monthTime = map.get("monthTime");
|
||||
return depotItemMapper.findStockNumByMaterialIdCounts(mId, monthTime);
|
||||
}
|
||||
|
||||
public int insertDepotItemWithObj(DepotItem depotItem) {
|
||||
return depotItemMapper.insertSelective(depotItem);
|
||||
}
|
||||
|
||||
public int updateDepotItemWithObj(DepotItem depotItem) {
|
||||
return depotItemMapper.updateByPrimaryKeySelective(depotItem);
|
||||
}
|
||||
|
||||
public int findByTypeAndMaterialId(String type, Long mId) {
|
||||
if(type.equals(TYPE)) {
|
||||
return depotItemMapper.findByTypeAndMaterialIdIn(mId);
|
||||
} else {
|
||||
return depotItemMapper.findByTypeAndMaterialIdOut(mId);
|
||||
}
|
||||
}
|
||||
|
||||
public List<DepotItemVo4WithInfoEx> getDetailList(Long headerId) {
|
||||
return depotItemMapper.getDetailList(headerId);
|
||||
}
|
||||
|
||||
public List<DepotItemVo4WithInfoEx> findByAll(String headIds, String materialIds, Integer offset, Integer rows) {
|
||||
return depotItemMapper.findByAll(headIds, materialIds, offset, rows);
|
||||
}
|
||||
|
||||
public int findByAllCount(String headIds, String materialIds) {
|
||||
return depotItemMapper.findByAllCount(headIds, materialIds);
|
||||
}
|
||||
|
||||
public Double findByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) {
|
||||
if (TYPE.equals(type)) {
|
||||
if (isPrev) {
|
||||
return depotItemMapper.findByTypeInIsPrev(ProjectId, MId, MonthTime);
|
||||
} else {
|
||||
return depotItemMapper.findByTypeInIsNotPrev(ProjectId, MId, MonthTime);
|
||||
}
|
||||
} else {
|
||||
if (isPrev) {
|
||||
return depotItemMapper.findByTypeOutIsPrev(ProjectId, MId, MonthTime);
|
||||
} else {
|
||||
return depotItemMapper.findByTypeOutIsNotPrev(ProjectId, MId, MonthTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Double findPriceByType(String type, Integer ProjectId, Long MId, String MonthTime, Boolean isPrev) {
|
||||
if (TYPE.equals(type)) {
|
||||
if (isPrev) {
|
||||
return depotItemMapper.findPriceByTypeInIsPrev(ProjectId, MId, MonthTime);
|
||||
} else {
|
||||
return depotItemMapper.findPriceByTypeInIsNotPrev(ProjectId, MId, MonthTime);
|
||||
}
|
||||
} else {
|
||||
if (isPrev) {
|
||||
return depotItemMapper.findPriceByTypeOutIsPrev(ProjectId, MId, MonthTime);
|
||||
} else {
|
||||
return depotItemMapper.findPriceByTypeOutIsNotPrev(ProjectId, MId, MonthTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Double buyOrSale(String type, String subType, Long MId, String MonthTime, String sumType) {
|
||||
if (SUM_TYPE.equals(sumType)) {
|
||||
return depotItemMapper.buyOrSaleNumber(type, subType, MId, MonthTime, sumType);
|
||||
} else {
|
||||
return depotItemMapper.buyOrSalePrice(type, subType, MId, MonthTime, sumType);
|
||||
}
|
||||
}
|
||||
|
||||
public Double findGiftByType(String subType, Integer ProjectId, Long MId, String type) {
|
||||
if (IN.equals(type)) {
|
||||
return depotItemMapper.findGiftByTypeIn(subType, ProjectId, MId);
|
||||
} else {
|
||||
return depotItemMapper.findGiftByTypeOut(subType, ProjectId, MId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.jsh.erp.service.functions;
|
||||
|
||||
import com.jsh.erp.service.ICommonQuery;
|
||||
import com.jsh.erp.service.app.AppResource;
|
||||
import com.jsh.erp.service.functions.FunctionsService;
|
||||
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 = "functions_component")
|
||||
@FunctionsResource
|
||||
public class FunctionsComponent implements ICommonQuery {
|
||||
|
||||
@Resource
|
||||
private FunctionsService functionsService;
|
||||
|
||||
@Override
|
||||
public Object selectOne(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map) {
|
||||
return getFunctionsList(map);
|
||||
}
|
||||
|
||||
private List<?> getFunctionsList(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
String type = StringUtil.getInfo(search, "type");
|
||||
String order = QueryUtils.order(map);
|
||||
return functionsService.select(name, type, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int counts(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
String type = StringUtil.getInfo(search, "type");
|
||||
return functionsService.countFunctions(name, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(String beanJson, HttpServletRequest request) {
|
||||
return functionsService.insertFunctions(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return functionsService.updateFunctions(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return functionsService.deleteFunctions(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return functionsService.batchDeleteFunctions(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return functionsService.checkIsNameExist(id, name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.jsh.erp.service.functions;
|
||||
|
||||
import com.jsh.erp.service.ResourceInfo;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author jishenghua qq752718920 2018-10-7 15:26:27
|
||||
*/
|
||||
@ResourceInfo(value = "functions", type = 30)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface FunctionsResource {
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.jsh.erp.service.functions;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.Functions;
|
||||
import com.jsh.erp.datasource.entities.FunctionsExample;
|
||||
import com.jsh.erp.datasource.mappers.FunctionsMapper;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class FunctionsService {
|
||||
private Logger logger = LoggerFactory.getLogger(FunctionsService.class);
|
||||
|
||||
@Resource
|
||||
private FunctionsMapper functionsMapper;
|
||||
|
||||
public Functions getFunctions(long id) {
|
||||
return functionsMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<Functions> getFunctions() {
|
||||
FunctionsExample example = new FunctionsExample();
|
||||
return functionsMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<Functions> select(String name, String type, int offset, int rows) {
|
||||
return functionsMapper.selectByConditionFunctions(name, type, offset, rows);
|
||||
}
|
||||
|
||||
public int countFunctions(String name, String type) {
|
||||
return functionsMapper.countsByFunctions(name, type);
|
||||
}
|
||||
|
||||
public int insertFunctions(String beanJson, HttpServletRequest request) {
|
||||
Functions depot = JSONObject.parseObject(beanJson, Functions.class);
|
||||
return functionsMapper.insertSelective(depot);
|
||||
}
|
||||
|
||||
public int updateFunctions(String beanJson, Long id) {
|
||||
Functions depot = JSONObject.parseObject(beanJson, Functions.class);
|
||||
depot.setId(id);
|
||||
return functionsMapper.updateByPrimaryKeySelective(depot);
|
||||
}
|
||||
|
||||
public int deleteFunctions(Long id) {
|
||||
return functionsMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int batchDeleteFunctions(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
FunctionsExample example = new FunctionsExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return functionsMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
FunctionsExample example = new FunctionsExample();
|
||||
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name);
|
||||
List<Functions> list = functionsMapper.selectByExample(example);
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public List<Functions> getRoleFunctions(String pNumber) {
|
||||
FunctionsExample example = new FunctionsExample();
|
||||
example.createCriteria().andEnabledEqualTo(true).andPnumberEqualTo(pNumber);
|
||||
example.setOrderByClause("Sort");
|
||||
List<Functions> list = functionsMapper.selectByExample(example);
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<Functions> findRoleFunctions(String pnumber){
|
||||
FunctionsExample example = new FunctionsExample();
|
||||
example.createCriteria().andEnabledEqualTo(true).andPnumberEqualTo(pnumber);
|
||||
example.setOrderByClause("Sort");
|
||||
List<Functions> list = functionsMapper.selectByExample(example);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.jsh.erp.service.inOutItem;
|
||||
|
||||
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(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map) {
|
||||
return getFunctionsList(map);
|
||||
}
|
||||
|
||||
private List<?> getFunctionsList(Map<String, String> map) {
|
||||
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 int counts(Map<String, String> map) {
|
||||
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(String beanJson, HttpServletRequest request) {
|
||||
return inOutItemService.insertInOutItem(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return inOutItemService.updateInOutItem(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return inOutItemService.deleteInOutItem(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return inOutItemService.batchDeleteInOutItem(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return inOutItemService.checkIsNameExist(id, name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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", type = 35)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface InOutItemResource {
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.jsh.erp.service.inOutItem;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.InOutItem;
|
||||
import com.jsh.erp.datasource.entities.InOutItemExample;
|
||||
import com.jsh.erp.datasource.mappers.InOutItemMapper;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class InOutItemService {
|
||||
private Logger logger = LoggerFactory.getLogger(InOutItemService.class);
|
||||
|
||||
@Resource
|
||||
private InOutItemMapper inOutItemMapper;
|
||||
|
||||
public InOutItem getInOutItem(long id) {
|
||||
return inOutItemMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<InOutItem> getInOutItem() {
|
||||
InOutItemExample example = new InOutItemExample();
|
||||
return inOutItemMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<InOutItem> select(String name, String type, String remark, int offset, int rows) {
|
||||
return inOutItemMapper.selectByConditionInOutItem(name, type, remark, offset, rows);
|
||||
}
|
||||
|
||||
public int countInOutItem(String name, String type, String remark) {
|
||||
return inOutItemMapper.countsByInOutItem(name, type, remark);
|
||||
}
|
||||
|
||||
public int insertInOutItem(String beanJson, HttpServletRequest request) {
|
||||
InOutItem depot = JSONObject.parseObject(beanJson, InOutItem.class);
|
||||
return inOutItemMapper.insertSelective(depot);
|
||||
}
|
||||
|
||||
public int updateInOutItem(String beanJson, Long id) {
|
||||
InOutItem depot = JSONObject.parseObject(beanJson, InOutItem.class);
|
||||
depot.setId(id);
|
||||
return inOutItemMapper.updateByPrimaryKeySelective(depot);
|
||||
}
|
||||
|
||||
public int deleteInOutItem(Long id) {
|
||||
return inOutItemMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int batchDeleteInOutItem(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
InOutItemExample example = new InOutItemExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return inOutItemMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
InOutItemExample example = new InOutItemExample();
|
||||
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name);
|
||||
List<InOutItem> list = inOutItemMapper.selectByExample(example);
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public List<InOutItem> findBySelect(String type) {
|
||||
InOutItemExample example = new InOutItemExample();
|
||||
if (type.equals("in")) {
|
||||
example.createCriteria().andTypeEqualTo("收入");
|
||||
} else if (type.equals("out")) {
|
||||
example.createCriteria().andTypeEqualTo("支出");
|
||||
}
|
||||
example.setOrderByClause("id desc");
|
||||
return inOutItemMapper.selectByExample(example);
|
||||
}
|
||||
}
|
||||
83
src/main/java/com/jsh/erp/service/log/LogComponent.java
Normal file
83
src/main/java/com/jsh/erp/service/log/LogComponent.java
Normal file
@@ -0,0 +1,83 @@
|
||||
package com.jsh.erp.service.log;
|
||||
|
||||
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 = "log_component")
|
||||
@LogResource
|
||||
public class LogComponent implements ICommonQuery {
|
||||
|
||||
@Resource
|
||||
private LogService logService;
|
||||
|
||||
@Override
|
||||
public Object selectOne(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map) {
|
||||
return getUserList(map);
|
||||
}
|
||||
|
||||
private List<?> getUserList(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String operation = StringUtil.getInfo(search, "operation");
|
||||
Integer usernameID = StringUtil.parseInteger(StringUtil.getInfo(search, "usernameID"));
|
||||
String clientIp = StringUtil.getInfo(search, "clientIp");
|
||||
Integer status = StringUtil.parseInteger(StringUtil.getInfo(search, "status"));
|
||||
String beginTime = StringUtil.getInfo(search, "beginTime");
|
||||
String endTime = StringUtil.getInfo(search, "endTime");
|
||||
String contentdetails = StringUtil.getInfo(search, "contentdetails");
|
||||
String order = QueryUtils.order(map);
|
||||
return logService.select(operation, usernameID, clientIp, status, beginTime, endTime, contentdetails,
|
||||
QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int counts(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String operation = StringUtil.getInfo(search, "operation");
|
||||
Integer usernameID = StringUtil.parseInteger(StringUtil.getInfo(search, "usernameID"));
|
||||
String clientIp = StringUtil.getInfo(search, "clientIp");
|
||||
Integer status = StringUtil.parseInteger(StringUtil.getInfo(search, "status"));
|
||||
String beginTime = StringUtil.getInfo(search, "beginTime");
|
||||
String endTime = StringUtil.getInfo(search, "endTime");
|
||||
String contentdetails = StringUtil.getInfo(search, "contentdetails");
|
||||
return logService.countLog(operation, usernameID, clientIp, status, beginTime, endTime, contentdetails);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(String beanJson, HttpServletRequest request) {
|
||||
return logService.insertLog(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return logService.updateLog(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return logService.deleteLog(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return logService.batchDeleteLog(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
15
src/main/java/com/jsh/erp/service/log/LogResource.java
Normal file
15
src/main/java/com/jsh/erp/service/log/LogResource.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.jsh.erp.service.log;
|
||||
|
||||
import com.jsh.erp.service.ResourceInfo;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author jishenghua qq752718920 2018-10-7 15:26:27
|
||||
*/
|
||||
@ResourceInfo(value = "log", type = 25)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface LogResource {
|
||||
}
|
||||
68
src/main/java/com/jsh/erp/service/log/LogService.java
Normal file
68
src/main/java/com/jsh/erp/service/log/LogService.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package com.jsh.erp.service.log;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.Log;
|
||||
import com.jsh.erp.datasource.entities.LogExample;
|
||||
import com.jsh.erp.datasource.mappers.LogMapper;
|
||||
import com.jsh.erp.utils.ExceptionCodeConstants;
|
||||
import com.jsh.erp.utils.JshException;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import com.jsh.erp.utils.Tools;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class LogService {
|
||||
private Logger logger = LoggerFactory.getLogger(LogService.class);
|
||||
@Resource
|
||||
private LogMapper logMapper;
|
||||
|
||||
public Log getLog(long id) {
|
||||
return logMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<Log> getLog() {
|
||||
LogExample example = new LogExample();
|
||||
return logMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<Log> select(String operation, Integer usernameID, String clientIp, Integer status, String beginTime, String endTime,
|
||||
String contentdetails, int offset, int rows) {
|
||||
return logMapper.selectByConditionLog(operation, usernameID, clientIp, status, beginTime, endTime,
|
||||
contentdetails, offset, rows);
|
||||
}
|
||||
|
||||
public int countLog(String operation, Integer usernameID, String clientIp, Integer status, String beginTime, String endTime,
|
||||
String contentdetails) {
|
||||
return logMapper.countsByLog(operation, usernameID, clientIp, status, beginTime, endTime, contentdetails);
|
||||
}
|
||||
|
||||
public int insertLog(String beanJson, HttpServletRequest request) {
|
||||
Log log = JSONObject.parseObject(beanJson, Log.class);
|
||||
return logMapper.insertSelective(log);
|
||||
}
|
||||
|
||||
public int updateLog(String beanJson, Long id) {
|
||||
Log log = JSONObject.parseObject(beanJson, Log.class);
|
||||
log.setId(id);
|
||||
return logMapper.updateByPrimaryKeySelective(log);
|
||||
}
|
||||
|
||||
public int deleteLog(Long id) {
|
||||
return logMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int batchDeleteLog(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
LogExample example = new LogExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return logMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.jsh.erp.service.material;
|
||||
|
||||
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 = "material_component")
|
||||
@MaterialResource
|
||||
public class MaterialComponent implements ICommonQuery {
|
||||
|
||||
@Resource
|
||||
private MaterialService materialService;
|
||||
|
||||
@Override
|
||||
public Object selectOne(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map) {
|
||||
return getMaterialList(map);
|
||||
}
|
||||
|
||||
private List<?> getMaterialList(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
String model = StringUtil.getInfo(search, "model");
|
||||
String order = QueryUtils.order(map);
|
||||
return materialService.select(name, model, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int counts(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
String model = StringUtil.getInfo(search, "model");
|
||||
return materialService.countMaterial(name, model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(String beanJson, HttpServletRequest request) {
|
||||
return materialService.insertMaterial(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return materialService.updateMaterial(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return materialService.deleteMaterial(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return materialService.batchDeleteMaterial(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return materialService.checkIsNameExist(id, name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.jsh.erp.service.material;
|
||||
|
||||
import com.jsh.erp.service.ResourceInfo;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author jishenghua qq752718920 2018-10-7 15:26:27
|
||||
*/
|
||||
@ResourceInfo(value = "material", type = 80)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface MaterialResource {
|
||||
}
|
||||
117
src/main/java/com/jsh/erp/service/material/MaterialService.java
Normal file
117
src/main/java/com/jsh/erp/service/material/MaterialService.java
Normal file
@@ -0,0 +1,117 @@
|
||||
package com.jsh.erp.service.material;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.Material;
|
||||
import com.jsh.erp.datasource.entities.MaterialExample;
|
||||
import com.jsh.erp.datasource.entities.MaterialVo4Unit;
|
||||
import com.jsh.erp.datasource.mappers.MaterialMapper;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class MaterialService {
|
||||
private Logger logger = LoggerFactory.getLogger(MaterialService.class);
|
||||
|
||||
@Resource
|
||||
private MaterialMapper materialMapper;
|
||||
|
||||
public Material getMaterial(long id) {
|
||||
return materialMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<Material> getMaterial() {
|
||||
MaterialExample example = new MaterialExample();
|
||||
return materialMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<Material> select(String name, String model, int offset, int rows) {
|
||||
return materialMapper.selectByConditionMaterial(name, model, offset, rows);
|
||||
}
|
||||
|
||||
public int countMaterial(String name, String model) {
|
||||
return materialMapper.countsByMaterial(name, model);
|
||||
}
|
||||
|
||||
public int insertMaterial(String beanJson, HttpServletRequest request) {
|
||||
Material material = JSONObject.parseObject(beanJson, Material.class);
|
||||
return materialMapper.insertSelective(material);
|
||||
}
|
||||
|
||||
public int updateMaterial(String beanJson, Long id) {
|
||||
Material material = JSONObject.parseObject(beanJson, Material.class);
|
||||
material.setId(id);
|
||||
return materialMapper.updateByPrimaryKeySelective(material);
|
||||
}
|
||||
|
||||
public int deleteMaterial(Long id) {
|
||||
return materialMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int batchDeleteMaterial(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
MaterialExample example = new MaterialExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return materialMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
MaterialExample example = new MaterialExample();
|
||||
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name);
|
||||
List<Material> list = materialMapper.selectByExample(example);
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public int checkIsExist(Long id, String name, String model, String color, String standard, String mfrs,
|
||||
String otherField1, String otherField2, String otherField3, String unit, Long unitId) {
|
||||
MaterialExample example = new MaterialExample();
|
||||
if (id > 0) {
|
||||
example.createCriteria().andIdNotEqualTo(id);
|
||||
}
|
||||
example.createCriteria().andNameEqualTo(name).andModelEqualTo(model).andColorEqualTo(color)
|
||||
.andStandardEqualTo(standard).andMfrsEqualTo(mfrs)
|
||||
.andOtherfield1EqualTo(otherField1).andOtherfield2EqualTo(otherField2).andOtherfield2EqualTo(otherField3);
|
||||
if (unit !=null) {
|
||||
example.createCriteria().andUnitEqualTo(unit);
|
||||
}
|
||||
if (unitId !=null) {
|
||||
example.createCriteria().andUnitidEqualTo(unitId);
|
||||
}
|
||||
List<Material> list = materialMapper.selectByExample(example);
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public int batchSetEnable(Boolean enabled, String materialIDs) {
|
||||
List<Long> ids = StringUtil.strToLongList(materialIDs);
|
||||
Material material = new Material();
|
||||
material.setEnabled(enabled);
|
||||
MaterialExample example = new MaterialExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
return materialMapper.updateByExampleSelective(material, example);
|
||||
}
|
||||
|
||||
public String findUnitName(Long mId){
|
||||
return materialMapper.findUnitName(mId);
|
||||
}
|
||||
|
||||
public List<MaterialVo4Unit> findById(Long id){
|
||||
return materialMapper.findById(id);
|
||||
}
|
||||
|
||||
public List<MaterialVo4Unit> findBySelect(){
|
||||
return materialMapper.findBySelect();
|
||||
}
|
||||
|
||||
public List<Material> findByOrder(){
|
||||
MaterialExample example = new MaterialExample();
|
||||
example.setOrderByClause("Name,Model asc");
|
||||
return materialMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.jsh.erp.service.materialCategory;
|
||||
|
||||
import com.jsh.erp.service.ICommonQuery;
|
||||
import com.jsh.erp.service.materialProperty.MaterialPropertyResource;
|
||||
import com.jsh.erp.service.materialProperty.MaterialPropertyService;
|
||||
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 = "materialCategory_component")
|
||||
@MaterialCategoryResource
|
||||
public class MaterialCategoryComponent implements ICommonQuery {
|
||||
|
||||
@Resource
|
||||
private MaterialCategoryService materialCategoryService;
|
||||
|
||||
@Override
|
||||
public Object selectOne(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map) {
|
||||
return getMaterialCategoryList(map);
|
||||
}
|
||||
|
||||
private List<?> getMaterialCategoryList(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
Integer parentId = StringUtil.parseInteger(StringUtil.getInfo(search, "parentId"));
|
||||
String order = QueryUtils.order(map);
|
||||
return materialCategoryService.select(name, parentId, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int counts(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
Integer parentId = StringUtil.parseInteger(StringUtil.getInfo(search, "parentId"));
|
||||
return materialCategoryService.countMaterialCategory(name, parentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(String beanJson, HttpServletRequest request) {
|
||||
return materialCategoryService.insertMaterialCategory(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return materialCategoryService.updateMaterialCategory(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return materialCategoryService.deleteMaterialCategory(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return materialCategoryService.batchDeleteMaterialCategory(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return materialCategoryService.checkIsNameExist(id, name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.jsh.erp.service.materialCategory;
|
||||
|
||||
import com.jsh.erp.service.ResourceInfo;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author jishenghua qq752718920 2018-10-7 15:26:27
|
||||
*/
|
||||
@ResourceInfo(value = "materialCategory", type = 75)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface MaterialCategoryResource {
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.jsh.erp.service.materialCategory;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.MaterialCategory;
|
||||
import com.jsh.erp.datasource.entities.MaterialCategoryExample;
|
||||
import com.jsh.erp.datasource.mappers.MaterialCategoryMapper;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class MaterialCategoryService {
|
||||
private Logger logger = LoggerFactory.getLogger(MaterialCategoryService.class);
|
||||
|
||||
@Resource
|
||||
private MaterialCategoryMapper materialCategoryMapper;
|
||||
|
||||
public MaterialCategory getMaterialCategory(long id) {
|
||||
return materialCategoryMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<MaterialCategory> getMaterialCategory() {
|
||||
MaterialCategoryExample example = new MaterialCategoryExample();
|
||||
return materialCategoryMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<MaterialCategory> getAllList(Long parentId) {
|
||||
MaterialCategoryExample example = new MaterialCategoryExample();
|
||||
example.createCriteria().andParentidEqualTo(parentId);
|
||||
example.setOrderByClause("id");
|
||||
return materialCategoryMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<MaterialCategory> select(String name, Integer parentId, int offset, int rows) {
|
||||
return materialCategoryMapper.selectByConditionMaterialCategory(name, parentId, offset, rows);
|
||||
}
|
||||
|
||||
public int countMaterialCategory(String name, Integer parentId) {
|
||||
return materialCategoryMapper.countsByMaterialCategory(name, parentId);
|
||||
}
|
||||
|
||||
public int insertMaterialCategory(String beanJson, HttpServletRequest request) {
|
||||
MaterialCategory materialCategory = JSONObject.parseObject(beanJson, MaterialCategory.class);
|
||||
return materialCategoryMapper.insertSelective(materialCategory);
|
||||
}
|
||||
|
||||
public int updateMaterialCategory(String beanJson, Long id) {
|
||||
MaterialCategory materialCategory = JSONObject.parseObject(beanJson, MaterialCategory.class);
|
||||
materialCategory.setId(id);
|
||||
return materialCategoryMapper.updateByPrimaryKeySelective(materialCategory);
|
||||
}
|
||||
|
||||
public int deleteMaterialCategory(Long id) {
|
||||
return materialCategoryMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int batchDeleteMaterialCategory(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
MaterialCategoryExample example = new MaterialCategoryExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return materialCategoryMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public List<MaterialCategory> findById(Long id) {
|
||||
MaterialCategoryExample example = new MaterialCategoryExample();
|
||||
example.createCriteria().andIdEqualTo(id);
|
||||
return materialCategoryMapper.selectByExample(example);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.jsh.erp.service.materialProperty;
|
||||
|
||||
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 = "materialProperty_component")
|
||||
@MaterialPropertyResource
|
||||
public class MaterialPropertyComponent implements ICommonQuery {
|
||||
|
||||
@Resource
|
||||
private MaterialPropertyService materialPropertyService;
|
||||
|
||||
@Override
|
||||
public Object selectOne(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map) {
|
||||
return getMaterialPropertyList(map);
|
||||
}
|
||||
|
||||
private List<?> getMaterialPropertyList(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
String order = QueryUtils.order(map);
|
||||
return materialPropertyService.select(name, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int counts(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
return materialPropertyService.countMaterialProperty(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(String beanJson, HttpServletRequest request) {
|
||||
return materialPropertyService.insertMaterialProperty(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return materialPropertyService.updateMaterialProperty(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return materialPropertyService.deleteMaterialProperty(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return materialPropertyService.batchDeleteMaterialProperty(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return materialPropertyService.checkIsNameExist(id, name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.jsh.erp.service.materialProperty;
|
||||
|
||||
import com.jsh.erp.service.ResourceInfo;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author jishenghua qq752718920 2018-10-7 15:26:27
|
||||
*/
|
||||
@ResourceInfo(value = "materialProperty", type = 60)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface MaterialPropertyResource {
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.jsh.erp.service.materialProperty;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.MaterialProperty;
|
||||
import com.jsh.erp.datasource.entities.MaterialPropertyExample;
|
||||
import com.jsh.erp.datasource.mappers.MaterialPropertyMapper;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class MaterialPropertyService {
|
||||
private Logger logger = LoggerFactory.getLogger(MaterialPropertyService.class);
|
||||
|
||||
@Resource
|
||||
private MaterialPropertyMapper materialPropertyMapper;
|
||||
|
||||
public MaterialProperty getMaterialProperty(long id) {
|
||||
return materialPropertyMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<MaterialProperty> getMaterialProperty() {
|
||||
MaterialPropertyExample example = new MaterialPropertyExample();
|
||||
return materialPropertyMapper.selectByExample(example);
|
||||
}
|
||||
public List<MaterialProperty> select(String name, int offset, int rows) {
|
||||
return materialPropertyMapper.selectByConditionMaterialProperty(name, offset, rows);
|
||||
}
|
||||
|
||||
public int countMaterialProperty(String name) {
|
||||
return materialPropertyMapper.countsByMaterialProperty(name);
|
||||
}
|
||||
|
||||
public int insertMaterialProperty(String beanJson, HttpServletRequest request) {
|
||||
MaterialProperty materialProperty = JSONObject.parseObject(beanJson, MaterialProperty.class);
|
||||
return materialPropertyMapper.insertSelective(materialProperty);
|
||||
}
|
||||
|
||||
public int updateMaterialProperty(String beanJson, Long id) {
|
||||
MaterialProperty materialProperty = JSONObject.parseObject(beanJson, MaterialProperty.class);
|
||||
materialProperty.setId(id);
|
||||
return materialPropertyMapper.updateByPrimaryKeySelective(materialProperty);
|
||||
}
|
||||
|
||||
public int deleteMaterialProperty(Long id) {
|
||||
return materialPropertyMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int batchDeleteMaterialProperty(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
MaterialPropertyExample example = new MaterialPropertyExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return materialPropertyMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.jsh.erp.service.person;
|
||||
|
||||
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(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map) {
|
||||
return getPersonList(map);
|
||||
}
|
||||
|
||||
private List<?> getPersonList(Map<String, String> map) {
|
||||
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 int counts(Map<String, String> map) {
|
||||
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(String beanJson, HttpServletRequest request) {
|
||||
return personService.insertPerson(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return personService.updatePerson(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return personService.deletePerson(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return personService.batchDeletePerson(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return personService.checkIsNameExist(id, name);
|
||||
}
|
||||
|
||||
}
|
||||
15
src/main/java/com/jsh/erp/service/person/PersonResource.java
Normal file
15
src/main/java/com/jsh/erp/service/person/PersonResource.java
Normal 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", type = 45)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface PersonResource {
|
||||
}
|
||||
93
src/main/java/com/jsh/erp/service/person/PersonService.java
Normal file
93
src/main/java/com/jsh/erp/service/person/PersonService.java
Normal file
@@ -0,0 +1,93 @@
|
||||
package com.jsh.erp.service.person;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.Person;
|
||||
import com.jsh.erp.datasource.entities.PersonExample;
|
||||
import com.jsh.erp.datasource.mappers.PersonMapper;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class PersonService {
|
||||
private Logger logger = LoggerFactory.getLogger(PersonService.class);
|
||||
|
||||
@Resource
|
||||
private PersonMapper personMapper;
|
||||
|
||||
public Person getPerson(long id) {
|
||||
return personMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<Person> getPerson() {
|
||||
PersonExample example = new PersonExample();
|
||||
return personMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<Person> select(String name, String type, int offset, int rows) {
|
||||
return personMapper.selectByConditionPerson(name, type, offset, rows);
|
||||
}
|
||||
|
||||
public int countPerson(String name, String type) {
|
||||
return personMapper.countsByPerson(name, type);
|
||||
}
|
||||
|
||||
public int insertPerson(String beanJson, HttpServletRequest request) {
|
||||
Person person = JSONObject.parseObject(beanJson, Person.class);
|
||||
return personMapper.insertSelective(person);
|
||||
}
|
||||
|
||||
public int updatePerson(String beanJson, Long id) {
|
||||
Person person = JSONObject.parseObject(beanJson, Person.class);
|
||||
person.setId(id);
|
||||
return personMapper.updateByPrimaryKeySelective(person);
|
||||
}
|
||||
|
||||
public int deletePerson(Long id) {
|
||||
return personMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int batchDeletePerson(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
PersonExample example = new PersonExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return personMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
PersonExample example = new PersonExample();
|
||||
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name);
|
||||
List<Person> list = personMapper.selectByExample(example);
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public String getPersonByIds(String personIDs) {
|
||||
List<Long> ids = StringUtil.strToLongList(personIDs);
|
||||
PersonExample example = new PersonExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
example.setOrderByClause("Id asc");
|
||||
List<Person> list = personMapper.selectByExample(example);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
if (null != list) {
|
||||
for (Person person : list) {
|
||||
sb.append(person.getName() + " ");
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public List<Person> getPersonByType(String type) {
|
||||
PersonExample example = new PersonExample();
|
||||
example.createCriteria().andTypeEqualTo(type);
|
||||
example.setOrderByClause("Id asc");
|
||||
return personMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
71
src/main/java/com/jsh/erp/service/role/RoleComponent.java
Normal file
71
src/main/java/com/jsh/erp/service/role/RoleComponent.java
Normal file
@@ -0,0 +1,71 @@
|
||||
package com.jsh.erp.service.role;
|
||||
|
||||
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 = "role_component")
|
||||
@RoleResource
|
||||
public class RoleComponent implements ICommonQuery {
|
||||
|
||||
@Resource
|
||||
private RoleService roleService;
|
||||
|
||||
@Override
|
||||
public Object selectOne(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map) {
|
||||
return getRoleList(map);
|
||||
}
|
||||
|
||||
private List<?> getRoleList(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
String order = QueryUtils.order(map);
|
||||
String filter = QueryUtils.filter(map);
|
||||
return roleService.select(name, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int counts(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
return roleService.countRole(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(String beanJson, HttpServletRequest request) {
|
||||
return roleService.insertRole(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return roleService.updateRole(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return roleService.deleteRole(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return roleService.batchDeleteRole(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
15
src/main/java/com/jsh/erp/service/role/RoleResource.java
Normal file
15
src/main/java/com/jsh/erp/service/role/RoleResource.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.jsh.erp.service.role;
|
||||
|
||||
import com.jsh.erp.service.ResourceInfo;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author jishenghua qq752718920 2018-10-7 15:26:27
|
||||
*/
|
||||
@ResourceInfo(value = "role", type = 10)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface RoleResource {
|
||||
}
|
||||
71
src/main/java/com/jsh/erp/service/role/RoleService.java
Normal file
71
src/main/java/com/jsh/erp/service/role/RoleService.java
Normal file
@@ -0,0 +1,71 @@
|
||||
package com.jsh.erp.service.role;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.Role;
|
||||
import com.jsh.erp.datasource.entities.RoleExample;
|
||||
import com.jsh.erp.datasource.entities.User;
|
||||
import com.jsh.erp.datasource.entities.UserExample;
|
||||
import com.jsh.erp.datasource.mappers.RoleMapper;
|
||||
import com.jsh.erp.datasource.mappers.UserMapper;
|
||||
import com.jsh.erp.utils.QueryUtils;
|
||||
import com.jsh.erp.utils.RegExpTools;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class RoleService {
|
||||
@Resource
|
||||
private RoleMapper roleMapper;
|
||||
|
||||
public Role getRole(long id) {
|
||||
return roleMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<Role> getRole() {
|
||||
RoleExample example = new RoleExample();
|
||||
return roleMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<Role> select(String name, int offset, int rows) {
|
||||
return roleMapper.selectByConditionRole(name, offset, rows);
|
||||
}
|
||||
|
||||
public int countRole(String name) {
|
||||
return roleMapper.countsByRole(name);
|
||||
}
|
||||
|
||||
public int insertRole(String beanJson, HttpServletRequest request) {
|
||||
Role role = JSONObject.parseObject(beanJson, Role.class);
|
||||
return roleMapper.insertSelective(role);
|
||||
}
|
||||
|
||||
public int updateRole(String beanJson, Long id) {
|
||||
Role role = JSONObject.parseObject(beanJson, Role.class);
|
||||
role.setId(id);
|
||||
return roleMapper.updateByPrimaryKeySelective(role);
|
||||
}
|
||||
|
||||
public int deleteRole(Long id) {
|
||||
return roleMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int batchDeleteRole(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
RoleExample example = new RoleExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return roleMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public List<Role> findUserRole(){
|
||||
RoleExample example = new RoleExample();
|
||||
example.setOrderByClause("Id");
|
||||
List<Role> list = roleMapper.selectByExample(example);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.jsh.erp.service.supplier;
|
||||
|
||||
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 = "supplier_component")
|
||||
@SupplierResource
|
||||
public class SupplierComponent implements ICommonQuery {
|
||||
|
||||
@Resource
|
||||
private SupplierService supplierService;
|
||||
|
||||
@Override
|
||||
public Object selectOne(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map) {
|
||||
return getSupplierList(map);
|
||||
}
|
||||
|
||||
private List<?> getSupplierList(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String supplier = StringUtil.getInfo(search, "supplier");
|
||||
String type = StringUtil.getInfo(search, "type");
|
||||
String phonenum = StringUtil.getInfo(search, "phonenum");
|
||||
String telephone = StringUtil.getInfo(search, "telephone");
|
||||
String description = StringUtil.getInfo(search, "description");
|
||||
String order = QueryUtils.order(map);
|
||||
return supplierService.select(supplier, type, phonenum, telephone, description, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int counts(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String supplier = StringUtil.getInfo(search, "supplier");
|
||||
String type = StringUtil.getInfo(search, "type");
|
||||
String phonenum = StringUtil.getInfo(search, "phonenum");
|
||||
String telephone = StringUtil.getInfo(search, "telephone");
|
||||
String description = StringUtil.getInfo(search, "description");
|
||||
return supplierService.countSupplier(supplier, type, phonenum, telephone, description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(String beanJson, HttpServletRequest request) {
|
||||
return supplierService.insertSupplier(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return supplierService.updateSupplier(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return supplierService.deleteSupplier(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return supplierService.batchDeleteSupplier(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return supplierService.checkIsNameExist(id, name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.jsh.erp.service.supplier;
|
||||
|
||||
import com.jsh.erp.service.ResourceInfo;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author jishenghua qq752718920 2018-10-7 15:26:27
|
||||
*/
|
||||
@ResourceInfo(value = "supplier", type = 70)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface SupplierResource {
|
||||
}
|
||||
102
src/main/java/com/jsh/erp/service/supplier/SupplierService.java
Normal file
102
src/main/java/com/jsh/erp/service/supplier/SupplierService.java
Normal file
@@ -0,0 +1,102 @@
|
||||
package com.jsh.erp.service.supplier;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.Supplier;
|
||||
import com.jsh.erp.datasource.entities.SupplierExample;
|
||||
import com.jsh.erp.datasource.mappers.SupplierMapper;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SupplierService {
|
||||
private Logger logger = LoggerFactory.getLogger(SupplierService.class);
|
||||
|
||||
@Resource
|
||||
private SupplierMapper supplierMapper;
|
||||
|
||||
public Supplier getSupplier(long id) {
|
||||
return supplierMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<Supplier> getSupplier() {
|
||||
SupplierExample example = new SupplierExample();
|
||||
return supplierMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<Supplier> select(String supplier, String type, String phonenum, String telephone, String description, int offset, int rows) {
|
||||
return supplierMapper.selectByConditionSupplier(supplier, type, phonenum, telephone, description, offset, rows);
|
||||
}
|
||||
|
||||
public int countSupplier(String supplier, String type, String phonenum, String telephone, String description) {
|
||||
return supplierMapper.countsBySupplier(supplier, type, phonenum, telephone, description);
|
||||
}
|
||||
|
||||
public int insertSupplier(String beanJson, HttpServletRequest request) {
|
||||
Supplier supplier = JSONObject.parseObject(beanJson, Supplier.class);
|
||||
return supplierMapper.insertSelective(supplier);
|
||||
}
|
||||
|
||||
public int updateSupplier(String beanJson, Long id) {
|
||||
Supplier supplier = JSONObject.parseObject(beanJson, Supplier.class);
|
||||
supplier.setId(id);
|
||||
return supplierMapper.updateByPrimaryKeySelective(supplier);
|
||||
}
|
||||
|
||||
public int deleteSupplier(Long id) {
|
||||
return supplierMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int batchDeleteSupplier(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
SupplierExample example = new SupplierExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return supplierMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
SupplierExample example = new SupplierExample();
|
||||
example.createCriteria().andIdNotEqualTo(id).andSupplierEqualTo(name);
|
||||
List<Supplier> list = supplierMapper.selectByExample(example);
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public int updateAdvanceIn(Long supplierId, Double advanceIn){
|
||||
Supplier supplier = supplierMapper.selectByPrimaryKey(supplierId);
|
||||
supplier.setAdvancein(supplier.getAdvancein() + advanceIn); //增加预收款的金额,可能增加的是负值
|
||||
return supplierMapper.updateByPrimaryKeySelective(supplier);
|
||||
}
|
||||
|
||||
public List<Supplier> findBySelectCus() {
|
||||
SupplierExample example = new SupplierExample();
|
||||
example.createCriteria().andTypeLike("客户").andEnabledEqualTo(true);
|
||||
example.setOrderByClause("id desc");
|
||||
return supplierMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<Supplier> findBySelectSup() {
|
||||
SupplierExample example = new SupplierExample();
|
||||
example.createCriteria().andTypeLike("供应商").andEnabledEqualTo(true);
|
||||
example.setOrderByClause("id desc");
|
||||
return supplierMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<Supplier> findBySelectRetail() {
|
||||
SupplierExample example = new SupplierExample();
|
||||
example.createCriteria().andTypeLike("会员").andEnabledEqualTo(true);
|
||||
example.setOrderByClause("id desc");
|
||||
return supplierMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<Supplier> findById(Long supplierId) {
|
||||
SupplierExample example = new SupplierExample();
|
||||
example.createCriteria().andIdEqualTo(supplierId);
|
||||
example.setOrderByClause("id desc");
|
||||
return supplierMapper.selectByExample(example);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.jsh.erp.service.systemConfig;
|
||||
|
||||
import com.jsh.erp.service.ICommonQuery;
|
||||
import com.jsh.erp.service.systemConfig.SystemConfigResource;
|
||||
import com.jsh.erp.service.systemConfig.SystemConfigService;
|
||||
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 = "systemConfig_component")
|
||||
@SystemConfigResource
|
||||
public class SystemConfigComponent implements ICommonQuery {
|
||||
|
||||
@Resource
|
||||
private SystemConfigService systemConfigService;
|
||||
|
||||
@Override
|
||||
public Object selectOne(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map) {
|
||||
return getSystemConfigList(map);
|
||||
}
|
||||
|
||||
private List<?> getSystemConfigList(Map<String, String> map) {
|
||||
String order = QueryUtils.order(map);
|
||||
return systemConfigService.select(QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int counts(Map<String, String> map) {
|
||||
return systemConfigService.countSystemConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(String beanJson, HttpServletRequest request) {
|
||||
return systemConfigService.insertSystemConfig(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return systemConfigService.updateSystemConfig(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return systemConfigService.deleteSystemConfig(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return systemConfigService.batchDeleteSystemConfig(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return systemConfigService.checkIsNameExist(id, name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.jsh.erp.service.systemConfig;
|
||||
|
||||
import com.jsh.erp.service.ResourceInfo;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author jishenghua qq752718920 2018-10-7 15:26:27
|
||||
*/
|
||||
@ResourceInfo(value = "systemConfig", type = 55)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface SystemConfigResource {
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.jsh.erp.service.systemConfig;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.SystemConfig;
|
||||
import com.jsh.erp.datasource.entities.SystemConfigExample;
|
||||
import com.jsh.erp.datasource.mappers.SystemConfigMapper;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SystemConfigService {
|
||||
private Logger logger = LoggerFactory.getLogger(SystemConfigService.class);
|
||||
|
||||
@Resource
|
||||
private SystemConfigMapper systemConfigMapper;
|
||||
|
||||
public SystemConfig getSystemConfig(long id) {
|
||||
return systemConfigMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<SystemConfig> getSystemConfig() {
|
||||
SystemConfigExample example = new SystemConfigExample();
|
||||
return systemConfigMapper.selectByExample(example);
|
||||
}
|
||||
public List<SystemConfig> select(int offset, int rows) {
|
||||
return systemConfigMapper.selectByConditionSystemConfig(offset, rows);
|
||||
}
|
||||
|
||||
public int countSystemConfig() {
|
||||
return systemConfigMapper.countsBySystemConfig();
|
||||
}
|
||||
|
||||
public int insertSystemConfig(String beanJson, HttpServletRequest request) {
|
||||
SystemConfig systemConfig = JSONObject.parseObject(beanJson, SystemConfig.class);
|
||||
return systemConfigMapper.insertSelective(systemConfig);
|
||||
}
|
||||
|
||||
public int updateSystemConfig(String beanJson, Long id) {
|
||||
SystemConfig systemConfig = JSONObject.parseObject(beanJson, SystemConfig.class);
|
||||
systemConfig.setId(id);
|
||||
return systemConfigMapper.updateByPrimaryKeySelective(systemConfig);
|
||||
}
|
||||
|
||||
public int deleteSystemConfig(Long id) {
|
||||
return systemConfigMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int batchDeleteSystemConfig(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
SystemConfigExample example = new SystemConfigExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return systemConfigMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
SystemConfigExample example = new SystemConfigExample();
|
||||
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name);
|
||||
List<SystemConfig> list = systemConfigMapper.selectByExample(example);
|
||||
return list.size();
|
||||
}
|
||||
}
|
||||
71
src/main/java/com/jsh/erp/service/unit/UnitComponent.java
Normal file
71
src/main/java/com/jsh/erp/service/unit/UnitComponent.java
Normal file
@@ -0,0 +1,71 @@
|
||||
package com.jsh.erp.service.unit;
|
||||
|
||||
import com.jsh.erp.service.ICommonQuery;
|
||||
import com.jsh.erp.service.app.AppResource;
|
||||
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 = "unit_component")
|
||||
@UnitResource
|
||||
public class UnitComponent implements ICommonQuery {
|
||||
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
|
||||
@Override
|
||||
public Object selectOne(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map) {
|
||||
return getUnitList(map);
|
||||
}
|
||||
|
||||
private List<?> getUnitList(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
String order = QueryUtils.order(map);
|
||||
return unitService.select(name, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int counts(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
return unitService.countUnit(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(String beanJson, HttpServletRequest request) {
|
||||
return unitService.insertUnit(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return unitService.updateUnit(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return unitService.deleteUnit(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return unitService.batchDeleteUnit(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return unitService.checkIsNameExist(id, name);
|
||||
}
|
||||
|
||||
}
|
||||
15
src/main/java/com/jsh/erp/service/unit/UnitResource.java
Normal file
15
src/main/java/com/jsh/erp/service/unit/UnitResource.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.jsh.erp.service.unit;
|
||||
|
||||
import com.jsh.erp.service.ResourceInfo;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author jishenghua qq752718920 2018-10-7 15:26:27
|
||||
*/
|
||||
@ResourceInfo(value = "unit", type = 40)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface UnitResource {
|
||||
}
|
||||
68
src/main/java/com/jsh/erp/service/unit/UnitService.java
Normal file
68
src/main/java/com/jsh/erp/service/unit/UnitService.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package com.jsh.erp.service.unit;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.Unit;
|
||||
import com.jsh.erp.datasource.entities.UnitExample;
|
||||
import com.jsh.erp.datasource.mappers.UnitMapper;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class UnitService {
|
||||
private Logger logger = LoggerFactory.getLogger(UnitService.class);
|
||||
|
||||
@Resource
|
||||
private UnitMapper unitMapper;
|
||||
|
||||
public Unit getUnit(long id) {
|
||||
return unitMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<Unit> getUnit() {
|
||||
UnitExample example = new UnitExample();
|
||||
return unitMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<Unit> select(String name, int offset, int rows) {
|
||||
return unitMapper.selectByConditionUnit(name, offset, rows);
|
||||
}
|
||||
|
||||
public int countUnit(String name) {
|
||||
return unitMapper.countsByUnit(name);
|
||||
}
|
||||
|
||||
public int insertUnit(String beanJson, HttpServletRequest request) {
|
||||
Unit unit = JSONObject.parseObject(beanJson, Unit.class);
|
||||
return unitMapper.insertSelective(unit);
|
||||
}
|
||||
|
||||
public int updateUnit(String beanJson, Long id) {
|
||||
Unit unit = JSONObject.parseObject(beanJson, Unit.class);
|
||||
unit.setId(id);
|
||||
return unitMapper.updateByPrimaryKeySelective(unit);
|
||||
}
|
||||
|
||||
public int deleteUnit(Long id) {
|
||||
return unitMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int batchDeleteUnit(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
UnitExample example = new UnitExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return unitMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
UnitExample example = new UnitExample();
|
||||
example.createCriteria().andIdNotEqualTo(id).andUnameEqualTo(name);
|
||||
List<Unit> list = unitMapper.selectByExample(example);
|
||||
return list.size();
|
||||
}
|
||||
}
|
||||
72
src/main/java/com/jsh/erp/service/user/UserComponent.java
Normal file
72
src/main/java/com/jsh/erp/service/user/UserComponent.java
Normal file
@@ -0,0 +1,72 @@
|
||||
package com.jsh.erp.service.user;
|
||||
|
||||
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.*;
|
||||
|
||||
@Service(value = "user_component")
|
||||
@UserResource
|
||||
public class UserComponent implements ICommonQuery {
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public Object selectOne(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map) {
|
||||
return getUserList(map);
|
||||
}
|
||||
|
||||
private List<?> getUserList(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String userName = StringUtil.getInfo(search, "userName");
|
||||
String loginName = StringUtil.getInfo(search, "loginName");
|
||||
String order = QueryUtils.order(map);
|
||||
String filter = QueryUtils.filter(map);
|
||||
return userService.select(userName, loginName, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int counts(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String userName = StringUtil.getInfo(search, "userName");
|
||||
String loginName = StringUtil.getInfo(search, "loginName");
|
||||
return userService.countUser(userName, loginName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(String beanJson, HttpServletRequest request) {
|
||||
return userService.insertUser(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return userService.updateUser(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return userService.deleteUser(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return userService.batchDeleteUser(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return userService.checkIsNameExist(id, name);
|
||||
}
|
||||
|
||||
}
|
||||
15
src/main/java/com/jsh/erp/service/user/UserResource.java
Normal file
15
src/main/java/com/jsh/erp/service/user/UserResource.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.jsh.erp.service.user;
|
||||
|
||||
import com.jsh.erp.service.ResourceInfo;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author jishenghua qq752718920 2018-10-7 15:26:27
|
||||
*/
|
||||
@ResourceInfo(value = "user", type = 5)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface UserResource {
|
||||
}
|
||||
133
src/main/java/com/jsh/erp/service/user/UserService.java
Normal file
133
src/main/java/com/jsh/erp/service/user/UserService.java
Normal file
@@ -0,0 +1,133 @@
|
||||
package com.jsh.erp.service.user;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.User;
|
||||
import com.jsh.erp.datasource.entities.UserExample;
|
||||
import com.jsh.erp.datasource.mappers.UserMapper;
|
||||
import com.jsh.erp.utils.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class UserService {
|
||||
private Logger logger = LoggerFactory.getLogger(UserService.class);
|
||||
@Resource
|
||||
private UserMapper userMapper;
|
||||
|
||||
public User getUser(long id) {
|
||||
return userMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<User> getUser() {
|
||||
UserExample example = new UserExample();
|
||||
return userMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<User> select(String userName, String loginName, int offset, int rows) {
|
||||
return userMapper.selectByConditionUser(userName, loginName, offset, rows);
|
||||
}
|
||||
|
||||
public int countUser(String userName, String loginName) {
|
||||
return userMapper.countsByUser(userName, loginName);
|
||||
}
|
||||
|
||||
public int insertUser(String beanJson, HttpServletRequest request) {
|
||||
User user = JSONObject.parseObject(beanJson, User.class);
|
||||
String password = "123456";
|
||||
//因密码用MD5加密,需要对密码进行转化
|
||||
try {
|
||||
password = Tools.md5Encryp(password);
|
||||
user.setPassword(password);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
logger.error(">>>>>>>>>>>>>>转化MD5字符串错误 :" + e.getMessage());
|
||||
}
|
||||
return userMapper.insertSelective(user);
|
||||
}
|
||||
|
||||
public int updateUser(String beanJson, Long id) {
|
||||
User user = JSONObject.parseObject(beanJson, User.class);
|
||||
user.setId(id);
|
||||
return userMapper.updateByPrimaryKeySelective(user);
|
||||
}
|
||||
|
||||
public int updateUserByObj(User user) {
|
||||
return userMapper.updateByPrimaryKeySelective(user);
|
||||
}
|
||||
|
||||
public int resetPwd(String md5Pwd, Long id) {
|
||||
User user = new User();
|
||||
user.setId(id);
|
||||
user.setPassword(md5Pwd);
|
||||
return userMapper.updateByPrimaryKeySelective(user);
|
||||
}
|
||||
|
||||
public int deleteUser(Long id) {
|
||||
return userMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int batchDeleteUser(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
UserExample example = new UserExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return userMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public int validateUser(String username, String password) throws JshException {
|
||||
try {
|
||||
/**默认是可以登录的*/
|
||||
List<User> list = null;
|
||||
try {
|
||||
UserExample example = new UserExample();
|
||||
example.createCriteria().andLoginameEqualTo(username);
|
||||
list = userMapper.selectByExample(example);
|
||||
} catch (Exception e) {
|
||||
logger.error(">>>>>>>>访问验证用户姓名是否存在后台信息异常", e);
|
||||
return ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION;
|
||||
}
|
||||
|
||||
if (null != list && list.size() == 0) {
|
||||
return ExceptionCodeConstants.UserExceptionCode.USER_NOT_EXIST;
|
||||
}
|
||||
|
||||
try {
|
||||
UserExample example = new UserExample();
|
||||
example.createCriteria().andLoginameEqualTo(username).andPasswordEqualTo(password);
|
||||
list = userMapper.selectByExample(example);
|
||||
} catch (Exception e) {
|
||||
logger.error(">>>>>>>>>>访问验证用户密码后台信息异常", e);
|
||||
return ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION;
|
||||
}
|
||||
|
||||
if (null != list && list.size() == 0) {
|
||||
return ExceptionCodeConstants.UserExceptionCode.USER_PASSWORD_ERROR;
|
||||
}
|
||||
return ExceptionCodeConstants.UserExceptionCode.USER_CONDITION_FIT;
|
||||
} catch (Exception e) {
|
||||
throw new JshException("unknown exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
public User getUserByUserName(String username) {
|
||||
UserExample example = new UserExample();
|
||||
example.createCriteria().andLoginameEqualTo(username);
|
||||
List<User> list = userMapper.selectByExample(example);
|
||||
User user = list.get(0);
|
||||
return user;
|
||||
}
|
||||
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
UserExample example = new UserExample();
|
||||
example.createCriteria().andIdNotEqualTo(id).andLoginameEqualTo(name);
|
||||
List<User> list = userMapper.selectByExample(example);
|
||||
return list.size();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.jsh.erp.service.userBusiness;
|
||||
|
||||
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 = "userBusiness_component")
|
||||
@UserBusinessResource
|
||||
public class UserBusinessComponent implements ICommonQuery {
|
||||
|
||||
@Resource
|
||||
private UserBusinessService userBusinessService;
|
||||
|
||||
@Override
|
||||
public Object selectOne(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map) {
|
||||
return getUserBusinessList(map);
|
||||
}
|
||||
|
||||
private List<?> getUserBusinessList(Map<String, String> map) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int counts(Map<String, String> map) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(String beanJson, HttpServletRequest request) {
|
||||
return userBusinessService.insertUserBusiness(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return userBusinessService.updateUserBusiness(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return userBusinessService.deleteUserBusiness(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return userBusinessService.batchDeleteUserBusiness(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return userBusinessService.checkIsNameExist(id, name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.jsh.erp.service.userBusiness;
|
||||
|
||||
import com.jsh.erp.service.ResourceInfo;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author jishenghua qq752718920 2018-10-7 15:26:27
|
||||
*/
|
||||
@ResourceInfo(value = "userBusiness", type = 50)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface UserBusinessResource {
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.jsh.erp.service.userBusiness;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.UserBusiness;
|
||||
import com.jsh.erp.datasource.entities.UserBusinessExample;
|
||||
import com.jsh.erp.datasource.mappers.UserBusinessMapper;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class UserBusinessService {
|
||||
private Logger logger = LoggerFactory.getLogger(UserBusinessService.class);
|
||||
|
||||
@Resource
|
||||
private UserBusinessMapper userBusinessMapper;
|
||||
|
||||
public UserBusiness getUserBusiness(long id) {
|
||||
return userBusinessMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<UserBusiness> getUserBusiness() {
|
||||
UserBusinessExample example = new UserBusinessExample();
|
||||
return userBusinessMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public int insertUserBusiness(String beanJson, HttpServletRequest request) {
|
||||
UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class);
|
||||
return userBusinessMapper.insertSelective(userBusiness);
|
||||
}
|
||||
|
||||
public int updateUserBusiness(String beanJson, Long id) {
|
||||
UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class);
|
||||
userBusiness.setId(id);
|
||||
return userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
|
||||
}
|
||||
|
||||
public int deleteUserBusiness(Long id) {
|
||||
return userBusinessMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int batchDeleteUserBusiness(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
UserBusinessExample example = new UserBusinessExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return userBusinessMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public List<UserBusiness> getBasicData(String keyId, String type){
|
||||
UserBusinessExample example = new UserBusinessExample();
|
||||
example.createCriteria().andKeyidEqualTo(keyId).andTypeEqualTo(type);
|
||||
List<UserBusiness> list = userBusinessMapper.selectByExample(example);
|
||||
return list;
|
||||
}
|
||||
|
||||
public Long checkIsValueExist(String type, String keyId) {
|
||||
UserBusinessExample example = new UserBusinessExample();
|
||||
example.createCriteria().andTypeEqualTo(type).andKeyidEqualTo(keyId);
|
||||
List<UserBusiness> list = userBusinessMapper.selectByExample(example);
|
||||
Long id = null;
|
||||
if(list.size() > 0) {
|
||||
id = list.get(0).getId();
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public Boolean checkIsUserBusinessExist(String TypeVale, String KeyIdValue, String UBValue) {
|
||||
UserBusinessExample example = new UserBusinessExample();
|
||||
String newVaule = "%" + UBValue + "%";
|
||||
if(TypeVale !=null && KeyIdValue !=null) {
|
||||
example.createCriteria().andTypeEqualTo(TypeVale).andKeyidEqualTo(KeyIdValue).andValueLike(newVaule);
|
||||
} else {
|
||||
example.createCriteria().andValueLike(newVaule);
|
||||
}
|
||||
List<UserBusiness> list = userBusinessMapper.selectByExample(example);
|
||||
if(list.size() > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user