基于javaweb+mysql的springboot办公erp管理系统(java+springboot+easyui+maven+mysql+html)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot办公erp管理系统(java+springboot+easyui+maven+mysql+html)
项目介绍
系统主要功能包括: 首页 零售管理:零售出库、零售退货; 采购管理:采购订单、采购入库、采购退货; 销售管理:销售订单、销售出库、销售退货; 仓库管理:其它入库、其它出库、调拨出库、组装单、拆卸单; 财务管理:收入单、支出单、收款单、付款单、转账单、收预付款; 报表查询:库存状况、结算账户、进货统计、销售统计、入库明细、出库明细、入库汇总、出库汇总、客户对账、供应商对账、库存预警; 商品管理:商品类别、商品信息、计量单位、序列号; 基本资料:供应商信息、客户信息、会员信息、仓库信息、收支项目、结算账户、经手人管理;
系统管理:角色管理、机构管理、用户管理、日志管理、系统配置;
环境需要
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或8.0版本;
6.是否Maven项目:是;
技术栈
-
核心框架:SpringBoot 2.0.0 * 持久层框架:Mybatis 1.3.2 * 日志管理:Log4j 2.10.0 * JS框架:Jquery 1.8.0 * UI框架: EasyUI 1.3.5 * 模板框架: AdminLTE 2.4.0
-
项目管理框架: Maven 3.2.3
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.properties配置文件中的数据库配置改为自己的配置; 4. 运行com.jsh.erp包中的ErpApplication类,启动项目。(使用SpringBoot的启动方式) 5. 浏览器地址访问登录页面http://localhost:8080/login.html 默认管理员账号:admin,管理员账号一些特殊模块不具有修改权限,建议使用普通账号:jsh,密码都为123456
/**
* 查询单位的累计应收和累计应付,收预付款不计入此处
* @param supplierId
* @param endTime
* @param supType
* @return
*/
public BigDecimal findTotalPay(Integer supplierId, String endTime, String supType) {
BigDecimal sum = BigDecimal.ZERO;
String getS = supplierId.toString();
int i = 1;
if (("customer").equals(supType)) { //客户
i = 1;
} else if (("vendor").equals(supType)) { //供应商
i = -1;
}
//收付款部分
sum = sum.add((allMoney(getS, "付款", "合计",endTime).add(allMoney(getS, "付款", "实际",endTime))).multiply(new BigDecimal(i)));
sum = sum.subtract((allMoney(getS, "收款", "合计",endTime).add(allMoney(getS, "收款", "实际",endTime))).multiply(new BigDecimal(i)));
sum = sum.add((allMoney(getS, "收入", "合计",endTime).subtract(allMoney(getS, "收入", "实际",endTime))).multiply(new BigDecimal(i)));
sum = sum.subtract((allMoney(getS, "支出", "合计",endTime).subtract(allMoney(getS, "支出", "实际",endTime))).multiply(new BigDecimal(i)));
return sum;
}
public List<AccountHeadVo4ListEx> getDetailByNumber(String billNo)throws Exception {
List<AccountHeadVo4ListEx> resList = new ArrayList<AccountHeadVo4ListEx>();
List<AccountHeadVo4ListEx> list = null;
try{
list = accountHeadMapperEx.getDetailByNumber(billNo);
}catch(Exception e){
JshException.readFail(logger, e);
}
if (null != list) {
for (AccountHeadVo4ListEx ah : list) {
if(ah.getChangeamount() != null) {
ah.setChangeamount(ah.getChangeamount().abs());
}
if(ah.getTotalprice() != null) {
ah.setTotalprice(ah.getTotalprice().abs());
}
resList.add(ah);
}
}
return resList;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteAccountHeadByIds(String ids)throws Exception {
logService.insertLog("财务",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
JshException.readFail(logger, e);
}
if(materialList!=null&&materialList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,CategoryIds[{}]",
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
}
/**
* 校验产品类型表 jsh_materialcategory
* */
List<MaterialCategory> materialCategoryList=null;
try{
materialCategoryList= materialCategoryMapperEx.getMaterialCategoryListByCategoryIds(idArray);
}catch(Exception e){
JshException.readFail(logger, e);
}
if(materialCategoryList!=null&&materialCategoryList.size()>0){
logger.error("异常码[{}],异常提示[{}],参数,CategoryIds[{}]",
ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
}
/**
* 校验通过执行删除操作
* */
deleteTotal= batchDeleteMaterialCategoryByIds(ids);
return deleteTotal;
}
}
}
info = materialService.importExcel(mList);
} catch (Exception e) {
e.printStackTrace();
message = "导入失败";
info.code = 500;
data.put("message", message);
info.data = data;
}
response.sendRedirect("../pages/materials/material.html");
}
public BigDecimal parseBigDecimalEx(String str)throws Exception{
if(!StringUtil.isEmpty(str)) {
return new BigDecimal(str);
} else {
return null;
}
}
@RequestMapping(value = "/getMaterialEnableSerialNumberList")
public String getMaterialEnableSerialNumberList(@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)throws Exception {
Map<String, Object> parameterMap = new HashMap<String, Object>();
//查询参数
JSONObject obj=JSON.parseObject(search);
Set<String> key= obj.keySet();
for(String keyEach: key){
parameterMap.put(keyEach,obj.getString(keyEach));
}
PageQueryInfo queryInfo = new PageQueryInfo();
Map<String, Object> objectMap = new HashMap<String, Object>();
if (pageSize == null || pageSize <= 0) {
pageSize = BusinessConstants.DEFAULT_PAGINATION_PAGE_SIZE;
}
if (currentPage == null || currentPage <= 0) {
currentPage = BusinessConstants.DEFAULT_PAGINATION_PAGE_NUMBER;
}
PageHelper.startPage(currentPage,pageSize,true);
List<Material> list = materialService.getMaterialEnableSerialNumberList(parameterMap);
//获取分页查询后的数据
String md5Pwd = Tools.md5Encryp(password);
//必须和原始密码一致才可以更新密码
if(user.getLoginame().equals("jsh")){
flag = 3; //管理员jsh不能修改密码
} else if (oldPassword.equalsIgnoreCase(user.getPassword())) {
user.setPassword(md5Pwd);
flag = userService.updateUserByObj(user); //1-成功
} else {
flag = 2; //原始密码输入错误
}
objectMap.put("status", flag);
if(flag > 0) {
return returnJson(objectMap, message, ErpInfo.OK.code);
} else {
return returnJson(objectMap, message, ErpInfo.ERROR.code);
}
} catch (Exception e) {
logger.error(">>>>>>>>>>>>>修改用户ID为 : " + userId + "密码信息失败", e);
flag = 3;
objectMap.put("status", flag);
return returnJson(objectMap, message, 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();
* @return
*/
public static String removeSymbolForString(String s) {
StringBuffer buffer = new StringBuffer();
char[] chars = s.toCharArray();
for (int i = 0; i < chars.length; i++) {
if ((chars[i] >= 19968 && chars[i] <= 40869) || (chars[i] >= 97 && chars[i] <= 122) || (chars[i] >= 65 && chars[i] <= 90)) {
buffer.append(chars[i]);
}
}
return buffer.toString();
}
/**
* 获取一个字符串的MD5
*
* @param msg
* @return 加密后的MD5字符串
* @throws NoSuchAlgorithmException
*/
public static String md5Encryp(String msg) throws NoSuchAlgorithmException {
// 生成一个MD5加密计算摘要
MessageDigest md = MessageDigest.getInstance("MD5");
// 计算md5函数
md.update(msg.getBytes());
return new BigInteger(1, md.digest()).toString(16);
}
/**
* 处理字符串null值
*
* @param beforeStr 处理前字符串
* @return 处理后的字符串
*/
public static String dealNullStr(String beforeStr) {
if (null == beforeStr || beforeStr.length() == 0)
return "";
return beforeStr;
}
/**
* description:
* 获取当前用户信息
* @Param:
* @return com.jsh.erp.datasource.entities.User
*/
public User getCurrentUser()throws Exception{
HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
return (User)request.getSession().getAttribute("user");
}
public List<UserEx> getUserList(Map<String, Object> parameterMap) throws Exception{
List<UserEx> list=null;
try{
list= userMapperEx.getUserList(parameterMap);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void addUserAndOrgUserRel(UserEx ue) throws Exception{
if(BusinessConstants.DEFAULT_MANAGER.equals(ue.getLoginame())) {
throw new BusinessRunTimeException(ExceptionConstants.USER_NAME_LIMIT_USE_CODE,
ExceptionConstants.USER_NAME_LIMIT_USE_MSG);
} else {
logService.insertLog("用户",
BusinessConstants.LOG_OPERATION_TYPE_ADD,
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
//检查用户名和登录名
checkUserNameAndLoginName(ue);
//新增用户信息
ue= this.addUser(ue);
if(ue==null){
logger.error("异常码[{}],异常提示[{}],参数,[{}]",
ExceptionConstants.USER_ADD_FAILED_CODE,ExceptionConstants.USER_ADD_FAILED_MSG);
throw new BusinessRunTimeException(ExceptionConstants.USER_ADD_FAILED_CODE,
ExceptionConstants.USER_ADD_FAILED_MSG);
}
if(ue.getOrgaId()==null){
//如果没有选择机构,就不建机构和用户的关联关系
//勾选判断3
//Boolean flag = false;
try {
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + functions2.getId().toString() + "]");
} catch (Exception e) {
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
}
if (flag == true) {
item2.put("checked", true);
}
//结束
List<Functions> dataList3 = functionsService.findRoleFunctions(functions2.getNumber());
JSONArray dataArray3 = new JSONArray();
if (null != dataList3) {
for (Functions functions3 : dataList3) {
item2.put("state", "closed"); //如果不为空,节点不展开
JSONObject item3 = new JSONObject();
item3.put("id", functions3.getId());
item3.put("text", functions3.getName());
//勾选判断4
//Boolean flag = false;
try {
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + functions3.getId().toString() + "]");
} catch (Exception e) {
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
}
if (flag == true) {
item3.put("checked", true);
}
//结束
dataArray3.add(item3);
item2.put("children", dataArray3);
}
}
dataArray2.add(item2);
item1.put("children", dataArray2);
}
}
dataArray1.add(item1);
item.put("children", dataArray1);
}
/**
* 统计该商品已分批出库的总数量-用于订单
* @param mid
* @param headerId
* @return
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public BigDecimal getFinishNumber(Long mid, Long headerId) {
DepotHead depotHead =depotHeadMapper.selectByPrimaryKey(headerId);
String linkNumber = depotHead.getLinknumber(); //关联单号
BigDecimal count = depotItemMapperEx.getFinishNumber(mid, linkNumber);
return count;
}
/**
* 库存统计
* @param depotId
* @param mId
* @param beginTime
* @param endTime
* @return
*/
public BigDecimal getStockByParam(Long depotId, Long mId, String beginTime, String endTime, Long tenantId){
DepotItemVo4Stock stockObj = depotItemMapperEx.getStockByParam(depotId, mId, beginTime, endTime, tenantId);
BigDecimal intNum = stockObj.getInNum();
BigDecimal outNum = stockObj.getOutNum();
return intNum.subtract(outNum);
}
/**
* 入库统计
* @param depotId
* @param mId
* @param beginTime
* @param endTime
* @return
*/
public BigDecimal getInNumByParam(Long depotId, Long mId, String beginTime, String endTime, Long tenantId){
DepotItemVo4Stock stockObj = depotItemMapperEx.getStockByParam(depotId, mId, beginTime, endTime, tenantId);
return stockObj.getInNum();
}
@Resource
private MaterialService materialService;
/**
* 只根据商品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()); //商品编号
item.put("Type", d.getNewtype()); //进出类型
item.put("BasicNumber", d.getBnum()); //数量
item.put("OperTime", d.getOtime()); //时间
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);
try{
list= depotMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public List<DepotEx> getDepotList(Map<String, Object> parameterMap)throws Exception {
List<DepotEx> list=null;
try{
list= depotMapperEx.getDepotList(parameterMap);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteDepotByIds(String ids)throws Exception {
logService.insertLog("仓库",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(",");
int result=0;
try{
result= depotMapperEx.batchDeleteDepotByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
/**
* create by: qiankunpingtai
* website:https://qiankunpingtai.cn
* description:
* 正常删除,要考虑数据完整性,进行完整性校验
* @Param: ids
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteDepotByIdsNormal(String ids) throws Exception {
/**
* 校验
* 1、单据主表 jsh_depothead
* 2、单据子表 jsh_depotitem
res.data = "获取数据失败";
}
return res;
}
/**
* create by: qiankunpingtai
* website:https://qiankunpingtai.cn
* description:
* 批量删除功能模块信息
* @Param: ids
* @return java.lang.Object
*/
@RequestMapping(value = "/batchDeleteFunctionsByIds")
public Object batchDeleteFunctionsByIds(@RequestParam("ids") String ids) throws Exception {
JSONObject result = ExceptionConstants.standardSuccess();
int i= functionsService.batchDeleteFunctionsByIds(ids);
if(i<1){
logger.error("异常码[{}],异常提示[{}],参数,ids[{}]",
ExceptionConstants.FUNCTIONS_DELETE_FAILED_CODE,ExceptionConstants.FUNCTIONS_DELETE_FAILED_MSG,ids);
throw new BusinessRunTimeException(ExceptionConstants.FUNCTIONS_DELETE_FAILED_CODE,
ExceptionConstants.FUNCTIONS_DELETE_FAILED_MSG);
}
return result;
}
}
ue= this.addUser(ue);
if(ue==null){
logger.error("异常码[{}],异常提示[{}],参数,[{}]",
ExceptionConstants.USER_ADD_FAILED_CODE,ExceptionConstants.USER_ADD_FAILED_MSG);
throw new BusinessRunTimeException(ExceptionConstants.USER_ADD_FAILED_CODE,
ExceptionConstants.USER_ADD_FAILED_MSG);
}
if(ue.getOrgaId()==null){
//如果没有选择机构,就不建机构和用户的关联关系
return;
}
//新增用户和机构关联关系
OrgaUserRel oul=new OrgaUserRel();
//机构id
oul.setOrgaId(ue.getOrgaId());
//用户id
oul.setUserId(ue.getId());
//用户在机构中的排序
oul.setUserBlngOrgaDsplSeq(ue.getUserBlngOrgaDsplSeq());
oul=orgaUserRelService.addOrgaUserRel(oul);
if(oul==null){
logger.error("异常码[{}],异常提示[{}],参数,[{}]",
ExceptionConstants.ORGA_USER_REL_ADD_FAILED_CODE,ExceptionConstants.ORGA_USER_REL_ADD_FAILED_MSG);
throw new BusinessRunTimeException(ExceptionConstants.ORGA_USER_REL_ADD_FAILED_CODE,
ExceptionConstants.ORGA_USER_REL_ADD_FAILED_MSG);
}
}
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public UserEx addUser(UserEx ue) throws Exception{
/**
* 新增用户默认设置
* 1、密码默认123456
* 2是否系统自带默认为非系统自带
* 3是否管理者默认为员工
* 4默认用户状态为正常
* */
ue.setPassword(Tools.md5Encryp(BusinessConstants.USER_DEFAULT_PASSWORD));
ue.setIsystem(BusinessConstants.USER_NOT_SYSTEM);
if(ue.getIsmanager()==null){
ue.setIsmanager(BusinessConstants.USER_NOT_MANAGER);
}
ue.setStatus(BusinessConstants.USER_STATUS_NORMAL);
int result=0;
try{
result= userMapperEx.addUser(ue);
}catch(Exception e){
JshException.writeFail(logger, e);
}
if(result>0){
return ue;
public static String getCenternTime(Date date) {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
}
/**
* 获得指定时间,格式为mm:ss
*
* @return 格式化后的日期格式
*/
public static String getTimeInfo(Date date) {
return new SimpleDateFormat("mm:ss").format(date);
}
/**
* 获取当前日期是星期几
* return 星期几
*/
public static String getWeekDay() {
Calendar c = Calendar.getInstance(Locale.CHINA);
c.setTime(new Date());
int day = c.get(Calendar.DAY_OF_WEEK);
String weekDay = "";
switch (day) {
case 1:
weekDay = "星期日";
break;
case 2:
weekDay = "星期一";
break;
case 3:
weekDay = "星期二";
break;
case 4:
weekDay = "星期三";
break;
case 5:
weekDay = "星期四";
break;
case 6:
weekDay = "星期五";
break;
case 7:
weekDay = "星期六";
break;
default:
break;
}
return weekDay;
}
}
return result;
}
public List<DepotItemVo4WithInfoEx> getDetailList(Long headerId)throws Exception {
List<DepotItemVo4WithInfoEx> list =null;
try{
list = depotItemMapperEx.getDetailList(headerId);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public List<DepotItemVo4WithInfoEx> findByAll(String headIds, String materialIds, Integer offset, Integer rows)throws Exception {
List<DepotItemVo4WithInfoEx> list =null;
try{
list = depotItemMapperEx.findByAll(headIds, materialIds, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public int findByAllCount(String headIds, String materialIds)throws Exception {
int result=0;
try{
result = depotItemMapperEx.findByAllCount(headIds, materialIds);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
public BigDecimal buyOrSale(String type, String subType, Long MId, String MonthTime, String sumType) throws Exception{
BigDecimal result= BigDecimal.ZERO;
try{
if (SUM_TYPE.equals(sumType)) {
result= depotItemMapperEx.buyOrSaleNumber(type, subType, MId, MonthTime, sumType);
} else {
result= depotItemMapperEx.buyOrSalePrice(type, subType, MId, MonthTime, sumType);
}
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
}
logService.insertLog("商品",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return res;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteMaterial(Long id, HttpServletRequest request)throws Exception {
int result =0;
try{
result= materialMapper.deleteByPrimaryKey(id);
logService.insertLog("商品",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(id).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteMaterial(String ids, HttpServletRequest request)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids);
MaterialExample example = new MaterialExample();
example.createCriteria().andIdIn(idList);
int result =0;
try{
result= materialMapper.deleteByExample(example);
logService.insertLog("商品", "批量删除,id集:" + ids, request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
public int checkIsNameExist(Long id, String name)throws Exception {
MaterialExample example = new MaterialExample();
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Material> list =null;
try{
list= materialMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list==null?0:list.size();
}
public int checkIsExist(Long id, String name, String model, String color, String standard, String mfrs,
String otherField1, String otherField2, String otherField3, String unit, Long unitId)throws Exception {
MaterialExample example = new MaterialExample();
MaterialExample.Criteria criteria = example.createCriteria();
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteDepotHead(Long id, HttpServletRequest request)throws Exception {
int result=0;
try{
result = depotHeadMapper.deleteByPrimaryKey(id);
logService.insertLog("单据",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(id).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteDepotHead(String ids, HttpServletRequest request)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids);
DepotHeadExample example = new DepotHeadExample();
example.createCriteria().andIdIn(idList);
int result=0;
try{
result = depotHeadMapper.deleteByExample(example);
logService.insertLog("单据", "批量删除,id集:" + ids, request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
public int checkIsNameExist(Long id, String name)throws Exception {
DepotHeadExample example = new DepotHeadExample();
example.createCriteria().andIdNotEqualTo(id).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<DepotHead> list = null;
try{
list = depotHeadMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list==null?0:list.size();
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchSetStatus(String status, String depotHeadIDs)throws Exception {
logService.insertLog("单据",
try{
result =depotItemMapperEx.findStockWarningCountTotal(pid);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
/**
* 统计该商品已分批出库的总数量-用于订单
* @param mid
* @param headerId
* @return
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public BigDecimal getFinishNumber(Long mid, Long headerId) {
DepotHead depotHead =depotHeadMapper.selectByPrimaryKey(headerId);
String linkNumber = depotHead.getLinknumber(); //关联单号
BigDecimal count = depotItemMapperEx.getFinishNumber(mid, linkNumber);
return count;
}
/**
* 库存统计
* @param depotId
* @param mId
* @param beginTime
* @param endTime
* @return
*/
public BigDecimal getStockByParam(Long depotId, Long mId, String beginTime, String endTime, Long tenantId){
DepotItemVo4Stock stockObj = depotItemMapperEx.getStockByParam(depotId, mId, beginTime, endTime, tenantId);
BigDecimal intNum = stockObj.getInNum();
BigDecimal outNum = stockObj.getOutNum();
return intNum.subtract(outNum);
}
/**
* 入库统计
* @param depotId
* @param mId
break;
case 7:
weekDay = "星期六";
break;
default:
break;
}
return weekDay;
}
/**
* 判断字符串是否全部为数字
*
* @param accountWaste
* @return boolean值
*/
public static boolean checkStrIsNum(String checkStr) {
if (checkStr == null || checkStr.length() == 0)
return false;
return Pattern.compile("^[0-9]*.{1}[0-9]*$").matcher(checkStr).matches();
// return Pattern.compile(":^[0-9]+(.[0-9])*$").matcher(checkStr).matches();
}
/**
* 获得前一天的时间
*
* @return 前一天日期
*/
public static String getPreviousDate() {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1);
return new SimpleDateFormat("yyyy-MM").format(cal.getTime());
}
/**
* 获取当前月份的前6个月(含当前月)
* @param date
* @return
*/
public static List<String> getSixMonth(String date) {
List<String> list = new ArrayList<String>();
int month = Integer.parseInt(date.substring(5, 7));
int year = Integer.parseInt(date.substring(0, 4));
for (int i = 5; i >= 0; i--) {
if (month > 6) {
if (month - i >= 10) {
list.add(year + "-" + String.valueOf(month - i));