作者主页:源码空间站2022
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
农业物资管理系统,管理员可以对角色进行配置,分配用户角色;
主要功能包含:登录、注册、修改密码、零售出库、零售退货、采购订单管理、采购入库管理、采购退货管理、销售管理、财务管理、报表管理、物资管理、基本资料管理。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.数据库:MySql 5.7版本;
6.是否Maven项目: 是;
技术栈
1. 后端:springboot MyBatis
2. 前端:HTML+css+javascript+jQuery+easyui
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;
3. 将项目中application.properties配置文件中的数据库配置改为自己的配置;
4. 运行成功后,访问http://localhost:8080/ 到登录页面
管理员用户名:admin 密码:123456
运行截图
代码相关
账户相关控制器
@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 = "/updateAmountIsDefault")
public String updateAmountIsDefault(@RequestParam("isDefault") Boolean isDefault,
@RequestParam("accountId") Long accountId,
HttpServletRequest request) throws Exception {
Map<String, Object> objectMap = new HashMap<String, Object>();
int res = accountService.updateAmountIsDefault(isDefault, accountId);
if (res > 0) {
return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
} else {
return ResponseJsonUtil.returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
}
}
/**
* 批量删除账户信息
*
* @return java.lang.Object
* @Param: ids
*/
@RequestMapping(value = "/batchDeleteAccountByIds")
public Object batchDeleteAccountByIds(@RequestParam("ids") String ids, @RequestParam(value = "deleteType",
required = false, defaultValue = BusinessConstants.DELETE_TYPE_NORMAL) String deleteType) throws Exception {
JSONObject result = ExceptionConstants.standardSuccess();
/**
* description:
* 出于兼容性考虑,没有传递删除类型时,默认为正常删除
*/
int i = 0;
if (BusinessConstants.DELETE_TYPE_NORMAL.equals(deleteType)) {
i = accountService.batchDeleteAccountByIdsNormal(ids);
} else if (BusinessConstants.DELETE_TYPE_FORCE.equals(deleteType)) {
i = accountService.batchDeleteAccountByIds(ids);
} else {
logger.error("异常码[{}],异常提示[{}],参数,ids[{}],deleteType[{}]",
ExceptionConstants.DELETE_REFUSED_CODE, ExceptionConstants.DELETE_REFUSED_MSG, ids, deleteType);
throw new BusinessRunTimeException(ExceptionConstants.DELETE_REFUSED_CODE,
ExceptionConstants.DELETE_REFUSED_MSG);
}
if (i < 1) {
logger.error("异常码[{}],异常提示[{}],参数,ids[{}]",
ExceptionConstants.ACCOUNT_DELETE_FAILED_CODE, ExceptionConstants.ACCOUNT_DELETE_FAILED_MSG, ids);
throw new BusinessRunTimeException(ExceptionConstants.ACCOUNT_DELETE_FAILED_CODE,
ExceptionConstants.ACCOUNT_DELETE_FAILED_MSG);
}
return result;
}
}
仓库管理控制器
@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
*/
@RequestMapping(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;
}
/**
* 批量删除仓库信息
*
* @return java.lang.Object
* @Param: ids
*/
@RequestMapping(value = "/batchDeleteDepotByIds")
public Object batchDeleteDepotByIds(@RequestParam("ids") String ids, @RequestParam(value = "deleteType",
required = false, defaultValue = BusinessConstants.DELETE_TYPE_NORMAL) String deleteType) throws Exception {
JSONObject result = ExceptionConstants.standardSuccess();
int i = 0;
if (BusinessConstants.DELETE_TYPE_NORMAL.equals(deleteType)) {
i = depotService.batchDeleteDepotByIdsNormal(ids);
} else if (BusinessConstants.DELETE_TYPE_FORCE.equals(deleteType)) {
i = depotService.batchDeleteDepotByIds(ids);
} else {
logger.error("异常码[{}],异常提示[{}],参数,ids[{}],deleteType[{}]",
ExceptionConstants.DELETE_REFUSED_CODE, ExceptionConstants.DELETE_REFUSED_MSG, ids, deleteType);
throw new BusinessRunTimeException(ExceptionConstants.DELETE_REFUSED_CODE,
ExceptionConstants.DELETE_REFUSED_MSG);
}
if (i < 1) {
logger.error("异常码[{}],异常提示[{}],参数,ids[{}]",
ExceptionConstants.DEPOT_DELETE_FAILED_CODE, ExceptionConstants.DEPOT_DELETE_FAILED_MSG, ids);
throw new BusinessRunTimeException(ExceptionConstants.DEPOT_DELETE_FAILED_CODE,
ExceptionConstants.DEPOT_DELETE_FAILED_MSG);
}
return result;
}
@PostMapping(value = "/updateDepotIsDefault")
public String updateDepotIsDefault(@RequestParam("isDefault") Boolean isDefault,
@RequestParam("depotID") Long depotID,
HttpServletRequest request) throws Exception {
Map<String, Object> objectMap = new HashMap<String, Object>();
int res = depotService.updateDepotIsDefault(isDefault, depotID);
if (res > 0) {
return ResponseJsonUtil.returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
} else {
return ResponseJsonUtil.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 stock = materialService.getInitStock(mId, depot.getId());
de.setStock(stock);
} else {
de.setStock(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;
}
}
如果也想学习本系统,下面领取。回复:087springboot