Commit f4ef5aa0 authored by 季圣华's avatar 季圣华
Browse files

vue版本上线

parent 76a0033a
package com.jsh.erp.config;
import com.baomidou.mybatisplus.core.parser.ISqlParser;
import com.baomidou.mybatisplus.core.parser.ISqlParserFilter;
import com.baomidou.mybatisplus.core.parser.SqlParserHelper;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;
import com.baomidou.mybatisplus.extension.plugins.tenant.TenantHandler;
import com.baomidou.mybatisplus.extension.plugins.tenant.TenantSqlParser;
import com.jsh.erp.utils.Tools;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.LongValue;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.reflection.MetaObject;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
@Service
public class TenantConfig {
@Bean
public PaginationInterceptor paginationInterceptor(HttpServletRequest request) {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
List<ISqlParser> sqlParserList = new ArrayList<>();
TenantSqlParser tenantSqlParser = new TenantSqlParser();
tenantSqlParser.setTenantHandler(new TenantHandler() {
@Override
public Expression getTenantId() {
String token = request.getHeader("X-Access-Token");
Long tenantId = Tools.getTenantIdByToken(token);
if (tenantId!=0L) {
return new LongValue(tenantId);
} else {
//超管
return null;
}
}
@Override
public String getTenantIdColumn() {
return "tenant_id";
}
@Override
public boolean doTableFilter(String tableName) {
//获取开启状态
Boolean res = true;
String token = request.getHeader("X-Access-Token");
Long tenantId = Tools.getTenantIdByToken(token);
if (tenantId!=0L) {
// 这里可以判断是否过滤表
if ("jsh_material_property".equals(tableName) || "jsh_sequence".equals(tableName)
|| "jsh_user_business".equals(tableName) || "jsh_function".equals(tableName)
|| "jsh_platform_config".equals(tableName) || "jsh_tenant".equals(tableName)) {
res = true;
} else {
res = false;
}
}
return res;
}
});
sqlParserList.add(tenantSqlParser);
paginationInterceptor.setSqlParserList(sqlParserList);
paginationInterceptor.setSqlParserFilter(new ISqlParserFilter() {
@Override
public boolean doFilter(MetaObject metaObject) {
MappedStatement ms = SqlParserHelper.getMappedStatement(metaObject);
// 过滤自定义查询此时无租户信息约束出现
if ("com.jsh.erp.datasource.mappers.UserMapperEx.getUserListByUserNameOrLoginName".equals(ms.getId())||
"com.jsh.erp.datasource.mappers.DepotItemMapperEx.getStockByParam".equals(ms.getId())) {
return true;
}
return false;
}
});
return paginationInterceptor;
}
/**
* 相当于顶部的:
* {@code @MapperScan("com.jsh.erp.datasource.mappers*")}
* 这里可以扩展,比如使用配置文件来配置扫描Mapper的路径
*/
@Bean
public MapperScannerConfigurer mapperScannerConfigurer() {
MapperScannerConfigurer scannerConfigurer = new MapperScannerConfigurer();
scannerConfigurer.setBasePackage("com.jsh.erp.datasource.mappers*");
return scannerConfigurer;
}
/**
* 性能分析拦截器,不建议生产使用
*/
@Bean
public PerformanceInterceptor performanceInterceptor(){
return new PerformanceInterceptor();
}
}
package com.jsh.erp.constants;
/**
* @ClassName:BusinessConstants
* @Description 业务字典类
* @Author qiankunpingtai
* @Date 2019-3-6 17:58
* @Version 1.0
**/
public class BusinessConstants {
/**
* 默认的日期格式
*/
public static final String DEFAULT_DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
/**
* 默认的分页起始页页码
*/
public static final Integer DEFAULT_PAGINATION_PAGE_NUMBER = 1;
/**
* 无数据时列表返回的默认数据条数
*/
public static final Long DEFAULT_LIST_NULL_NUMBER = 0L;
/**
* 默认的分页条数
*/
public static final Integer DEFAULT_PAGINATION_PAGE_SIZE = 10;
/**
* 单据主表出入库类型 type 入库 出库
* depothead
* */
public static final String DEPOTHEAD_TYPE_STORAGE = "入库";
public static final String DEPOTHEAD_TYPE_OUT = "出库";
/**
* 付款类型 payType //现付/预付款
* */
public static final String PAY_TYPE_PREPAID = "预付款";
public static final String PAY_TYPE_BY_CASH = "现付";
/**
* 删除标记 deleteFlag '0'未删除 '1'已删除
* */
public static final String DELETE_FLAG_DELETED = "1";
public static final String DELETE_FLAG_EXISTS = "0";
/**
* 是否卖出 isSell '0'未卖出 '1'已卖出
* */
public static final String IS_SELL_SELLED = "1";
public static final String IS_SELL_HOLD = "0";
/**
* 商品是否开启序列号标识enableSerialNumber '0'未启用 '1'启用
* */
public static final String ENABLE_SERIAL_NUMBER_ENABLED = "1";
public static final String ENABLE_SERIAL_NUMBER_NOT_ENABLED = "0";
/**
* 单据状态 billsStatus '0'未审核 '1'审核 '2'已转采购|销售
* */
public static final String BILLS_STATUS_UN_AUDIT = "0";
public static final String BILLS_STATUS_AUDIT = "1";
public static final String BILLS_STATUS_SKIP = "2";
/**
* 出入库分类
*采购、采购退货、其它、零售、销售、调拨
* */
public static final String SUB_TYPE_PURCHASE = "采购";
public static final String SUB_TYPE_PURCHASE_TETURNS = "采购退货";
public static final String SUB_TYPE_OTHER = "其它";
public static final String SUB_TYPE_RETAIL = "零售";
public static final String SUB_TYPE_SALES = "销售";
public static final String SUB_TYPE_TRANSFER = "调拨";
/**
* 批量插入sql时最大的数据条数
* */
public static final int BATCH_INSERT_MAX_NUMBER = 500;
/**
* sequence名称
* */
//sequence返回字符串的最小长度
public static final Long SEQ_TO_STRING_MIN_LENGTH = 10000000000L;
//sequence长度小于基准长度时前追加基础值
public static final String SEQ_TO_STRING_LESS_INSERT = "0";
//单据编号
public static final String DEPOT_NUMBER_SEQ = "depot_number_seq";
/**
* 商品类别根目录id
* */
/**
* create by: qiankunpingtai
* create time: 2019/3/14 11:41
* description:
* 为了使用户可以自己建初始目录,设定根目录的父级目录id为-1
*
*/
public static final Long MATERIAL_CATEGORY_ROOT_PARENT_ID = -1L;
/**
* 商品类别状态
* 0系统默认,1启用,2删除
* */
public static final String MATERIAL_CATEGORY_STATUS_DEFAULT = "0";
public static final String MATERIAL_CATEGORY_STATUS_ENABLE = "1";
public static final String MATERIAL_CATEGORY_STATUS_DELETE = "2";
/**
* 机构状态
* 1未营业、2正常营业、3暂停营业、4终止营业,5已除名
* */
public static final String ORGANIZATION_STCD_NOT_OPEN = "1";
public static final String ORGANIZATION_STCD_OPEN = "2";
public static final String ORGANIZATION_STCD_BUSINESS_SUSPENDED = "3";
public static final String ORGANIZATION_STCD_BUSINESS_TERMINATED = "4";
public static final String ORGANIZATION_STCD_REMOVED = "5";
/**
* 根机构父级编号
* 根机父级构编号默认为-1
* */
public static final String ORGANIZATION_ROOT_PARENT_NO = "-1";
/**
* 新增用户默认密码
* */
public static final String USER_DEFAULT_PASSWORD = "123456";
/**
* 用户是否系统自带
* 0、非系统自带,1系统自带
* */
public static final byte USER_NOT_SYSTEM = 0;
public static final byte USER_IS_SYSTEM = 1;
/**
* 用户是否为管理者
* 0、管理者,1员工
* */
public static final byte USER_IS_MANAGER = 0;
public static final byte USER_NOT_MANAGER = 1;
/**
* 用户状态
* 0:正常,1:删除,2封禁
* */
public static final byte USER_STATUS_NORMAL = 0;
public static final byte USER_STATUS_DELETE = 1;
public static final byte USER_STATUS_BANNED = 2;
/**
* 日志操作
* 新增、修改、删除、登录、导入
* */
public static final String LOG_OPERATION_TYPE_ADD = "新增";
public static final String LOG_OPERATION_TYPE_BATCH_ADD = "批量新增";
public static final String LOG_OPERATION_TYPE_EDIT = "修改";
public static final String LOG_OPERATION_TYPE_DELETE = "删除";
public static final String LOG_OPERATION_TYPE_LOGIN = "登录";
public static final String LOG_OPERATION_TYPE_IMPORT = "导入";
/**
* 数据数量单位
* 条
* */
public static final String LOG_DATA_UNIT = "条";
/**
* 删除类型
* 1正常删除
* 2强制删除
* */
public static final String DELETE_TYPE_NORMAL = "1";
public static final String DELETE_TYPE_FORCE = "2";
/**
* 默认管理员账号
*/
public static final String DEFAULT_MANAGER = "admin";
public static final String ROLE_TYPE_PRIVATE = "个人数据";
public static final String ROLE_TYPE_THIS_ORG = "本机构数据";
/**
* redis相关
* */
//session的生命周期,秒
public static final Long MAX_SESSION_IN_SECONDS=60*60*24L;
}
package com.jsh.erp.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.Account;
import com.jsh.erp.datasource.vo.AccountVo4InOutList;
import com.jsh.erp.datasource.vo.AccountVo4List;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.account.AccountService;
import com.jsh.erp.utils.BaseResponseInfo;
import com.jsh.erp.utils.ErpInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
/**
* @author jishenghua 75271*8920
*/
@RestController
@RequestMapping(value = "/account")
public class AccountController {
private Logger logger = LoggerFactory.getLogger(AccountController.class);
@Resource
private AccountService accountService;
/**
* 查找结算账户信息-下拉框
* @param request
* @return
*/
@GetMapping(value = "/findBySelect")
public String findBySelect(HttpServletRequest request) throws Exception {
String res = null;
try {
List<Account> dataList = accountService.findBySelect();
//存放数据json数组
JSONArray dataArray = new JSONArray();
if (null != dataList) {
for (Account account : dataList) {
JSONObject item = new JSONObject();
item.put("Id", account.getId());
//结算账户名称
item.put("AccountName", account.getName());
dataArray.add(item);
}
}
res = dataArray.toJSONString();
} catch(Exception e){
e.printStackTrace();
res = "获取数据失败";
}
return res;
}
/**
* 获取所有结算账户
* @param request
* @return
*/
@GetMapping(value = "/getAccount")
public BaseResponseInfo getAccount(HttpServletRequest request) throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
List<Account> accountList = accountService.getAccount();
map.put("accountList", accountList);
res.code = 200;
res.data = map;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
/**
* 账户流水信息
* @param currentPage
* @param pageSize
* @param accountId
* @param initialAmount
* @param request
* @return
*/
@GetMapping(value = "/findAccountInOutList")
public BaseResponseInfo findAccountInOutList(@RequestParam("currentPage") Integer currentPage,
@RequestParam("pageSize") Integer pageSize,
@RequestParam("accountId") Long accountId,
@RequestParam("initialAmount") BigDecimal initialAmount,
HttpServletRequest request) throws Exception{
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
List<AccountVo4InOutList> dataList = accountService.findAccountInOutList(accountId, (currentPage-1)*pageSize, pageSize);
int total = accountService.findAccountInOutListCount(accountId);
map.put("total", total);
//存放数据json数组
JSONArray dataArray = new JSONArray();
if (null != dataList) {
for (AccountVo4InOutList aEx : dataList) {
String timeStr = aEx.getOperTime().toString();
BigDecimal balance = accountService.getAccountSum(accountId, timeStr, "date").add(accountService.getAccountSumByHead(accountId, timeStr, "date"))
.add(accountService.getAccountSumByDetail(accountId, timeStr, "date")).add(accountService.getManyAccountSum(accountId, timeStr, "date")).add(initialAmount);
aEx.setBalance(balance);
dataArray.add(aEx);
}
}
map.put("rows", dataArray);
res.code = 200;
res.data = map;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
@PostMapping(value = "/updateIsDefault")
public String updateIsDefault(@RequestBody JSONObject object,
HttpServletRequest request) throws Exception{
Long accountId = object.getLong("id");
Map<String, Object> objectMap = new HashMap<>();
int res = accountService.updateIsDefault(accountId);
if(res > 0) {
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
} else {
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
}
}
/**
* 结算账户的统计
* @param request
* @return
*/
@GetMapping(value = "/getStatistics")
public BaseResponseInfo getStatistics(@RequestParam("name") String name,
@RequestParam("serialNo") String serialNo,
HttpServletRequest request) throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
try {
Map<String, Object> map = accountService.getStatistics(name, serialNo);
res.code = 200;
res.data = map;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
}
package com.jsh.erp.controller;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.AccountHeadVo4Body;
import com.jsh.erp.datasource.entities.AccountHeadVo4ListEx;
import com.jsh.erp.service.accountHead.AccountHeadService;
import com.jsh.erp.utils.BaseResponseInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author jishenghua 752*718*920
*/
@RestController
@RequestMapping(value = "/accountHead")
public class AccountHeadController {
private Logger logger = LoggerFactory.getLogger(AccountHeadController.class);
@Resource
private AccountHeadService accountHeadService;
/**
* 新增财务主表及财务子表信息
* @param body
* @param request
* @return
* @throws Exception
*/
@PostMapping(value = "/addAccountHeadAndDetail")
public Object addAccountHeadAndDetail(@RequestBody AccountHeadVo4Body body, HttpServletRequest request) throws Exception{
JSONObject result = ExceptionConstants.standardSuccess();
String beanJson = body.getInfo();
String rows = body.getRows();
accountHeadService.addAccountHeadAndDetail(beanJson,rows, request);
return result;
}
/**
* 更新财务主表及财务子表信息
* @param body
* @param request
* @return
* @throws Exception
*/
@PutMapping(value = "/updateAccountHeadAndDetail")
public Object updateAccountHeadAndDetail(@RequestBody AccountHeadVo4Body body, HttpServletRequest request) throws Exception{
JSONObject result = ExceptionConstants.standardSuccess();
String beanJson = body.getInfo();
String rows = body.getRows();
accountHeadService.updateAccountHeadAndDetail(beanJson,rows,request);
return result;
}
/**
* 查询单位的累计应收和累计应付,收预付款不计入此处
* @param supplierId
* @param endTime
* @param supType
* @param request
* @return
*/
@GetMapping(value = "/findTotalPay")
public BaseResponseInfo findTotalPay(@RequestParam("supplierId") Integer supplierId,
@RequestParam("endTime") String endTime,
@RequestParam("supType") String supType,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
JSONObject outer = new JSONObject();
BigDecimal sum = accountHeadService.findTotalPay(supplierId, endTime, supType);
outer.put("getAllMoney", sum);
map.put("rows", outer);
res.code = 200;
res.data = map;
} catch (Exception e) {
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
/**
* 根据编号查询单据信息
* @param billNo
* @param request
* @return
*/
@GetMapping(value = "/getDetailByNumber")
public BaseResponseInfo getDetailByNumber(@RequestParam("billNo") String billNo,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
AccountHeadVo4ListEx ahl = new AccountHeadVo4ListEx();
try {
List<AccountHeadVo4ListEx> list = accountHeadService.getDetailByNumber(billNo);
if(list.size() == 1) {
ahl = list.get(0);
}
res.code = 200;
res.data = ahl;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
}
package com.jsh.erp.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.vo.AccountItemVo4List;
import com.jsh.erp.service.accountItem.AccountItemService;
import com.jsh.erp.utils.BaseResponseInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author ji sheng hua 752*718*920
*/
@RestController
@RequestMapping(value = "/accountItem")
public class AccountItemController {
private Logger logger = LoggerFactory.getLogger(AccountItemController.class);
@Resource
private AccountItemService accountItemService;
@GetMapping(value = "/getDetailList")
public BaseResponseInfo getDetailList(@RequestParam("headerId") Long headerId,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
try {
List<AccountItemVo4List> dataList = new ArrayList<>();
if(headerId != 0) {
dataList = accountItemService.getDetailList(headerId);
}
JSONObject outer = new JSONObject();
outer.put("total", dataList.size());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if (null != dataList) {
for (AccountItemVo4List ai : dataList) {
JSONObject item = new JSONObject();
item.put("accountId", ai.getAccountId());
item.put("accountName", ai.getAccountName());
item.put("inOutItemId", ai.getInOutItemId());
item.put("inOutItemName", ai.getInOutItemName());
BigDecimal eachAmount = ai.getEachAmount();
item.put("eachAmount", (eachAmount.compareTo(BigDecimal.ZERO))==-1 ? BigDecimal.ZERO.subtract(eachAmount): eachAmount);
item.put("remark", ai.getRemark());
dataArray.add(item);
}
}
outer.put("rows", dataArray);
res.code = 200;
res.data = outer;
} catch (Exception e) {
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
}
package com.jsh.erp.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.Depot;
import com.jsh.erp.datasource.entities.DepotEx;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.depot.DepotService;
import com.jsh.erp.service.material.MaterialService;
import com.jsh.erp.service.systemConfig.SystemConfigService;
import com.jsh.erp.service.userBusiness.UserBusinessService;
import com.jsh.erp.utils.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
/**
* @author ji sheng hua 752*718*920
*/
@RestController
@RequestMapping(value = "/depot")
public class DepotController {
private Logger logger = LoggerFactory.getLogger(DepotController.class);
@Resource
private DepotService depotService;
@Resource
private UserBusinessService userBusinessService;
@Resource
private SystemConfigService systemConfigService;
@Resource
private MaterialService materialService;
@GetMapping(value = "/getAllList")
public BaseResponseInfo getAllList(HttpServletRequest request) throws Exception{
BaseResponseInfo res = new BaseResponseInfo();
try {
List<Depot> depotList = depotService.getAllList();
res.code = 200;
res.data = depotList;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
/**
* 用户对应仓库显示
* @param type
* @param keyId
* @param request
* @return
*/
@PostMapping(value = "/findUserDepot")
public JSONArray findUserDepot(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId,
HttpServletRequest request) throws Exception{
JSONArray arr = new JSONArray();
try {
List<Depot> dataList = depotService.findUserDepot();
//开始拼接json数据
JSONObject outer = new JSONObject();
outer.put("id", 1);
outer.put("text", "仓库列表");
outer.put("state", "open");
//存放数据json数组
JSONArray dataArray = new JSONArray();
if (null != dataList) {
for (Depot depot : dataList) {
JSONObject item = new JSONObject();
item.put("id", depot.getId());
item.put("text", depot.getName());
//勾选判断1
Boolean flag = false;
try {
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + depot.getId().toString() + "]");
} catch (Exception e) {
logger.error(">>>>>>>>>>>>>>>>>设置用户对应的仓库:类型" + type + " KeyId为: " + keyId + " 存在异常!");
}
if (flag == true) {
item.put("checked", true);
}
//结束
dataArray.add(item);
}
}
outer.put("children", dataArray);
arr.add(outer);
} catch (Exception e) {
e.printStackTrace();
}
return arr;
}
/**
* 获取用户拥有权限的仓库列表
* @param type
* @param keyId
* @param request
* @return
* @throws Exception
*/
@GetMapping(value = "/findDepotByUserId")
public JSONArray findDepotByUserId(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId,
HttpServletRequest request) throws Exception{
JSONArray arr = new JSONArray();
try {
List<Depot> dataList = depotService.findUserDepot();
//开始拼接json数据
if (null != dataList) {
boolean depotFlag = systemConfigService.getDepotFlag();
for (Depot depot : dataList) {
JSONObject item = new JSONObject();
//勾选判断1
Boolean flag = false;
try {
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + depot.getId().toString() + "]");
} catch (DataAccessException e) {
logger.error(">>>>>>>>>>>>>>>>>查询用户对应的仓库:类型" + type + " KeyId为: " + keyId + " 存在异常!");
}
if (!depotFlag || flag) {
item.put("id", depot.getId());
item.put("depotName", depot.getName());
arr.add(item);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return arr;
}
@PostMapping(value = "/updateIsDefault")
public String updateIsDefault(@RequestBody JSONObject object,
HttpServletRequest request) throws Exception{
Long depotId = object.getLong("id");
Map<String, Object> objectMap = new HashMap<>();
int res = depotService.updateIsDefault(depotId);
if(res > 0) {
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
} else {
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
}
}
@GetMapping(value = "/getAllListWithStock")
public BaseResponseInfo getAllList(@RequestParam("mId") Long mId,
HttpServletRequest request) {
BaseResponseInfo res = new BaseResponseInfo();
try {
List<Depot> list = depotService.getAllList();
List<DepotEx> depotList = new ArrayList<DepotEx>();
for(Depot depot: list) {
DepotEx de = new DepotEx();
if(mId!=0) {
BigDecimal initStock = materialService.getInitStock(mId, depot.getId());
BigDecimal currentStock = materialService.getCurrentStock(mId, depot.getId());
de.setInitStock(initStock);
de.setCurrentStock(currentStock);
} else {
de.setInitStock(BigDecimal.ZERO);
de.setCurrentStock(BigDecimal.ZERO);
}
de.setId(depot.getId());
de.setName(depot.getName());
depotList.add(de);
}
res.code = 200;
res.data = depotList;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
}
package com.jsh.erp.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.DepotHead;
import com.jsh.erp.datasource.entities.DepotHeadVo4Body;
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.exception.BusinessParamCheckingException;
import com.jsh.erp.service.depotHead.DepotHeadService;
import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.redis.RedisService;
import com.jsh.erp.utils.BaseResponseInfo;
import com.jsh.erp.utils.ErpInfo;
import com.jsh.erp.utils.StringUtil;
import com.jsh.erp.utils.Tools;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.sql.Date;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
import static com.jsh.erp.utils.Tools.getNow3;
/**
* @author ji-sheng-hua 752*718*920
*/
@RestController
@RequestMapping(value = "/depotHead")
public class DepotHeadController {
private Logger logger = LoggerFactory.getLogger(DepotHeadController.class);
@Resource
private DepotHeadService depotHeadService;
@Resource
private RedisService redisService;
/**
* 批量设置状态-审核或者反审核
* @param jsonObject
* @param request
* @return
*/
@PostMapping(value = "/batchSetStatus")
public String batchSetStatus(@RequestBody JSONObject jsonObject,
HttpServletRequest request) throws Exception{
Map<String, Object> objectMap = new HashMap<>();
String status = jsonObject.getString("status");
String ids = jsonObject.getString("ids");
int res = depotHeadService.batchSetStatus(status, ids);
if(res > 0) {
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
} else {
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
}
}
/**
* 入库出库明细接口
* @param currentPage
* @param pageSize
* @param oId
* @param materialParam
* @param depotId
* @param beginTime
* @param endTime
* @param type
* @param request
* @return
*/
@GetMapping(value = "/findInDetail")
public BaseResponseInfo findInDetail(@RequestParam("currentPage") Integer currentPage,
@RequestParam("pageSize") Integer pageSize,
@RequestParam("organId") Integer oId,
@RequestParam("materialParam") String materialParam,
@RequestParam("depotId") Integer depotId,
@RequestParam("beginTime") String beginTime,
@RequestParam("endTime") String endTime,
@RequestParam("type") String type,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
List<DepotHeadVo4InDetail> resList = new ArrayList<DepotHeadVo4InDetail>();
List<DepotHeadVo4InDetail> list = depotHeadService.findByAll(beginTime, endTime, type, materialParam, depotId, oId, (currentPage-1)*pageSize, pageSize);
int total = depotHeadService.findByAllCount(beginTime, endTime, type, materialParam, depotId, oId);
map.put("total", total);
//存放数据json数组
if (null != list) {
for (DepotHeadVo4InDetail dhd : list) {
resList.add(dhd);
}
}
map.put("rows", resList);
res.code = 200;
res.data = map;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
/**
* 入库出库统计接口
* @param currentPage
* @param pageSize
* @param oId
* @param materialParam
* @param depotId
* @param beginTime
* @param endTime
* @param type
* @param request
* @return
*/
@GetMapping(value = "/findInOutMaterialCount")
public BaseResponseInfo findInOutMaterialCount(@RequestParam("currentPage") Integer currentPage,
@RequestParam("pageSize") Integer pageSize,
@RequestParam("organId") Integer oId,
@RequestParam("materialParam") String materialParam,
@RequestParam("depotId") Integer depotId,
@RequestParam("beginTime") String beginTime,
@RequestParam("endTime") String endTime,
@RequestParam("type") String type,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
List<DepotHeadVo4InOutMCount> resList = new ArrayList<>();
List<DepotHeadVo4InOutMCount> list = depotHeadService.findInOutMaterialCount(beginTime, endTime, type, materialParam, depotId, oId, (currentPage-1)*pageSize, pageSize);
int total = depotHeadService.findInOutMaterialCountTotal(beginTime, endTime, type, materialParam, depotId, oId);
map.put("total", total);
//存放数据json数组
if (null != list) {
for (DepotHeadVo4InOutMCount dhc : list) {
resList.add(dhc);
}
}
map.put("rows", resList);
res.code = 200;
res.data = map;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
/**
* 对账单接口
* @param currentPage
* @param pageSize
* @param beginTime
* @param endTime
* @param organId
* @param supType
* @param request
* @return
*/
@GetMapping(value = "/findStatementAccount")
public BaseResponseInfo findStatementAccount(@RequestParam("currentPage") Integer currentPage,
@RequestParam("pageSize") Integer pageSize,
@RequestParam("beginTime") String beginTime,
@RequestParam("endTime") String endTime,
@RequestParam("organId") Integer organId,
@RequestParam("supType") String supType,
HttpServletRequest request) throws Exception{
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
int j = 1;
if (supType.equals("客户")) { //客户
j = 1;
} else if (supType.equals("供应商")) { //供应商
j = -1;
}
List<DepotHeadVo4StatementAccount> resList = new ArrayList<DepotHeadVo4StatementAccount>();
List<DepotHeadVo4StatementAccount> list = depotHeadService.findStatementAccount(beginTime, endTime, organId, supType, (currentPage-1)*pageSize, pageSize);
int total = depotHeadService.findStatementAccountCount(beginTime, endTime, organId, supType);
map.put("total", total);
//存放数据json数组
if (null != list) {
for (DepotHeadVo4StatementAccount dha : list) {
dha.setNumber(dha.getNumber()); //单据编号
dha.setType(dha.getType()); //类型
String type = dha.getType();
BigDecimal p1 = BigDecimal.ZERO ;
BigDecimal p2 = BigDecimal.ZERO;
if (dha.getDiscountLastMoney() != null) {
p1 = dha.getDiscountLastMoney();
}
if (dha.getChangeAmount() != null) {
p2 = dha.getChangeAmount();
}
BigDecimal allPrice = BigDecimal.ZERO;
if ((p1.compareTo(BigDecimal.ZERO))==-1) {
p1 = p1.abs();
}
if(dha.getOtherMoney()!=null) {
p1 = p1.add(dha.getOtherMoney()); //与其它费用相加
}
if ((p2 .compareTo(BigDecimal.ZERO))==-1) {
p2 = p2.abs();
}
if (type.equals("采购入库")) {
allPrice = p2.subtract(p1);
} else if (type.equals("销售退货入库")) {
allPrice = p2.subtract(p1);
} else if (type.equals("销售出库")) {
allPrice = p1.subtract(p2);
} else if (type.equals("采购退货出库")) {
allPrice = p1.subtract(p2);
} else if (type.equals("付款")) {
allPrice = p1.add(p2);
} else if (type.equals("收款")) {
allPrice = BigDecimal.ZERO.subtract(p1.add(p2));
} else if (type.equals("收入")) {
allPrice = p1.subtract(p2);
} else if (type.equals("支出")) {
allPrice = p2.subtract(p1);
}
dha.setBillMoney(p1); //单据金额
dha.setChangeAmount(p2); //实际支付
DecimalFormat df = new DecimalFormat(".##");
dha.setAllPrice(new BigDecimal(df.format(allPrice.multiply(new BigDecimal(j))))); //本期变化
dha.setSupplierName(dha.getSupplierName()); //单位名称
dha.setoTime(dha.getoTime()); //单据日期
resList.add(dha);
}
}
map.put("rows", resList);
res.code = 200;
res.data = map;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
/**
* 查询单位的累计应收和累计应付,零售不能计入
* @param supplierId
* @param endTime
* @param supType
* @param request
* @return
*/
@GetMapping(value = "/findTotalPay")
public BaseResponseInfo findTotalPay(@RequestParam("supplierId") Integer supplierId,
@RequestParam("endTime") String endTime,
@RequestParam("supType") String supType,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
JSONObject outer = new JSONObject();
BigDecimal sum = depotHeadService.findTotalPay(supplierId, endTime, supType);
outer.put("getAllMoney", sum);
map.put("rows", outer);
res.code = 200;
res.data = map;
} catch (Exception e) {
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
/**
* 根据编号查询单据信息
* @param number
* @param request
* @return
*/
@GetMapping(value = "/getDetailByNumber")
public BaseResponseInfo getDetailByNumber(@RequestParam("number") String number,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
DepotHeadVo4List dhl = new DepotHeadVo4List();
try {
List<DepotHeadVo4List> list = depotHeadService.getDetailByNumber(number);
if(list.size() == 1) {
dhl = list.get(0);
}
res.code = 200;
res.data = dhl;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
/**
* 新增单据主表及单据子表信息
* @param body
* @param request
* @return
* @throws Exception
*/
@PostMapping(value = "/addDepotHeadAndDetail")
public Object addDepotHeadAndDetail(@RequestBody DepotHeadVo4Body body, HttpServletRequest request) throws Exception{
JSONObject result = ExceptionConstants.standardSuccess();
String beanJson = body.getInfo();
String rows = body.getRows();
Long billsNumLimit = Long.parseLong(redisService.getObjectFromSessionByKey(request,"billsNumLimit").toString());
Long tenantId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"tenantId").toString());
Long count = depotHeadService.countDepotHead(null,null,null,null,null,null,null,null,null);
if(count>= billsNumLimit) {
throw new BusinessParamCheckingException(ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_CODE,
ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_MSG);
} else {
depotHeadService.addDepotHeadAndDetail(beanJson,rows,tenantId, request);
}
return result;
}
/**
* 更新单据主表及单据子表信息
* @param body
* @param request
* @return
* @throws Exception
*/
@PutMapping(value = "/updateDepotHeadAndDetail")
public Object updateDepotHeadAndDetail(@RequestBody DepotHeadVo4Body body, HttpServletRequest request) throws Exception{
Long tenantId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"tenantId").toString());
JSONObject result = ExceptionConstants.standardSuccess();
String beanJson = body.getInfo();
String rows = body.getRows();
BigDecimal preTotalPrice = body.getPreTotalPrice();
depotHeadService.updateDepotHeadAndDetail(beanJson,rows,preTotalPrice,tenantId,request);
return result;
}
/**
* 统计今日销售额、今日进货额、本月销售额、本月进货额
* @param request
* @return
*/
@GetMapping(value = "/getBuyAndSaleStatistics")
public BaseResponseInfo getBuyAndSaleStatistics(HttpServletRequest request) {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
String today = Tools.getNow() + " 00:00:00";
String firstDay = Tools.getCurrentMonth() + "-01 00:00:00";
BigDecimal todaySale = depotHeadService.getBuyAndSaleStatistics("出库", "销售",
1, today, getNow3()); //今日销售出库
BigDecimal todayRetailSale = depotHeadService.getBuyAndSaleRetailStatistics("出库", "零售",
0, today, getNow3()); //今日零售出库
BigDecimal todayBuy = depotHeadService.getBuyAndSaleStatistics("入库", "采购",
1, today, getNow3()); //今日采购入库
BigDecimal monthSale = depotHeadService.getBuyAndSaleStatistics("出库", "销售",
1,firstDay, getNow3()); //本月销售出库
BigDecimal monthRetailSale = depotHeadService.getBuyAndSaleRetailStatistics("出库", "零售",
0,firstDay, getNow3()); //本月零售出库
BigDecimal monthBuy = depotHeadService.getBuyAndSaleStatistics("入库", "采购",
1, firstDay, getNow3()); //本月采购入库
map.put("todaySale", todaySale.add(todayRetailSale));
map.put("todayBuy", todayBuy);
map.put("thisMonthSale", monthSale.add(monthRetailSale));
map.put("thisMonthBuy", monthBuy);
res.code = 200;
res.data = map;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
/**
* 根据当前用户获取操作员数组,用于控制当前用户的数据权限,限制可以看到的单据范围
* 注意:该接口提供给部分插件使用,勿删
* @param request
* @return
*/
@GetMapping(value = "/getCreatorByCurrentUser")
public BaseResponseInfo getCreatorByRoleType(HttpServletRequest request) {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
String creator = "";
String roleType = redisService.getObjectFromSessionByKey(request,"roleType").toString();
if(StringUtil.isNotEmpty(roleType)) {
creator = depotHeadService.getCreatorByRoleType(roleType);
}
res.code = 200;
res.data = creator;
} catch (Exception e) {
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
}
package com.jsh.erp.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.Function;
import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.entities.UserBusiness;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.functions.FunctionService;
import com.jsh.erp.service.userBusiness.UserBusinessService;
import com.jsh.erp.utils.BaseResponseInfo;
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.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
/**
* @author ji-sheng-hua jshERP
*/
@RestController
@RequestMapping(value = "/function")
public class FunctionController {
private Logger logger = LoggerFactory.getLogger(FunctionController.class);
@Resource
private FunctionService functionService;
@Resource
private UserBusinessService userBusinessService;
@PostMapping(value = "/findMenu")
public JSONArray findMenu(@RequestParam(value="pNumber") String pNumber,
@RequestParam(value="hasFunction") String hasFunction,
HttpServletRequest request)throws Exception {
//存放数据json数组
JSONArray dataArray = new JSONArray();
try {
//当前用户所拥有的功能列表,格式如:[1][2][5]
String fc = hasFunction;
List<Function> dataList = functionService.getRoleFunction(pNumber);
if (dataList.size() != 0) {
dataArray = getMenuByFunction(dataList, fc);
}
} catch (DataAccessException e) {
logger.error(">>>>>>>>>>>>>>>>>>>查找异常", e);
}
return dataArray;
}
public JSONArray getMenuByFunction(List<Function> dataList, String fc) throws Exception {
JSONArray dataArray = new JSONArray();
for (Function function : dataList) {
JSONObject item = new JSONObject();
List<Function> newList = functionService.getRoleFunction(function.getNumber());
item.put("id", function.getId());
item.put("text", function.getName());
item.put("icon", function.getIcon());
item.put("url", function.getUrl());
//if (Tools.isPluginUrl(function.getUrl())) {
// item.put("path", Tools.md5Encryp(function.getUrl()));
//} else {
// item.put("path", function.getUrl());
//}
item.put("component", function.getComponent());
if (newList.size()>0) {
JSONArray childrenArr = getMenuByFunction(newList, fc);
if(childrenArr.size()>0) {
item.put("children", childrenArr);
dataArray.add(item);
}
} else {
if (fc.indexOf("[" + function.getId().toString() + "]") != -1) {
dataArray.add(item);
}
}
}
return dataArray;
}
@PostMapping(value = "/findMenuByPNumber")
public JSONArray findMenuByPNumber(@RequestBody JSONObject jsonObject,
HttpServletRequest request)throws Exception {
String pNumber = jsonObject.getString("pNumber");
String userId = jsonObject.getString("userId");
//存放数据json数组
JSONArray dataArray = new JSONArray();
try {
Long roleId = 0L;
String fc = "";
List<UserBusiness> roleList = userBusinessService.getBasicData(userId, "UserRole");
if(roleList!=null && roleList.size()>0){
String value = roleList.get(0).getValue();
if(StringUtil.isNotEmpty(value)){
String roleIdStr = value.replace("[", "").replace("]", "");
roleId = Long.parseLong(roleIdStr);
}
}
//当前用户所拥有的功能列表,格式如:[1][2][5]
List<UserBusiness> funList = userBusinessService.getBasicData(roleId.toString(), "RoleFunctions");
if(funList!=null && funList.size()>0){
fc = funList.get(0).getValue();
}
List<Function> dataList = functionService.getRoleFunction(pNumber);
if (dataList.size() != 0) {
dataArray = getMenuByFunction(dataList, fc);
}
} catch (DataAccessException e) {
logger.error(">>>>>>>>>>>>>>>>>>>查找异常", e);
}
return dataArray;
}
/**
* 角色对应功能显示
* @param request
* @return
*/
@GetMapping(value = "/findRoleFunction")
public JSONArray findRoleFunction(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId,
HttpServletRequest request)throws Exception {
JSONArray arr = new JSONArray();
try {
List<Function> dataListFun = functionService.findRoleFunction("0");
//开始拼接json数据
JSONObject outer = new JSONObject();
outer.put("id", 1);
outer.put("key", 1);
outer.put("value", 1);
outer.put("title", "功能列表");
outer.put("attributes", "功能列表");
//存放数据json数组
JSONArray dataArray = new JSONArray();
if (null != dataListFun) {
//根据条件从列表里面移除"系统管理"
List<Function> dataList = new ArrayList<>();
for (Function fun : dataListFun) {
String token = request.getHeader("X-Access-Token");
Long tenantId = Tools.getTenantIdByToken(token);
if (tenantId!=0L) {
if(!("系统管理").equals(fun.getName())) {
dataList.add(fun);
}
} else {
//超管
dataList.add(fun);
}
}
dataArray = getFunctionList(dataList, type, keyId);
outer.put("children", dataArray);
}
arr.add(outer);
} catch (Exception e) {
e.printStackTrace();
}
return arr;
}
public JSONArray getFunctionList(List<Function> dataList, String type, String keyId) throws Exception {
JSONArray dataArray = new JSONArray();
if (null != dataList) {
for (Function function : dataList) {
JSONObject item = new JSONObject();
item.put("id", function.getId());
item.put("key", function.getId());
item.put("value", function.getId());
item.put("title", function.getName());
item.put("attributes", function.getName());
Boolean flag = false;
try {
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + function.getId().toString() + "]");
} catch (Exception e) {
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
}
if (flag == true) {
item.put("checked", true);
}
List<Function> funList = functionService.findRoleFunction(function.getNumber());
if(funList.size()>0) {
JSONArray funArr = getFunctionList(funList, type, keyId);
item.put("children", funArr);
dataArray.add(item);
} else {
dataArray.add(item);
}
}
}
return dataArray;
}
/**
* 根据id列表查找功能信息
* @param functionsIds
* @param request
* @return
*/
@GetMapping(value = "/findByIds")
public BaseResponseInfo findByIds(@RequestParam("functionsIds") String functionsIds,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
try {
List<Function> dataList = functionService.findByIds(functionsIds);
JSONObject outer = new JSONObject();
outer.put("total", dataList.size());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if (null != dataList) {
for (Function function : dataList) {
JSONObject item = new JSONObject();
item.put("Id", function.getId());
item.put("Name", function.getName());
item.put("PushBtn", function.getPushBtn());
item.put("op", 1);
dataArray.add(item);
}
}
outer.put("rows", dataArray);
res.code = 200;
res.data = outer;
} catch (Exception e) {
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
}
package com.jsh.erp.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.InOutItem;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.inOutItem.InOutItemService;
import com.jsh.erp.utils.BaseResponseInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author jishenghua jshERP 2018年12月25日14:38:08
*/
@RestController
@RequestMapping(value = "/inOutItem")
public class InOutItemController {
private Logger logger = LoggerFactory.getLogger(InOutItemController.class);
@Resource
private InOutItemService inOutItemService;
/**
* 查找收支项目信息-下拉框
* @param request
* @return
*/
@GetMapping(value = "/findBySelect")
public String findBySelect(@RequestParam("type") String type, HttpServletRequest request) throws Exception{
String res = null;
try {
List<InOutItem> dataList = inOutItemService.findBySelect(type);
//存放数据json数组
JSONArray dataArray = new JSONArray();
if (null != dataList) {
for (InOutItem inOutItem : dataList) {
JSONObject item = new JSONObject();
item.put("id", inOutItem.getId());
//收支项目名称
item.put("name", inOutItem.getName());
dataArray.add(item);
}
}
res = dataArray.toJSONString();
} catch(Exception e){
e.printStackTrace();
res = "获取数据失败";
}
return res;
}
}
package com.jsh.erp.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.MaterialCategory;
import com.jsh.erp.datasource.entities.SerialNumberEx;
import com.jsh.erp.datasource.vo.TreeNode;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.materialCategory.MaterialCategoryService;
import com.jsh.erp.utils.BaseResponseInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* @author ji—sheng—hua jshERP
*/
@RestController
@RequestMapping(value = "/materialCategory")
public class MaterialCategoryController {
private Logger logger = LoggerFactory.getLogger(MaterialCategoryController.class);
@Resource
private MaterialCategoryService materialCategoryService;
@GetMapping(value = "/getAllList")
public BaseResponseInfo getAllList(@RequestParam("parentId") Long parentId, HttpServletRequest request) throws Exception{
BaseResponseInfo res = new BaseResponseInfo();
try {
List<MaterialCategory> materialCategoryList = materialCategoryService.getAllList(parentId);
res.code = 200;
res.data = materialCategoryList;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
/**
* 根据id来查询商品名称
* @param id
* @param request
* @return
*/
@GetMapping(value = "/findById")
public BaseResponseInfo findById(@RequestParam("id") Long id, HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
try {
List<MaterialCategory> dataList = materialCategoryService.findById(id);
JSONObject outer = new JSONObject();
if (null != dataList) {
for (MaterialCategory mc : dataList) {
outer.put("id", mc.getId());
outer.put("name", mc.getName());
outer.put("parentId", mc.getParentId());
List<MaterialCategory> dataParentList = materialCategoryService.findById(mc.getParentId());
if(dataParentList!=null&&dataParentList.size()>0){
outer.put("parentName", dataParentList.get(0).getName());
}
outer.put("sort", mc.getSort());
outer.put("serialNo", mc.getSerialNo());
outer.put("remark", mc.getRemark());
}
}
res.code = 200;
res.data = outer;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
/**
* create by: cjl
* description:
* 获取商品类别树数据
* create time: 2019/2/19 11:49
* @Param:
* @return com.alibaba.fastjson.JSONArray
*/
@RequestMapping(value = "/getMaterialCategoryTree")
public JSONArray getMaterialCategoryTree(@RequestParam("id") Long id) throws Exception{
JSONArray arr=new JSONArray();
List<TreeNode> materialCategoryTree = materialCategoryService.getMaterialCategoryTree(id);
if(materialCategoryTree!=null&&materialCategoryTree.size()>0){
for(TreeNode node:materialCategoryTree){
String str=JSON.toJSONString(node);
JSONObject obj=JSON.parseObject(str);
arr.add(obj) ;
}
}
return arr;
}
/**
* create by: cjl
* description:
* 新增商品类别数据
* create time: 2019/2/19 17:17
* @Param: beanJson
* @return java.lang.Object
*/
@RequestMapping(value = "/addMaterialCategory")
public Object addMaterialCategory(@RequestParam("info") String beanJson) throws Exception {
JSONObject result = ExceptionConstants.standardSuccess();
MaterialCategory mc= JSON.parseObject(beanJson, MaterialCategory.class);
int i= materialCategoryService.addMaterialCategory(mc);
if(i<1){
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_ADD_FAILED_CODE,
ExceptionConstants.MATERIAL_CATEGORY_ADD_FAILED_MSG);
}
return result;
}
/**
* create by: cjl
* description:
* 修改商品类别数据
* create time: 2019/2/20 9:30
* @Param: beanJson
* @return java.lang.Object
*/
@RequestMapping(value = "/editMaterialCategory")
public Object editMaterialCategory(@RequestParam("info") String beanJson) throws Exception {
JSONObject result = ExceptionConstants.standardSuccess();
MaterialCategory mc= JSON.parseObject(beanJson, MaterialCategory.class);
int i= materialCategoryService.editMaterialCategory(mc);
if(i<1){
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_EDIT_FAILED_CODE,
ExceptionConstants.MATERIAL_CATEGORY_EDIT_FAILED_MSG);
}
return result;
}
}
package com.jsh.erp.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.MaterialExtend;
import com.jsh.erp.datasource.vo.MaterialExtendVo4List;
import com.jsh.erp.service.materialExtend.MaterialExtendService;
import com.jsh.erp.utils.BaseResponseInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author jijiaqing
*/
@RestController
@RequestMapping(value = "/materialsExtend")
public class MaterialExtendController {
private Logger logger = LoggerFactory.getLogger(MaterialExtendController.class);
@Resource
private MaterialExtendService materialExtendService;
@GetMapping(value = "/getDetailList")
public BaseResponseInfo getDetailList(@RequestParam("materialId") Long materialId,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
List<MaterialExtendVo4List> dataList = new ArrayList<MaterialExtendVo4List>();
if(materialId!=0) {
dataList = materialExtendService.getDetailList(materialId);
}
JSONObject outer = new JSONObject();
outer.put("total", dataList.size());
//存放数据json数组
JSONArray dataArray = new JSONArray();
if (null != dataList) {
for (MaterialExtendVo4List md : dataList) {
JSONObject item = new JSONObject();
item.put("id", md.getId());
item.put("barCode", md.getBarCode());
item.put("commodityUnit", md.getCommodityUnit());
item.put("purchaseDecimal", md.getPurchaseDecimal());
item.put("commodityDecimal", md.getCommodityDecimal());
item.put("wholesaleDecimal", md.getWholesaleDecimal());
item.put("lowDecimal", md.getLowDecimal());
dataArray.add(item);
}
}
outer.put("rows", dataArray);
res.code = 200;
res.data = outer;
} catch (Exception e) {
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
@GetMapping(value = "/getInfoByBarCode")
public BaseResponseInfo getInfoByBarCode(@RequestParam("barCode") String barCode,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
MaterialExtend materialExtend = materialExtendService.getInfoByBarCode(barCode);
res.code = 200;
res.data = materialExtend;
} catch (Exception e) {
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
}
package com.jsh.erp.controller;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.material.MaterialService;
import com.jsh.erp.service.materialProperty.MaterialPropertyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* Description
*
* @Author: qiankunpingtai
* @Date: 2019/3/29 15:24
*/
@RestController
@RequestMapping(value = "/materialProperty")
public class MaterialPropertyController {
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment