vue版本上线
This commit is contained in:
@@ -0,0 +1,166 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,420 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,698 @@
|
||||
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.*;
|
||||
import com.jsh.erp.datasource.vo.DepotItemStockWarningCount;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.service.materialExtend.MaterialExtendService;
|
||||
import com.jsh.erp.service.depotItem.DepotItemService;
|
||||
import com.jsh.erp.service.material.MaterialService;
|
||||
import com.jsh.erp.service.redis.RedisService;
|
||||
import com.jsh.erp.service.unit.UnitService;
|
||||
import com.jsh.erp.utils.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||
|
||||
/**
|
||||
* @author ji-sheng-hua 华夏erp
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/depotItem")
|
||||
public class DepotItemController {
|
||||
private Logger logger = LoggerFactory.getLogger(DepotItemController.class);
|
||||
|
||||
@Resource
|
||||
private DepotItemService depotItemService;
|
||||
|
||||
@Resource
|
||||
private MaterialService materialService;
|
||||
|
||||
@Resource
|
||||
private MaterialExtendService materialExtendService;
|
||||
|
||||
@Resource
|
||||
private UnitService unitService;
|
||||
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
|
||||
/**
|
||||
* 只根据商品id查询单据列表
|
||||
* @param mId
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/findDetailByTypeAndMaterialId")
|
||||
public String findDetailByTypeAndMaterialId(
|
||||
@RequestParam(value = Constants.PAGE_SIZE, required = false) Integer pageSize,
|
||||
@RequestParam(value = Constants.CURRENT_PAGE, required = false) Integer currentPage,
|
||||
@RequestParam("materialId") String mId, HttpServletRequest request)throws Exception {
|
||||
Map<String, String> parameterMap = ParamUtils.requestToMap(request);
|
||||
parameterMap.put("mId", mId);
|
||||
PageQueryInfo queryInfo = new PageQueryInfo();
|
||||
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||
if (pageSize != null && pageSize <= 0) {
|
||||
pageSize = 10;
|
||||
}
|
||||
String offset = ParamUtils.getPageOffset(currentPage, pageSize);
|
||||
if (StringUtil.isNotEmpty(offset)) {
|
||||
parameterMap.put(Constants.OFFSET, offset);
|
||||
}
|
||||
List<DepotItemVo4DetailByTypeAndMId> list = depotItemService.findDetailByTypeAndMaterialIdList(parameterMap);
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if (list != null) {
|
||||
for (DepotItemVo4DetailByTypeAndMId d: list) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("Number", d.getNumber()); //商品编号
|
||||
String type = d.getType();
|
||||
String subType = d.getSubType();
|
||||
if(("其它").equals(type)) {
|
||||
item.put("Type", subType); //进出类型
|
||||
} else {
|
||||
item.put("Type", subType + type); //进出类型
|
||||
}
|
||||
item.put("depotName", d.getDepotName()); //仓库名称
|
||||
item.put("BasicNumber", d.getBnum()); //数量
|
||||
item.put("OperTime", d.getOtime().getTime()); //时间
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
objectMap.put("page", queryInfo);
|
||||
if (list == null) {
|
||||
queryInfo.setRows(new ArrayList<Object>());
|
||||
queryInfo.setTotal(BusinessConstants.DEFAULT_LIST_NULL_NUMBER);
|
||||
return returnJson(objectMap, "查找不到数据", ErpInfo.OK.code);
|
||||
}
|
||||
queryInfo.setRows(dataArray);
|
||||
queryInfo.setTotal(depotItemService.findDetailByTypeAndMaterialIdCounts(parameterMap));
|
||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商品条码和仓库id查询库存数量
|
||||
* @param depotId
|
||||
* @param barCode
|
||||
* @param request
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping(value = "/findStockByDepotAndBarCode")
|
||||
public BaseResponseInfo findStockByDepotAndBarCode(
|
||||
@RequestParam("depotId") Long depotId,
|
||||
@RequestParam("barCode") String barCode,
|
||||
HttpServletRequest request) throws Exception{
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
try {
|
||||
BigDecimal stock = BigDecimal.ZERO;
|
||||
Long tenantId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"tenantId").toString());
|
||||
List<MaterialVo4Unit> list = materialService.getMaterialByBarCode(barCode);
|
||||
if(list!=null && list.size()>0) {
|
||||
MaterialVo4Unit materialVo4Unit = list.get(0);
|
||||
stock = depotItemService.getStockByParam(depotId,materialVo4Unit.getId(),null,null,tenantId);
|
||||
String commodityUnit = materialVo4Unit.getCommodityUnit();
|
||||
Long unitId = materialVo4Unit.getUnitId();
|
||||
if(unitId!=null) {
|
||||
Integer ratio = 1;
|
||||
Unit unit = unitService.getUnit(unitId);
|
||||
if(commodityUnit.equals(unit.getOtherUnit())){
|
||||
ratio = unit.getRatio();
|
||||
if(ratio!=0) {
|
||||
stock = stock.divide(BigDecimal.valueOf(ratio),2,BigDecimal.ROUND_HALF_UP); //两位小数
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
map.put("stock", stock);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/getDetailList")
|
||||
public BaseResponseInfo getDetailList(@RequestParam("headerId") Long headerId,
|
||||
@RequestParam("mpList") String mpList,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Long tenantId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"tenantId").toString());
|
||||
try {
|
||||
List<DepotItemVo4WithInfoEx> dataList = new ArrayList<DepotItemVo4WithInfoEx>();
|
||||
if(headerId != 0) {
|
||||
dataList = depotItemService.getDetailList(headerId);
|
||||
}
|
||||
String[] mpArr = mpList.split(",");
|
||||
JSONObject outer = new JSONObject();
|
||||
outer.put("total", dataList.size());
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if (null != dataList) {
|
||||
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("materialExtendId", diEx.getMaterialExtendId() == null ? "" : diEx.getMaterialExtendId());
|
||||
item.put("barCode", diEx.getBarCode());
|
||||
item.put("name", diEx.getMName());
|
||||
item.put("standard", diEx.getMStandard());
|
||||
item.put("model", diEx.getMModel());
|
||||
item.put("materialOther", getOtherInfo(mpArr, diEx));
|
||||
Integer ratio = diEx.getRatio();
|
||||
BigDecimal stock = depotItemService.getStockByParam(diEx.getDepotId(),diEx.getMaterialId(),null,null,tenantId);
|
||||
if(ratio!=null){
|
||||
BigDecimal ratioDecimal = new BigDecimal(ratio.toString());
|
||||
if(ratioDecimal.compareTo(BigDecimal.ZERO)!=0){
|
||||
String otherUnit = diEx.getOtherUnit();
|
||||
if(otherUnit.equals(diEx.getMaterialUnit())) {
|
||||
stock = stock.divide(ratioDecimal,2,BigDecimal.ROUND_HALF_UP); //两位小数
|
||||
}
|
||||
}
|
||||
}
|
||||
item.put("stock", stock);
|
||||
item.put("unit", diEx.getMaterialUnit());
|
||||
item.put("operNumber", diEx.getOperNumber());
|
||||
item.put("basicNumber", diEx.getBasicNumber());
|
||||
item.put("unitPrice", diEx.getUnitPrice());
|
||||
item.put("taxUnitPrice", diEx.getTaxUnitPrice());
|
||||
item.put("allPrice", diEx.getAllPrice());
|
||||
item.put("remark", diEx.getRemark());
|
||||
item.put("img", diEx.getImg());
|
||||
item.put("depotId", diEx.getDepotId() == null ? "" : diEx.getDepotId());
|
||||
item.put("depotName", diEx.getDepotId() == null ? "" : diEx.getDepotName());
|
||||
item.put("anotherDepotId", diEx.getAnotherDepotId() == null ? "" : diEx.getAnotherDepotId());
|
||||
item.put("anotherDepotName", diEx.getAnotherDepotId() == null ? "" : diEx.getAnotherDepotName());
|
||||
item.put("taxRate", diEx.getTaxRate());
|
||||
item.put("taxMoney", diEx.getTaxMoney());
|
||||
item.put("taxLastMoney", diEx.getTaxLastMoney());
|
||||
item.put("mType", diEx.getMaterialType());
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取扩展信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getOtherInfo(String[] mpArr, DepotItemVo4WithInfoEx diEx)throws Exception {
|
||||
String materialOther = "";
|
||||
for (int i = 0; i < mpArr.length; i++) {
|
||||
if (mpArr[i].equals("制造商")) {
|
||||
materialOther = materialOther + ((diEx.getMMfrs() == null || diEx.getMMfrs().equals("")) ? "" : "(" + diEx.getMMfrs() + ")");
|
||||
}
|
||||
if (mpArr[i].equals("自定义1")) {
|
||||
materialOther = materialOther + ((diEx.getMOtherField1() == null || diEx.getMOtherField1().equals("")) ? "" : "(" + diEx.getMOtherField1() + ")");
|
||||
}
|
||||
if (mpArr[i].equals("自定义2")) {
|
||||
materialOther = materialOther + ((diEx.getMOtherField2() == null || diEx.getMOtherField2().equals("")) ? "" : "(" + diEx.getMOtherField2() + ")");
|
||||
}
|
||||
if (mpArr[i].equals("自定义3")) {
|
||||
materialOther = materialOther + ((diEx.getMOtherField3() == null || diEx.getMOtherField3().equals("")) ? "" : "(" + diEx.getMOtherField3() + ")");
|
||||
}
|
||||
}
|
||||
return materialOther;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找所有的明细
|
||||
* @param currentPage
|
||||
* @param pageSize
|
||||
* @param depotId
|
||||
* @param monthTime
|
||||
* @param materialParam
|
||||
* @param mpList
|
||||
* @param request
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping(value = "/findByAll")
|
||||
public BaseResponseInfo findByAll(@RequestParam("currentPage") Integer currentPage,
|
||||
@RequestParam("pageSize") Integer pageSize,
|
||||
@RequestParam("depotId") Long depotId,
|
||||
@RequestParam("monthTime") String monthTime,
|
||||
@RequestParam("materialParam") String materialParam,
|
||||
@RequestParam("mpList") String mpList,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Long tenantId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"tenantId").toString());
|
||||
String timeA = monthTime+"-01 00:00:00";
|
||||
String timeB = Tools.lastDayOfMonth(monthTime)+" 23:59:59";
|
||||
try {
|
||||
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(StringUtil.toNull(materialParam),
|
||||
timeB,(currentPage-1)*pageSize, pageSize);
|
||||
String[] mpArr = mpList.split(",");
|
||||
int total = depotItemService.findByAllCount(StringUtil.toNull(materialParam), timeB);
|
||||
map.put("total", total);
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if (null != dataList) {
|
||||
List<Long> idList = new ArrayList<Long>();
|
||||
for (DepotItemVo4WithInfoEx m : dataList) {
|
||||
idList.add(m.getMId());
|
||||
}
|
||||
List<MaterialExtend> meList = materialExtendService.getListByMIds(idList);
|
||||
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
Long mId = diEx.getMId();
|
||||
item.put("materialName", diEx.getMName());
|
||||
item.put("materialModel", diEx.getMModel());
|
||||
item.put("materialStandard", diEx.getMStandard());
|
||||
//扩展信息
|
||||
String materialOther = getOtherInfo(mpArr, diEx);
|
||||
item.put("materialOther", materialOther);
|
||||
item.put("materialColor", diEx.getMColor());
|
||||
item.put("unitName", getUName(diEx.getMaterialUnit(), diEx.getUnitName()));
|
||||
|
||||
item.put("prevSum", depotItemService.getStockByParam(depotId,mId,null,timeA,tenantId));
|
||||
item.put("inSum", depotItemService.getInNumByParam(depotId,mId,timeA,timeB,tenantId));
|
||||
item.put("outSum", depotItemService.getOutNumByParam(depotId,mId,timeA,timeB,tenantId));
|
||||
BigDecimal thisSum = depotItemService.getStockByParam(depotId,mId,null,timeB,tenantId);
|
||||
item.put("thisSum", thisSum);
|
||||
for(MaterialExtend me:meList) {
|
||||
if(me.getMaterialId().longValue() == diEx.getMId().longValue()) {
|
||||
if(me.getPurchaseDecimal()!=null) {
|
||||
item.put("unitPrice", me.getPurchaseDecimal());
|
||||
item.put("thisAllPrice", thisSum.multiply(me.getPurchaseDecimal()));
|
||||
}
|
||||
}
|
||||
}
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
map.put("rows", dataArray);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel表格
|
||||
* @param depotId
|
||||
* @param monthTime
|
||||
* @param materialParam
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/exportExcel")
|
||||
public void exportExcel(@RequestParam("depotId") Long depotId,
|
||||
@RequestParam("monthTime") String monthTime,
|
||||
@RequestParam("materialParam") String materialParam,
|
||||
HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
Long tenantId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"tenantId").toString());
|
||||
String timeA = monthTime+"-01 00:00:00";
|
||||
String timeB = Tools.lastDayOfMonth(monthTime)+" 23:59:59";
|
||||
try {
|
||||
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(StringUtil.toNull(materialParam),
|
||||
timeB, null, null);
|
||||
//存放数据json数组
|
||||
String[] names = {"名称", "规格", "型号", "单位", "单价", "上月结存数量", "入库数量", "出库数量", "本月结存数量", "结存金额"};
|
||||
String title = "库存报表";
|
||||
List<String[]> objects = new ArrayList<String[]>();
|
||||
if (null != dataList) {
|
||||
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||
Long mId = diEx.getMId();
|
||||
String[] objs = new String[10];
|
||||
objs[0] = diEx.getMName();
|
||||
objs[1] = diEx.getMStandard();
|
||||
objs[2] = diEx.getMModel();
|
||||
objs[3] = diEx.getMaterialUnit();
|
||||
objs[4] = diEx.getPurchaseDecimal().toString();
|
||||
objs[5] = depotItemService.getStockByParam(depotId,mId,null,timeA,tenantId).toString();
|
||||
objs[6] = depotItemService.getInNumByParam(depotId,mId,timeA,timeB,tenantId).toString();
|
||||
objs[7] = depotItemService.getOutNumByParam(depotId,mId,timeA,timeB,tenantId).toString();
|
||||
BigDecimal thisSum = depotItemService.getStockByParam(depotId,mId,null,timeB,tenantId);
|
||||
objs[8] = thisSum.toString();
|
||||
objs[9] = thisSum.multiply(diEx.getPurchaseDecimal()).toString();
|
||||
objects.add(objs);
|
||||
}
|
||||
}
|
||||
File file = ExcelUtils.exportObjectsWithoutTitle(title, names, title, objects);
|
||||
ExportExecUtil.showExec(file, file.getName() + "-" + monthTime, response);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计总计金额
|
||||
* @param depotId
|
||||
* @param monthTime
|
||||
* @param materialParam
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/totalCountMoney")
|
||||
public BaseResponseInfo totalCountMoney(@RequestParam("depotId") Long depotId,
|
||||
@RequestParam("monthTime") String monthTime,
|
||||
@RequestParam("materialParam") String materialParam,
|
||||
HttpServletRequest request) throws Exception{
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Long tenantId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"tenantId").toString());
|
||||
String endTime = Tools.lastDayOfMonth(monthTime)+" 23:59:59";
|
||||
try {
|
||||
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(StringUtil.toNull(materialParam),
|
||||
endTime, null, null);
|
||||
BigDecimal thisAllPrice = BigDecimal.ZERO;
|
||||
if (null != dataList) {
|
||||
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||
Long mId = diEx.getMId();
|
||||
BigDecimal thisSum = depotItemService.getStockByParam(depotId,mId,null,endTime,tenantId);
|
||||
BigDecimal unitPrice = diEx.getPurchaseDecimal();
|
||||
thisAllPrice = thisAllPrice.add(thisSum.multiply(unitPrice));
|
||||
}
|
||||
}
|
||||
map.put("totalCount", thisAllPrice);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 进货统计
|
||||
* @param currentPage
|
||||
* @param pageSize
|
||||
* @param monthTime
|
||||
* @param materialParam
|
||||
* @param mpList
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/buyIn")
|
||||
public BaseResponseInfo buyIn(@RequestParam("currentPage") Integer currentPage,
|
||||
@RequestParam("pageSize") Integer pageSize,
|
||||
@RequestParam("monthTime") String monthTime,
|
||||
@RequestParam("materialParam") String materialParam,
|
||||
@RequestParam("mpList") String mpList,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String endTime = Tools.lastDayOfMonth(monthTime)+" 23:59:59";
|
||||
try {
|
||||
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(StringUtil.toNull(materialParam),
|
||||
endTime, (currentPage-1)*pageSize, pageSize);
|
||||
String[] mpArr = mpList.split(",");
|
||||
int total = depotItemService.findByAllCount(StringUtil.toNull(materialParam), endTime);
|
||||
map.put("total", total);
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if (null != dataList) {
|
||||
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
BigDecimal InSum = depotItemService.buyOrSale("入库", "采购", diEx.getMId(), monthTime, "number");
|
||||
BigDecimal OutSum = depotItemService.buyOrSale("出库", "采购退货", diEx.getMId(), monthTime, "number");
|
||||
BigDecimal InSumPrice = depotItemService.buyOrSale("入库", "采购", diEx.getMId(), monthTime, "price");
|
||||
BigDecimal OutSumPrice = depotItemService.buyOrSale("出库", "采购退货", diEx.getMId(), monthTime, "price");
|
||||
item.put("materialName", diEx.getMName());
|
||||
item.put("materialModel", diEx.getMModel());
|
||||
item.put("materialStandard", diEx.getMStandard());
|
||||
//扩展信息
|
||||
String materialOther = getOtherInfo(mpArr, diEx);
|
||||
item.put("materialOther", materialOther);
|
||||
item.put("materialColor", diEx.getMColor());
|
||||
item.put("materialUnit", diEx.getMaterialUnit());
|
||||
item.put("unitName", diEx.getUnitName());
|
||||
item.put("inSum", InSum);
|
||||
item.put("outSum", OutSum);
|
||||
item.put("inSumPrice", InSumPrice);
|
||||
item.put("outSumPrice", OutSumPrice);
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
map.put("rows", dataArray);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 销售统计
|
||||
* @param currentPage
|
||||
* @param pageSize
|
||||
* @param monthTime
|
||||
* @param materialParam
|
||||
* @param mpList
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/saleOut")
|
||||
public BaseResponseInfo saleOut(@RequestParam("currentPage") Integer currentPage,
|
||||
@RequestParam("pageSize") Integer pageSize,
|
||||
@RequestParam("monthTime") String monthTime,
|
||||
@RequestParam("materialParam") String materialParam,
|
||||
@RequestParam("mpList") String mpList,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String endTime = Tools.lastDayOfMonth(monthTime)+" 23:59:59";
|
||||
try {
|
||||
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(StringUtil.toNull(materialParam),
|
||||
endTime,(currentPage-1)*pageSize, pageSize);
|
||||
String[] mpArr = mpList.split(",");
|
||||
int total = depotItemService.findByAllCount(StringUtil.toNull(materialParam), endTime);
|
||||
map.put("total", total);
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if (null != dataList) {
|
||||
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
BigDecimal OutSumRetail = depotItemService.buyOrSale("出库", "零售", diEx.getMId(), monthTime,"number");
|
||||
BigDecimal OutSum = depotItemService.buyOrSale("出库", "销售", diEx.getMId(), monthTime,"number");
|
||||
BigDecimal InSumRetail = depotItemService.buyOrSale("入库", "零售退货", diEx.getMId(), monthTime,"number");
|
||||
BigDecimal InSum = depotItemService.buyOrSale("入库", "销售退货", diEx.getMId(), monthTime,"number");
|
||||
BigDecimal OutSumRetailPrice = depotItemService.buyOrSale("出库", "零售", diEx.getMId(), monthTime,"price");
|
||||
BigDecimal OutSumPrice = depotItemService.buyOrSale("出库", "销售", diEx.getMId(), monthTime,"price");
|
||||
BigDecimal InSumRetailPrice = depotItemService.buyOrSale("入库", "零售退货", diEx.getMId(), monthTime,"price");
|
||||
BigDecimal InSumPrice = depotItemService.buyOrSale("入库", "销售退货", diEx.getMId(), monthTime,"price");
|
||||
BigDecimal OutInSumPrice = (OutSumRetailPrice.add(OutSumPrice)).subtract(InSumRetailPrice.add(InSumPrice));
|
||||
item.put("materialName", diEx.getMName());
|
||||
item.put("materialModel", diEx.getMModel());
|
||||
item.put("materialStandard", diEx.getMStandard());
|
||||
//扩展信息
|
||||
String materialOther = getOtherInfo(mpArr, diEx);
|
||||
item.put("materialOther", materialOther);
|
||||
item.put("materialColor", diEx.getMColor());
|
||||
item.put("materialUnit", diEx.getMaterialUnit());
|
||||
item.put("unitName", diEx.getUnitName());
|
||||
item.put("outSum", OutSumRetail.add(OutSum));
|
||||
item.put("inSum", InSumRetail.add(InSum));
|
||||
item.put("outSumPrice", OutSumRetailPrice.add(OutSumPrice));
|
||||
item.put("inSumPrice", InSumRetailPrice.add(InSumPrice));
|
||||
item.put("outInSumPrice",OutInSumPrice);//实际销售金额
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
map.put("rows", dataArray);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单位
|
||||
* @param materialUnit
|
||||
* @param uName
|
||||
* @return
|
||||
*/
|
||||
public String getUName(String materialUnit, String uName) {
|
||||
String unitName = null;
|
||||
if(!StringUtil.isEmpty(materialUnit)) {
|
||||
unitName = materialUnit;
|
||||
} else if(!StringUtil.isEmpty(uName)) {
|
||||
unitName = uName.substring(0,uName.indexOf(","));
|
||||
}
|
||||
return unitName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 库存预警报表
|
||||
* @param currentPage
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/findStockWarningCount")
|
||||
public BaseResponseInfo findStockWarningCount(@RequestParam("currentPage") Integer currentPage,
|
||||
@RequestParam("pageSize") Integer pageSize,
|
||||
@RequestParam("materialParam") String materialParam,
|
||||
@RequestParam("depotId") Long depotId,
|
||||
@RequestParam("mpList") String mpList)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
try {
|
||||
String[] mpArr = mpList.split(",");
|
||||
List<DepotItemStockWarningCount> list = depotItemService.findStockWarningCount((currentPage-1)*pageSize, pageSize,materialParam,depotId);
|
||||
//存放数据json数组
|
||||
if (null != list) {
|
||||
for (DepotItemStockWarningCount disw : list) {
|
||||
DepotItemVo4WithInfoEx diEx = new DepotItemVo4WithInfoEx();
|
||||
diEx.setMMfrs(disw.getMMfrs());
|
||||
diEx.setMOtherField1(disw.getMOtherField1());
|
||||
diEx.setMOtherField2(disw.getMOtherField2());
|
||||
diEx.setMOtherField3(disw.getMOtherField3());
|
||||
disw.setMaterialOther(getOtherInfo(mpArr, diEx));
|
||||
disw.setMaterialUnit(getUName(disw.getMaterialUnit(), disw.getUnitName()));
|
||||
}
|
||||
}
|
||||
int total = depotItemService.findStockWarningCountTotal(materialParam,depotId);
|
||||
map.put("total", total);
|
||||
map.put("rows", list);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
/**
|
||||
* 导出库存预警excel表格
|
||||
* @param depotId
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/exportWarningExcel")
|
||||
public BaseResponseInfo exportWarningExcel(
|
||||
@RequestParam("depotId") Long depotId,
|
||||
@RequestParam("materialParam") String materialParam,
|
||||
@RequestParam("mpList") String mpList,
|
||||
HttpServletRequest request, HttpServletResponse response)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String message = "成功";
|
||||
try {
|
||||
String[] mpArr = mpList.split(",");
|
||||
List<DepotItemStockWarningCount> dataList = depotItemService.findStockWarningCount(null, null, materialParam, depotId);
|
||||
//存放数据json数组
|
||||
Long pid = depotId;
|
||||
String[] names = {"名称", "规格", "型号", "扩展信息", "单位", "安全存量", "当前库存", "建议入库量"};
|
||||
String title = "库存预警报表";
|
||||
List<String[]> objects = new ArrayList<String[]>();
|
||||
if (null != dataList) {
|
||||
for (DepotItemStockWarningCount diEx : dataList) {
|
||||
DepotItemVo4WithInfoEx diVI = new DepotItemVo4WithInfoEx();
|
||||
diVI.setMMfrs(diEx.getMMfrs());
|
||||
diVI.setMOtherField1(diEx.getMOtherField1());
|
||||
diVI.setMOtherField2(diEx.getMOtherField2());
|
||||
diVI.setMOtherField3(diEx.getMOtherField3());
|
||||
String materialOther = getOtherInfo(mpArr, diVI);
|
||||
String unitName = getUName(diEx.getMaterialUnit(), diEx.getUnitName());
|
||||
String[] objs = new String[8];
|
||||
objs[0] = diEx.getMName();
|
||||
objs[1] = diEx.getMStandard();
|
||||
objs[2] = diEx.getMModel();
|
||||
objs[3] = materialOther;
|
||||
objs[4] = unitName;
|
||||
objs[5] = diEx.getSafetystock() == null ? "0" : diEx.getSafetystock().toString();
|
||||
objs[6] = diEx.getCurrentNumber() == null ? "0" : diEx.getCurrentNumber().toString();
|
||||
objs[7] = diEx.getLinjieNumber() == null ? "0" : diEx.getLinjieNumber().toString();
|
||||
objects.add(objs);
|
||||
}
|
||||
}
|
||||
File file = ExcelUtils.exportObjectsWithoutTitle(title+pid, names, title, objects);
|
||||
ExportExecUtil.showExec(file, file.getName(), response);
|
||||
res.code = 200;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
message = "导出失败";
|
||||
res.code = 500;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计采购或销售的总金额
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping(value = "/buyOrSalePrice")
|
||||
public BaseResponseInfo buyOrSalePrice(HttpServletRequest request, HttpServletResponse response)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String message = "成功";
|
||||
try {
|
||||
List<String> list = Tools.getLastMonths(6);
|
||||
JSONArray buyPriceList = new JSONArray();
|
||||
for(String month: list) {
|
||||
JSONObject obj = new JSONObject();
|
||||
BigDecimal outPrice = depotItemService.inOrOutPrice("入库", "采购", month);
|
||||
BigDecimal inPrice = depotItemService.inOrOutPrice("出库", "采购退货", month);
|
||||
obj.put("x", month);
|
||||
obj.put("y", outPrice.subtract(inPrice));
|
||||
buyPriceList.add(obj);
|
||||
}
|
||||
map.put("buyPriceList", buyPriceList);
|
||||
JSONArray salePriceList = new JSONArray();
|
||||
for(String month: list) {
|
||||
JSONObject obj = new JSONObject();
|
||||
BigDecimal outPrice = depotItemService.inOrOutPrice("出库", "销售", month);
|
||||
BigDecimal inPrice = depotItemService.inOrOutPrice("入库", "销售退货", month);
|
||||
obj.put("x", month);
|
||||
obj.put("y", outPrice.subtract(inPrice));
|
||||
salePriceList.add(obj);
|
||||
}
|
||||
map.put("salePriceList", salePriceList);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
message = "统计失败";
|
||||
res.code = 500;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,476 @@
|
||||
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.DepotEx;
|
||||
import com.jsh.erp.datasource.entities.Material;
|
||||
import com.jsh.erp.datasource.entities.MaterialVo4Unit;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.service.depotItem.DepotItemService;
|
||||
import com.jsh.erp.service.material.MaterialService;
|
||||
import com.jsh.erp.service.redis.RedisService;
|
||||
import com.jsh.erp.utils.*;
|
||||
import jxl.Sheet;
|
||||
import jxl.Workbook;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||
|
||||
/**
|
||||
* @author ji|sheng|hua jshERP
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/material")
|
||||
public class MaterialController {
|
||||
private Logger logger = LoggerFactory.getLogger(MaterialController.class);
|
||||
|
||||
@Resource
|
||||
private MaterialService materialService;
|
||||
|
||||
@Resource
|
||||
private DepotItemService depotItemService;
|
||||
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
|
||||
@GetMapping(value = "/checkIsExist")
|
||||
public String checkIsExist(@RequestParam("id") Long id, @RequestParam("name") String name,
|
||||
@RequestParam("model") String model, @RequestParam("color") String color,
|
||||
@RequestParam("standard") String standard, @RequestParam("mfrs") String mfrs,
|
||||
@RequestParam("otherField1") String otherField1, @RequestParam("otherField2") String otherField2,
|
||||
@RequestParam("otherField3") String otherField3, @RequestParam("unit") String unit,@RequestParam("unitId") Long unitId,
|
||||
HttpServletRequest request)throws Exception {
|
||||
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||
int exist = materialService.checkIsExist(id, name, model, color, standard, mfrs,
|
||||
otherField1, otherField2, otherField3, unit, unitId);
|
||||
if(exist > 0) {
|
||||
objectMap.put("status", true);
|
||||
} else {
|
||||
objectMap.put("status", false);
|
||||
}
|
||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置状态-启用或者禁用
|
||||
* @param jsonObject
|
||||
* @param request
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@PostMapping(value = "/batchSetStatus")
|
||||
public String batchSetStatus(@RequestBody JSONObject jsonObject,
|
||||
HttpServletRequest request)throws Exception {
|
||||
Boolean status = jsonObject.getBoolean("status");
|
||||
String ids = jsonObject.getString("ids");
|
||||
Map<String, Object> objectMap = new HashMap<>();
|
||||
int res = materialService.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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据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<MaterialVo4Unit> list = materialService.findById(id);
|
||||
res.code = 200;
|
||||
res.data = list;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据meId来查询商品名称
|
||||
* @param meId
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/findByIdWithBarCode")
|
||||
public BaseResponseInfo findByIdWithBarCode(@RequestParam("meId") Long meId,
|
||||
@RequestParam("mpList") String mpList,
|
||||
HttpServletRequest request) throws Exception{
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
String[] mpArr = mpList.split(",");
|
||||
MaterialVo4Unit mu = new MaterialVo4Unit();
|
||||
List<MaterialVo4Unit> list = materialService.findByIdWithBarCode(meId);
|
||||
if(list!=null && list.size()>0) {
|
||||
mu = list.get(0);
|
||||
String expand = ""; //扩展信息
|
||||
for (int i = 0; i < mpArr.length; i++) {
|
||||
if (mpArr[i].equals("制造商")) {
|
||||
expand = expand + ((mu.getMfrs() == null || mu.getMfrs().equals("")) ? "" : "(" + mu.getMfrs() + ")");
|
||||
}
|
||||
if (mpArr[i].equals("自定义1")) {
|
||||
expand = expand + ((mu.getOtherField1() == null || mu.getOtherField1().equals("")) ? "" : "(" + mu.getOtherField1() + ")");
|
||||
}
|
||||
if (mpArr[i].equals("自定义2")) {
|
||||
expand = expand + ((mu.getOtherField2() == null || mu.getOtherField2().equals("")) ? "" : "(" + mu.getOtherField2() + ")");
|
||||
}
|
||||
if (mpArr[i].equals("自定义3")) {
|
||||
expand = expand + ((mu.getOtherField3() == null || mu.getOtherField3().equals("")) ? "" : "(" + mu.getOtherField3() + ")");
|
||||
}
|
||||
}
|
||||
mu.setMaterialOther(expand);
|
||||
}
|
||||
res.code = 200;
|
||||
res.data = mu;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找商品信息-下拉框
|
||||
* @param mpList
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/findBySelect")
|
||||
public JSONObject findBySelect(@RequestParam(value = "categoryId", required = false) Long categoryId,
|
||||
@RequestParam(value = "q", required = false) String q,
|
||||
@RequestParam("mpList") String mpList,
|
||||
@RequestParam(value = "depotId", required = false) Long depotId,
|
||||
@RequestParam("page") Integer currentPage,
|
||||
@RequestParam("rows") Integer pageSize,
|
||||
HttpServletRequest request) throws Exception{
|
||||
JSONObject object = new JSONObject();
|
||||
try {
|
||||
Long tenantId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"tenantId").toString());
|
||||
List<MaterialVo4Unit> dataList = materialService.findBySelectWithBarCode(categoryId, q, (currentPage-1)*pageSize, pageSize);
|
||||
String[] mpArr = mpList.split(",");
|
||||
int total = materialService.findBySelectWithBarCodeCount(categoryId, q);
|
||||
object.put("total", total);
|
||||
JSONArray dataArray = new JSONArray();
|
||||
//存放数据json数组
|
||||
if (null != dataList) {
|
||||
for (MaterialVo4Unit material : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", material.getMeId()); //商品扩展表的id
|
||||
String ratio; //比例
|
||||
if (material.getUnitId() == null || material.getUnitId().equals("")) {
|
||||
ratio = "";
|
||||
} else {
|
||||
ratio = material.getUnitName();
|
||||
if(ratio!=null) {
|
||||
ratio = ratio.substring(ratio.indexOf("("));
|
||||
}
|
||||
}
|
||||
//名称/型号/扩展信息/包装
|
||||
String MaterialName = "";
|
||||
String mBarCode = "";
|
||||
if(material.getmBarCode()!=null) {
|
||||
mBarCode = material.getmBarCode();
|
||||
MaterialName = MaterialName + mBarCode + "_";
|
||||
}
|
||||
item.put("mBarCode", mBarCode);
|
||||
MaterialName = MaterialName + " " + material.getName()
|
||||
+ ((material.getStandard() == null || material.getStandard().equals("")) ? "" : "(" + material.getStandard() + ")")
|
||||
+ ((material.getModel() == null || material.getModel().equals("")) ? "" : "(" + material.getModel() + ")");
|
||||
String expand = ""; //扩展信息
|
||||
for (int i = 0; i < mpArr.length; i++) {
|
||||
if (mpArr[i].equals("制造商")) {
|
||||
expand = expand + ((material.getMfrs() == null || material.getMfrs().equals("")) ? "" : "(" + material.getMfrs() + ")");
|
||||
}
|
||||
if (mpArr[i].equals("自定义1")) {
|
||||
expand = expand + ((material.getOtherField1() == null || material.getOtherField1().equals("")) ? "" : "(" + material.getOtherField1() + ")");
|
||||
}
|
||||
if (mpArr[i].equals("自定义2")) {
|
||||
expand = expand + ((material.getOtherField2() == null || material.getOtherField2().equals("")) ? "" : "(" + material.getOtherField2() + ")");
|
||||
}
|
||||
if (mpArr[i].equals("自定义3")) {
|
||||
expand = expand + ((material.getOtherField3() == null || material.getOtherField3().equals("")) ? "" : "(" + material.getOtherField3() + ")");
|
||||
}
|
||||
}
|
||||
MaterialName = MaterialName + expand + ((material.getCommodityUnit() == null || material.getCommodityUnit().equals("")) ? "" : "(" + material.getCommodityUnit() + ")") + ratio;
|
||||
item.put("materialName", MaterialName);
|
||||
item.put("categoryName", material.getCategoryName());
|
||||
item.put("name", material.getName());
|
||||
item.put("expand", expand);
|
||||
item.put("model", material.getModel());
|
||||
item.put("standard", material.getStandard());
|
||||
item.put("unit", material.getCommodityUnit() + ratio);
|
||||
if(depotId!=null) {
|
||||
BigDecimal stock = depotItemService.getStockByParam(depotId,material.getId(),null,null,tenantId);
|
||||
item.put("stock", stock);
|
||||
}
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
object.put("rows", dataArray);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商品id查找商品信息
|
||||
* @param meId
|
||||
* @param request
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping(value = "/getMaterialByMeId")
|
||||
public JSONObject getMaterialByMeId(@RequestParam(value = "meId", required = false) Long meId,
|
||||
@RequestParam("mpList") String mpList,
|
||||
HttpServletRequest request) throws Exception{
|
||||
JSONObject item = new JSONObject();
|
||||
try {
|
||||
String[] mpArr = mpList.split(",");
|
||||
List<MaterialVo4Unit> materialList = materialService.getMaterialByMeId(meId);
|
||||
if(materialList!=null && materialList.size()!=1) {
|
||||
return item;
|
||||
} else if(materialList.size() == 1) {
|
||||
MaterialVo4Unit material = materialList.get(0);
|
||||
item.put("Id", material.getMeId()); //商品扩展表的id
|
||||
String ratio; //比例
|
||||
if (material.getUnitId() == null || material.getUnitId().equals("")) {
|
||||
ratio = "";
|
||||
} else {
|
||||
ratio = material.getUnitName();
|
||||
ratio = ratio.substring(ratio.indexOf("("));
|
||||
}
|
||||
//名称/型号/扩展信息/包装
|
||||
String MaterialName = "";
|
||||
MaterialName = MaterialName + material.getmBarCode() + "_" + material.getName()
|
||||
+ ((material.getStandard() == null || material.getStandard().equals("")) ? "" : "(" + material.getStandard() + ")");
|
||||
String expand = ""; //扩展信息
|
||||
for (int i = 0; i < mpArr.length; i++) {
|
||||
if (mpArr[i].equals("颜色")) {
|
||||
expand = expand + ((material.getColor() == null || material.getColor().equals("")) ? "" : "(" + material.getColor() + ")");
|
||||
}
|
||||
if (mpArr[i].equals("制造商")) {
|
||||
expand = expand + ((material.getMfrs() == null || material.getMfrs().equals("")) ? "" : "(" + material.getMfrs() + ")");
|
||||
}
|
||||
if (mpArr[i].equals("自定义1")) {
|
||||
expand = expand + ((material.getOtherField1() == null || material.getOtherField1().equals("")) ? "" : "(" + material.getOtherField1() + ")");
|
||||
}
|
||||
if (mpArr[i].equals("自定义2")) {
|
||||
expand = expand + ((material.getOtherField2() == null || material.getOtherField2().equals("")) ? "" : "(" + material.getOtherField2() + ")");
|
||||
}
|
||||
if (mpArr[i].equals("自定义3")) {
|
||||
expand = expand + ((material.getOtherField3() == null || material.getOtherField3().equals("")) ? "" : "(" + material.getOtherField3() + ")");
|
||||
}
|
||||
}
|
||||
MaterialName = MaterialName + expand + ((material.getUnit() == null || material.getUnit().equals("")) ? "" : "(" + material.getUnit() + ")") + ratio;
|
||||
item.put("MaterialName", MaterialName);
|
||||
item.put("name", material.getName());
|
||||
item.put("expand", expand);
|
||||
item.put("model", material.getModel());
|
||||
item.put("standard", material.getStandard());
|
||||
item.put("unit", material.getUnit() + ratio);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成excel表格
|
||||
* @param barCode
|
||||
* @param name
|
||||
* @param standard
|
||||
* @param model
|
||||
* @param categoryId
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@GetMapping(value = "/exportExcel")
|
||||
public void exportExcel(@RequestParam("categoryId") String categoryId,
|
||||
@RequestParam("barCode") String barCode,
|
||||
@RequestParam("name") String name,
|
||||
@RequestParam("standard") String standard,
|
||||
@RequestParam("model") String model,
|
||||
@RequestParam("mpList") String mpList,
|
||||
HttpServletRequest request, HttpServletResponse response) {
|
||||
try {
|
||||
List<MaterialVo4Unit> dataList = materialService.findByAll(StringUtil.toNull(barCode), StringUtil.toNull(name),
|
||||
StringUtil.toNull(standard), StringUtil.toNull(model), StringUtil.toNull(categoryId));
|
||||
String[] names = {"名称", "类型", "型号", "安全存量", "单位", "零售价", "最低售价", "采购价", "销售价", "备注", "状态"};
|
||||
String title = "商品信息";
|
||||
List<String[]> objects = new ArrayList<String[]>();
|
||||
if (null != dataList) {
|
||||
for (MaterialVo4Unit m : dataList) {
|
||||
String[] objs = new String[11];
|
||||
objs[0] = m.getName();
|
||||
objs[1] = m.getCategoryName();
|
||||
objs[2] = m.getModel();
|
||||
objs[3] = m.getSafetyStock() == null? "" : m.getSafetyStock().toString();
|
||||
objs[4] = m.getCommodityUnit();
|
||||
objs[5] = m.getCommodityDecimal() == null? "" : m.getCommodityDecimal().toString();
|
||||
objs[6] = m.getLowDecimal() == null? "" : m.getLowDecimal().toString();
|
||||
objs[7] = m.getPurchaseDecimal() == null? "" : m.getPurchaseDecimal().toString();
|
||||
objs[8] = m.getWholesaleDecimal() == null? "" : m.getWholesaleDecimal().toString();
|
||||
objs[9] = m.getRemark();
|
||||
objs[10] = m.getEnabled() ? "启用" : "禁用";
|
||||
objects.add(objs);
|
||||
}
|
||||
}
|
||||
File file = ExcelUtils.exportObjectsWithoutTitle(title, names, title, objects);
|
||||
ExportExecUtil.showExec(file, file.getName(), response);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* excel表格导入产品(含初始库存)
|
||||
* @param file
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/importExcel")
|
||||
public BaseResponseInfo importExcel(MultipartFile file,
|
||||
HttpServletRequest request, HttpServletResponse response) throws Exception{
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
String message = "成功";
|
||||
try {
|
||||
Sheet src = null;
|
||||
//文件合法性校验
|
||||
try {
|
||||
Workbook workbook = Workbook.getWorkbook(file.getInputStream());
|
||||
src = workbook.getSheet(0);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
res = materialService.importExcel(src);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public BigDecimal parseBigDecimalEx(String str)throws Exception{
|
||||
if(!StringUtil.isEmpty(str)) {
|
||||
return new BigDecimal(str);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@GetMapping(value = "/getMaterialEnableSerialNumberList")
|
||||
public JSONObject getMaterialEnableSerialNumberList(
|
||||
@RequestParam(value = "q", required = false) String q,
|
||||
@RequestParam("page") Integer currentPage,
|
||||
@RequestParam("rows") Integer pageSize,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response)throws Exception {
|
||||
JSONObject object= new JSONObject();
|
||||
try {
|
||||
List<MaterialVo4Unit> list = materialService.getMaterialEnableSerialNumberList(q, (currentPage-1)*pageSize, pageSize);
|
||||
Long count = materialService.getMaterialEnableSerialNumberCount(q);
|
||||
object.put("rows", list);
|
||||
object.put("total", count);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/getMaxBarCode")
|
||||
public BaseResponseInfo getMaxBarCode() throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String barCode = materialService.getMaxBarCode();
|
||||
map.put("barCode", barCode);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品名称模糊匹配
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping(value = "/getMaterialNameList")
|
||||
public JSONArray getMaterialNameList() throws Exception {
|
||||
JSONArray arr = new JSONArray();
|
||||
try {
|
||||
List<String> list = materialService.getMaterialNameList();
|
||||
for (String s : list) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("value", s);
|
||||
item.put("text", s);
|
||||
arr.add(item);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条码查询商品信息
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping(value = "/getMaterialByBarCode")
|
||||
public BaseResponseInfo getMaterialByBarCode(@RequestParam("barCode") String barCode,
|
||||
@RequestParam("mpList") String mpList,
|
||||
HttpServletRequest request) throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
String[] mpArr = mpList.split(",");
|
||||
MaterialVo4Unit mu = new MaterialVo4Unit();
|
||||
List<MaterialVo4Unit> list = materialService.getMaterialByBarCode(barCode);
|
||||
if(list!=null && list.size()>0) {
|
||||
mu = list.get(0);
|
||||
String expand = ""; //扩展信息
|
||||
for (int i = 0; i < mpArr.length; i++) {
|
||||
if (mpArr[i].equals("制造商")) {
|
||||
expand = expand + ((mu.getMfrs() == null || mu.getMfrs().equals("")) ? "" : "(" + mu.getMfrs() + ")");
|
||||
}
|
||||
if (mpArr[i].equals("自定义1")) {
|
||||
expand = expand + ((mu.getOtherField1() == null || mu.getOtherField1().equals("")) ? "" : "(" + mu.getOtherField1() + ")");
|
||||
}
|
||||
if (mpArr[i].equals("自定义2")) {
|
||||
expand = expand + ((mu.getOtherField2() == null || mu.getOtherField2().equals("")) ? "" : "(" + mu.getOtherField2() + ")");
|
||||
}
|
||||
if (mpArr[i].equals("自定义3")) {
|
||||
expand = expand + ((mu.getOtherField3() == null || mu.getOtherField3().equals("")) ? "" : "(" + mu.getOtherField3() + ")");
|
||||
}
|
||||
}
|
||||
mu.setMaterialOther(expand);
|
||||
}
|
||||
res.code = 200;
|
||||
res.data = mu;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
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 {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.jsh.erp.controller;
|
||||
|
||||
import com.jsh.erp.datasource.entities.Msg;
|
||||
import com.jsh.erp.service.msg.MsgService;
|
||||
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 ji sheng hua jshERP
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/msg")
|
||||
public class MsgController {
|
||||
private Logger logger = LoggerFactory.getLogger(MsgController.class);
|
||||
|
||||
@Resource
|
||||
private MsgService msgService;
|
||||
|
||||
@GetMapping("/getMsgByStatus")
|
||||
public BaseResponseInfo getMsgByStatus(@RequestParam("status") String status,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
List<Msg> list = msgService.getMsgByStatus(status);
|
||||
res.code = 200;
|
||||
res.data = list;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@PostMapping("/batchUpdateStatus")
|
||||
public BaseResponseInfo batchUpdateStatus(@RequestParam("ids") String ids,
|
||||
@RequestParam("status") String status,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
msgService.batchUpdateStatus(ids, status);
|
||||
res.code = 200;
|
||||
res.data = "更新成功";
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping("/getMsgCountByStatus")
|
||||
public BaseResponseInfo getMsgCountByStatus(@RequestParam("status") String status,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
Map<String, Long> map = new HashMap<String, Long>();
|
||||
Long count = msgService.getMsgCountByStatus(status);
|
||||
map.put("count", count);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
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.ExceptionConstants;
|
||||
import com.jsh.erp.datasource.entities.MaterialCategory;
|
||||
import com.jsh.erp.datasource.entities.Organization;
|
||||
import com.jsh.erp.datasource.vo.TreeNode;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.service.materialCategory.MaterialCategoryService;
|
||||
import com.jsh.erp.service.organization.OrganizationService;
|
||||
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.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* create by: cjl
|
||||
* description:
|
||||
*
|
||||
* create time: 2019/3/6 10:54
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/organization")
|
||||
public class OrganizationController {
|
||||
private Logger logger = LoggerFactory.getLogger(OrganizationController.class);
|
||||
|
||||
@Resource
|
||||
private OrganizationService organizationService;
|
||||
/**
|
||||
* 根据id来查询机构信息
|
||||
* @param id
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/findById")
|
||||
public BaseResponseInfo findById(@RequestParam("id") Long id, HttpServletRequest request) throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
try {
|
||||
List<Organization> dataList = organizationService.findById(id);
|
||||
JSONObject outer = new JSONObject();
|
||||
if (null != dataList) {
|
||||
for (Organization org : dataList) {
|
||||
outer.put("id", org.getId());
|
||||
outer.put("orgFullName", org.getOrgFullName());
|
||||
outer.put("orgAbr", org.getOrgAbr());
|
||||
outer.put("parentId", org.getParentId());
|
||||
List<Organization> dataParentList = organizationService.findByParentId(org.getParentId());
|
||||
if(dataParentList!=null&&dataParentList.size()>0){
|
||||
//父级机构名称显示简称
|
||||
outer.put("orgParentName", dataParentList.get(0).getOrgAbr());
|
||||
}
|
||||
outer.put("orgNo", org.getOrgNo());
|
||||
outer.put("sort", org.getSort());
|
||||
outer.put("remark", org.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 = "/getOrganizationTree")
|
||||
public JSONArray getOrganizationTree(@RequestParam("id") Long id) throws Exception{
|
||||
JSONArray arr=new JSONArray();
|
||||
List<TreeNode> organizationTree= organizationService.getOrganizationTree(id);
|
||||
if(organizationTree!=null&&organizationTree.size()>0){
|
||||
for(TreeNode node:organizationTree){
|
||||
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
|
||||
*/
|
||||
@PostMapping(value = "/addOrganization")
|
||||
public Object addOrganization(@RequestParam("info") String beanJson) throws Exception {
|
||||
JSONObject result = ExceptionConstants.standardSuccess();
|
||||
Organization org= JSON.parseObject(beanJson, Organization.class);
|
||||
int i= organizationService.addOrganization(org);
|
||||
if(i<1){
|
||||
throw new BusinessRunTimeException(ExceptionConstants.ORGANIZATION_ADD_FAILED_CODE,
|
||||
ExceptionConstants.ORGANIZATION_ADD_FAILED_MSG);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* create by: cjl
|
||||
* description:
|
||||
* 修改机构信息
|
||||
* create time: 2019/2/20 9:30
|
||||
* @Param: beanJson
|
||||
* @return java.lang.Object
|
||||
*/
|
||||
@PostMapping(value = "/editOrganization")
|
||||
public Object editOrganization(@RequestParam("info") String beanJson) throws Exception {
|
||||
JSONObject result = ExceptionConstants.standardSuccess();
|
||||
Organization org= JSON.parseObject(beanJson, Organization.class);
|
||||
int i= organizationService.editOrganization(org);
|
||||
if(i<1){
|
||||
throw new BusinessRunTimeException(ExceptionConstants.ORGANIZATION_EDIT_FAILED_CODE,
|
||||
ExceptionConstants.ORGANIZATION_EDIT_FAILED_MSG);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
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.Person;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.service.person.PersonService;
|
||||
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 ji|sheng|hua 华夏erp
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/person")
|
||||
public class PersonController {
|
||||
private Logger logger = LoggerFactory.getLogger(PersonController.class);
|
||||
|
||||
@Resource
|
||||
private PersonService personService;
|
||||
|
||||
@GetMapping(value = "/getAllList")
|
||||
public BaseResponseInfo getAllList(HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
try {
|
||||
List<Person> personList = personService.getPerson();
|
||||
map.put("personList", personList);
|
||||
res.code = 200;
|
||||
res.data = personList;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据Id获取经手人信息
|
||||
* @param personIDs
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getPersonByIds")
|
||||
public BaseResponseInfo getPersonByIds(@RequestParam("personIDs") String personIDs,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
try {
|
||||
String names = personService.getPersonByIds(personIDs);
|
||||
map.put("names", names);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型获取经手人信息
|
||||
* @param type
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getPersonByType")
|
||||
public BaseResponseInfo getPersonByType(@RequestParam("type") String type,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
try {
|
||||
List<Person> personList = personService.getPersonByType(type);
|
||||
map.put("personList", personList);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型获取经手人信息 1-业务员,2-仓管员,3-财务员
|
||||
* @param typeNum
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/getPersonByNumType")
|
||||
public JSONArray getPersonByNumType(@RequestParam("type") String typeNum,
|
||||
HttpServletRequest request)throws Exception {
|
||||
JSONArray dataArray = new JSONArray();
|
||||
try {
|
||||
String type = "";
|
||||
if (typeNum.equals("1")) {
|
||||
type = "业务员";
|
||||
} else if (typeNum.equals("2")) {
|
||||
type = "仓管员";
|
||||
} else if (typeNum.equals("3")) {
|
||||
type = "财务员";
|
||||
}
|
||||
List<Person> personList = personService.getPersonByType(type);
|
||||
if (null != personList) {
|
||||
for (Person person : personList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", person.getId());
|
||||
item.put("name", person.getName());
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return dataArray;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.jsh.erp.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.PlatformConfig;
|
||||
import com.jsh.erp.service.platformConfig.PlatformConfigService;
|
||||
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.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||
|
||||
/**
|
||||
* @author ji|sheng|hua 华夏erp QQ7827-18920
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/platformConfig")
|
||||
public class PlatformConfigController {
|
||||
private Logger logger = LoggerFactory.getLogger(PlatformConfigController.class);
|
||||
|
||||
@Resource
|
||||
private PlatformConfigService platformConfigService;
|
||||
|
||||
/**
|
||||
* 获取平台名称
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getPlatformName")
|
||||
public String getPlatformName(HttpServletRequest request)throws Exception {
|
||||
String res;
|
||||
try {
|
||||
String platformKey = "platform_name";
|
||||
PlatformConfig platformConfig = platformConfigService.getPlatformConfigByKey(platformKey);
|
||||
res = platformConfig.getPlatformValue();
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res = "ERP系统";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据platformKey更新platformValue
|
||||
* @param object
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/updatePlatformConfigByKey")
|
||||
public String updatePlatformConfigByKey(@RequestBody JSONObject object,
|
||||
HttpServletRequest request)throws Exception {
|
||||
Map<String, Object> objectMap = new HashMap<>();
|
||||
String platformKey = object.getString("platformKey");
|
||||
String platformValue = object.getString("platformValue");
|
||||
int res = platformConfigService.updatePlatformConfigByKey(platformKey, platformValue);
|
||||
if(res > 0) {
|
||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||
} else {
|
||||
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据platformKey查询信息
|
||||
* @param platformKey
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getPlatformConfigByKey")
|
||||
public BaseResponseInfo getPlatformConfigByKey(@RequestParam("platformKey") String platformKey,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
PlatformConfig platformConfig = platformConfigService.getPlatformConfigByKey(platformKey);
|
||||
res.code = 200;
|
||||
res.data = platformConfig;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
package com.jsh.erp.controller;
|
||||
|
||||
import com.gitee.starblues.integration.application.PluginApplication;
|
||||
import com.gitee.starblues.integration.operator.PluginOperator;
|
||||
import com.gitee.starblues.integration.operator.module.PluginInfo;
|
||||
import com.jsh.erp.utils.BaseResponseInfo;
|
||||
import com.jsh.erp.utils.ComputerInfo;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.DigestUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 插件jar 包测试功能
|
||||
* @author jishenghua
|
||||
* @version 1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/plugin")
|
||||
public class PluginController {
|
||||
|
||||
|
||||
private final PluginOperator pluginOperator;
|
||||
|
||||
@Autowired
|
||||
public PluginController(PluginApplication pluginApplication) {
|
||||
this.pluginOperator = pluginApplication.getPluginOperator();
|
||||
}
|
||||
/**
|
||||
* 获取插件信息
|
||||
* @return 返回插件信息
|
||||
*/
|
||||
@GetMapping(value = "/list")
|
||||
public BaseResponseInfo getPluginInfo(@RequestParam(value = "name",required = false) String name,
|
||||
@RequestParam("currentPage") Integer currentPage,
|
||||
@RequestParam("pageSize") Integer pageSize,
|
||||
HttpServletRequest request) throws Exception{
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
try {
|
||||
List<PluginInfo> resList = new ArrayList<>();
|
||||
List<PluginInfo> list = pluginOperator.getPluginInfo();
|
||||
if(StringUtil.isEmpty(name)) {
|
||||
resList = list;
|
||||
} else {
|
||||
for(PluginInfo pi : list) {
|
||||
String desc = pi.getPluginDescriptor().getPluginDescription();
|
||||
if(desc.contains(name)) {
|
||||
resList.add(pi);
|
||||
}
|
||||
}
|
||||
}
|
||||
map.put("rows", resList);
|
||||
map.put("total", resList.size());
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取插件jar文件名
|
||||
* @return 获取插件文件名。只在生产环境显示
|
||||
*/
|
||||
@GetMapping("/files")
|
||||
public Set<String> getPluginFilePaths(){
|
||||
try {
|
||||
return pluginOperator.getPluginFilePaths();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据插件id停止插件
|
||||
* @param id 插件id
|
||||
* @return 返回操作结果
|
||||
*/
|
||||
@PostMapping("/stop/{id}")
|
||||
public BaseResponseInfo stop(@PathVariable("id") String id){
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String message = "";
|
||||
try {
|
||||
if(pluginOperator.stop(id)){
|
||||
message = "plugin '" + id +"' stop success";
|
||||
} else {
|
||||
message = "plugin '" + id +"' stop failure";
|
||||
}
|
||||
map.put("message", message);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
map.put("message", "plugin '" + id +"' stop failure. " + e.getMessage());
|
||||
res.code = 500;
|
||||
res.data = map;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据插件id启动插件
|
||||
* @param id 插件id
|
||||
* @return 返回操作结果
|
||||
*/
|
||||
@PostMapping("/start/{id}")
|
||||
public BaseResponseInfo start(@PathVariable("id") String id){
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String message = "";
|
||||
try {
|
||||
if(pluginOperator.start(id)){
|
||||
message = "plugin '" + id +"' start success";
|
||||
} else {
|
||||
message = "plugin '" + id +"' start failure";
|
||||
}
|
||||
map.put("message", message);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
map.put("message", "plugin '" + id +"' start failure. " + e.getMessage());
|
||||
res.code = 500;
|
||||
res.data = map;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据插件id卸载插件
|
||||
* @param id 插件id
|
||||
* @return 返回操作结果
|
||||
*/
|
||||
@PostMapping("/uninstall/{id}")
|
||||
public BaseResponseInfo uninstall(@PathVariable("id") String id){
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String message = "";
|
||||
try {
|
||||
if(pluginOperator.uninstall(id, true)){
|
||||
message = "plugin '" + id +"' uninstall success";
|
||||
} else {
|
||||
message = "plugin '" + id +"' uninstall failure";
|
||||
}
|
||||
map.put("message", message);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
map.put("message", "plugin '" + id +"' uninstall failure. " + e.getMessage());
|
||||
res.code = 500;
|
||||
res.data = map;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据插件路径安装插件。该插件jar必须在服务器上存在。注意: 该操作只适用于生产环境
|
||||
* @param path 插件路径名称
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PostMapping("/installByPath")
|
||||
public String install(@RequestParam("path") String path){
|
||||
try {
|
||||
if(pluginOperator.install(Paths.get(path))){
|
||||
return "installByPath success";
|
||||
} else {
|
||||
return "installByPath failure";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "installByPath failure : " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传并安装插件。注意: 该操作只适用于生产环境
|
||||
* @param file 上传文件 multipartFile
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PostMapping("/uploadInstallPluginJar")
|
||||
public BaseResponseInfo install(MultipartFile file, HttpServletRequest request, HttpServletResponse response){
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
pluginOperator.uploadPluginAndStart(file);
|
||||
res.code = 200;
|
||||
res.data = "导入成功";
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "导入失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传插件的配置文件。注意: 该操作只适用于生产环境
|
||||
* @param multipartFile 上传文件 multipartFile
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PostMapping("/uploadPluginConfigFile")
|
||||
public String uploadConfig(@RequestParam("configFile") MultipartFile multipartFile){
|
||||
try {
|
||||
if(pluginOperator.uploadConfigFile(multipartFile)){
|
||||
return "uploadConfig success";
|
||||
} else {
|
||||
return "uploadConfig failure";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "uploadConfig failure : " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 备份插件。注意: 该操作只适用于生产环境
|
||||
* @param pluginId 插件id
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PostMapping("/back/{pluginId}")
|
||||
public String backupPlugin(@PathVariable("pluginId") String pluginId){
|
||||
try {
|
||||
if(pluginOperator.backupPlugin(pluginId, "testBack")){
|
||||
return "backupPlugin success";
|
||||
} else {
|
||||
return "backupPlugin failure";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "backupPlugin failure : " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取加密后的mac
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getMacWithSecret")
|
||||
public BaseResponseInfo getMacWithSecret(){
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
String mac = ComputerInfo.getMacAddress();
|
||||
res.code = 200;
|
||||
res.data = DigestUtils.md5DigestAsHex(mac.getBytes());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.jsh.erp.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.constants.BusinessConstants;
|
||||
import com.jsh.erp.service.CommonQueryManager;
|
||||
import com.jsh.erp.utils.*;
|
||||
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;
|
||||
|
||||
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||
|
||||
/**
|
||||
* by jishenghua 2018-9-12 23:58:10 华夏erp
|
||||
*/
|
||||
@RestController
|
||||
public class ResourceController {
|
||||
|
||||
@Resource
|
||||
private CommonQueryManager configResourceManager;
|
||||
|
||||
@GetMapping(value = "/{apiName}/info")
|
||||
public String getList(@PathVariable("apiName") String apiName,
|
||||
@RequestParam("id") Long id,
|
||||
HttpServletRequest request) throws Exception {
|
||||
Object obj = configResourceManager.selectOne(apiName, id);
|
||||
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||
if(obj != null) {
|
||||
objectMap.put("info", obj);
|
||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||
} else {
|
||||
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping(value = "/{apiName}/list")
|
||||
public String getList(@PathVariable("apiName") String apiName,
|
||||
@RequestParam(value = Constants.PAGE_SIZE, required = false) Integer pageSize,
|
||||
@RequestParam(value = Constants.CURRENT_PAGE, required = false) Integer currentPage,
|
||||
@RequestParam(value = Constants.SEARCH, required = false) String search,
|
||||
HttpServletRequest request)throws Exception {
|
||||
Map<String, String> parameterMap = ParamUtils.requestToMap(request);
|
||||
parameterMap.put(Constants.SEARCH, search);
|
||||
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||
if (pageSize != null && pageSize <= 0) {
|
||||
pageSize = 10;
|
||||
}
|
||||
String offset = ParamUtils.getPageOffset(currentPage, pageSize);
|
||||
if (StringUtil.isNotEmpty(offset)) {
|
||||
parameterMap.put(Constants.OFFSET, offset);
|
||||
}
|
||||
List<?> list = configResourceManager.select(apiName, parameterMap);
|
||||
if (list != null) {
|
||||
objectMap.put("total", configResourceManager.counts(apiName, parameterMap));
|
||||
objectMap.put("rows", list);
|
||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||
} else {
|
||||
objectMap.put("total", BusinessConstants.DEFAULT_LIST_NULL_NUMBER);
|
||||
objectMap.put("rows", new ArrayList<Object>());
|
||||
return returnJson(objectMap, "查找不到数据", ErpInfo.OK.code);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping(value = "/{apiName}/add", produces = {"application/javascript", "application/json"})
|
||||
public String addResource(@PathVariable("apiName") String apiName,
|
||||
@RequestBody JSONObject obj, HttpServletRequest request)throws Exception {
|
||||
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||
int insert = configResourceManager.insert(apiName, obj, request);
|
||||
if(insert > 0) {
|
||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||
} else if(insert == -1) {
|
||||
return returnJson(objectMap, ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code);
|
||||
} else {
|
||||
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping(value = "/{apiName}/update", produces = {"application/javascript", "application/json"})
|
||||
public String updateResource(@PathVariable("apiName") String apiName,
|
||||
@RequestBody JSONObject obj, HttpServletRequest request)throws Exception {
|
||||
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||
int update = configResourceManager.update(apiName, obj, request);
|
||||
if(update > 0) {
|
||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||
} else if(update == -1) {
|
||||
return returnJson(objectMap, ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code);
|
||||
} else {
|
||||
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/{apiName}/delete", produces = {"application/javascript", "application/json"})
|
||||
public String deleteResource(@PathVariable("apiName") String apiName,
|
||||
@RequestParam("id") Long id, HttpServletRequest request)throws Exception {
|
||||
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||
int delete = configResourceManager.delete(apiName, id, request);
|
||||
if(delete > 0) {
|
||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||
} else {
|
||||
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/{apiName}/deleteBatch", produces = {"application/javascript", "application/json"})
|
||||
public String batchDeleteResource(@PathVariable("apiName") String apiName,
|
||||
@RequestParam("ids") String ids, HttpServletRequest request)throws Exception {
|
||||
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||
int delete = configResourceManager.deleteBatch(apiName, ids, request);
|
||||
if(delete > 0) {
|
||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||
} else {
|
||||
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping(value = "/{apiName}/checkIsNameExist")
|
||||
public String checkIsNameExist(@PathVariable("apiName") String apiName,
|
||||
@RequestParam Long id, @RequestParam(value ="name", required = false) String name,
|
||||
HttpServletRequest request)throws Exception {
|
||||
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||
int exist = configResourceManager.checkIsNameExist(apiName, id, name);
|
||||
if(exist > 0) {
|
||||
objectMap.put("status", true);
|
||||
} else {
|
||||
objectMap.put("status", false);
|
||||
}
|
||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
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.Role;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.service.role.RoleService;
|
||||
import com.jsh.erp.service.user.UserService;
|
||||
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
||||
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 = "/role")
|
||||
public class RoleController {
|
||||
private Logger logger = LoggerFactory.getLogger(RoleController.class);
|
||||
|
||||
@Resource
|
||||
private RoleService roleService;
|
||||
|
||||
@Resource
|
||||
private UserBusinessService userBusinessService;
|
||||
|
||||
/**
|
||||
* 角色对应应用显示
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/findUserRole")
|
||||
public JSONArray findUserRole(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId,
|
||||
HttpServletRequest request)throws Exception {
|
||||
JSONArray arr = new JSONArray();
|
||||
try {
|
||||
List<Role> dataList = roleService.findUserRole();
|
||||
if (null != dataList) {
|
||||
for (Role role : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", role.getId());
|
||||
item.put("text", role.getName());
|
||||
//勾选判断1
|
||||
Boolean flag = false;
|
||||
try {
|
||||
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + role.getId().toString() + "]");
|
||||
} catch (Exception e) {
|
||||
logger.error(">>>>>>>>>>>>>>>>>设置用户对应的角色:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
||||
}
|
||||
if (flag == true) {
|
||||
item.put("checked", true);
|
||||
}
|
||||
arr.add(item);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/list")
|
||||
public List<Role> list(HttpServletRequest request)throws Exception {
|
||||
return roleService.getRole();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.jsh.erp.controller;
|
||||
|
||||
import com.jsh.erp.service.depotHead.DepotHeadService;
|
||||
import com.jsh.erp.service.sequence.SequenceService;
|
||||
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.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ji-sheng-hua 752*718*920
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/sequence")
|
||||
public class SequenceController {
|
||||
private Logger logger = LoggerFactory.getLogger(SequenceController.class);
|
||||
|
||||
@Resource
|
||||
private SequenceService sequenceService;
|
||||
|
||||
/**
|
||||
* 单据编号生成接口
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/buildNumber")
|
||||
public BaseResponseInfo buildNumber(HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
try {
|
||||
String number = sequenceService.buildOnlyNumber();
|
||||
map.put("defaultNumber", number);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.jsh.erp.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.constants.ExceptionConstants;
|
||||
import com.jsh.erp.datasource.entities.SerialNumberEx;
|
||||
import com.jsh.erp.exception.BusinessParamCheckingException;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.service.serialNumber.SerialNumberService;
|
||||
import com.jsh.erp.utils.ErpInfo;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
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.Map;
|
||||
|
||||
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @Author: cjl
|
||||
* @Date: 2019/1/22 10:29
|
||||
*/
|
||||
@RestController
|
||||
public class SerialNumberController {
|
||||
private Logger logger = LoggerFactory.getLogger(SerialNumberController.class);
|
||||
|
||||
@Resource
|
||||
private SerialNumberService serialNumberService;
|
||||
/**
|
||||
* create by: cjl
|
||||
* description:
|
||||
* 检查序列号是否存在
|
||||
* create time: 2019/1/22 11:02
|
||||
* @Param: id
|
||||
* @Param: materialName
|
||||
* @Param: serialNumber
|
||||
* @Param: request
|
||||
* @return java.lang.Object
|
||||
*/
|
||||
@PostMapping("/serialNumber/checkIsExist")
|
||||
@ResponseBody
|
||||
public Object checkIsExist(@RequestParam("id") Long id, @RequestParam("materialName") String materialName,
|
||||
@RequestParam("serialNumber") String serialNumber, HttpServletRequest request) throws Exception{
|
||||
JSONObject result = ExceptionConstants.standardSuccess();
|
||||
if(StringUtil.isEmpty(serialNumber)){
|
||||
throw new BusinessParamCheckingException(ExceptionConstants.SERIAL_NUMBERE_NOT_BE_EMPTY_CODE,
|
||||
ExceptionConstants.SERIAL_NUMBERE_NOT_BE_EMPTY_MSG);
|
||||
}
|
||||
serialNumberService.checkIsExist(id, materialName, serialNumber);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* create by: cjl
|
||||
* description:
|
||||
*批量添加序列号
|
||||
* create time: 2019/1/29 15:11
|
||||
* @Param: materialName
|
||||
* @Param: serialNumberPrefix
|
||||
* @Param: batAddTotal
|
||||
* @Param: remark
|
||||
* @return java.lang.Object
|
||||
*/
|
||||
@PostMapping("/serialNumber/batAddSerialNumber")
|
||||
@ResponseBody
|
||||
public String batAddSerialNumber(@RequestBody JSONObject jsonObject, HttpServletRequest request)throws Exception{
|
||||
Map<String, Object> objectMap = new HashMap<>();
|
||||
String materialCode = jsonObject.getString("materialCode");
|
||||
String serialNumberPrefix = jsonObject.getString("serialNumberPrefix");
|
||||
Integer batAddTotal = jsonObject.getInteger("batAddTotal");
|
||||
String remark = jsonObject.getString("remark");
|
||||
int insert = serialNumberService.batAddSerialNumber(materialCode,serialNumberPrefix,batAddTotal,remark);
|
||||
if(insert > 0) {
|
||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||
} else if(insert == -1) {
|
||||
return returnJson(objectMap, ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code);
|
||||
} else {
|
||||
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,422 @@
|
||||
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.Supplier;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.service.supplier.SupplierService;
|
||||
import com.jsh.erp.service.systemConfig.SystemConfigService;
|
||||
import com.jsh.erp.service.user.UserService;
|
||||
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
||||
import com.jsh.erp.utils.*;
|
||||
import jxl.Sheet;
|
||||
import jxl.Workbook;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||
|
||||
/**
|
||||
* @author ji|sheng|hua 华夏erp
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/supplier")
|
||||
public class SupplierController {
|
||||
private Logger logger = LoggerFactory.getLogger(SupplierController.class);
|
||||
|
||||
@Resource
|
||||
private SupplierService supplierService;
|
||||
|
||||
@Resource
|
||||
private UserBusinessService userBusinessService;
|
||||
|
||||
@Resource
|
||||
private SystemConfigService systemConfigService;
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
/**
|
||||
* 更新供应商-只更新预付款,其余用原来的值
|
||||
* @param supplierId
|
||||
* @param advanceIn
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/updateAdvanceIn")
|
||||
public String updateAdvanceIn(@RequestParam("supplierId") Long supplierId,
|
||||
@RequestParam("advanceIn") BigDecimal advanceIn,
|
||||
HttpServletRequest request)throws Exception {
|
||||
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||
int res = supplierService.updateAdvanceIn(supplierId, advanceIn);
|
||||
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
|
||||
*/
|
||||
@PostMapping(value = "/findBySelect_cus")
|
||||
public JSONArray findBySelectCus(@RequestParam(value = "UBType", required = false) String ubType,
|
||||
@RequestParam(value = "UBKeyId", required = false) String ubKeyId,
|
||||
HttpServletRequest request) {
|
||||
JSONArray arr = new JSONArray();
|
||||
try {
|
||||
List<Supplier> supplierList = supplierService.findBySelectCus();
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if (null != supplierList) {
|
||||
boolean customerFlag = systemConfigService.getCustomerFlag();
|
||||
for (Supplier supplier : supplierList) {
|
||||
JSONObject item = new JSONObject();
|
||||
//勾选判断1
|
||||
Boolean flag = false;
|
||||
try {
|
||||
flag = userBusinessService.checkIsUserBusinessExist(ubType, ubKeyId, "[" + supplier.getId().toString() + "]");
|
||||
} catch (DataAccessException e) {
|
||||
logger.error(">>>>>>>>>>>>>>>>>查询用户对应的客户:存在异常!");
|
||||
}
|
||||
if (!customerFlag || flag) {
|
||||
item.put("id", supplier.getId());
|
||||
item.put("supplier", supplier.getSupplier()); //客户名称
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
arr = dataArray;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找供应商信息-下拉框
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/findBySelect_sup")
|
||||
public JSONArray findBySelectSup(HttpServletRequest request) throws Exception{
|
||||
JSONArray arr = new JSONArray();
|
||||
try {
|
||||
List<Supplier> supplierList = supplierService.findBySelectSup();
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if (null != supplierList) {
|
||||
for (Supplier supplier : supplierList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", supplier.getId());
|
||||
//供应商名称
|
||||
item.put("supplier", supplier.getSupplier());
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
arr = dataArray;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找会员信息-下拉框
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/findBySelect_retail")
|
||||
public JSONArray findBySelectRetail(HttpServletRequest request)throws Exception {
|
||||
JSONArray arr = new JSONArray();
|
||||
try {
|
||||
List<Supplier> supplierList = supplierService.findBySelectRetail();
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if (null != supplierList) {
|
||||
for (Supplier supplier : supplierList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", supplier.getId());
|
||||
//客户名称
|
||||
item.put("supplier", supplier.getSupplier());
|
||||
item.put("advanceIn", supplier.getAdvanceIn()); //预付款金额
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
arr = dataArray;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查找信息
|
||||
* @param supplierId
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/findById")
|
||||
public BaseResponseInfo findById(@RequestParam("supplierId") Long supplierId,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
JSONArray dataArray = new JSONArray();
|
||||
List<Supplier> dataList = supplierService.findById(supplierId);
|
||||
if (null != dataList) {
|
||||
for (Supplier supplier : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", supplier.getId());
|
||||
//名称
|
||||
item.put("supplier", supplier.getSupplier());
|
||||
item.put("type", supplier.getType());
|
||||
item.put("contacts", supplier.getContacts());
|
||||
item.put("phonenum", supplier.getPhoneNum());
|
||||
item.put("email", supplier.getEmail());
|
||||
item.put("AdvanceIn", supplier.getAdvanceIn());
|
||||
item.put("BeginNeedGet", supplier.getBeginNeedGet());
|
||||
item.put("BeginNeedPay", supplier.getBeginNeedPay());
|
||||
/**
|
||||
* 2018-01-28这里会有空指针异常
|
||||
* */
|
||||
if(supplier.getIsystem()!=null){
|
||||
item.put("isystem", supplier.getIsystem() == (short) 0 ? "是" : "否");
|
||||
}
|
||||
item.put("description", supplier.getDescription());
|
||||
item.put("fax", supplier.getFax());
|
||||
item.put("telephone", supplier.getTelephone());
|
||||
item.put("address", supplier.getAddress());
|
||||
item.put("taxNum", supplier.getTaxNum());
|
||||
item.put("bankName", supplier.getBankName());
|
||||
item.put("accountNumber", supplier.getAccountNumber());
|
||||
item.put("taxRate", supplier.getTaxRate());
|
||||
item.put("enabled", supplier.getEnabled());
|
||||
dataArray.add(item);
|
||||
}
|
||||
res.code = 200;
|
||||
res.data = dataArray;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置状态-启用或者禁用
|
||||
* @param jsonObject
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/batchSetStatus")
|
||||
public String batchSetStatus(@RequestBody JSONObject jsonObject,
|
||||
HttpServletRequest request)throws Exception {
|
||||
Boolean status = jsonObject.getBoolean("status");
|
||||
String ids = jsonObject.getString("ids");
|
||||
Map<String, Object> objectMap = new HashMap<>();
|
||||
int res = supplierService.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 type
|
||||
* @param keyId
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/findUserCustomer")
|
||||
public JSONArray findUserCustomer(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId,
|
||||
HttpServletRequest request) throws Exception{
|
||||
JSONArray arr = new JSONArray();
|
||||
try {
|
||||
List<Supplier> dataList = supplierService.findUserCustomer();
|
||||
//开始拼接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 (Supplier supplier : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", supplier.getId());
|
||||
item.put("text", supplier.getSupplier());
|
||||
//勾选判断1
|
||||
Boolean flag = false;
|
||||
try {
|
||||
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + supplier.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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成excel表格
|
||||
* @param supplier
|
||||
* @param type
|
||||
* @param phonenum
|
||||
* @param telephone
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/exportExcel")
|
||||
public void exportExcel(@RequestParam("supplier") String supplier,
|
||||
@RequestParam("type") String type,
|
||||
@RequestParam("phonenum") String phonenum,
|
||||
@RequestParam("telephone") String telephone,
|
||||
HttpServletRequest request, HttpServletResponse response) {
|
||||
try {
|
||||
List<Supplier> dataList = supplierService.findByAll(supplier, type, phonenum, telephone);
|
||||
String[] names = {"名称", "类型", "联系人", "电话", "电子邮箱", "预收款", "期初应收", "期初应付", "备注", "传真", "手机", "地址", "纳税人识别号", "开户行", "账号", "税率", "状态"};
|
||||
String title = "信息报表";
|
||||
List<String[]> objects = new ArrayList<String[]>();
|
||||
if (null != dataList) {
|
||||
for (Supplier s : dataList) {
|
||||
String[] objs = new String[17];
|
||||
objs[0] = s.getSupplier();
|
||||
objs[1] = s.getType();
|
||||
objs[2] = s.getContacts();
|
||||
objs[3] = s.getPhoneNum();
|
||||
objs[4] = s.getEmail();
|
||||
objs[5] = s.getAdvanceIn() == null? "" : s.getAdvanceIn().toString();
|
||||
objs[6] = s.getBeginNeedGet() == null? "" : s.getBeginNeedGet().toString();
|
||||
objs[7] = s.getBeginNeedPay() == null? "" : s.getBeginNeedPay().toString();
|
||||
objs[8] = s.getDescription();
|
||||
objs[9] = s.getFax();
|
||||
objs[10] = s.getTelephone();
|
||||
objs[11] = s.getAddress();
|
||||
objs[12] = s.getTaxNum();
|
||||
objs[13] = s.getBankName();
|
||||
objs[14] = s.getAccountNumber();
|
||||
objs[15] = s.getTaxRate() == null? "" : s.getTaxRate().toString();
|
||||
objs[16] = s.getEnabled() ? "启用" : "禁用";
|
||||
objects.add(objs);
|
||||
}
|
||||
}
|
||||
File file = ExcelUtils.exportObjectsWithoutTitle(title, names, title, objects);
|
||||
ExportExecUtil.showExec(file, file.getName(), response);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入excel表格
|
||||
* @param file
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/importExcel")
|
||||
public BaseResponseInfo importExcel(MultipartFile file,
|
||||
HttpServletRequest request, HttpServletResponse response) throws Exception{
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
importFun(file);
|
||||
res.code = 200;
|
||||
res.data = "导入成功";
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "导入失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public String importFun(MultipartFile file)throws Exception{
|
||||
BaseResponseInfo info = new BaseResponseInfo();
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
String message = "成功";
|
||||
try {
|
||||
Sheet src = null;
|
||||
//文件合法性校验
|
||||
try {
|
||||
Workbook workbook = Workbook.getWorkbook(file.getInputStream());
|
||||
src = workbook.getSheet(0);
|
||||
} catch (Exception e) {
|
||||
message = "导入文件不合法,请检查";
|
||||
data.put("message", message);
|
||||
info.code = 400;
|
||||
info.data = data;
|
||||
}
|
||||
//每行中数据顺序 "名称","类型","联系人","电话","电子邮箱","预收款","期初应收","期初应付","备注","传真","手机","地址","纳税人识别号","开户行","账号","税率","状态"
|
||||
List<Supplier> sList = new ArrayList<Supplier>();
|
||||
for (int i = 1; i < src.getRows(); i++) {
|
||||
Supplier s = new Supplier();
|
||||
s.setSupplier(ExcelUtils.getContent(src, i, 0));
|
||||
s.setType(ExcelUtils.getContent(src, i, 1));
|
||||
s.setContacts(ExcelUtils.getContent(src, i, 2));
|
||||
s.setPhoneNum(ExcelUtils.getContent(src, i, 3));
|
||||
s.setEmail(ExcelUtils.getContent(src, i, 4));
|
||||
s.setAdvanceIn(parseBigDecimalEx(ExcelUtils.getContent(src, i, 5)));
|
||||
s.setBeginNeedGet(parseBigDecimalEx(ExcelUtils.getContent(src, i, 6)));
|
||||
s.setBeginNeedPay(parseBigDecimalEx(ExcelUtils.getContent(src, i, 7)));
|
||||
s.setDescription(ExcelUtils.getContent(src, i, 8));
|
||||
s.setFax(ExcelUtils.getContent(src, i, 9));
|
||||
s.setTelephone(ExcelUtils.getContent(src, i, 10));
|
||||
s.setAddress(ExcelUtils.getContent(src, i, 11));
|
||||
s.setTaxNum(ExcelUtils.getContent(src, i, 12));
|
||||
s.setBankName(ExcelUtils.getContent(src, i, 13));
|
||||
s.setAccountNumber(ExcelUtils.getContent(src, i, 14));
|
||||
s.setTaxRate(parseBigDecimalEx(ExcelUtils.getContent(src, i, 15)));
|
||||
String enabled = ExcelUtils.getContent(src, i, 16);
|
||||
s.setEnabled(enabled.equals("启用")? true: false);
|
||||
s.setIsystem(Byte.parseByte("1"));
|
||||
sList.add(s);
|
||||
}
|
||||
info = supplierService.importExcel(sList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
message = "导入失败";
|
||||
info.code = 500;
|
||||
data.put("message", message);
|
||||
info.data = data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public BigDecimal parseBigDecimalEx(String str)throws Exception{
|
||||
if(!StringUtil.isEmpty(str)) {
|
||||
return new BigDecimal(str);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
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.Depot;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.service.depot.DepotService;
|
||||
import com.jsh.erp.service.systemConfig.SystemConfigService;
|
||||
import com.jsh.erp.service.user.UserService;
|
||||
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
||||
import com.jsh.erp.utils.BaseResponseInfo;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
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.List;
|
||||
|
||||
/**
|
||||
* Description
|
||||
* @Author: jishenghua
|
||||
* @Date: 2021-3-13 0:01
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/systemConfig")
|
||||
public class SystemConfigController {
|
||||
private Logger logger = LoggerFactory.getLogger(SystemConfigController.class);
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@Resource
|
||||
private DepotService depotService;
|
||||
|
||||
@Resource
|
||||
private UserBusinessService userBusinessService;
|
||||
|
||||
@Resource
|
||||
private SystemConfigService systemConfigService;
|
||||
|
||||
@GetMapping(value = "/getDictItems/{dictCode}")
|
||||
public BaseResponseInfo getDictItems(@PathVariable String dictCode,
|
||||
HttpServletRequest request) {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
Long userId = userService.getUserId(request);
|
||||
JSONArray arr = new JSONArray();
|
||||
if(StringUtil.isNotEmpty(dictCode)) {
|
||||
if (dictCode.equals("depotDict")) {
|
||||
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;
|
||||
String type = "UserDepot";
|
||||
try {
|
||||
flag = userBusinessService.checkIsUserBusinessExist(type, userId.toString(), "[" + depot.getId().toString() + "]");
|
||||
} catch (DataAccessException e) {
|
||||
logger.error(">>>>>>>>>>>>>>>>>查询用户对应的仓库:类型" + type + " KeyId为: " + userId + " 存在异常!");
|
||||
}
|
||||
if (!depotFlag || flag) {
|
||||
item.put("value", depot.getId().toString());
|
||||
item.put("text", depot.getName());
|
||||
item.put("title", depot.getName());
|
||||
arr.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
res.code = 200;
|
||||
res.data = arr;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.jsh.erp.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.constants.BusinessConstants;
|
||||
import com.jsh.erp.constants.ExceptionConstants;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.service.unit.UnitService;
|
||||
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/4/1 15:38
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/unit")
|
||||
public class UnitController {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.jsh.erp.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.constants.ExceptionConstants;
|
||||
import com.jsh.erp.datasource.entities.UserBusiness;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.service.user.UserService;
|
||||
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
||||
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.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||
|
||||
/**
|
||||
* @author ji_sheng_hua jshERP
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/userBusiness")
|
||||
public class UserBusinessController {
|
||||
private Logger logger = LoggerFactory.getLogger(UserBusinessController.class);
|
||||
|
||||
@Resource
|
||||
private UserBusinessService userBusinessService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@GetMapping(value = "/getBasicData")
|
||||
public BaseResponseInfo getBasicData(@RequestParam(value = "KeyId") String keyId,
|
||||
@RequestParam(value = "Type") String type,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
List<UserBusiness> list = userBusinessService.getBasicData(keyId, type);
|
||||
Map<String, List> mapData = new HashMap<String, List>();
|
||||
mapData.put("userBusinessList", list);
|
||||
res.code = 200;
|
||||
res.data = mapData;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "查询权限失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/checkIsValueExist")
|
||||
public String checkIsValueExist(@RequestParam(value ="type", required = false) String type,
|
||||
@RequestParam(value ="keyId", required = false) String keyId,
|
||||
HttpServletRequest request)throws Exception {
|
||||
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||
Long id = userBusinessService.checkIsValueExist(type, keyId);
|
||||
if(id != null) {
|
||||
objectMap.put("id", id);
|
||||
} else {
|
||||
objectMap.put("id", null);
|
||||
}
|
||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新角色的按钮权限
|
||||
* @param userBusinessId
|
||||
* @param btnStr
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/updateBtnStr")
|
||||
public BaseResponseInfo updateBtnStr(@RequestParam(value ="userBusinessId", required = false) Long userBusinessId,
|
||||
@RequestParam(value ="btnStr", required = false) String btnStr,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
int back = userBusinessService.updateBtnStr(userBusinessId, btnStr);
|
||||
if(back > 0) {
|
||||
res.code = 200;
|
||||
res.data = "成功";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "查询权限失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,401 @@
|
||||
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.SysLoginModel;
|
||||
import com.jsh.erp.datasource.entities.Tenant;
|
||||
import com.jsh.erp.datasource.entities.User;
|
||||
import com.jsh.erp.datasource.entities.UserEx;
|
||||
import com.jsh.erp.datasource.vo.TreeNodeEx;
|
||||
import com.jsh.erp.exception.BusinessParamCheckingException;
|
||||
import com.jsh.erp.service.log.LogService;
|
||||
import com.jsh.erp.service.redis.RedisService;
|
||||
import com.jsh.erp.service.tenant.TenantService;
|
||||
import com.jsh.erp.service.user.UserService;
|
||||
import com.jsh.erp.utils.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
||||
|
||||
/**
|
||||
* @author ji_sheng_hua 华夏erp
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/user")
|
||||
public class UserController {
|
||||
private Logger logger = LoggerFactory.getLogger(UserController.class);
|
||||
|
||||
@Value("${manage.roleId}")
|
||||
private Integer manageRoleId;
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@Resource
|
||||
private TenantService tenantService;
|
||||
|
||||
@Resource
|
||||
private LogService logService;
|
||||
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
|
||||
private static String SUCCESS = "操作成功";
|
||||
private static String ERROR = "操作失败";
|
||||
private static final String HTTP = "http://";
|
||||
private static final String CODE_OK = "200";
|
||||
private static final String BASE_CHECK_CODES = "qwertyuiplkjhgfdsazxcvbnmQWERTYUPLKJHGFDSAZXCVBNM1234567890";
|
||||
|
||||
@PostMapping(value = "/login")
|
||||
public BaseResponseInfo login(@RequestBody User userParam,
|
||||
HttpServletRequest request)throws Exception {
|
||||
logger.info("============用户登录 login 方法调用开始==============");
|
||||
String msgTip = "";
|
||||
User user=null;
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
String loginName = userParam.getLoginName().trim();
|
||||
String password = userParam.getPassword().trim();
|
||||
//判断用户是否已经登录过,登录过不再处理
|
||||
Object userId = redisService.getObjectFromSessionByKey(request,"userId");
|
||||
if (userId != null) {
|
||||
logger.info("====用户已经登录过, login 方法调用结束====");
|
||||
msgTip = "user already login";
|
||||
}
|
||||
//获取用户状态
|
||||
int userStatus = -1;
|
||||
try {
|
||||
redisService.deleteObjectBySession(request,"tenantId");
|
||||
userStatus = userService.validateUser(loginName, password);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error(">>>>>>>>>>>>>用户 " + loginName + " 登录 login 方法 访问服务层异常====", e);
|
||||
msgTip = "access service exception";
|
||||
}
|
||||
String token = UUID.randomUUID().toString().replaceAll("-", "") + "";
|
||||
switch (userStatus) {
|
||||
case ExceptionCodeConstants.UserExceptionCode.USER_NOT_EXIST:
|
||||
msgTip = "user is not exist";
|
||||
break;
|
||||
case ExceptionCodeConstants.UserExceptionCode.USER_PASSWORD_ERROR:
|
||||
msgTip = "user password error";
|
||||
break;
|
||||
case ExceptionCodeConstants.UserExceptionCode.BLACK_USER:
|
||||
msgTip = "user is black";
|
||||
break;
|
||||
case ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION:
|
||||
msgTip = "access service error";
|
||||
break;
|
||||
default:
|
||||
try {
|
||||
msgTip = "user can login";
|
||||
//验证通过 ,可以登录,放入session,记录登录日志
|
||||
user = userService.getUserByLoginName(loginName);
|
||||
if(user.getTenantId()!=null) {
|
||||
token = token + "_" + user.getTenantId();
|
||||
}
|
||||
redisService.storageObjectBySession(token,"userId",user.getId());
|
||||
String roleType = userService.getRoleTypeByUserId(user.getId()); //角色类型
|
||||
redisService.storageObjectBySession(token,"roleType",roleType);
|
||||
if(user.getTenantId()!=null) {
|
||||
Tenant tenant = tenantService.getTenantByTenantId(user.getTenantId());
|
||||
if(tenant!=null) {
|
||||
Long tenantId = tenant.getTenantId();
|
||||
Integer userNumLimit = tenant.getUserNumLimit();
|
||||
Integer billsNumLimit = tenant.getBillsNumLimit();
|
||||
if(tenantId!=null) {
|
||||
redisService.storageObjectBySession(token,"tenantId",tenantId); //租户tenantId
|
||||
redisService.storageObjectBySession(token,"userNumLimit",userNumLimit); //用户限制数
|
||||
redisService.storageObjectBySession(token,"billsNumLimit",billsNumLimit); //单据限制数
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error(">>>>>>>>>>>>>>>查询用户名为:" + loginName + " ,用户信息异常", e);
|
||||
}
|
||||
break;
|
||||
}
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("msgTip", msgTip);
|
||||
if(user!=null){
|
||||
redisService.storageObjectBySession(token,"token", token);
|
||||
logService.insertLogWithUserId(user.getId(), user.getTenantId(), "用户",
|
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_LOGIN).append(user.getLoginName()).toString(),
|
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||
data.put("token", token);
|
||||
data.put("user", user);
|
||||
}
|
||||
res.code = 200;
|
||||
res.data = data;
|
||||
logger.info("===============用户登录 login 方法调用结束===============");
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
logger.error(e.getMessage());
|
||||
res.code = 500;
|
||||
res.data = "用户登录失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/getUserSession")
|
||||
public BaseResponseInfo getSessionUser(HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
Long userId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"userId").toString());
|
||||
User user = userService.getUser(userId);
|
||||
user.setPassword(null);
|
||||
data.put("user", user);
|
||||
res.code = 200;
|
||||
res.data = data;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取session失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/logout")
|
||||
public BaseResponseInfo logout(HttpServletRequest request, HttpServletResponse response)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
redisService.deleteObjectBySession(request,"user");
|
||||
redisService.deleteObjectBySession(request,"tenantId");
|
||||
redisService.deleteObjectBySession(request,"userNumLimit");
|
||||
redisService.deleteObjectBySession(request,"billsNumLimit");
|
||||
response.sendRedirect("/login.html");
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "退出失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/resetPwd")
|
||||
public String resetPwd(@RequestBody JSONObject jsonObject,
|
||||
HttpServletRequest request) throws Exception {
|
||||
Map<String, Object> objectMap = new HashMap<>();
|
||||
Long id = jsonObject.getLong("id");
|
||||
String password = "123456";
|
||||
String md5Pwd = Tools.md5Encryp(password);
|
||||
int update = userService.resetPwd(md5Pwd, id);
|
||||
if(update > 0) {
|
||||
return returnJson(objectMap, SUCCESS, ErpInfo.OK.code);
|
||||
} else {
|
||||
return returnJson(objectMap, ERROR, ErpInfo.ERROR.code);
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping(value = "/updatePwd")
|
||||
public String updatePwd(@RequestBody JSONObject jsonObject, HttpServletRequest request)throws Exception {
|
||||
Integer flag = 0;
|
||||
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||
try {
|
||||
String info = "";
|
||||
Long userId = jsonObject.getLong("userId");
|
||||
String oldpwd = jsonObject.getString("oldpassword");
|
||||
String password = jsonObject.getString("password");
|
||||
User user = userService.getUser(userId);
|
||||
String oldPassword = Tools.md5Encryp(oldpwd);
|
||||
String md5Pwd = Tools.md5Encryp(password);
|
||||
//必须和原始密码一致才可以更新密码
|
||||
if(user.getLoginName().equals("jsh")){
|
||||
flag = 3; //jsh用户不能修改密码
|
||||
info = "jsh用户不能修改密码";
|
||||
} else if (oldPassword.equalsIgnoreCase(user.getPassword())) {
|
||||
user.setPassword(md5Pwd);
|
||||
flag = userService.updateUserByObj(user); //1-成功
|
||||
info = "修改成功";
|
||||
} else {
|
||||
flag = 2; //原始密码输入错误
|
||||
info = "原始密码输入错误";
|
||||
}
|
||||
objectMap.put("status", flag);
|
||||
if(flag > 0) {
|
||||
return returnJson(objectMap, info, ErpInfo.OK.code);
|
||||
} else {
|
||||
return returnJson(objectMap, ERROR, ErpInfo.ERROR.code);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(">>>>>>>>>>>>>修改用户ID为 : " + jsonObject.getLong("userId") + "密码信息失败", e);
|
||||
flag = 3;
|
||||
objectMap.put("status", flag);
|
||||
return returnJson(objectMap, ERROR, ErpInfo.ERROR.code);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部用户数据列表
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getAllList")
|
||||
public BaseResponseInfo getAllList(HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
List<User> dataList = userService.getUser();
|
||||
if(dataList!=null) {
|
||||
data.put("userList", dataList);
|
||||
}
|
||||
res.code = 200;
|
||||
res.data = data;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户列表,用于用户下拉框
|
||||
* @param request
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping(value = "/getUserList")
|
||||
public JSONArray getUserList(HttpServletRequest request)throws Exception {
|
||||
JSONArray dataArray = new JSONArray();
|
||||
try {
|
||||
List<User> dataList = userService.getUser();
|
||||
if (null != dataList) {
|
||||
for (User user : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("id", user.getId());
|
||||
item.put("userName", user.getUsername());
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return dataArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* create by: cjl
|
||||
* description:
|
||||
* 新增用户及机构和用户关系
|
||||
* create time: 2019/3/8 16:06
|
||||
* @Param: beanJson
|
||||
* @return java.lang.Object
|
||||
*/
|
||||
@PostMapping("/addUser")
|
||||
@ResponseBody
|
||||
public Object addUser(@RequestBody JSONObject obj, HttpServletRequest request)throws Exception{
|
||||
JSONObject result = ExceptionConstants.standardSuccess();
|
||||
Long userNumLimit = Long.parseLong(redisService.getObjectFromSessionByKey(request,"userNumLimit").toString());
|
||||
Long count = userService.countUser(null,null);
|
||||
if(count>= userNumLimit) {
|
||||
throw new BusinessParamCheckingException(ExceptionConstants.USER_OVER_LIMIT_FAILED_CODE,
|
||||
ExceptionConstants.USER_OVER_LIMIT_FAILED_MSG);
|
||||
} else {
|
||||
UserEx ue= JSONObject.parseObject(obj.toJSONString(), UserEx.class);
|
||||
userService.addUserAndOrgUserRel(ue);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* create by: cjl
|
||||
* description:
|
||||
* 修改用户及机构和用户关系
|
||||
* create time: 2019/3/8 16:06
|
||||
* @Param: beanJson
|
||||
* @return java.lang.Object
|
||||
*/
|
||||
@PutMapping("/updateUser")
|
||||
@ResponseBody
|
||||
public Object updateUser(@RequestBody JSONObject obj)throws Exception{
|
||||
JSONObject result = ExceptionConstants.standardSuccess();
|
||||
UserEx ue= JSONObject.parseObject(obj.toJSONString(), UserEx.class);
|
||||
userService.updateUserAndOrgUserRel(ue);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册用户
|
||||
* @param ue
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@PostMapping(value = "/registerUser")
|
||||
public Object registerUser(@RequestBody UserEx ue,
|
||||
HttpServletRequest request)throws Exception{
|
||||
JSONObject result = ExceptionConstants.standardSuccess();
|
||||
ue.setUsername(ue.getLoginName());
|
||||
userService.checkUserNameAndLoginName(ue); //检查用户名和登录名
|
||||
ue = userService.registerUser(ue,manageRoleId,request);
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping("/getOrganizationUserTree")
|
||||
public JSONArray getOrganizationUserTree()throws Exception{
|
||||
JSONArray arr=new JSONArray();
|
||||
List<TreeNodeEx> organizationUserTree= userService.getOrganizationUserTree();
|
||||
if(organizationUserTree!=null&&organizationUserTree.size()>0){
|
||||
for(TreeNodeEx node:organizationUserTree){
|
||||
String str=JSON.toJSONString(node);
|
||||
JSONObject obj=JSON.parseObject(str);
|
||||
arr.add(obj) ;
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
@GetMapping("/getRoleTypeByUserId")
|
||||
public BaseResponseInfo getRoleTypeByUserId(HttpServletRequest request) {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
String roleType = redisService.getObjectFromSessionByKey(request,"roleType").toString();
|
||||
data.put("roleType", roleType);
|
||||
res.code = 200;
|
||||
res.data = data;
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/randomImage/{key}")
|
||||
public BaseResponseInfo randomImage(HttpServletResponse response,@PathVariable String key){
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
String codeNum = Tools.getCharAndNum(4);
|
||||
String base64 = RandImageUtil.generate(codeNum);
|
||||
data.put("codeNum", codeNum);
|
||||
data.put("base64", base64);
|
||||
res.code = 200;
|
||||
res.data = data;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
res.code = 500;
|
||||
res.data = "获取失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user