基于javaweb+mysql的springboot农业物资管理系统(java+springboot+easyui+html+maven+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot农业物资管理系统(java+springboot+easyui+html+maven+mysql)
项目介绍
农业物资管理系统,管理员可以对角色进行配置,分配用户角色; 主要功能包含:登录、注册、修改密码、零售出库、零售退货、采购订单管理、采购入库管理、采购退货管理、销售管理、财务管理、报表管理、物资管理、基本资料管理。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本;
6.是否Maven项目: 是;
技术栈
-
后端:springboot MyBatis
-
前端:HTML+css+javascript+jQuery+easyui
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行; 3. 将项目中application.properties配置文件中的数据库配置改为自己的配置; 4. 运行成功后,访问http://localhost:8080/ 到登录页面 管理员用户名:admin 密码:123456
JshException.writeFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateAccountItemWithObj(AccountItem accountItem)throws Exception {
int result=0;
try{
result = accountItemMapper.updateByPrimaryKeySelective(accountItem);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
public List<AccountItemVo4List> getDetailList(Long headerId) {
List<AccountItemVo4List> list=null;
try{
list = accountItemMapperEx.getDetailList(headerId);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public String saveDetials(String inserted, String deleted, String updated, Long headerId, String listType) throws Exception {
logService.insertLog("财务明细",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(",headerId:").append(headerId).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
//转为json
JSONArray insertedJson = JSONArray.parseArray(inserted);
JSONArray deletedJson = JSONArray.parseArray(deleted);
JSONArray updatedJson = JSONArray.parseArray(updated);
if (null != insertedJson) {
for (int i = 0; i < insertedJson.size(); i++) {
AccountItem accountItem = new AccountItem();
JSONObject tempInsertedJson = JSONObject.parseObject(insertedJson.getString(i));
accountItem.setHeaderid(headerId);
if (tempInsertedJson.get("AccountId") != null && !tempInsertedJson.get("AccountId").equals("")) {
accountItem.setAccountid(tempInsertedJson.getLong("AccountId"));
}
if (tempInsertedJson.get("InOutItemId") != null && !tempInsertedJson.get("InOutItemId").equals("")) {
accountItem.setInoutitemid(tempInsertedJson.getLong("InOutItemId"));
}
if (tempInsertedJson.get("EachAmount") != null && !tempInsertedJson.get("EachAmount").equals("")) {
BigDecimal eachAmount = tempInsertedJson.getBigDecimal("EachAmount");
depotItem.setMunit(tempUpdatedJson.getString("Unit"));
if (!StringUtil.isEmpty(tempUpdatedJson.get("OperNumber").toString())) {
depotItem.setOpernumber(tempUpdatedJson.getBigDecimal("OperNumber"));
try {
String Unit = tempUpdatedJson.get("Unit").toString();
BigDecimal oNumber = tempUpdatedJson.getBigDecimal("OperNumber");
Long mId = Long.parseLong(tempUpdatedJson.get("MaterialId").toString());
//以下进行单位换算
// String UnitName = findUnitName(mId); //查询计量单位名称
String unitName = materialService.findUnitName(mId);
if (!StringUtil.isEmpty(unitName)) {
String unitList = unitName.substring(0, unitName.indexOf("("));
String ratioList = unitName.substring(unitName.indexOf("("));
String basicUnit = unitList.substring(0, unitList.indexOf(",")); //基本单位
String otherUnit = unitList.substring(unitList.indexOf(",") + 1); //副单位
Integer ratio = Integer.parseInt(ratioList.substring(ratioList.indexOf(":") + 1).replace(")", "")); //比例
if (Unit.equals(basicUnit)) { //如果等于基础单位
depotItem.setBasicnumber(oNumber); //数量一致
} else if (Unit.equals(otherUnit)) { //如果等于副单位
depotItem.setBasicnumber(oNumber.multiply(new BigDecimal(ratio))); //数量乘以比例
}
} else {
depotItem.setBasicnumber(oNumber); //其他情况
}
} catch (Exception e) {
logger.error(">>>>>>>>>>>>>>>>>>>设置基础数量异常", e);
}
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("UnitPrice").toString())) {
depotItem.setUnitprice(tempUpdatedJson.getBigDecimal("UnitPrice"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxUnitPrice").toString())) {
depotItem.setTaxunitprice(tempUpdatedJson.getBigDecimal("TaxUnitPrice"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("AllPrice").toString())) {
depotItem.setAllprice(tempUpdatedJson.getBigDecimal("AllPrice"));
}
depotItem.setRemark(tempUpdatedJson.getString("Remark"));
if (tempUpdatedJson.get("DepotId") != null && !StringUtil.isEmpty(tempUpdatedJson.get("DepotId").toString())) {
depotItem.setDepotid(tempUpdatedJson.getLong("DepotId"));
}
if (tempUpdatedJson.get("AnotherDepotId") != null && !StringUtil.isEmpty(tempUpdatedJson.get("AnotherDepotId").toString())) {
depotItem.setAnotherdepotid(tempUpdatedJson.getLong("AnotherDepotId"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxRate").toString())) {
depotItem.setTaxrate(tempUpdatedJson.getBigDecimal("TaxRate"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxMoney").toString())) {
depotItem.setTaxmoney(tempUpdatedJson.getBigDecimal("TaxMoney"));
}
if (!StringUtil.isEmpty(tempUpdatedJson.get("TaxLastMoney").toString())) {
depotItem.setTaxlastmoney(tempUpdatedJson.getBigDecimal("TaxLastMoney"));
}
if (list == null) {
queryInfo.setRows(new ArrayList<Object>());
queryInfo.setTotal(BusinessConstants.DEFAULT_LIST_NULL_NUMBER);
return returnJson(objectMap, "查找不到数据", ErpInfo.OK.code);
}
queryInfo.setRows(list);
queryInfo.setTotal(pageInfo.getTotal());
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
}
/**
* create by: qiankunpingtai
* website:https://qiankunpingtai.cn
* description:
* 批量删除商品信息
* @Param: ids
* @return java.lang.Object
*/
@RequestMapping(value = "/batchDeleteMaterialByIds")
public Object batchDeleteMaterialByIds(@RequestParam("ids") String ids,@RequestParam(value="deleteType",
required =false,defaultValue= BusinessConstants.DELETE_TYPE_NORMAL)String deleteType) throws Exception {
JSONObject result = ExceptionConstants.standardSuccess();
int i=0;
if(BusinessConstants.DELETE_TYPE_NORMAL.equals(deleteType)){
i= materialService.batchDeleteMaterialByIdsNormal(ids);
}else if(BusinessConstants.DELETE_TYPE_FORCE.equals(deleteType)){
i= materialService.batchDeleteMaterialByIds(ids);
}else{
logger.error("异常码[{}],异常提示[{}],参数,ids[{}],deleteType[{}]",
ExceptionConstants.DELETE_REFUSED_CODE,ExceptionConstants.DELETE_REFUSED_MSG,ids,deleteType);
throw new BusinessRunTimeException(ExceptionConstants.DELETE_REFUSED_CODE,
ExceptionConstants.DELETE_REFUSED_MSG);
}
if(i<1){
logger.error("异常码[{}],异常提示[{}],参数,ids[{}]",
ExceptionConstants.MATERIAL_DELETE_FAILED_CODE,ExceptionConstants.MATERIAL_DELETE_FAILED_MSG,ids);
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_DELETE_FAILED_CODE,
ExceptionConstants.MATERIAL_DELETE_FAILED_MSG);
}
return result;
}
}
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public List<MaterialCategory> getMCList(Long parentId)throws Exception {
List<MaterialCategory> res= new ArrayList<MaterialCategory>();
List<MaterialCategory> list=null;
MaterialCategoryExample example = new MaterialCategoryExample();
example.createCriteria().andParentidEqualTo(parentId).andIdNotEqualTo(1l);
example.setOrderByClause("id");
list=materialCategoryMapper.selectByExample(example);
if(list!=null && list.size()>0) {
res.addAll(list);
for(MaterialCategory mc : list) {
List<MaterialCategory> mcList = getMCList(mc.getId());
if(mcList!=null && mcList.size()>0) {
res.addAll(mcList);
}
}
}
return res;
}
public List<MaterialCategory> select(String name, Integer parentId, int offset, int rows) throws Exception{
List<MaterialCategory> list=null;
try{
list=materialCategoryMapperEx.selectByConditionMaterialCategory(name, parentId, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public Long countMaterialCategory(String name, Integer parentId) throws Exception{
Long result=null;
try{
result=materialCategoryMapperEx.countsByMaterialCategory(name, parentId);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertMaterialCategory(String beanJson, HttpServletRequest request)throws Exception {
accountItem.setEachamount(eachAmount);
} else {
accountItem.setEachamount(BigDecimal.ZERO);
}
accountItem.setRemark(tempUpdatedJson.getString("Remark"));
this.updateAccountItemWithObj(accountItem);
}
}
return null;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteAccountItemByIds(String ids) throws Exception{
logService.insertLog("财务明细",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(",");
int result=0;
try{
result = accountItemMapperEx.batchDeleteAccountItemByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
}
}
}
List<AccountHead> dataList=null;
try{
dataList = accountHeadMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
if (dataList != null) {
String ids = "";
for (AccountHead accountHead : dataList) {
ids = ids + accountHead.getId() + ",";
}
if (!ids.equals("")) {
ids = ids.substring(0, ids.length() - 1);
}
AccountItemExample exampleAi = new AccountItemExample();
if (!ids.equals("")) {
List<Long> idList = StringUtil.strToLongList(ids);
exampleAi.createCriteria().andAccountidEqualTo(id).andHeaderidIn(idList)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
} else {
exampleAi.createCriteria().andAccountidEqualTo(id)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
}
List<AccountItem> dataListOne = accountItemMapper.selectByExample(exampleAi);
if (dataListOne != null) {
for (AccountItem accountItem : dataListOne) {
if(accountItem.getEachamount()!=null) {
accountSum = accountSum.add(accountItem.getEachamount());
}
}
}
}
} catch (DataAccessException e) {
logger.error(">>>>>>>>>查找进销存信息异常", e);
} catch (Exception e) {
logger.error(">>>>>>>>>异常信息:", e);
}
return accountSum;
}
/**
* 单个账户的金额求和-多账户的明细合计
*
* @param id
* @return
for (MaterialVo4Unit material : dataList) {
JSONObject item = new JSONObject();
item.put("Id", material.getId());
String ratio; //比例
if (material.getUnitid() == null || material.getUnitid().equals("")) {
ratio = "";
} else {
ratio = material.getUnitName();
ratio = ratio.substring(ratio.indexOf("("));
}
//品名/型号/扩展信息/包装
String MaterialName = material.getName() + ((material.getModel() == null || material.getModel().equals("")) ? "" : "(" + material.getModel() + ")");
for (int i = 0; i < mpArr.length; i++) {
if (mpArr[i].equals("颜色")) {
MaterialName = MaterialName + ((material.getColor() == null || material.getColor().equals("")) ? "" : "(" + material.getColor() + ")");
}
if (mpArr[i].equals("规格")) {
MaterialName = MaterialName + ((material.getStandard() == null || material.getStandard().equals("")) ? "" : "(" + material.getStandard() + ")");
}
if (mpArr[i].equals("制造商")) {
MaterialName = MaterialName + ((material.getMfrs() == null || material.getMfrs().equals("")) ? "" : "(" + material.getMfrs() + ")");
}
if (mpArr[i].equals("自定义1")) {
MaterialName = MaterialName + ((material.getOtherfield1() == null || material.getOtherfield1().equals("")) ? "" : "(" + material.getOtherfield1() + ")");
}
if (mpArr[i].equals("自定义2")) {
MaterialName = MaterialName + ((material.getOtherfield2() == null || material.getOtherfield2().equals("")) ? "" : "(" + material.getOtherfield2() + ")");
}
if (mpArr[i].equals("自定义3")) {
MaterialName = MaterialName + ((material.getOtherfield3() == null || material.getOtherfield3().equals("")) ? "" : "(" + material.getOtherfield3() + ")");
}
}
MaterialName = MaterialName + ((material.getUnit() == null || material.getUnit().equals("")) ? "" : "(" + material.getUnit() + ")") + ratio;
item.put("MaterialName", MaterialName);
dataArray.add(item);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return dataArray;
}
/**
* 查找商品信息-统计排序
* @param request
* @return
} else {
depotItem.setBasicnumber(oNumber); //其他情况
}
} catch (Exception e) {
logger.error(">>>>>>>>>>>>>>>>>>>设置基础数量异常", e);
}
}
if (!StringUtil.isEmpty(tempInsertedJson.get("UnitPrice").toString())) {
depotItem.setUnitprice(tempInsertedJson.getBigDecimal("UnitPrice"));
}
if (!StringUtil.isEmpty(tempInsertedJson.get("TaxUnitPrice").toString())) {
depotItem.setTaxunitprice(tempInsertedJson.getBigDecimal("TaxUnitPrice"));
}
if (!StringUtil.isEmpty(tempInsertedJson.get("AllPrice").toString())) {
depotItem.setAllprice(tempInsertedJson.getBigDecimal("AllPrice"));
}
depotItem.setRemark(tempInsertedJson.getString("Remark"));
if (tempInsertedJson.get("DepotId") != null && !StringUtil.isEmpty(tempInsertedJson.get("DepotId").toString())) {
depotItem.setDepotid(tempInsertedJson.getLong("DepotId"));
}
if (tempInsertedJson.get("AnotherDepotId") != null && !StringUtil.isEmpty(tempInsertedJson.get("AnotherDepotId").toString())) {
depotItem.setAnotherdepotid(tempInsertedJson.getLong("AnotherDepotId"));
}
if (!StringUtil.isEmpty(tempInsertedJson.get("TaxRate").toString())) {
depotItem.setTaxrate(tempInsertedJson.getBigDecimal("TaxRate"));
}
if (!StringUtil.isEmpty(tempInsertedJson.get("TaxMoney").toString())) {
depotItem.setTaxmoney(tempInsertedJson.getBigDecimal("TaxMoney"));
}
if (!StringUtil.isEmpty(tempInsertedJson.get("TaxLastMoney").toString())) {
depotItem.setTaxlastmoney(tempInsertedJson.getBigDecimal("TaxLastMoney"));
}
if (tempInsertedJson.get("OtherField1") != null) {
depotItem.setOtherfield1(tempInsertedJson.getString("OtherField1"));
}
if (tempInsertedJson.get("OtherField2") != null) {
depotItem.setOtherfield2(tempInsertedJson.getString("OtherField2"));
}
if (tempInsertedJson.get("OtherField3") != null) {
depotItem.setOtherfield3(tempInsertedJson.getString("OtherField3"));
}
if (tempInsertedJson.get("OtherField4") != null) {
oul=orgaUserRelService.addOrgaUserRel(oul);
if(oul==null){
logger.error("异常码[{}],异常提示[{}],参数,[{}]",
ExceptionConstants.ORGA_USER_REL_ADD_FAILED_CODE,ExceptionConstants.ORGA_USER_REL_ADD_FAILED_MSG);
throw new BusinessRunTimeException(ExceptionConstants.ORGA_USER_REL_ADD_FAILED_CODE,
ExceptionConstants.ORGA_USER_REL_ADD_FAILED_MSG);
}
}
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public UserEx addUser(UserEx ue) throws Exception{
/**
* 新增用户默认设置
* 1、密码默认123456
* 2是否系统自带默认为非系统自带
* 3是否管理者默认为员工
* 4默认用户状态为正常
* */
ue.setPassword(Tools.md5Encryp(BusinessConstants.USER_DEFAULT_PASSWORD));
ue.setIsystem(BusinessConstants.USER_NOT_SYSTEM);
if(ue.getIsmanager()==null){
ue.setIsmanager(BusinessConstants.USER_NOT_MANAGER);
}
ue.setStatus(BusinessConstants.USER_STATUS_NORMAL);
int result=0;
try{
result= userMapperEx.addUser(ue);
}catch(Exception e){
JshException.writeFail(logger, e);
}
if(result>0){
return ue;
}
return null;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public UserEx registerUser(UserEx ue, Integer manageRoleId, HttpServletRequest request) throws Exception{
/**
* create by: qiankunpingtai
* website:https://qiankunpingtai.cn
* description:
return accountMapper.selectByPrimaryKey(id);
}
public List<Account> getAccount() throws Exception{
AccountExample example = new AccountExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Account> list=null;
try{
list=accountMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public List<AccountVo4List> select(String name, String serialNo, String remark, int offset, int rows) throws Exception{
List<AccountVo4List> resList = new ArrayList<AccountVo4List>();
List<AccountVo4List> list=null;
try{
list = accountMapperEx.selectByConditionAccount(name, serialNo, remark, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
String timeStr = Tools.getCurrentMonth();
if (null != list && null !=timeStr) {
for (AccountVo4List al : list) {
DecimalFormat df = new DecimalFormat(".##");
BigDecimal thisMonthAmount = getAccountSum(al.getId(), timeStr, "month").add(getAccountSumByHead(al.getId(), timeStr, "month")).add(getAccountSumByDetail(al.getId(), timeStr, "month")).add(getManyAccountSum(al.getId(), timeStr, "month"));
String thisMonthAmountFmt = "0";
if ((thisMonthAmount.compareTo(BigDecimal.ZERO))!=0) {
thisMonthAmountFmt = df.format(thisMonthAmount);
}
al.setThismonthamount(thisMonthAmountFmt); //本月发生额
BigDecimal currentAmount = getAccountSum(al.getId(), "", "month").add(getAccountSumByHead(al.getId(), "", "month")).add(getAccountSumByDetail(al.getId(), "", "month")).add(getManyAccountSum(al.getId(), "", "month")) .add(al.getInitialamount()) ;
al.setCurrentamount(currentAmount);
resList.add(al);
}
}
return resList;
}
public Long countAccount(String name, String serialNo, String remark)throws Exception {
Long result=null;
logService.insertLog("序列号", BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
int result=0;
try{
result=serialNumberMapper.insertSelective(serialNumber);
logService.insertLog("序列号", BusinessConstants.LOG_OPERATION_TYPE_ADD, request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateSerialNumber(String beanJson, Long id, HttpServletRequest request) throws Exception{
SerialNumber serialNumber = JSONObject.parseObject(beanJson, SerialNumber.class);
serialNumber.setId(id);
int result=0;
try{
result=serialNumberMapper.updateByPrimaryKeySelective(serialNumber);
logService.insertLog("序列号",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteSerialNumber(Long id, HttpServletRequest request)throws Exception {
int result=0;
try{
result=serialNumberMapper.deleteByPrimaryKey(id);
logService.insertLog("序列号",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(id).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteSerialNumber(String ids, HttpServletRequest request)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids);
SerialNumberExample example = new SerialNumberExample();
example.createCriteria().andIdIn(idList);
if (!ids.equals("")) {
ids = ids.substring(0, ids.length() - 1);
}
AccountItemExample exampleAi = new AccountItemExample();
if (!ids.equals("")) {
List<Long> idList = StringUtil.strToLongList(ids);
exampleAi.createCriteria().andAccountidEqualTo(id).andHeaderidIn(idList)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
} else {
exampleAi.createCriteria().andAccountidEqualTo(id)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
}
List<AccountItem> dataListOne = accountItemMapper.selectByExample(exampleAi);
if (dataListOne != null) {
for (AccountItem accountItem : dataListOne) {
if(accountItem.getEachamount()!=null) {
accountSum = accountSum.add(accountItem.getEachamount());
}
}
}
}
} catch (DataAccessException e) {
logger.error(">>>>>>>>>查找进销存信息异常", e);
} catch (Exception e) {
logger.error(">>>>>>>>>异常信息:", e);
}
return accountSum;
}
/**
* 单个账户的金额求和-多账户的明细合计
*
* @param id
* @return
*/
public BigDecimal getManyAccountSum(Long id, String timeStr, String type)throws Exception {
BigDecimal accountSum = BigDecimal.ZERO;
try {
DepotHeadExample example = new DepotHeadExample();
if (!timeStr.equals("")) {
Date bTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
Date eTime = StringUtil.getDateByString(timeStr + "-31 00:00:00", null);
Date mTime = StringUtil.getDateByString(timeStr + "-01 00:00:00", null);
if (type.equals("month")) {
example.createCriteria().andAccountidlistLike("%" +id.toString() + "%")
.andOpertimeGreaterThanOrEqualTo(bTime).andOpertimeLessThanOrEqualTo(eTime)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
} else if (type.equals("date")) {
example.createCriteria().andAccountidlistLike("%" +id.toString() + "%")
.andOpertimeLessThanOrEqualTo(mTime)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
}
if (!StringUtils.isEmpty(ip) && !"unknown".equalsIgnoreCase(ip)) {
// 多次反向代理后会有多个IP值,第一个为真实IP。
int index = ip.indexOf(',');
if (index != -1) {
return ip.substring(0, index);
} else {
return ip;
}
} else {
return request.getRemoteAddr();
}
}
/**
* 转化前台批量传入的ID值
*
* @param data
* @return 转化后的ID值数组
*/
public static int[] changeDataForm(String data) {
String[] dataStr = data.split(",");
int[] dataInt = new int[dataStr.length];
for (int i = 0; i < dataStr.length; i++)
dataInt[i] = Integer.parseInt(dataStr[i]);
return dataInt;
}
/**
* 解决导出文件中文乱码问题firefox和ie下中文乱码
*/
public static String changeUnicode(String fileName, String browserType) {
String returnFileName = "";
try {
if (browserType.equalsIgnoreCase("MSIE")) {
returnFileName = URLEncoder.encode(fileName, "ISO8859-1");
returnFileName = returnFileName.replace(" ", "%20");
if (returnFileName.length() > 150) {
returnFileName = new String(fileName.getBytes("GB2312"), "ISO8859-1");
returnFileName = returnFileName.replace(" ", "%20");
}
} else if (browserType.equalsIgnoreCase("Firefox")) {
returnFileName = new String(fileName.getBytes("ISO8859-1"), "ISO8859-1");
private Logger logger = LoggerFactory.getLogger(AccountService.class);
@Resource
private AccountMapper accountMapper;
@Resource
private AccountMapperEx accountMapperEx;
@Resource
private DepotHeadMapper depotHeadMapper;
@Resource
private DepotHeadMapperEx depotHeadMapperEx;
@Resource
private AccountHeadMapper accountHeadMapper;
@Resource
private AccountHeadMapperEx accountHeadMapperEx;
@Resource
private AccountItemMapper accountItemMapper;
@Resource
private AccountItemMapperEx accountItemMapperEx;
@Resource
private LogService logService;
@Resource
private UserService userService;
public Account getAccount(long id) throws Exception{
return accountMapper.selectByPrimaryKey(id);
}
public List<Account> getAccount() throws Exception{
AccountExample example = new AccountExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Account> list=null;
try{
list=accountMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
//转为json
JSONArray insertedJson = JSONArray.parseArray(inserted);
JSONArray deletedJson = JSONArray.parseArray(deleted);
JSONArray updatedJson = JSONArray.parseArray(updated);
/**
* 删除的可以继续卖,删除的需要将使用的序列号回收
* 插入的需要判断当前货源是否充足
* 更新的需要判断货源是否充足
* */
if (null != deletedJson) {
StringBuffer bf=new StringBuffer();
for (int i = 0; i < deletedJson.size(); i++) {
//首先回收序列号,如果是调拨,不用处理序列号
JSONObject tempDeletedJson = JSONObject.parseObject(deletedJson.getString(i));
if(BusinessConstants.DEPOTHEAD_TYPE_OUT.equals(depotHead.getType())
&&!BusinessConstants.SUB_TYPE_TRANSFER.equals(depotHead.getSubtype())){
DepotItem depotItem = getDepotItem(tempDeletedJson.getLong("Id"));
if(depotItem==null){
continue;
}
/**
* 判断商品是否开启序列号,开启的收回序列号,未开启的跳过
* */
Material material= materialService.getMaterial(depotItem.getMaterialid());
if(material==null){
continue;
}
if(BusinessConstants.ENABLE_SERIAL_NUMBER_ENABLED.equals(material.getEnableserialnumber())){
serialNumberService.cancelSerialNumber(depotItem.getMaterialid(),depotItem.getHeaderid(),(depotItem.getBasicnumber()==null?0:depotItem.getBasicnumber()).intValue(),
userInfo);
}
}
this.deleteDepotItem(tempDeletedJson.getLong("Id"), request);
bf.append(tempDeletedJson.getLong("Id"));
if(i<(deletedJson.size()-1)){
bf.append(",");
}
}
this.batchDeleteDepotItemByIds(bf.toString());
}
if (null != insertedJson) {
for (int i = 0; i < insertedJson.size(); i++) {
} catch (Exception e) {
e.printStackTrace();
logger.error(">>>>>>>>>>>>>>>查询用户名为:" + username + " ,用户信息异常", e);
}
break;
}
Map<String, Object> data = new HashMap<String, Object>();
data.put("msgTip", msgTip);
/**
* 在IE模式下,无法获取到user数据,
* 在此处明确添加上user信息
* */
if(user!=null){
data.put("user",user);
}
res.code = 200;
res.data = data;
logger.info("===============用户登录 login 方法调用结束===============");
} catch(Exception e){
e.printStackTrace();
logger.error(e.getMessage());
res.code = 500;
res.data = "用户登录失败";
}
return res;
}
@GetMapping(value = "/getUserSession")
public BaseResponseInfo getSessionUser(HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
try {
Map<String, Object> data = new HashMap<String, Object>();
Object userInfo = request.getSession().getAttribute("user");
if(userInfo!=null) {
User user = (User) userInfo;
user.setPassword(null);
data.put("user", user);
}
res.code = 200;
res.data = data;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
/**
* 入库出库统计接口
* @param currentPage
* @param pageSize
* @param oId
* @param pid
* @param dids
* @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("projectId") Integer pid,
@RequestParam("depotIds") String dids,
@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<DepotHeadVo4InOutMCount>();
List<DepotHeadVo4InOutMCount> list = depotHeadService.findInOutMaterialCount(beginTime, endTime, type, pid, dids, oId, (currentPage-1)*pageSize, pageSize);
int total = depotHeadService.findInOutMaterialCountTotal(beginTime, endTime, type, pid, dids, oId);
map.put("total", total);
//存放数据json数组
if (null != list) {
for (DepotHeadVo4InOutMCount dhc : list) {
resList.add(dhc);
}
if(list.size()>1){
//超过一条数据存在,该登录名已存在
logger.error("异常码[{}],异常提示[{}],参数,loginName:[{}]",
ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_CODE,ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_MSG,loginName);
throw new BusinessRunTimeException(ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_CODE,
ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_MSG);
}
//一条数据,新增时抛出异常,修改时和当前的id不同时抛出异常
if(list.size()==1){
if(userId==null||(userId!=null&&!userId.equals(list.get(0).getId()))){
logger.error("异常码[{}],异常提示[{}],参数,loginName:[{}]",
ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_CODE,ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_MSG,loginName);
throw new BusinessRunTimeException(ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_CODE,
ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_MSG);
}
}
}
}
//检查用户名
if(!StringUtils.isEmpty(userEx.getUsername())){
String userName=userEx.getUsername();
list=this.getUserListByUserName(userName);
if(list!=null&&list.size()>0){
if(list.size()>1){
//超过一条数据存在,该用户名已存在
logger.error("异常码[{}],异常提示[{}],参数,userName:[{}]",
ExceptionConstants.USER_USER_NAME_ALREADY_EXISTS_CODE,ExceptionConstants.USER_USER_NAME_ALREADY_EXISTS_MSG,userName);
throw new BusinessRunTimeException(ExceptionConstants.USER_USER_NAME_ALREADY_EXISTS_CODE,
ExceptionConstants.USER_USER_NAME_ALREADY_EXISTS_MSG);
}
//一条数据,新增时抛出异常,修改时和当前的id不同时抛出异常
if(list.size()==1){
if(userId==null||(userId!=null&&!userId.equals(list.get(0).getId()))){
logger.error("异常码[{}],异常提示[{}],参数,userName:[{}]",
ExceptionConstants.USER_USER_NAME_ALREADY_EXISTS_CODE,ExceptionConstants.USER_USER_NAME_ALREADY_EXISTS_MSG,userName);
throw new BusinessRunTimeException(ExceptionConstants.USER_USER_NAME_ALREADY_EXISTS_CODE,
ExceptionConstants.USER_USER_NAME_ALREADY_EXISTS_MSG);
}
}
}
}
}
/**
* 通过用户名获取用户列表
* */
public List<User> getUserListByUserName(String userName)throws Exception{
List<User> list =null;
try{
list=userMapperEx.getUserListByUserNameOrLoginName(userName,null);
}catch(Exception e){
JshException.readFail(logger, e);