Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
f4ef5aa0
"src/main/vscode:/vscode.git/clone" did not exist on "537e3738920af7082474843d0f382f9f30697ee3"
Commit
f4ef5aa0
authored
Apr 07, 2021
by
季圣华
Browse files
vue版本上线
parent
76a0033a
Changes
242
Hide whitespace changes
Inline
Side-by-side
Too many changes to show.
To preserve performance only
20 of 242+
files are displayed.
Plain diff
Email patch
jshERP-boot/src/main/java/com/jsh/erp/config/TenantConfig.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.config
;
import
com.baomidou.mybatisplus.core.parser.ISqlParser
;
import
com.baomidou.mybatisplus.core.parser.ISqlParserFilter
;
import
com.baomidou.mybatisplus.core.parser.SqlParserHelper
;
import
com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor
;
import
com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor
;
import
com.baomidou.mybatisplus.extension.plugins.tenant.TenantHandler
;
import
com.baomidou.mybatisplus.extension.plugins.tenant.TenantSqlParser
;
import
com.jsh.erp.utils.Tools
;
import
net.sf.jsqlparser.expression.Expression
;
import
net.sf.jsqlparser.expression.LongValue
;
import
org.apache.ibatis.mapping.MappedStatement
;
import
org.apache.ibatis.reflection.MetaObject
;
import
org.mybatis.spring.mapper.MapperScannerConfigurer
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.stereotype.Service
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.ArrayList
;
import
java.util.List
;
@Service
public
class
TenantConfig
{
@Bean
public
PaginationInterceptor
paginationInterceptor
(
HttpServletRequest
request
)
{
PaginationInterceptor
paginationInterceptor
=
new
PaginationInterceptor
();
List
<
ISqlParser
>
sqlParserList
=
new
ArrayList
<>();
TenantSqlParser
tenantSqlParser
=
new
TenantSqlParser
();
tenantSqlParser
.
setTenantHandler
(
new
TenantHandler
()
{
@Override
public
Expression
getTenantId
()
{
String
token
=
request
.
getHeader
(
"X-Access-Token"
);
Long
tenantId
=
Tools
.
getTenantIdByToken
(
token
);
if
(
tenantId
!=
0L
)
{
return
new
LongValue
(
tenantId
);
}
else
{
//超管
return
null
;
}
}
@Override
public
String
getTenantIdColumn
()
{
return
"tenant_id"
;
}
@Override
public
boolean
doTableFilter
(
String
tableName
)
{
//获取开启状态
Boolean
res
=
true
;
String
token
=
request
.
getHeader
(
"X-Access-Token"
);
Long
tenantId
=
Tools
.
getTenantIdByToken
(
token
);
if
(
tenantId
!=
0L
)
{
// 这里可以判断是否过滤表
if
(
"jsh_material_property"
.
equals
(
tableName
)
||
"jsh_sequence"
.
equals
(
tableName
)
||
"jsh_user_business"
.
equals
(
tableName
)
||
"jsh_function"
.
equals
(
tableName
)
||
"jsh_platform_config"
.
equals
(
tableName
)
||
"jsh_tenant"
.
equals
(
tableName
))
{
res
=
true
;
}
else
{
res
=
false
;
}
}
return
res
;
}
});
sqlParserList
.
add
(
tenantSqlParser
);
paginationInterceptor
.
setSqlParserList
(
sqlParserList
);
paginationInterceptor
.
setSqlParserFilter
(
new
ISqlParserFilter
()
{
@Override
public
boolean
doFilter
(
MetaObject
metaObject
)
{
MappedStatement
ms
=
SqlParserHelper
.
getMappedStatement
(
metaObject
);
// 过滤自定义查询此时无租户信息约束出现
if
(
"com.jsh.erp.datasource.mappers.UserMapperEx.getUserListByUserNameOrLoginName"
.
equals
(
ms
.
getId
())||
"com.jsh.erp.datasource.mappers.DepotItemMapperEx.getStockByParam"
.
equals
(
ms
.
getId
()))
{
return
true
;
}
return
false
;
}
});
return
paginationInterceptor
;
}
/**
* 相当于顶部的:
* {@code @MapperScan("com.jsh.erp.datasource.mappers*")}
* 这里可以扩展,比如使用配置文件来配置扫描Mapper的路径
*/
@Bean
public
MapperScannerConfigurer
mapperScannerConfigurer
()
{
MapperScannerConfigurer
scannerConfigurer
=
new
MapperScannerConfigurer
();
scannerConfigurer
.
setBasePackage
(
"com.jsh.erp.datasource.mappers*"
);
return
scannerConfigurer
;
}
/**
* 性能分析拦截器,不建议生产使用
*/
@Bean
public
PerformanceInterceptor
performanceInterceptor
(){
return
new
PerformanceInterceptor
();
}
}
jshERP-boot/src/main/java/com/jsh/erp/constants/BusinessConstants.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.constants
;
/**
* @ClassName:BusinessConstants
* @Description 业务字典类
* @Author qiankunpingtai
* @Date 2019-3-6 17:58
* @Version 1.0
**/
public
class
BusinessConstants
{
/**
* 默认的日期格式
*/
public
static
final
String
DEFAULT_DATETIME_FORMAT
=
"yyyy-MM-dd HH:mm:ss"
;
/**
* 默认的分页起始页页码
*/
public
static
final
Integer
DEFAULT_PAGINATION_PAGE_NUMBER
=
1
;
/**
* 无数据时列表返回的默认数据条数
*/
public
static
final
Long
DEFAULT_LIST_NULL_NUMBER
=
0L
;
/**
* 默认的分页条数
*/
public
static
final
Integer
DEFAULT_PAGINATION_PAGE_SIZE
=
10
;
/**
* 单据主表出入库类型 type 入库 出库
* depothead
* */
public
static
final
String
DEPOTHEAD_TYPE_STORAGE
=
"入库"
;
public
static
final
String
DEPOTHEAD_TYPE_OUT
=
"出库"
;
/**
* 付款类型 payType //现付/预付款
* */
public
static
final
String
PAY_TYPE_PREPAID
=
"预付款"
;
public
static
final
String
PAY_TYPE_BY_CASH
=
"现付"
;
/**
* 删除标记 deleteFlag '0'未删除 '1'已删除
* */
public
static
final
String
DELETE_FLAG_DELETED
=
"1"
;
public
static
final
String
DELETE_FLAG_EXISTS
=
"0"
;
/**
* 是否卖出 isSell '0'未卖出 '1'已卖出
* */
public
static
final
String
IS_SELL_SELLED
=
"1"
;
public
static
final
String
IS_SELL_HOLD
=
"0"
;
/**
* 商品是否开启序列号标识enableSerialNumber '0'未启用 '1'启用
* */
public
static
final
String
ENABLE_SERIAL_NUMBER_ENABLED
=
"1"
;
public
static
final
String
ENABLE_SERIAL_NUMBER_NOT_ENABLED
=
"0"
;
/**
* 单据状态 billsStatus '0'未审核 '1'审核 '2'已转采购|销售
* */
public
static
final
String
BILLS_STATUS_UN_AUDIT
=
"0"
;
public
static
final
String
BILLS_STATUS_AUDIT
=
"1"
;
public
static
final
String
BILLS_STATUS_SKIP
=
"2"
;
/**
* 出入库分类
*采购、采购退货、其它、零售、销售、调拨
* */
public
static
final
String
SUB_TYPE_PURCHASE
=
"采购"
;
public
static
final
String
SUB_TYPE_PURCHASE_TETURNS
=
"采购退货"
;
public
static
final
String
SUB_TYPE_OTHER
=
"其它"
;
public
static
final
String
SUB_TYPE_RETAIL
=
"零售"
;
public
static
final
String
SUB_TYPE_SALES
=
"销售"
;
public
static
final
String
SUB_TYPE_TRANSFER
=
"调拨"
;
/**
* 批量插入sql时最大的数据条数
* */
public
static
final
int
BATCH_INSERT_MAX_NUMBER
=
500
;
/**
* sequence名称
* */
//sequence返回字符串的最小长度
public
static
final
Long
SEQ_TO_STRING_MIN_LENGTH
=
10000000000L
;
//sequence长度小于基准长度时前追加基础值
public
static
final
String
SEQ_TO_STRING_LESS_INSERT
=
"0"
;
//单据编号
public
static
final
String
DEPOT_NUMBER_SEQ
=
"depot_number_seq"
;
/**
* 商品类别根目录id
* */
/**
* create by: qiankunpingtai
* create time: 2019/3/14 11:41
* description:
* 为了使用户可以自己建初始目录,设定根目录的父级目录id为-1
*
*/
public
static
final
Long
MATERIAL_CATEGORY_ROOT_PARENT_ID
=
-
1L
;
/**
* 商品类别状态
* 0系统默认,1启用,2删除
* */
public
static
final
String
MATERIAL_CATEGORY_STATUS_DEFAULT
=
"0"
;
public
static
final
String
MATERIAL_CATEGORY_STATUS_ENABLE
=
"1"
;
public
static
final
String
MATERIAL_CATEGORY_STATUS_DELETE
=
"2"
;
/**
* 机构状态
* 1未营业、2正常营业、3暂停营业、4终止营业,5已除名
* */
public
static
final
String
ORGANIZATION_STCD_NOT_OPEN
=
"1"
;
public
static
final
String
ORGANIZATION_STCD_OPEN
=
"2"
;
public
static
final
String
ORGANIZATION_STCD_BUSINESS_SUSPENDED
=
"3"
;
public
static
final
String
ORGANIZATION_STCD_BUSINESS_TERMINATED
=
"4"
;
public
static
final
String
ORGANIZATION_STCD_REMOVED
=
"5"
;
/**
* 根机构父级编号
* 根机父级构编号默认为-1
* */
public
static
final
String
ORGANIZATION_ROOT_PARENT_NO
=
"-1"
;
/**
* 新增用户默认密码
* */
public
static
final
String
USER_DEFAULT_PASSWORD
=
"123456"
;
/**
* 用户是否系统自带
* 0、非系统自带,1系统自带
* */
public
static
final
byte
USER_NOT_SYSTEM
=
0
;
public
static
final
byte
USER_IS_SYSTEM
=
1
;
/**
* 用户是否为管理者
* 0、管理者,1员工
* */
public
static
final
byte
USER_IS_MANAGER
=
0
;
public
static
final
byte
USER_NOT_MANAGER
=
1
;
/**
* 用户状态
* 0:正常,1:删除,2封禁
* */
public
static
final
byte
USER_STATUS_NORMAL
=
0
;
public
static
final
byte
USER_STATUS_DELETE
=
1
;
public
static
final
byte
USER_STATUS_BANNED
=
2
;
/**
* 日志操作
* 新增、修改、删除、登录、导入
* */
public
static
final
String
LOG_OPERATION_TYPE_ADD
=
"新增"
;
public
static
final
String
LOG_OPERATION_TYPE_BATCH_ADD
=
"批量新增"
;
public
static
final
String
LOG_OPERATION_TYPE_EDIT
=
"修改"
;
public
static
final
String
LOG_OPERATION_TYPE_DELETE
=
"删除"
;
public
static
final
String
LOG_OPERATION_TYPE_LOGIN
=
"登录"
;
public
static
final
String
LOG_OPERATION_TYPE_IMPORT
=
"导入"
;
/**
* 数据数量单位
* 条
* */
public
static
final
String
LOG_DATA_UNIT
=
"条"
;
/**
* 删除类型
* 1正常删除
* 2强制删除
* */
public
static
final
String
DELETE_TYPE_NORMAL
=
"1"
;
public
static
final
String
DELETE_TYPE_FORCE
=
"2"
;
/**
* 默认管理员账号
*/
public
static
final
String
DEFAULT_MANAGER
=
"admin"
;
public
static
final
String
ROLE_TYPE_PRIVATE
=
"个人数据"
;
public
static
final
String
ROLE_TYPE_THIS_ORG
=
"本机构数据"
;
/**
* redis相关
* */
//session的生命周期,秒
public
static
final
Long
MAX_SESSION_IN_SECONDS
=
60
*
60
*
24L
;
}
jshERP-boot/src/main/java/com/jsh/erp/constants/ExceptionConstants.java
0 → 100644
View file @
f4ef5aa0
package
com.jsh.erp.constants
;
import
com.alibaba.fastjson.JSONObject
;
public
class
ExceptionConstants
{
/**
* code 格式 type+五位数字,例如3500000
* ResourceInfo(value = "inOutItem", type = 35)
*
* */
public
static
final
String
GLOBAL_RETURNS_CODE
=
"code"
;
public
static
final
String
GLOBAL_RETURNS_MESSAGE
=
"msg"
;
public
static
final
String
GLOBAL_RETURNS_DATA
=
"data"
;
/**
* 正常返回/操作成功
**/
public
static
final
int
SERVICE_SUCCESS_CODE
=
200
;
public
static
final
String
SERVICE_SUCCESS_MSG
=
"操作成功"
;
/**
* 数据查询异常
*/
public
static
final
int
DATA_READ_FAIL_CODE
=
300
;
public
static
final
String
DATA_READ_FAIL_MSG
=
"数据查询异常"
;
/**
* 数据写入异常
*/
public
static
final
int
DATA_WRITE_FAIL_CODE
=
301
;
public
static
final
String
DATA_WRITE_FAIL_MSG
=
"数据写入异常"
;
/**
* 系统运行时未知错误
**/
public
static
final
int
SERVICE_SYSTEM_ERROR_CODE
=
500
;
public
static
final
String
SERVICE_SYSTEM_ERROR_MSG
=
"未知异常"
;
/**
* 删除操作被拒绝,请联系管理员
**/
public
static
final
int
DELETE_REFUSED_CODE
=
600
;
public
static
final
String
DELETE_REFUSED_MSG
=
"删除操作被拒绝,请联系管理员"
;
/**
* 检测到存在依赖数据,是否强制删除?
**/
public
static
final
int
DELETE_FORCE_CONFIRM_CODE
=
601
;
public
static
final
String
DELETE_FORCE_CONFIRM_MSG
=
"检测到存在依赖数据,不能删除!"
;
/**
* 用户信息
* type = 5
* */
//添加用户信息失败
public
static
final
int
USER_ADD_FAILED_CODE
=
500000
;
public
static
final
String
USER_ADD_FAILED_MSG
=
"添加用户信息失败"
;
//删除用户信息失败
public
static
final
int
USER_DELETE_FAILED_CODE
=
500001
;
public
static
final
String
USER_DELETE_FAILED_MSG
=
"删除用户信息失败"
;
//修改用户信息失败
public
static
final
int
USER_EDIT_FAILED_CODE
=
500002
;
public
static
final
String
USER_EDIT_FAILED_MSG
=
"修改用户信息失败"
;
//用户名已存在
public
static
final
int
USER_USER_NAME_ALREADY_EXISTS_CODE
=
500003
;
public
static
final
String
USER_USER_NAME_ALREADY_EXISTS_MSG
=
"用户名在本系统已存在"
;
//登录名已存在
public
static
final
int
USER_LOGIN_NAME_ALREADY_EXISTS_CODE
=
500003
;
public
static
final
String
USER_LOGIN_NAME_ALREADY_EXISTS_MSG
=
"登录名在本系统已存在"
;
//用户录入数量超出限制
public
static
final
int
USER_OVER_LIMIT_FAILED_CODE
=
500004
;
public
static
final
String
USER_OVER_LIMIT_FAILED_MSG
=
"用户录入数量超出限制,请联系管理员"
;
//此用户名限制使用
public
static
final
int
USER_NAME_LIMIT_USE_CODE
=
500004
;
public
static
final
String
USER_NAME_LIMIT_USE_MSG
=
"此用户名限制使用"
;
/**
* 角色信息
* type = 10
* */
//添加角色信息失败
public
static
final
int
ROLE_ADD_FAILED_CODE
=
1000000
;
public
static
final
String
ROLE_ADD_FAILED_MSG
=
"添加角色信息失败"
;
//删除角色信息失败
public
static
final
int
ROLE_DELETE_FAILED_CODE
=
1000001
;
public
static
final
String
ROLE_DELETE_FAILED_MSG
=
"删除角色信息失败"
;
//修改角色信息失败
public
static
final
int
ROLE_EDIT_FAILED_CODE
=
1000002
;
public
static
final
String
ROLE_EDIT_FAILED_MSG
=
"修改角色信息失败"
;
/**
* 应用信息
* type = 15
* */
//添加角色信息失败
public
static
final
int
APP_ADD_FAILED_CODE
=
1500000
;
public
static
final
String
APP_ADD_FAILED_MSG
=
"添加应用信息失败"
;
//删除角色信息失败
public
static
final
int
APP_DELETE_FAILED_CODE
=
1500001
;
public
static
final
String
APP_DELETE_FAILED_MSG
=
"删除应用信息失败"
;
//修改角色信息失败
public
static
final
int
APP_EDIT_FAILED_CODE
=
1500002
;
public
static
final
String
APP_EDIT_FAILED_MSG
=
"修改应用信息失败"
;
/**
* 仓库信息
* type = 20
* */
//添加仓库信息失败
public
static
final
int
DEPOT_ADD_FAILED_CODE
=
2000000
;
public
static
final
String
DEPOT_ADD_FAILED_MSG
=
"添加仓库信息失败"
;
//删除仓库信息失败
public
static
final
int
DEPOT_DELETE_FAILED_CODE
=
2000001
;
public
static
final
String
DEPOT_DELETE_FAILED_MSG
=
"删除仓库信息失败"
;
//修改仓库信息失败
public
static
final
int
DEPOT_EDIT_FAILED_CODE
=
2000002
;
public
static
final
String
DEPOT_EDIT_FAILED_MSG
=
"修改仓库信息失败"
;
/**
* 功能模块信息
* type = 30
* */
//添加角色信息失败
public
static
final
int
FUNCTIONS_ADD_FAILED_CODE
=
3000000
;
public
static
final
String
FUNCTIONS_ADD_FAILED_MSG
=
"添加功能模块信息失败"
;
//删除角色信息失败
public
static
final
int
FUNCTIONS_DELETE_FAILED_CODE
=
3000001
;
public
static
final
String
FUNCTIONS_DELETE_FAILED_MSG
=
"删除功能模块信息失败"
;
//修改角色信息失败
public
static
final
int
FUNCTIONS_EDIT_FAILED_CODE
=
3000002
;
public
static
final
String
FUNCTIONS_EDIT_FAILED_MSG
=
"修改功能模块信息失败"
;
/**
* 收支项目信息
* type = 35
* */
//添加收支项目信息失败
public
static
final
int
IN_OUT_ITEM_ADD_FAILED_CODE
=
3500000
;
public
static
final
String
IN_OUT_ITEM_ADD_FAILED_MSG
=
"添加收支项目信息失败"
;
//删除收支项目信息失败
public
static
final
int
IN_OUT_ITEM_DELETE_FAILED_CODE
=
3500001
;
public
static
final
String
IN_OUT_ITEM_DELETE_FAILED_MSG
=
"删除收支项目信息失败"
;
//修改收支项目信息失败
public
static
final
int
IN_OUT_ITEM_EDIT_FAILED_CODE
=
3500002
;
public
static
final
String
IN_OUT_ITEM_EDIT_FAILED_MSG
=
"修改收支项目信息失败"
;
/**
* 多单位信息
* type = 40
* */
//添加多单位信息失败
public
static
final
int
UNIT_ADD_FAILED_CODE
=
4000000
;
public
static
final
String
UNIT_ADD_FAILED_MSG
=
"添加多单位信息失败"
;
//删除多单位信息失败
public
static
final
int
UNIT_DELETE_FAILED_CODE
=
4000001
;
public
static
final
String
UNIT_DELETE_FAILED_MSG
=
"删除多单位信息失败"
;
//修改多单位信息失败
public
static
final
int
UNIT_EDIT_FAILED_CODE
=
4000002
;
public
static
final
String
UNIT_EDIT_FAILED_MSG
=
"修改多单位信息失败"
;
/**
* 经手人信息
* type = 45
* */
//添加经手人信息失败
public
static
final
int
PERSON_ADD_FAILED_CODE
=
4500000
;
public
static
final
String
PERSON_ADD_FAILED_MSG
=
"添加经手人信息失败"
;
//删除经手人信息失败
public
static
final
int
PERSON_DELETE_FAILED_CODE
=
4500001
;
public
static
final
String
PERSON_DELETE_FAILED_MSG
=
"删除经手人信息失败"
;
//修改经手人信息失败
public
static
final
int
PERSON_EDIT_FAILED_CODE
=
4500002
;
public
static
final
String
PERSON_EDIT_FAILED_MSG
=
"修改经手人信息失败"
;
/**
* 用户角色模块关系信息
* type = 50
* */
//添加用户角色模块关系信息失败
public
static
final
int
USER_BUSINESS_ADD_FAILED_CODE
=
5000000
;
public
static
final
String
USER_BUSINESS_ADD_FAILED_MSG
=
"添加用户角色模块关系信息失败"
;
//删除用户角色模块关系信息失败
public
static
final
int
USER_BUSINESS_DELETE_FAILED_CODE
=
5000001
;
public
static
final
String
USER_BUSINESS_DELETE_FAILED_MSG
=
"删除用户角色模块关系信息失败"
;
//修改用户角色模块关系信息失败
public
static
final
int
USER_BUSINESS_EDIT_FAILED_CODE
=
5000002
;
public
static
final
String
USER_BUSINESS_EDIT_FAILED_MSG
=
"修改用户角色模块关系信息失败"
;
/**
* 系统参数信息
* type = 55
* */
//添加系统参数信息失败
public
static
final
int
SYSTEM_CONFIG_ADD_FAILED_CODE
=
5500000
;
public
static
final
String
SYSTEM_CONFIG_ADD_FAILED_MSG
=
"添加系统参数信息失败"
;
//删除系统参数信息失败
public
static
final
int
SYSTEM_CONFIG_DELETE_FAILED_CODE
=
5500001
;
public
static
final
String
SYSTEM_CONFIG_DELETE_FAILED_MSG
=
"删除系统参数信息失败"
;
//修改系统参数信息失败
public
static
final
int
SYSTEM_CONFIG_EDIT_FAILED_CODE
=
5500002
;
public
static
final
String
SYSTEM_CONFIG_EDIT_FAILED_MSG
=
"修改系统参数信息失败"
;
/**
* 商品扩展信息
* type = 60
* */
//添加商品扩展信息失败
public
static
final
int
MATERIAL_PROPERTY_ADD_FAILED_CODE
=
6000000
;
public
static
final
String
MATERIAL_PROPERTY_ADD_FAILED_MSG
=
"添加商品扩展信息失败"
;
//删除商品扩展信息失败
public
static
final
int
MATERIAL_PROPERTY_DELETE_FAILED_CODE
=
6000001
;
public
static
final
String
MATERIAL_PROPERTY_DELETE_FAILED_MSG
=
"删除商品扩展信息失败"
;
//修改商品扩展信息失败
public
static
final
int
MATERIAL_PROPERTY_EDIT_FAILED_CODE
=
6000002
;
public
static
final
String
MATERIAL_PROPERTY_EDIT_FAILED_MSG
=
"修改商品扩展信息失败"
;
/**
* 账户信息
* type = 65
* */
//添加账户信息失败
public
static
final
int
ACCOUNT_ADD_FAILED_CODE
=
6500000
;
public
static
final
String
ACCOUNT_ADD_FAILED_MSG
=
"添加账户信息失败"
;
//删除账户信息失败
public
static
final
int
ACCOUNT_DELETE_FAILED_CODE
=
6500001
;
public
static
final
String
ACCOUNT_DELETE_FAILED_MSG
=
"删除账户信息失败"
;
//修改账户信息失败
public
static
final
int
ACCOUNT_EDIT_FAILED_CODE
=
6500002
;
public
static
final
String
ACCOUNT_EDIT_FAILED_MSG
=
"修改账户信息失败"
;
/**
* 供应商信息
* type = 70
* */
//添加供应商信息失败
public
static
final
int
SUPPLIER_ADD_FAILED_CODE
=
7000000
;
public
static
final
String
SUPPLIER_ADD_FAILED_MSG
=
"添加供应商信息失败"
;
//删除供应商信息失败
public
static
final
int
SUPPLIER_DELETE_FAILED_CODE
=
7000001
;
public
static
final
String
SUPPLIER_DELETE_FAILED_MSG
=
"删除供应商信息失败"
;
//修改供应商信息失败
public
static
final
int
SUPPLIER_EDIT_FAILED_CODE
=
7000002
;
public
static
final
String
SUPPLIER_EDIT_FAILED_MSG
=
"修改供应商信息失败"
;
/**
* 商品类别信息
* type = 75
* */
//添加商品类别信息失败
public
static
final
int
MATERIAL_CATEGORY_ADD_FAILED_CODE
=
7500000
;
public
static
final
String
MATERIAL_CATEGORY_ADD_FAILED_MSG
=
"添加商品类别信息失败"
;
//删除商品类别信息失败
public
static
final
int
MATERIAL_CATEGORY_DELETE_FAILED_CODE
=
7500001
;
public
static
final
String
MATERIAL_CATEGORY_DELETE_FAILED_MSG
=
"删除商品类别信息失败"
;
//修改商品类别信息失败
public
static
final
int
MATERIAL_CATEGORY_EDIT_FAILED_CODE
=
7500002
;
public
static
final
String
MATERIAL_CATEGORY_EDIT_FAILED_MSG
=
"修改商品类别信息失败"
;
//商品类别编号已存在
public
static
final
int
MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE
=
7500003
;
public
static
final
String
MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG
=
"商品类别编号已存在"
;
//根目录不支持修改
public
static
final
int
MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_EDIT_CODE
=
7500004
;
public
static
final
String
MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_EDIT_MSG
=
"根目录不支持修改"
;
//根目录不支持删除
public
static
final
int
MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_DELETE_CODE
=
7500005
;
public
static
final
String
MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_DELETE_MSG
=
"根目录不支持删除"
;
/**
* 商品信息
* type = 80
* */
//添加商品信息信息失败
public
static
final
int
MATERIAL_ADD_FAILED_CODE
=
7500000
;
public
static
final
String
MATERIAL_ADD_FAILED_MSG
=
"添加商品信息失败"
;
//删除商品信息失败
public
static
final
int
MATERIAL_DELETE_FAILED_CODE
=
7500001
;
public
static
final
String
MATERIAL_DELETE_FAILED_MSG
=
"删除商品信息失败"
;
//修改商品信息失败
public
static
final
int
MATERIAL_EDIT_FAILED_CODE
=
7500002
;
public
static
final
String
MATERIAL_EDIT_FAILED_MSG
=
"修改商品信息失败"
;
//商品信息不存在
public
static
final
int
MATERIAL_NOT_EXISTS_CODE
=
8000000
;
public
static
final
String
MATERIAL_NOT_EXISTS_MSG
=
"商品信息不存在"
;
//商品信息不唯一
public
static
final
int
MATERIAL_NOT_ONLY_CODE
=
8000001
;
public
static
final
String
MATERIAL_NOT_ONLY_MSG
=
"商品信息不唯一"
;
//该商品未开启序列号
public
static
final
int
MATERIAL_NOT_ENABLE_SERIAL_NUMBER_CODE
=
8000002
;
public
static
final
String
MATERIAL_NOT_ENABLE_SERIAL_NUMBER_MSG
=
"该商品未开启序列号功能"
;
//该商品已绑定序列号数量小于等于商品现有库存
public
static
final
int
MATERIAL_SERIAL_NUMBERE_NOT_MORE_THAN_STORAGE_CODE
=
8000003
;
public
static
final
String
MATERIAL_SERIAL_NUMBERE_NOT_MORE_THAN_STORAGE_MSG
=
"该商品已绑定序列号数量大于等于商品现有库存"
;
//商品库存不足
public
static
final
int
MATERIAL_STOCK_NOT_ENOUGH_CODE
=
8000004
;
public
static
final
String
MATERIAL_STOCK_NOT_ENOUGH_MSG
=
"商品:%s库存不足"
;
/**
* 单据信息
* type = 85
* */
//添加单据信息失败
public
static
final
int
DEPOT_HEAD_ADD_FAILED_CODE
=
8500000
;
public
static
final
String
DEPOT_HEAD_ADD_FAILED_MSG
=
"添加单据信息失败"
;
//删除单据信息失败
public
static
final
int
DEPOT_HEAD_DELETE_FAILED_CODE
=
8500001
;
public
static
final
String
DEPOT_HEAD_DELETE_FAILED_MSG
=
"删除单据信息失败"
;
//修改单据信息失败
public
static
final
int
DEPOT_HEAD_EDIT_FAILED_CODE
=
8500002
;
public
static
final
String
DEPOT_HEAD_EDIT_FAILED_MSG
=
"修改单据信息失败"
;
//单据录入数量超出限制
public
static
final
int
DEPOT_HEAD_OVER_LIMIT_FAILED_CODE
=
8500003
;
public
static
final
String
DEPOT_HEAD_OVER_LIMIT_FAILED_MSG
=
"单据录入数量超出限制,请联系管理员"
;
//单据录入-仓库不能为空
public
static
final
int
DEPOT_HEAD_DEPOT_FAILED_CODE
=
8500004
;
public
static
final
String
DEPOT_HEAD_DEPOT_FAILED_MSG
=
"仓库不能为空"
;
//单据录入-调入仓库不能为空
public
static
final
int
DEPOT_HEAD_ANOTHER_DEPOT_FAILED_CODE
=
8500005
;
public
static
final
String
DEPOT_HEAD_ANOTHER_DEPOT_FAILED_MSG
=
"调入仓库不能为空"
;
/**
* 单据明细信息
* type = 90
* */
//添加单据明细信息失败
public
static
final
int
DEPOT_ITEM_ADD_FAILED_CODE
=
9000000
;
public
static
final
String
DEPOT_ITEM_ADD_FAILED_MSG
=
"添加单据明细信息失败"
;
//删除单据明细信息失败
public
static
final
int
DEPOT_ITEM_DELETE_FAILED_CODE
=
9000001
;
public
static
final
String
DEPOT_ITEM_DELETE_FAILED_MSG
=
"删除单据明细信息失败"
;
//修改单据明细信息失败
public
static
final
int
DEPOT_ITEM_EDIT_FAILED_CODE
=
9000002
;
public
static
final
String
DEPOT_ITEM_EDIT_FAILED_MSG
=
"修改单据明细信息失败"
;
/**
* 财务信息
* type = 95
* */
//添加财务信息失败
public
static
final
int
ACCOUNT_HEAD_ADD_FAILED_CODE
=
9500000
;
public
static
final
String
ACCOUNT_HEAD_ADD_FAILED_MSG
=
"添加财务信息失败"
;
//删除财务信息失败
public
static
final
int
ACCOUNT_HEAD_DELETE_FAILED_CODE
=
9500001
;
public
static
final
String
ACCOUNT_HEAD_DELETE_FAILED_MSG
=
"删除财务信息失败"
;
//修改财务信息失败
public
static
final
int
ACCOUNT_HEAD_EDIT_FAILED_CODE
=
9500002
;
public
static
final
String
ACCOUNT_HEAD_EDIT_FAILED_MSG
=
"修改财务信息失败"
;
/**
* 财务明细信息
* type = 100
* */
//添加财务明细信息失败
public
static
final
int
ACCOUNT_ITEM_ADD_FAILED_CODE
=
10000000
;
public
static
final
String
ACCOUNT_ITEM_ADD_FAILED_MSG
=
"添加财务明细信息失败"
;
//删除财务明细信息失败
public
static
final
int
ACCOUNT_ITEM_DELETE_FAILED_CODE
=
10000001
;
public
static
final
String
ACCOUNT_ITEM_DELETE_FAILED_MSG
=
"删除财务明细信息失败"
;
//修改财务明细信息失败
public
static
final
int
ACCOUNT_ITEM_EDIT_FAILED_CODE
=
10000002
;
public
static
final
String
ACCOUNT_ITEM_EDIT_FAILED_MSG
=
"修改财务明细信息失败"
;
/**
* 序列号
* type = 105
* */
/**序列号已存在*/
public
static
final
int
SERIAL_NUMBERE_ALREADY_EXISTS_CODE
=
10500000
;
public
static
final
String
SERIAL_NUMBERE_ALREADY_EXISTS_MSG
=
"序列号已存在"
;
/**序列号不能为为空*/
public
static
final
int
SERIAL_NUMBERE_NOT_BE_EMPTY_CODE
=
10500001
;
public
static
final
String
SERIAL_NUMBERE_NOT_BE_EMPTY_MSG
=
"序列号不能为为空"
;
/**商品%s下序列号不充足,请补充后重试*/
public
static
final
int
MATERIAL_SERIAL_NUMBERE_NOT_ENOUGH_CODE
=
10500002
;
public
static
final
String
MATERIAL_SERIAL_NUMBERE_NOT_ENOUGH_MSG
=
"商品:%s下序列号不充足,请补充后重试"
;
/**删序列号信息失败*/
public
static
final
int
SERIAL_NUMBERE_DELETE_FAILED_CODE
=
10500003
;
public
static
final
String
SERIAL_NUMBERE_DELETE_FAILED_MSG
=
"删序列号信息失败"
;
/**
* 机构信息
* type = 110
* */
//添加机构信息失败
public
static
final
int
ORGANIZATION_ADD_FAILED_CODE
=
11000000
;
public
static
final
String
ORGANIZATION_ADD_FAILED_MSG
=
"添加机构信息失败"
;
//删除机构信息失败
public
static
final
int
ORGANIZATION_DELETE_FAILED_CODE
=
11000001
;
public
static
final
String
ORGANIZATION_DELETE_FAILED_MSG
=
"删除机构信息失败"
;
//修改机构信息失败
public
static
final
int
ORGANIZATION_EDIT_FAILED_CODE
=
11000002
;
public
static
final
String
ORGANIZATION_EDIT_FAILED_MSG
=
"修改机构信息失败"
;
//机构编号已存在
public
static
final
int
ORGANIZATION_NO_ALREADY_EXISTS_CODE
=
11000003
;
public
static
final
String
ORGANIZATION_NO_ALREADY_EXISTS_MSG
=
"机构编号已存在"
;
//根机构不允许删除
public
static
final
int
ORGANIZATION_ROOT_NOT_ALLOWED_DELETE_CODE
=
11000004
;
public
static
final
String
ORGANIZATION_ROOT_NOT_ALLOWED_DELETE_MSG
=
"根机构不允许删除"
;
//根机构不允许修改
public
static
final
int
ORGANIZATION_ROOT_NOT_ALLOWED_EDIT_CODE
=
11000005
;
public
static
final
String
ORGANIZATION_ROOT_NOT_ALLOWED_EDIT_MSG
=
"根机构不允许修改"
;
/**
* 机构用户关联关系
* type = 115
* */
//添加机构用户关联关系失败
public
static
final
int
ORGA_USER_REL_ADD_FAILED_CODE
=
11500000
;
public
static
final
String
ORGA_USER_REL_ADD_FAILED_MSG
=
"添加机构用户关联关系失败"
;
//删除机构用户关联关系失败
public
static
final
int
ORGA_USER_REL_DELETE_FAILED_CODE
=
11500001
;
public
static
final
String
ORGA_USER_REL_DELETE_FAILED_MSG
=
"删除机构用户关联关系失败"
;
//修改机构用户关联关系失败
public
static
final
int
ORGA_USER_REL_EDIT_FAILED_CODE
=
11500002
;
public
static
final
String
ORGA_USER_REL_EDIT_FAILED_MSG
=
"修改机构用户关联关系失败"
;
//演示用户禁止操作
public
static
final
int
SYSTEM_CONFIG_TEST_USER_CODE
=
-
1
;
public
static
final
String
SYSTEM_CONFIG_TEST_USER_MSG
=
"演示用户禁止操作"
;
/**
* 标准正常返回/操作成功返回
* @return
*/
public
static
JSONObject
standardSuccess
()
{
JSONObject
success
=
new
JSONObject
();
success
.
put
(
GLOBAL_RETURNS_CODE
,
SERVICE_SUCCESS_CODE
);
success
.
put
(
GLOBAL_RETURNS_MESSAGE
,
SERVICE_SUCCESS_MSG
);
return
success
;
}
public
static
JSONObject
standardErrorUserOver
()
{
JSONObject
success
=
new
JSONObject
();
success
.
put
(
GLOBAL_RETURNS_CODE
,
USER_OVER_LIMIT_FAILED_CODE
);
success
.
put
(
GLOBAL_RETURNS_MESSAGE
,
USER_OVER_LIMIT_FAILED_MSG
);
return
success
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/controller/AccountController.java
0 → 100644
View file @
f4ef5aa0
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
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/controller/AccountHeadController.java
0 → 100644
View file @
f4ef5aa0
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
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/controller/AccountItemController.java
0 → 100644
View file @
f4ef5aa0
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
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/controller/DepotController.java
0 → 100644
View file @
f4ef5aa0
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
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/controller/DepotHeadController.java
0 → 100644
View file @
f4ef5aa0
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
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/controller/DepotItemController.java
0 → 100644
View file @
f4ef5aa0
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
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/controller/FunctionController.java
0 → 100644
View file @
f4ef5aa0
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
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/controller/InOutItemController.java
0 → 100644
View file @
f4ef5aa0
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
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialCategoryController.java
0 → 100644
View file @
f4ef5aa0
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
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialController.java
0 → 100644
View file @
f4ef5aa0
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
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialExtendController.java
0 → 100644
View file @
f4ef5aa0
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
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/controller/MaterialPropertyController.java
0 → 100644
View file @
f4ef5aa0
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
{
}
jshERP-boot/src/main/java/com/jsh/erp/controller/MsgController.java
0 → 100644
View file @
f4ef5aa0
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
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/controller/OrganizationController.java
0 → 100644
View file @
f4ef5aa0
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
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/controller/PersonController.java
0 → 100644
View file @
f4ef5aa0
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
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/controller/PlatformConfigController.java
0 → 100644
View file @
f4ef5aa0
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
;
}
}
jshERP-boot/src/main/java/com/jsh/erp/controller/PluginController.java
0 → 100644
View file @
f4ef5aa0
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
;
}
}
Prev
1
2
3
4
5
6
…
13
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment