diff --git a/WebRoot/WEB-INF/classes/com/jsh/action/asset/AssetAction.class b/WebRoot/WEB-INF/classes/com/jsh/action/asset/AssetAction.class index 8a2b680a..3980ab42 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/action/asset/AssetAction.class and b/WebRoot/WEB-INF/classes/com/jsh/action/asset/AssetAction.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/action/asset/ReportAction.class b/WebRoot/WEB-INF/classes/com/jsh/action/asset/ReportAction.class index 16c9ca38..1e40724e 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/action/asset/ReportAction.class and b/WebRoot/WEB-INF/classes/com/jsh/action/asset/ReportAction.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/action/basic/UserAction.class b/WebRoot/WEB-INF/classes/com/jsh/action/basic/UserAction.class index 30fa8fa6..7f5d033a 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/action/basic/UserAction.class and b/WebRoot/WEB-INF/classes/com/jsh/action/basic/UserAction.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/action/materials/DepotItemAction.class b/WebRoot/WEB-INF/classes/com/jsh/action/materials/DepotItemAction.class index 38a7a910..ba2877bf 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/action/materials/DepotItemAction.class and b/WebRoot/WEB-INF/classes/com/jsh/action/materials/DepotItemAction.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/dao/asset/ReportDAO.class b/WebRoot/WEB-INF/classes/com/jsh/dao/asset/ReportDAO.class index 94f59f0a..d476dee8 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/dao/asset/ReportDAO.class and b/WebRoot/WEB-INF/classes/com/jsh/dao/asset/ReportDAO.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/dao/asset/ReportIDAO.class b/WebRoot/WEB-INF/classes/com/jsh/dao/asset/ReportIDAO.class index a1fa8523..31fa71a8 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/dao/asset/ReportIDAO.class and b/WebRoot/WEB-INF/classes/com/jsh/dao/asset/ReportIDAO.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/dao/basic/UserBusinessDAO.class b/WebRoot/WEB-INF/classes/com/jsh/dao/basic/UserBusinessDAO.class index 364d9439..09278624 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/dao/basic/UserBusinessDAO.class and b/WebRoot/WEB-INF/classes/com/jsh/dao/basic/UserBusinessDAO.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/dao/basic/UserBusinessIDAO.class b/WebRoot/WEB-INF/classes/com/jsh/dao/basic/UserBusinessIDAO.class index 08451d72..30e51bd6 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/dao/basic/UserBusinessIDAO.class and b/WebRoot/WEB-INF/classes/com/jsh/dao/basic/UserBusinessIDAO.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/dao/materials/DepotHeadDAO.class b/WebRoot/WEB-INF/classes/com/jsh/dao/materials/DepotHeadDAO.class index bd5ae618..b52cea52 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/dao/materials/DepotHeadDAO.class and b/WebRoot/WEB-INF/classes/com/jsh/dao/materials/DepotHeadDAO.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/dao/materials/DepotHeadIDAO.class b/WebRoot/WEB-INF/classes/com/jsh/dao/materials/DepotHeadIDAO.class index f556f175..ec22b35c 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/dao/materials/DepotHeadIDAO.class and b/WebRoot/WEB-INF/classes/com/jsh/dao/materials/DepotHeadIDAO.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/dao/materials/DepotItemDAO.class b/WebRoot/WEB-INF/classes/com/jsh/dao/materials/DepotItemDAO.class index 96302d0a..1b1bb4e9 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/dao/materials/DepotItemDAO.class and b/WebRoot/WEB-INF/classes/com/jsh/dao/materials/DepotItemDAO.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/dao/materials/DepotItemIDAO.class b/WebRoot/WEB-INF/classes/com/jsh/dao/materials/DepotItemIDAO.class index 2d9a9e50..fdefbedb 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/dao/materials/DepotItemIDAO.class and b/WebRoot/WEB-INF/classes/com/jsh/dao/materials/DepotItemIDAO.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/exception/JshException.class b/WebRoot/WEB-INF/classes/com/jsh/exception/JshException.class new file mode 100644 index 00000000..a900fd7a Binary files /dev/null and b/WebRoot/WEB-INF/classes/com/jsh/exception/JshException.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/model/po/Basicuser.hbm.xml b/WebRoot/WEB-INF/classes/com/jsh/model/po/Basicuser.hbm.xml index 5b7a04eb..e6abb717 100644 --- a/WebRoot/WEB-INF/classes/com/jsh/model/po/Basicuser.hbm.xml +++ b/WebRoot/WEB-INF/classes/com/jsh/model/po/Basicuser.hbm.xml @@ -18,7 +18,7 @@ - + 登陆密码 diff --git a/WebRoot/WEB-INF/classes/com/jsh/model/vo/materials/DepotHeadModel.class b/WebRoot/WEB-INF/classes/com/jsh/model/vo/materials/DepotHeadModel.class index aa655910..cb952e7c 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/model/vo/materials/DepotHeadModel.class and b/WebRoot/WEB-INF/classes/com/jsh/model/vo/materials/DepotHeadModel.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/service/asset/AssetIService.class b/WebRoot/WEB-INF/classes/com/jsh/service/asset/AssetIService.class index 71e2733d..33ccb5b2 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/service/asset/AssetIService.class and b/WebRoot/WEB-INF/classes/com/jsh/service/asset/AssetIService.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/service/asset/AssetService.class b/WebRoot/WEB-INF/classes/com/jsh/service/asset/AssetService.class index 670e2ed1..4aebc9c5 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/service/asset/AssetService.class and b/WebRoot/WEB-INF/classes/com/jsh/service/asset/AssetService.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/service/asset/ReportIService.class b/WebRoot/WEB-INF/classes/com/jsh/service/asset/ReportIService.class index 90823132..02a31771 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/service/asset/ReportIService.class and b/WebRoot/WEB-INF/classes/com/jsh/service/asset/ReportIService.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/service/asset/ReportService.class b/WebRoot/WEB-INF/classes/com/jsh/service/asset/ReportService.class index fe1201a8..e5434466 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/service/asset/ReportService.class and b/WebRoot/WEB-INF/classes/com/jsh/service/asset/ReportService.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/service/basic/UserBusinessIService.class b/WebRoot/WEB-INF/classes/com/jsh/service/basic/UserBusinessIService.class index 154fa1f0..fe35362d 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/service/basic/UserBusinessIService.class and b/WebRoot/WEB-INF/classes/com/jsh/service/basic/UserBusinessIService.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/service/basic/UserBusinessService.class b/WebRoot/WEB-INF/classes/com/jsh/service/basic/UserBusinessService.class index cc01cc51..3ebfc440 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/service/basic/UserBusinessService.class and b/WebRoot/WEB-INF/classes/com/jsh/service/basic/UserBusinessService.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/service/basic/UserIService.class b/WebRoot/WEB-INF/classes/com/jsh/service/basic/UserIService.class index 48a0f9bd..44acb782 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/service/basic/UserIService.class and b/WebRoot/WEB-INF/classes/com/jsh/service/basic/UserIService.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/service/basic/UserService.class b/WebRoot/WEB-INF/classes/com/jsh/service/basic/UserService.class index e2a903bc..69b98f37 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/service/basic/UserService.class and b/WebRoot/WEB-INF/classes/com/jsh/service/basic/UserService.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/service/materials/DepotHeadIService.class b/WebRoot/WEB-INF/classes/com/jsh/service/materials/DepotHeadIService.class index 603645db..c3319043 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/service/materials/DepotHeadIService.class and b/WebRoot/WEB-INF/classes/com/jsh/service/materials/DepotHeadIService.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/service/materials/DepotHeadService.class b/WebRoot/WEB-INF/classes/com/jsh/service/materials/DepotHeadService.class index 9e379826..76b63db3 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/service/materials/DepotHeadService.class and b/WebRoot/WEB-INF/classes/com/jsh/service/materials/DepotHeadService.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/service/materials/DepotItemIService.class b/WebRoot/WEB-INF/classes/com/jsh/service/materials/DepotItemIService.class index 864f20d2..49164b44 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/service/materials/DepotItemIService.class and b/WebRoot/WEB-INF/classes/com/jsh/service/materials/DepotItemIService.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/service/materials/DepotItemService.class b/WebRoot/WEB-INF/classes/com/jsh/service/materials/DepotItemService.class index 22c5f16f..183d72a8 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/service/materials/DepotItemService.class and b/WebRoot/WEB-INF/classes/com/jsh/service/materials/DepotItemService.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/util/common/BeanFactoryUtil.class b/WebRoot/WEB-INF/classes/com/jsh/util/common/BeanFactoryUtil.class index e4ca17d2..1585e535 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/util/common/BeanFactoryUtil.class and b/WebRoot/WEB-INF/classes/com/jsh/util/common/BeanFactoryUtil.class differ diff --git a/WebRoot/WEB-INF/classes/com/jsh/util/common/Tools.class b/WebRoot/WEB-INF/classes/com/jsh/util/common/Tools.class index 6aa1fd0e..668b9714 100644 Binary files a/WebRoot/WEB-INF/classes/com/jsh/util/common/Tools.class and b/WebRoot/WEB-INF/classes/com/jsh/util/common/Tools.class differ diff --git a/sql/jsh_erp.sql b/sql/jsh_erp.sql index d35d2dfd..d4f661a8 100644 --- a/sql/jsh_erp.sql +++ b/sql/jsh_erp.sql @@ -2,7 +2,7 @@ MySQL Backup Source Server Version: 5.1.54 Source Database: jsh_erp -Date: 2016-11-13 13:35:26 +Date: 2016-11-20 13:29:35 */ SET FOREIGN_KEY_CHECKS=0; @@ -213,7 +213,7 @@ CREATE TABLE `jsh_log` ( PRIMARY KEY (`id`), KEY `FKF2696AA13E226853` (`userID`), CONSTRAINT `FKF2696AA13E226853` FOREIGN KEY (`userID`) REFERENCES `jsh_user` (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=1664 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=1674 DEFAULT CHARSET=utf8; -- ---------------------------- -- Table structure for `jsh_material` @@ -295,7 +295,7 @@ CREATE TABLE `jsh_user` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `username` varchar(255) NOT NULL COMMENT '用户姓名--例如张三', `loginame` varchar(255) DEFAULT NULL COMMENT '登录用户名--可能为空', - `password` varchar(30) DEFAULT NULL COMMENT '登陆密码', + `password` varchar(50) DEFAULT NULL COMMENT '登陆密码', `position` varchar(200) DEFAULT NULL COMMENT '职位', `department` varchar(255) DEFAULT NULL COMMENT '所属部门', `email` varchar(100) DEFAULT NULL COMMENT '电子邮箱', @@ -306,7 +306,7 @@ CREATE TABLE `jsh_user` ( `description` varchar(500) DEFAULT NULL COMMENT '用户描述信息', `remark` varchar(500) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=66 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=68 DEFAULT CHARSET=utf8; -- ---------------------------- -- Table structure for `jsh_userbusiness` @@ -360,11 +360,11 @@ INSERT INTO `jsh_functions` VALUES ('101','070203','资料查阅','0702','../Fil INSERT INTO `jsh_log` VALUES ('1316','63','增加用户','192.168.1.105','2016-10-04 14:53:11','0','增加用户名称为 曹玉丽 成功!','增加用户成功'), ('1317','63','增加用户','192.168.1.105','2016-10-04 14:53:30','0','增加用户名称为 郭秀红 成功!','增加用户成功'), ('1318','63','更新用户','192.168.1.105','2016-10-04 14:53:47','0','更新用户ID为 64 成功!','更新用户成功'), ('1319','63','更新用户','192.168.1.105','2016-10-04 14:53:58','0','更新用户ID为 63 成功!','更新用户成功'), ('1320','63','退出系统','192.168.1.105','2016-10-04 14:54:21','0','管理用户:jishenghua 退出系统','jishenghua 退出系统'), ('1321','63','登录系统','192.168.1.105','2016-10-04 14:54:28','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1322','63','更新用户','','2016-10-04 14:54:42','0','更新用户ID为 63密码信息 成功!','更新用户成功'), ('1323','63','登录系统','192.168.1.105','2016-10-04 14:54:47','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1324','63','退出系统','192.168.1.105','2016-10-04 14:55:16','0','管理用户:jsh 退出系统','jsh 退出系统'), ('1325','64','登录系统','192.168.1.105','2016-10-04 14:55:24','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1326','64','批量删除角色','192.168.1.105','2016-10-04 14:56:01','0','批量删除角色ID为 6 成功!','批量删除角色成功'), ('1327','64','批量删除角色','192.168.1.105','2016-10-04 14:56:04','0','批量删除角色ID为 7 成功!','批量删除角色成功'), ('1328','64','批量删除角色','192.168.1.105','2016-10-04 14:56:07','0','批量删除角色ID为 8 成功!','批量删除角色成功'), ('1329','64','批量删除角色','192.168.1.105','2016-10-04 14:56:10','0','批量删除角色ID为 9 成功!','批量删除角色成功'), ('1330','64','批量删除角色','192.168.1.105','2016-10-04 14:56:13','0','批量删除角色ID为 10 成功!','批量删除角色成功'), ('1331','64','批量删除角色','192.168.1.105','2016-10-04 14:56:16','0','批量删除角色ID为 11 成功!','批量删除角色成功'), ('1332','64','删除角色','192.168.1.105','2016-10-04 14:56:50','0','删除角色ID为 19 成功!','删除角色成功'), ('1333','64','删除角色','192.168.1.105','2016-10-04 14:56:52','0','删除角色ID为 18 成功!','删除角色成功'), ('1334','64','删除角色','192.168.1.105','2016-10-04 14:56:53','0','删除角色ID为 17 成功!','删除角色成功'), ('1335','64','删除角色','192.168.1.105','2016-10-04 14:56:54','0','删除角色ID为 16 成功!','删除角色成功'), ('1336','64','删除角色','192.168.1.105','2016-10-04 14:56:56','0','删除角色ID为 20 成功!','删除角色成功'), ('1337','64','删除角色','192.168.1.105','2016-10-04 14:56:59','0','删除角色ID为 21 成功!','删除角色成功'), ('1338','64','删除角色','192.168.1.105','2016-10-04 14:57:00','0','删除角色ID为 15 成功!','删除角色成功'), ('1339','64','删除角色','192.168.1.105','2016-10-04 14:57:02','0','删除角色ID为 14 成功!','删除角色成功'), ('1340','64','删除角色','192.168.1.105','2016-10-04 14:57:04','0','删除角色ID为 13 成功!','删除角色成功'), ('1341','64','删除角色','192.168.1.105','2016-10-04 14:57:05','0','删除角色ID为 23 成功!','删除角色成功'), ('1342','64','删除角色','192.168.1.105','2016-10-04 14:57:07','0','删除角色ID为 25 成功!','删除角色成功'), ('1343','64','删除角色','192.168.1.105','2016-10-04 14:57:09','0','删除角色ID为 27 成功!','删除角色成功'), ('1344','64','删除角色','192.168.1.105','2016-10-04 14:57:10','0','删除角色ID为 28 成功!','删除角色成功'), ('1345','64','删除角色','192.168.1.105','2016-10-04 14:57:12','0','删除角色ID为 30 成功!','删除角色成功'), ('1346','64','删除角色','192.168.1.105','2016-10-04 14:57:14','0','删除角色ID为 32 成功!','删除角色成功'), ('1347','64','删除角色','192.168.1.105','2016-10-04 14:57:17','0','删除角色ID为 33 成功!','删除角色成功'), ('1348','64','删除角色','192.168.1.105','2016-10-04 14:57:18','0','删除角色ID为 35 成功!','删除角色成功'), ('1349','64','删除角色','192.168.1.105','2016-10-04 14:57:20','0','删除角色ID为 31 成功!','删除角色成功'), ('1350','64','删除角色','192.168.1.105','2016-10-04 14:57:21','0','删除角色ID为 29 成功!','删除角色成功'), ('1351','64','删除角色','192.168.1.105','2016-10-04 14:57:22','0','删除角色ID为 34 成功!','删除角色成功'), ('1352','64','删除角色','192.168.1.105','2016-10-04 14:57:23','0','删除角色ID为 36 成功!','删除角色成功'), ('1353','64','删除角色','192.168.1.105','2016-10-04 14:57:26','0','删除角色ID为 38 成功!','删除角色成功'), ('1354','64','删除角色','192.168.1.105','2016-10-04 14:57:27','0','删除角色ID为 40 成功!','删除角色成功'), ('1355','64','删除角色','192.168.1.105','2016-10-04 14:57:28','0','删除角色ID为 26 成功!','删除角色成功'), ('1356','64','删除角色','192.168.1.105','2016-10-04 14:57:29','0','删除角色ID为 24 成功!','删除角色成功'), ('1357','64','删除角色','192.168.1.105','2016-10-04 14:57:31','0','删除角色ID为 22 成功!','删除角色成功'), ('1358','64','删除角色','192.168.1.105','2016-10-04 14:57:32','0','删除角色ID为 37 成功!','删除角色成功'), ('1359','64','删除角色','192.168.1.105','2016-10-04 14:57:34','0','删除角色ID为 12 成功!','删除角色成功'), ('1360','64','更新UserBusiness','192.168.1.105','2016-10-04 14:58:08','0','更新UserBusiness的ID为 2 成功!','更新UserBusiness成功'), ('1361','64','更新UserBusiness','192.168.1.105','2016-10-04 15:00:01','0','更新UserBusiness的ID为 6 成功!','更新UserBusiness成功'), ('1362','64','更新UserBusiness','192.168.1.105','2016-10-04 15:00:29','0','更新UserBusiness的ID为 6 成功!','更新UserBusiness成功'), ('1363','64','增加UserBusiness','192.168.1.105','2016-10-04 15:00:56','0','增加UserBusiness为 UserRole 成功!','增加UserBusiness成功'), ('1364','64','增加UserBusiness','192.168.1.105','2016-10-04 15:01:01','0','增加UserBusiness为 UserDepot 成功!','增加UserBusiness成功'), ('1365','64','退出系统','192.168.1.105','2016-10-04 15:01:15','0','管理用户:cyl 退出系统','cyl 退出系统'), ('1366','63','登录系统','192.168.1.105','2016-10-04 15:01:17','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1367','63','增加UserBusiness','192.168.1.105','2016-10-04 15:01:29','0','增加UserBusiness为 UserRole 成功!','增加UserBusiness成功'), ('1368','63','增加UserBusiness','192.168.1.105','2016-10-04 15:01:34','0','增加UserBusiness为 UserDepot 成功!','增加UserBusiness成功'), ('1369','63','退出系统','192.168.1.105','2016-10-04 15:01:40','0','管理用户:jsh 退出系统','jsh 退出系统'), ('1370','64','登录系统','192.168.1.105','2016-10-04 15:01:45','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1371','64','退出系统','192.168.1.105','2016-10-04 15:03:23','0','管理用户:cyl 退出系统','cyl 退出系统'), ('1372','63','登录系统','192.168.1.105','2016-10-04 15:03:31','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1373','63','增加供应商','192.168.1.105','2016-10-04 15:15:37','0','增加供应商名称为 客户AAAA 成功!','增加供应商成功'), ('1374','63','增加仓管通','192.168.1.105','2016-10-04 15:16:30','0','增加仓管通编号为 123123 成功!','增加仓管通成功'), ('1375','63','保存仓管通明细','192.168.1.105','2016-10-04 15:16:30','0','保存仓管通明细对应主表编号为 4 成功!','保存仓管通明细成功'), ('1376','63','增加功能','192.168.1.105','2016-10-04 15:18:49','0','增加功能名称为 销售出库审核 成功!','增加功能成功'), ('1377','63','更新功能','192.168.1.105','2016-10-04 15:18:58','0','更新功能ID为 193 成功!','更新功能成功'), ('1378','63','更新功能','192.168.1.105','2016-10-04 15:19:14','0','更新功能ID为 193 成功!','更新功能成功'), ('1379','63','更新UserBusiness','192.168.1.105','2016-10-04 15:19:50','0','更新UserBusiness的ID为 5 成功!','更新UserBusiness成功'), ('1380','63','更新状态仓管通','192.168.1.105','2016-10-04 15:20:14','0','更新状态-待审核-ID为 4 成功!','更新状态仓管通成功'), ('1381','63','更新状态仓管通','192.168.1.105','2016-10-04 15:20:28','0','更新状态-已生效-ID为 4 成功!','更新状态仓管通成功'), ('1382','63','更新UserBusiness','192.168.1.105','2016-10-04 15:21:13','0','更新UserBusiness的ID为 6 成功!','更新UserBusiness成功'), ('1383','63','退出系统','192.168.1.105','2016-10-04 15:21:24','0','管理用户:jsh 退出系统','jsh 退出系统'), ('1384','64','登录系统','192.168.1.105','2016-10-04 15:21:26','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1385','63','登录系统','192.168.1.102','2016-10-05 10:00:48','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1386','63','退出系统','192.168.1.102','2016-10-05 10:00:56','0','管理用户:jsh 退出系统','jsh 退出系统'), ('1387','64','登录系统','192.168.1.102','2016-10-05 10:01:00','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1388','64','退出系统','192.168.1.102','2016-10-05 10:01:24','0','管理用户:cyl 退出系统','cyl 退出系统'), ('1389','63','登录系统','192.168.1.102','2016-10-05 10:01:28','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1390','63','更新UserBusiness','192.168.1.102','2016-10-05 10:02:07','0','更新UserBusiness的ID为 6 成功!','更新UserBusiness成功'), ('1391','63','退出系统','192.168.1.102','2016-10-05 10:02:11','0','管理用户:jsh 退出系统','jsh 退出系统'), ('1392','64','登录系统','192.168.1.102','2016-10-05 10:02:13','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1393','64','增加物料','192.168.1.102','2016-10-05 10:05:10','0','增加物料名称为 花边 成功!','增加物料成功'), ('1394','64','更新物料类别','192.168.1.102','2016-10-05 10:05:42','0','更新物料类别ID为 244 成功!','更新物料类别成功'), ('1395','64','增加物料类别','192.168.1.102','2016-10-05 10:08:28','0','增加物料类别名称为 棉布 成功!','增加物料类别成功'), ('1396','64','增加物料类别','192.168.1.102','2016-10-05 10:08:46','0','增加物料类别名称为 网布 成功!','增加物料类别成功'), ('1397','64','更新物料','192.168.1.102','2016-10-05 10:09:23','0','更新物料ID为 5 成功!','更新物料成功'), ('1398','64','批量删除仓管通','192.168.1.102','2016-10-05 10:11:05','1','批量删除仓管通ID为 1 失败!','批量删除仓管通失败'), ('1399','64','删除物料','192.168.1.102','2016-10-05 10:11:41','0','删除物料ID为 4 成功!','删除物料成功'), ('1400','64','增加物料','192.168.1.102','2016-10-05 10:13:11','0','增加物料名称为 花边 成功!','增加物料成功'), ('1401','64','增加物料','192.168.1.102','2016-10-05 10:15:21','0','增加物料名称为 花边 成功!','增加物料成功'), ('1402','64','增加物料','192.168.1.102','2016-10-05 10:15:55','0','增加物料名称为 花边 成功!','增加物料成功'), ('1403','64','增加仓管通','192.168.1.102','2016-10-05 10:18:39','0','增加仓管通编号为 30198 成功!','增加仓管通成功'), ('1404','64','更新仓管通','192.168.1.102','2016-10-05 10:19:42','0','更新仓管通ID为 5 成功!','更新仓管通成功'), ('1405','64','保存仓管通明细','192.168.1.102','2016-10-05 10:19:42','0','保存仓管通明细对应主表编号为 5 成功!','保存仓管通明细成功'), ('1406','64','更新仓管通','192.168.1.102','2016-10-05 10:21:18','0','更新仓管通ID为 5 成功!','更新仓管通成功'), ('1407','64','保存仓管通明细','192.168.1.102','2016-10-05 10:21:18','0','保存仓管通明细对应主表编号为 5 成功!','保存仓管通明细成功'), ('1408','64','增加仓管通','192.168.1.102','2016-10-05 10:22:35','0','增加仓管通编号为 30199 成功!','增加仓管通成功'), ('1409','64','增加物料类别','192.168.1.102','2016-10-05 10:24:53','0','增加物料类别名称为 其他 成功!','增加物料类别成功'), ('1410','64','增加物料','192.168.1.102','2016-10-05 10:25:48','0','增加物料名称为 花边 成功!','增加物料成功'), ('1411','64','增加物料','192.168.1.102','2016-10-05 10:26:37','0','增加物料名称为 花边 成功!','增加物料成功'), ('1412','64','增加物料','192.168.1.102','2016-10-05 10:27:30','0','增加物料名称为 花边 成功!','增加物料成功'), ('1413','64','增加物料','192.168.1.102','2016-10-05 10:28:48','0','增加物料名称为 花边 成功!','增加物料成功'), ('1414','64','增加物料','192.168.1.102','2016-10-05 10:31:03','0','增加物料名称为 线边 成功!','增加物料成功'), ('1415','64','更新物料','192.168.1.102','2016-10-05 10:34:21','0','更新物料ID为 13 成功!','更新物料成功'); INSERT INTO `jsh_log` VALUES ('1416','64','更新物料','192.168.1.102','2016-10-05 10:34:40','0','更新物料ID为 11 成功!','更新物料成功'), ('1417','64','更新物料','192.168.1.102','2016-10-05 10:34:45','0','更新物料ID为 10 成功!','更新物料成功'), ('1418','64','更新物料','192.168.1.102','2016-10-05 10:35:24','0','更新物料ID为 9 成功!','更新物料成功'), ('1419','64','更新物料','192.168.1.102','2016-10-05 10:35:37','0','更新物料ID为 8 成功!','更新物料成功'), ('1420','64','更新物料','192.168.1.102','2016-10-05 10:35:44','0','更新物料ID为 7 成功!','更新物料成功'), ('1421','63','登录系统','192.168.1.102','2016-10-05 10:44:31','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1422','63','退出系统','192.168.1.102','2016-10-05 10:44:39','0','管理用户:jsh 退出系统','jsh 退出系统'), ('1423','64','登录系统','192.168.1.102','2016-10-05 10:44:44','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1424','64','登录系统','192.168.1.102','2016-10-05 12:00:45','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1425','64','登录系统','192.168.1.102','2016-10-05 12:02:51','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1426','64','更新物料','192.168.1.102','2016-10-05 12:05:01','0','更新物料ID为 9 成功!','更新物料成功'), ('1427','64','更新仓管通','192.168.1.102','2016-10-05 12:07:32','0','更新仓管通ID为 6 成功!','更新仓管通成功'), ('1428','64','保存仓管通明细','192.168.1.102','2016-10-05 12:07:32','0','保存仓管通明细对应主表编号为 6 成功!','保存仓管通明细成功'), ('1429','64','登录系统','192.168.1.102','2016-10-05 12:33:28','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1430','64','批量删除仓管通','192.168.1.102','2016-10-05 12:34:27','1','批量删除仓管通ID为 6,5 失败!','批量删除仓管通失败'), ('1431','64','登录系统','192.168.1.102','2016-10-05 12:36:23','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1432','64','批量删除仓管通','192.168.1.102','2016-10-05 12:37:26','0','批量删除仓管通ID为 6,5 成功!','批量删除仓管通成功'), ('1433','64','批量删除物料','192.168.1.102','2016-10-05 12:37:39','0','批量删除物料ID为 5,6,7,8,9,10,11,12,13 成功!','批量删除物料成功'), ('1434','64','增加物料','192.168.1.102','2016-10-05 12:41:40','0','增加物料名称为 飞梭 成功!','增加物料成功'), ('1435','64','增加仓管通','192.168.1.102','2016-10-05 12:45:55','0','增加仓管通编号为 30198 成功!','增加仓管通成功'), ('1436','64','保存仓管通明细','192.168.1.102','2016-10-05 12:45:55','0','保存仓管通明细对应主表编号为 7 成功!','保存仓管通明细成功'), ('1437','64','增加物料','192.168.1.102','2016-10-05 12:46:55','0','增加物料名称为 飞梭 成功!','增加物料成功'), ('1438','64','更新仓管通','192.168.1.102','2016-10-05 12:47:23','0','更新仓管通ID为 7 成功!','更新仓管通成功'), ('1439','64','保存仓管通明细','192.168.1.102','2016-10-05 12:47:23','0','保存仓管通明细对应主表编号为 7 成功!','保存仓管通明细成功'), ('1440','64','增加仓管通','192.168.1.102','2016-10-05 12:51:01','0','增加仓管通编号为 30199 成功!','增加仓管通成功'), ('1441','64','保存仓管通明细','192.168.1.102','2016-10-05 12:51:02','0','保存仓管通明细对应主表编号为 8 成功!','保存仓管通明细成功'), ('1442','64','增加仓管通','192.168.1.102','2016-10-05 12:52:10','0','增加仓管通编号为 30205 成功!','增加仓管通成功'), ('1443','64','保存仓管通明细','192.168.1.102','2016-10-05 12:52:10','0','保存仓管通明细对应主表编号为 9 成功!','保存仓管通明细成功'), ('1444','64','增加物料','192.168.1.102','2016-10-05 12:52:52','0','增加物料名称为 飞梭 成功!','增加物料成功'), ('1445','64','更新仓管通','192.168.1.102','2016-10-05 12:57:46','0','更新仓管通ID为 9 成功!','更新仓管通成功'), ('1446','64','保存仓管通明细','192.168.1.102','2016-10-05 12:57:47','0','保存仓管通明细对应主表编号为 9 成功!','保存仓管通明细成功'), ('1447','64','增加物料','192.168.1.102','2016-10-05 12:58:37','0','增加物料名称为 棉线 成功!','增加物料成功'), ('1448','64','更新仓管通','192.168.1.102','2016-10-05 12:59:56','0','更新仓管通ID为 9 成功!','更新仓管通成功'), ('1449','64','保存仓管通明细','192.168.1.102','2016-10-05 12:59:57','0','保存仓管通明细对应主表编号为 9 成功!','保存仓管通明细成功'), ('1450','64','增加物料','192.168.1.102','2016-10-05 13:02:53','0','增加物料名称为 飞梭 成功!','增加物料成功'), ('1451','64','增加仓管通','192.168.1.102','2016-10-05 13:03:18','0','增加仓管通编号为 30213 成功!','增加仓管通成功'), ('1452','64','保存仓管通明细','192.168.1.102','2016-10-05 13:03:18','0','保存仓管通明细对应主表编号为 10 成功!','保存仓管通明细成功'), ('1453','64','增加仓管通','192.168.1.102','2016-10-05 13:11:36','0','增加仓管通编号为 30229 成功!','增加仓管通成功'), ('1454','64','保存仓管通明细','192.168.1.102','2016-10-05 13:11:36','0','保存仓管通明细对应主表编号为 11 成功!','保存仓管通明细成功'), ('1455','64','更新仓管通','192.168.1.102','2016-10-05 14:19:29','0','更新仓管通ID为 9 成功!','更新仓管通成功'), ('1456','64','更新仓管通','192.168.1.102','2016-10-05 14:19:59','0','更新仓管通ID为 9 成功!','更新仓管通成功'), ('1457','64','增加仓管通','192.168.1.102','2016-10-05 14:23:56','0','增加仓管通编号为 30230 成功!','增加仓管通成功'), ('1458','64','保存仓管通明细','192.168.1.102','2016-10-05 14:23:58','0','保存仓管通明细对应主表编号为 12 成功!','保存仓管通明细成功'), ('1459','64','增加仓管通','192.168.1.102','2016-10-05 14:30:48','0','增加仓管通编号为 30228 成功!','增加仓管通成功'), ('1460','64','保存仓管通明细','192.168.1.102','2016-10-05 14:30:50','0','保存仓管通明细对应主表编号为 13 成功!','保存仓管通明细成功'), ('1461','64','增加物料','192.168.1.102','2016-10-05 14:31:53','0','增加物料名称为 棉线 成功!','增加物料成功'), ('1462','64','增加物料','192.168.1.102','2016-10-05 14:34:39','0','增加物料名称为 棉线 成功!','增加物料成功'), ('1463','64','增加物料','192.168.1.102','2016-10-05 14:35:24','0','增加物料名称为 棉线 成功!','增加物料成功'), ('1464','64','增加物料','192.168.1.102','2016-10-05 14:38:22','0','增加物料名称为 棉线 成功!','增加物料成功'), ('1465','64','增加物料','192.168.1.102','2016-10-05 14:41:03','0','增加物料名称为 棉线 成功!','增加物料成功'), ('1466','64','更新仓管通','192.168.1.102','2016-10-05 14:43:45','0','更新仓管通ID为 13 成功!','更新仓管通成功'), ('1467','64','保存仓管通明细','192.168.1.102','2016-10-05 14:43:46','0','保存仓管通明细对应主表编号为 13 成功!','保存仓管通明细成功'), ('1468','64','增加仓管通','192.168.1.102','2016-10-05 14:44:56','0','增加仓管通编号为 30227 成功!','增加仓管通成功'), ('1469','64','增加物料','192.168.1.102','2016-10-05 14:46:19','0','增加物料名称为 飞梭 成功!','增加物料成功'), ('1470','64','更新仓管通','192.168.1.102','2016-10-05 14:46:59','0','更新仓管通ID为 14 成功!','更新仓管通成功'), ('1471','64','保存仓管通明细','192.168.1.102','2016-10-05 14:46:59','0','保存仓管通明细对应主表编号为 14 成功!','保存仓管通明细成功'), ('1472','64','增加物料','192.168.1.102','2016-10-05 14:47:44','0','增加物料名称为 飞梭 成功!','增加物料成功'), ('1473','64','更新仓管通','192.168.1.102','2016-10-05 14:49:08','0','更新仓管通ID为 14 成功!','更新仓管通成功'), ('1474','64','保存仓管通明细','192.168.1.102','2016-10-05 14:49:09','0','保存仓管通明细对应主表编号为 14 成功!','保存仓管通明细成功'), ('1475','64','增加物料','192.168.1.102','2016-10-05 14:51:24','0','增加物料名称为 飞梭 成功!','增加物料成功'), ('1476','64','增加仓管通','192.168.1.102','2016-10-05 14:52:10','0','增加仓管通编号为 30257 成功!','增加仓管通成功'), ('1477','64','保存仓管通明细','192.168.1.102','2016-10-05 14:52:12','0','保存仓管通明细对应主表编号为 15 成功!','保存仓管通明细成功'), ('1478','64','增加物料','192.168.1.102','2016-10-05 14:55:48','0','增加物料名称为 飞梭 成功!','增加物料成功'), ('1479','64','增加仓管通','192.168.1.102','2016-10-05 14:56:40','0','增加仓管通编号为 30249 成功!','增加仓管通成功'), ('1480','64','保存仓管通明细','192.168.1.102','2016-10-05 14:56:42','0','保存仓管通明细对应主表编号为 16 成功!','保存仓管通明细成功'), ('1481','64','增加物料','192.168.1.102','2016-10-05 14:59:16','0','增加物料名称为 飞梭 成功!','增加物料成功'), ('1482','64','增加物料','192.168.1.102','2016-10-05 15:00:43','0','增加物料名称为 飞梭 成功!','增加物料成功'), ('1483','64','增加物料','192.168.1.102','2016-10-05 15:03:20','0','增加物料名称为 棉线 成功!','增加物料成功'), ('1484','64','增加物料','192.168.1.102','2016-10-05 15:16:06','0','增加物料名称为 棉线 成功!','增加物料成功'), ('1485','64','增加仓管通','192.168.1.102','2016-10-05 15:16:53','0','增加仓管通编号为 30258 成功!','增加仓管通成功'), ('1486','64','保存仓管通明细','192.168.1.102','2016-10-05 15:16:56','0','保存仓管通明细对应主表编号为 17 成功!','保存仓管通明细成功'), ('1487','64','增加物料','192.168.1.102','2016-10-05 15:20:21','0','增加物料名称为 棉线 成功!','增加物料成功'), ('1488','64','更新仓管通','192.168.1.102','2016-10-05 15:21:11','0','更新仓管通ID为 17 成功!','更新仓管通成功'), ('1489','64','保存仓管通明细','192.168.1.102','2016-10-05 15:21:12','0','保存仓管通明细对应主表编号为 17 成功!','保存仓管通明细成功'), ('1490','64','更新仓管通','192.168.1.102','2016-10-05 15:21:29','0','更新仓管通ID为 17 成功!','更新仓管通成功'), ('1491','64','增加物料','192.168.1.102','2016-10-05 15:25:26','0','增加物料名称为 棉线 成功!','增加物料成功'), ('1492','64','增加仓管通','192.168.1.102','2016-10-05 15:31:34','0','增加仓管通编号为 30260 成功!','增加仓管通成功'), ('1493','64','保存仓管通明细','192.168.1.102','2016-10-05 15:31:36','0','保存仓管通明细对应主表编号为 18 成功!','保存仓管通明细成功'), ('1494','64','更新仓管通','192.168.1.102','2016-10-05 15:33:08','0','更新仓管通ID为 18 成功!','更新仓管通成功'), ('1495','64','保存仓管通明细','192.168.1.102','2016-10-05 15:33:10','0','保存仓管通明细对应主表编号为 18 成功!','保存仓管通明细成功'), ('1496','64','更新仓管通','192.168.1.102','2016-10-05 15:33:58','0','更新仓管通ID为 18 成功!','更新仓管通成功'), ('1497','64','增加物料','192.168.1.102','2016-10-05 15:35:44','0','增加物料名称为 棉线 成功!','增加物料成功'), ('1498','64','增加仓管通','192.168.1.102','2016-10-05 15:37:25','0','增加仓管通编号为 30271 成功!','增加仓管通成功'), ('1499','64','保存仓管通明细','192.168.1.102','2016-10-05 15:37:26','0','保存仓管通明细对应主表编号为 19 成功!','保存仓管通明细成功'), ('1500','64','增加仓管通','192.168.1.102','2016-10-05 15:40:12','0','增加仓管通编号为 30278 成功!','增加仓管通成功'), ('1501','64','保存仓管通明细','192.168.1.102','2016-10-05 15:40:19','0','保存仓管通明细对应主表编号为 20 成功!','保存仓管通明细成功'), ('1502','64','增加物料','192.168.1.102','2016-10-05 15:42:50','0','增加物料名称为 飞梭 成功!','增加物料成功'), ('1503','64','增加仓管通','192.168.1.102','2016-10-05 15:45:27','0','增加仓管通编号为 30296 成功!','增加仓管通成功'), ('1504','64','保存仓管通明细','192.168.1.102','2016-10-05 15:45:31','0','保存仓管通明细对应主表编号为 21 成功!','保存仓管通明细成功'), ('1505','64','增加物料','192.168.1.102','2016-10-05 15:49:31','0','增加物料名称为 飞梭 成功!','增加物料成功'), ('1506','64','增加物料','192.168.1.102','2016-10-05 15:50:44','0','增加物料名称为 飞梭 成功!','增加物料成功'), ('1507','64','增加物料','192.168.1.102','2016-10-05 15:52:26','0','增加物料名称为 飞梭 成功!','增加物料成功'), ('1508','64','增加物料','192.168.1.102','2016-10-05 15:54:11','0','增加物料名称为 飞梭 成功!','增加物料成功'), ('1509','64','增加仓管通','192.168.1.102','2016-10-05 15:55:02','0','增加仓管通编号为 30295 成功!','增加仓管通成功'), ('1510','64','保存仓管通明细','192.168.1.102','2016-10-05 15:55:04','0','保存仓管通明细对应主表编号为 22 成功!','保存仓管通明细成功'), ('1511','64','增加物料','192.168.1.102','2016-10-05 15:56:15','0','增加物料名称为 飞梭 成功!','增加物料成功'), ('1512','64','增加物料','192.168.1.102','2016-10-05 15:56:50','0','增加物料名称为 飞梭 成功!','增加物料成功'), ('1513','64','增加物料','192.168.1.102','2016-10-05 15:58:36','0','增加物料名称为 飞梭 成功!','增加物料成功'), ('1514','64','增加物料','192.168.1.102','2016-10-05 16:01:43','0','增加物料名称为 棉线 成功!','增加物料成功'), ('1515','64','增加物料','192.168.1.102','2016-10-05 16:05:22','0','增加物料名称为 飞梭 成功!','增加物料成功'); INSERT INTO `jsh_log` VALUES ('1516','64','增加仓管通','192.168.1.102','2016-10-05 16:06:32','0','增加仓管通编号为 30305 成功!','增加仓管通成功'), ('1517','64','保存仓管通明细','192.168.1.102','2016-10-05 16:06:33','0','保存仓管通明细对应主表编号为 23 成功!','保存仓管通明细成功'), ('1518','64','增加物料','192.168.1.102','2016-10-05 16:08:24','0','增加物料名称为 飞梭 成功!','增加物料成功'), ('1519','64','增加仓管通','192.168.1.102','2016-10-05 16:10:53','0','增加仓管通编号为 30309 成功!','增加仓管通成功'), ('1520','64','保存仓管通明细','192.168.1.102','2016-10-05 16:10:57','0','保存仓管通明细对应主表编号为 24 成功!','保存仓管通明细成功'), ('1521','64','增加仓管通','192.168.1.102','2016-10-05 16:13:45','0','增加仓管通编号为 30315 成功!','增加仓管通成功'), ('1522','64','保存仓管通明细','192.168.1.102','2016-10-05 16:13:49','0','保存仓管通明细对应主表编号为 25 成功!','保存仓管通明细成功'), ('1523','64','更新仓管通','192.168.1.102','2016-10-05 16:17:22','0','更新仓管通ID为 25 成功!','更新仓管通成功'), ('1524','64','保存仓管通明细','192.168.1.102','2016-10-05 16:17:23','0','保存仓管通明细对应主表编号为 25 成功!','保存仓管通明细成功'), ('1525','64','增加仓管通','192.168.1.102','2016-10-05 16:18:16','0','增加仓管通编号为 30316 成功!','增加仓管通成功'), ('1526','64','更新仓管通','192.168.1.102','2016-10-05 16:18:46','0','更新仓管通ID为 26 成功!','更新仓管通成功'), ('1527','64','登录系统','192.168.1.106','2016-10-05 17:01:51','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1528','64','登录系统','192.168.1.107','2016-10-06 08:24:57','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1529','64','登录系统','127.0.0.1','2016-10-06 10:43:18','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1530','64','登录系统','127.0.0.1','2016-10-06 15:04:09','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1531','64','登录系统','127.0.0.1','2016-10-06 15:30:25','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1532','64','登录系统','192.168.1.107','2016-10-06 20:13:50','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1533','64','增加仓管通','192.168.1.107','2016-10-06 21:37:26','0','增加仓管通编号为 1001 成功!','增加仓管通成功'), ('1534','64','保存仓管通明细','192.168.1.107','2016-10-06 21:37:27','0','保存仓管通明细对应主表编号为 27 成功!','保存仓管通明细成功'), ('1535','64','登录系统','192.168.1.107','2016-10-06 22:14:09','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1536','64','增加仓管通','192.168.1.107','2016-10-07 00:25:54','0','增加仓管通编号为 123123 成功!','增加仓管通成功'), ('1537','64','保存仓管通明细','192.168.1.107','2016-10-07 00:25:54','0','保存仓管通明细对应主表编号为 28 成功!','保存仓管通明细成功'), ('1538','64','更新仓管通','192.168.1.107','2016-10-07 00:27:33','0','更新仓管通ID为 28 成功!','更新仓管通成功'), ('1539','64','保存仓管通明细','192.168.1.107','2016-10-07 00:27:33','0','保存仓管通明细对应主表编号为 28 成功!','保存仓管通明细成功'), ('1540','64','登录系统','192.168.1.107','2016-10-07 07:11:42','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1541','64','更新仓管通','192.168.1.107','2016-10-07 07:12:52','0','更新仓管通ID为 27 成功!','更新仓管通成功'), ('1542','64','保存仓管通明细','192.168.1.107','2016-10-07 07:12:52','0','保存仓管通明细对应主表编号为 27 成功!','保存仓管通明细成功'), ('1543','64','更新仓管通','192.168.1.107','2016-10-07 07:16:15','0','更新仓管通ID为 28 成功!','更新仓管通成功'), ('1544','64','保存仓管通明细','192.168.1.107','2016-10-07 07:16:15','0','保存仓管通明细对应主表编号为 28 成功!','保存仓管通明细成功'), ('1545','64','登录系统','192.168.1.107','2016-10-07 08:42:16','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1546','64','更新仓管通','192.168.1.107','2016-10-07 09:11:13','0','更新仓管通ID为 28 成功!','更新仓管通成功'), ('1547','64','保存仓管通明细','192.168.1.107','2016-10-07 09:11:14','0','保存仓管通明细对应主表编号为 28 成功!','保存仓管通明细成功'), ('1548','64','退出系统','192.168.1.107','2016-10-07 09:12:07','0','管理用户:cyl 退出系统','cyl 退出系统'), ('1549','63','登录系统','192.168.1.107','2016-10-07 09:12:12','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1550','63','更新UserBusiness','192.168.1.107','2016-10-07 09:12:49','0','更新UserBusiness的ID为 6 成功!','更新UserBusiness成功'), ('1551','63','退出系统','192.168.1.107','2016-10-07 09:12:53','0','管理用户:jsh 退出系统','jsh 退出系统'), ('1552','64','登录系统','192.168.1.107','2016-10-07 09:12:59','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1553','64','退出系统','192.168.1.107','2016-10-07 09:13:15','0','管理用户:cyl 退出系统','cyl 退出系统'), ('1554','63','登录系统','192.168.1.107','2016-10-07 09:13:20','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1555','63','更新UserBusiness','192.168.1.107','2016-10-07 09:14:08','0','更新UserBusiness的ID为 6 成功!','更新UserBusiness成功'), ('1556','63','退出系统','192.168.1.107','2016-10-07 09:14:13','0','管理用户:jsh 退出系统','jsh 退出系统'), ('1557','64','登录系统','192.168.1.107','2016-10-07 09:14:18','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1558','64','退出系统','192.168.1.107','2016-10-07 09:14:55','0','管理用户:cyl 退出系统','cyl 退出系统'), ('1559','63','登录系统','192.168.1.107','2016-10-07 09:14:59','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1560','63','更新UserBusiness','192.168.1.107','2016-10-07 09:15:52','0','更新UserBusiness的ID为 6 成功!','更新UserBusiness成功'), ('1561','63','退出系统','192.168.1.107','2016-10-07 09:15:56','0','管理用户:jsh 退出系统','jsh 退出系统'), ('1562','64','登录系统','192.168.1.107','2016-10-07 09:16:02','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1563','63','登录系统','192.168.8.105','2016-10-08 17:58:33','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1564','64','登录系统','192.168.8.105','2016-10-08 18:03:13','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1565','64','登录系统','192.168.112.100','2016-10-08 21:25:05','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1566','64','登录系统','192.168.1.107','2016-10-15 16:33:07','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1567','64','退出系统','192.168.1.107','2016-10-15 16:38:03','0','管理用户:cyl 退出系统','cyl 退出系统'), ('1568','63','登录系统','192.168.1.107','2016-10-15 16:38:10','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1569','64','登录系统','192.168.1.105','2016-10-16 09:30:46','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1570','64','登录系统','192.168.1.105','2016-10-16 09:35:30','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1571','64','更新仓管通','192.168.1.105','2016-10-16 11:31:53','0','更新仓管通ID为 28 成功!','更新仓管通成功'), ('1572','64','保存仓管通明细','192.168.1.105','2016-10-16 11:31:53','0','保存仓管通明细对应主表编号为 28 成功!','保存仓管通明细成功'), ('1573','64','登录系统','192.168.112.102','2016-10-16 20:13:38','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1574','64','登录系统','192.168.112.102','2016-10-22 16:11:53','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1575','64','登录系统','192.168.112.102','2016-10-22 16:42:20','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1576','64','更新仓管通','192.168.112.102','2016-10-22 17:53:43','0','更新仓管通ID为 28 成功!','更新仓管通成功'), ('1577','64','保存仓管通明细','192.168.112.102','2016-10-22 17:53:43','0','保存仓管通明细对应主表编号为 28 成功!','保存仓管通明细成功'), ('1578','64','登录系统','192.168.112.102','2016-10-22 19:58:45','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1579','64','退出系统','192.168.112.102','2016-10-22 19:59:50','0','管理用户:cyl 退出系统','cyl 退出系统'), ('1580','63','登录系统','192.168.112.102','2016-10-22 19:59:53','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1581','63','增加资产','192.168.112.102','2016-10-22 20:04:48','0','增加资产名称ID为 27 成功!','增加资产成功'), ('1582','63','登录系统','192.168.112.102','2016-10-22 21:14:52','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1583','64','登录系统','192.168.112.102','2016-10-23 20:12:34','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1584','64','登录系统','192.168.112.102','2016-10-23 20:58:11','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1585','64','登录系统','192.168.4.108','2016-10-30 17:29:19','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1586','64','登录系统','192.168.112.102','2016-10-30 20:18:07','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1587','64','登录系统','192.168.1.104','2016-11-06 09:10:05','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1588','64','登录系统','192.168.1.104','2016-11-06 13:44:03','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1589','64','退出系统','192.168.1.104','2016-11-06 13:45:02','0','管理用户:cyl 退出系统','cyl 退出系统'), ('1590','64','登录系统','192.168.1.104','2016-11-06 13:46:31','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1591','64','登录系统','192.168.112.100','2016-11-06 21:26:43','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1592','64','退出系统','192.168.112.100','2016-11-06 21:27:01','0','管理用户:cyl 退出系统','cyl 退出系统'), ('1593','64','登录系统','192.168.112.100','2016-11-06 23:15:25','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1594','64','登录系统','127.0.0.1','2016-11-07 09:04:00','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1595','64','登录系统','127.0.0.1','2016-11-07 09:04:40','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1596','64','退出系统','127.0.0.1','2016-11-07 09:06:49','0','管理用户:cyl 退出系统','cyl 退出系统'), ('1597','64','登录系统','192.168.4.108','2016-11-08 22:01:22','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1598','64','退出系统','192.168.4.108','2016-11-08 22:02:18','0','管理用户:cyl 退出系统','cyl 退出系统'), ('1599','63','登录系统','192.168.4.108','2016-11-08 22:02:29','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1600','63','退出系统','192.168.4.108','2016-11-08 22:04:34','0','管理用户:jsh 退出系统','jsh 退出系统'), ('1601','64','登录系统','192.168.4.108','2016-11-08 22:04:43','0','管理用户:cyl 登录系统','cyl 登录系统'), ('1602','64','批量删除仓管通','192.168.4.108','2016-11-08 22:05:58','0','批量删除仓管通ID为 27,26,25,24,23,22,21,20,19,18,17,16,15,14,13 成功!','批量删除仓管通成功'), ('1603','64','批量删除仓管通','192.168.4.108','2016-11-08 22:06:09','0','批量删除仓管通ID为 12,11,10,9,8,7 成功!','批量删除仓管通成功'), ('1604','64','批量删除仓管通','192.168.4.108','2016-11-08 22:06:24','0','批量删除仓管通ID为 28 成功!','批量删除仓管通成功'), ('1605','64','更新经手人','192.168.4.108','2016-11-08 22:07:08','0','更新经手人ID为 1 成功!','更新经手人成功'), ('1606','64','更新经手人','192.168.4.108','2016-11-08 22:07:14','0','更新经手人ID为 2 成功!','更新经手人成功'), ('1607','64','更新供应商','192.168.4.108','2016-11-08 22:07:58','0','更新供应商ID为 1 成功!','更新供应商成功'), ('1608','64','批量删除物料','192.168.4.108','2016-11-08 22:08:26','0','批量删除物料ID为 15,16,17,18,19,20,21,22,23,24,25,26,27,28,29 成功!','批量删除物料成功'), ('1609','64','批量删除物料','192.168.4.108','2016-11-08 22:08:36','0','批量删除物料ID为 30,31,32,33,34,35,36,37,38,39,40,41,42,43,44 成功!','批量删除物料成功'), ('1610','64','批量删除物料','192.168.4.108','2016-11-08 22:08:40','0','批量删除物料ID为 45,46,47,48,49,50,51,52,53,54,55,56,57,58,59 成功!','批量删除物料成功'), ('1611','64','批量删除物料','192.168.4.108','2016-11-08 22:08:48','0','批量删除物料ID为 60,61,62,63,64,65,66,67,68,69,70,71,72,73,74 成功!','批量删除物料成功'), ('1612','64','批量删除物料','192.168.4.108','2016-11-08 22:08:53','0','批量删除物料ID为 75,76,77,78,79,80,81,82,83,84,85,86,87,88,89 成功!','批量删除物料成功'), ('1613','64','批量删除物料','192.168.4.108','2016-11-08 22:09:03','0','批量删除物料ID为 90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139 成功!','批量删除物料成功'), ('1614','64','批量删除物料','192.168.4.108','2016-11-08 22:09:09','0','批量删除物料ID为 140,141,142,143,144,145,146,147,148,149,150,151,152,153,154 成功!','批量删除物料成功'), ('1615','64','批量删除物料','192.168.4.108','2016-11-08 22:09:14','0','批量删除物料ID为 155,156,157,158,159,160,161,162,163,164,165,166,167,168,169 成功!','批量删除物料成功'); -INSERT INTO `jsh_log` VALUES ('1616','64','批量删除物料','192.168.4.108','2016-11-08 22:09:31','0','批量删除物料ID为 170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219 成功!','批量删除物料成功'), ('1617','64','批量删除物料','192.168.4.108','2016-11-08 22:09:39','0','批量删除物料ID为 220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269 成功!','批量删除物料成功'), ('1618','64','批量删除物料','192.168.4.108','2016-11-08 22:09:48','0','批量删除物料ID为 270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319 成功!','批量删除物料成功'), ('1619','64','批量删除物料','192.168.4.108','2016-11-08 22:09:56','0','批量删除物料ID为 320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369 成功!','批量删除物料成功'), ('1620','64','批量删除物料','192.168.4.108','2016-11-08 22:10:08','0','批量删除物料ID为 370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419 成功!','批量删除物料成功'), ('1621','64','批量删除物料','192.168.4.108','2016-11-08 22:10:17','0','批量删除物料ID为 420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469 成功!','批量删除物料成功'), ('1622','64','批量删除物料','192.168.4.108','2016-11-08 22:10:37','0','批量删除物料ID为 470,471,472,473,474,475,476,477,478,479,480,481,482,483,484 成功!','批量删除物料成功'), ('1623','64','批量删除物料','192.168.4.108','2016-11-08 22:10:48','0','批量删除物料ID为 486 成功!','批量删除物料成功'), ('1624','64','批量删除物料','192.168.4.108','2016-11-08 22:11:10','0','批量删除物料ID为 488,489,490,491,492,493,494,495,496,497 成功!','批量删除物料成功'), ('1625','64','更新物料','192.168.4.108','2016-11-08 22:11:33','0','更新物料ID为 487 成功!','更新物料成功'), ('1626','64','更新物料','192.168.4.108','2016-11-08 22:11:46','0','更新物料ID为 485 成功!','更新物料成功'), ('1627','64','增加物料','192.168.4.108','2016-11-08 22:12:18','0','增加物料名称为 蕾丝 成功!','增加物料成功'), ('1628','64','更新供应商','192.168.4.108','2016-11-08 22:12:41','0','更新供应商ID为 1 成功!','更新供应商成功'), ('1629','64','更新仓库','192.168.4.108','2016-11-08 22:13:06','0','更新仓库ID为 1 成功!','更新仓库成功'), ('1630','64','增加仓管通','192.168.4.108','2016-11-08 22:14:37','0','增加仓管通编号为 1234 成功!','增加仓管通成功'), ('1631','64','保存仓管通明细','192.168.4.108','2016-11-08 22:14:38','0','保存仓管通明细对应主表编号为 29 成功!','保存仓管通明细成功'), ('1632','64','增加仓管通','192.168.4.108','2016-11-08 22:15:16','0','增加仓管通编号为 1235 成功!','增加仓管通成功'), ('1633','64','保存仓管通明细','192.168.4.108','2016-11-08 22:15:17','0','保存仓管通明细对应主表编号为 30 成功!','保存仓管通明细成功'), ('1634','64','增加仓管通','192.168.4.108','2016-11-08 22:16:11','0','增加仓管通编号为 123A 成功!','增加仓管通成功'), ('1635','64','保存仓管通明细','192.168.4.108','2016-11-08 22:16:11','0','保存仓管通明细对应主表编号为 31 成功!','保存仓管通明细成功'), ('1636','64','退出系统','192.168.4.108','2016-11-08 22:16:39','0','管理用户:cyl 退出系统','cyl 退出系统'), ('1637','63','登录系统','192.168.4.108','2016-11-08 22:16:42','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1638','63','登录系统','192.168.4.108','2016-11-08 22:17:05','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1639','63','更新用户','192.168.4.108','2016-11-08 22:17:34','0','更新用户ID为 64 成功!','更新用户成功'), ('1640','63','更新用户','192.168.4.108','2016-11-08 22:17:48','0','更新用户ID为 65 成功!','更新用户成功'), ('1641','63','退出系统','192.168.4.108','2016-11-08 22:18:07','0','管理用户:jsh 退出系统','jsh 退出系统'), ('1642','65','登录系统','192.168.4.108','2016-11-08 22:18:16','0','管理用户:ls 登录系统','ls 登录系统'), ('1643','65','退出系统','192.168.4.108','2016-11-08 22:18:22','0','管理用户:ls 退出系统','ls 退出系统'), ('1644','65','登录系统','192.168.4.108','2016-11-08 22:18:39','0','管理用户:ls 登录系统','ls 登录系统'), ('1645','65','更新仓管通','192.168.4.108','2016-11-08 22:18:50','0','更新仓管通ID为 30 成功!','更新仓管通成功'), ('1646','65','更新仓管通','192.168.4.108','2016-11-08 22:18:53','0','更新仓管通ID为 29 成功!','更新仓管通成功'), ('1647','65','更新仓管通','192.168.4.108','2016-11-08 22:19:03','0','更新仓管通ID为 31 成功!','更新仓管通成功'), ('1648','65','退出系统','192.168.4.108','2016-11-08 22:20:46','0','管理用户:ls 退出系统','ls 退出系统'), ('1649','63','登录系统','192.168.4.108','2016-11-08 22:20:57','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1650','63','登录系统','192.168.4.108','2016-11-08 22:29:58','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1651','63','退出系统','192.168.4.108','2016-11-08 22:30:22','0','管理用户:jsh 退出系统','jsh 退出系统'), ('1652','65','登录系统','192.168.4.108','2016-11-08 22:30:26','0','管理用户:ls 登录系统','ls 登录系统'), ('1653','63','登录系统','127.0.0.1','2016-11-10 09:15:50','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1654','65','登录系统','192.168.1.105','2016-11-13 12:21:50','0','管理用户:ls 登录系统','ls 登录系统'), ('1655','65','登录系统','192.168.1.105','2016-11-13 12:41:50','0','管理用户:ls 登录系统','ls 登录系统'), ('1656','65','登录系统','192.168.1.105','2016-11-13 12:41:51','0','管理用户:ls 登录系统','ls 登录系统'), ('1657','65','登录系统','192.168.1.105','2016-11-13 13:09:10','0','管理用户:ls 登录系统','ls 登录系统'), ('1658','65','退出系统','192.168.1.105','2016-11-13 13:09:16','0','管理用户:ls 退出系统','ls 退出系统'), ('1659','65','登录系统','192.168.1.105','2016-11-13 13:09:21','0','管理用户:ls 登录系统','ls 登录系统'), ('1660','65','登录系统','192.168.1.105','2016-11-13 13:31:39','0','管理用户:ls 登录系统','ls 登录系统'), ('1661','65','退出系统','192.168.1.105','2016-11-13 13:32:20','0','管理用户:ls 退出系统','ls 退出系统'), ('1662','65','登录系统','192.168.1.105','2016-11-13 13:32:25','0','管理用户:ls 登录系统','ls 登录系统'), ('1663','65','登录系统','192.168.1.105','2016-11-13 13:35:12','0','管理用户:ls 登录系统','ls 登录系统'); +INSERT INTO `jsh_log` VALUES ('1616','64','批量删除物料','192.168.4.108','2016-11-08 22:09:31','0','批量删除物料ID为 170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219 成功!','批量删除物料成功'), ('1617','64','批量删除物料','192.168.4.108','2016-11-08 22:09:39','0','批量删除物料ID为 220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269 成功!','批量删除物料成功'), ('1618','64','批量删除物料','192.168.4.108','2016-11-08 22:09:48','0','批量删除物料ID为 270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319 成功!','批量删除物料成功'), ('1619','64','批量删除物料','192.168.4.108','2016-11-08 22:09:56','0','批量删除物料ID为 320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369 成功!','批量删除物料成功'), ('1620','64','批量删除物料','192.168.4.108','2016-11-08 22:10:08','0','批量删除物料ID为 370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419 成功!','批量删除物料成功'), ('1621','64','批量删除物料','192.168.4.108','2016-11-08 22:10:17','0','批量删除物料ID为 420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469 成功!','批量删除物料成功'), ('1622','64','批量删除物料','192.168.4.108','2016-11-08 22:10:37','0','批量删除物料ID为 470,471,472,473,474,475,476,477,478,479,480,481,482,483,484 成功!','批量删除物料成功'), ('1623','64','批量删除物料','192.168.4.108','2016-11-08 22:10:48','0','批量删除物料ID为 486 成功!','批量删除物料成功'), ('1624','64','批量删除物料','192.168.4.108','2016-11-08 22:11:10','0','批量删除物料ID为 488,489,490,491,492,493,494,495,496,497 成功!','批量删除物料成功'), ('1625','64','更新物料','192.168.4.108','2016-11-08 22:11:33','0','更新物料ID为 487 成功!','更新物料成功'), ('1626','64','更新物料','192.168.4.108','2016-11-08 22:11:46','0','更新物料ID为 485 成功!','更新物料成功'), ('1627','64','增加物料','192.168.4.108','2016-11-08 22:12:18','0','增加物料名称为 蕾丝 成功!','增加物料成功'), ('1628','64','更新供应商','192.168.4.108','2016-11-08 22:12:41','0','更新供应商ID为 1 成功!','更新供应商成功'), ('1629','64','更新仓库','192.168.4.108','2016-11-08 22:13:06','0','更新仓库ID为 1 成功!','更新仓库成功'), ('1630','64','增加仓管通','192.168.4.108','2016-11-08 22:14:37','0','增加仓管通编号为 1234 成功!','增加仓管通成功'), ('1631','64','保存仓管通明细','192.168.4.108','2016-11-08 22:14:38','0','保存仓管通明细对应主表编号为 29 成功!','保存仓管通明细成功'), ('1632','64','增加仓管通','192.168.4.108','2016-11-08 22:15:16','0','增加仓管通编号为 1235 成功!','增加仓管通成功'), ('1633','64','保存仓管通明细','192.168.4.108','2016-11-08 22:15:17','0','保存仓管通明细对应主表编号为 30 成功!','保存仓管通明细成功'), ('1634','64','增加仓管通','192.168.4.108','2016-11-08 22:16:11','0','增加仓管通编号为 123A 成功!','增加仓管通成功'), ('1635','64','保存仓管通明细','192.168.4.108','2016-11-08 22:16:11','0','保存仓管通明细对应主表编号为 31 成功!','保存仓管通明细成功'), ('1636','64','退出系统','192.168.4.108','2016-11-08 22:16:39','0','管理用户:cyl 退出系统','cyl 退出系统'), ('1637','63','登录系统','192.168.4.108','2016-11-08 22:16:42','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1638','63','登录系统','192.168.4.108','2016-11-08 22:17:05','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1639','63','更新用户','192.168.4.108','2016-11-08 22:17:34','0','更新用户ID为 64 成功!','更新用户成功'), ('1640','63','更新用户','192.168.4.108','2016-11-08 22:17:48','0','更新用户ID为 65 成功!','更新用户成功'), ('1641','63','退出系统','192.168.4.108','2016-11-08 22:18:07','0','管理用户:jsh 退出系统','jsh 退出系统'), ('1642','65','登录系统','192.168.4.108','2016-11-08 22:18:16','0','管理用户:ls 登录系统','ls 登录系统'), ('1643','65','退出系统','192.168.4.108','2016-11-08 22:18:22','0','管理用户:ls 退出系统','ls 退出系统'), ('1644','65','登录系统','192.168.4.108','2016-11-08 22:18:39','0','管理用户:ls 登录系统','ls 登录系统'), ('1645','65','更新仓管通','192.168.4.108','2016-11-08 22:18:50','0','更新仓管通ID为 30 成功!','更新仓管通成功'), ('1646','65','更新仓管通','192.168.4.108','2016-11-08 22:18:53','0','更新仓管通ID为 29 成功!','更新仓管通成功'), ('1647','65','更新仓管通','192.168.4.108','2016-11-08 22:19:03','0','更新仓管通ID为 31 成功!','更新仓管通成功'), ('1648','65','退出系统','192.168.4.108','2016-11-08 22:20:46','0','管理用户:ls 退出系统','ls 退出系统'), ('1649','63','登录系统','192.168.4.108','2016-11-08 22:20:57','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1650','63','登录系统','192.168.4.108','2016-11-08 22:29:58','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1651','63','退出系统','192.168.4.108','2016-11-08 22:30:22','0','管理用户:jsh 退出系统','jsh 退出系统'), ('1652','65','登录系统','192.168.4.108','2016-11-08 22:30:26','0','管理用户:ls 登录系统','ls 登录系统'), ('1653','63','登录系统','127.0.0.1','2016-11-10 09:15:50','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1654','65','登录系统','192.168.1.105','2016-11-13 12:21:50','0','管理用户:ls 登录系统','ls 登录系统'), ('1655','65','登录系统','192.168.1.105','2016-11-13 12:41:50','0','管理用户:ls 登录系统','ls 登录系统'), ('1656','65','登录系统','192.168.1.105','2016-11-13 12:41:51','0','管理用户:ls 登录系统','ls 登录系统'), ('1657','65','登录系统','192.168.1.105','2016-11-13 13:09:10','0','管理用户:ls 登录系统','ls 登录系统'), ('1658','65','退出系统','192.168.1.105','2016-11-13 13:09:16','0','管理用户:ls 退出系统','ls 退出系统'), ('1659','65','登录系统','192.168.1.105','2016-11-13 13:09:21','0','管理用户:ls 登录系统','ls 登录系统'), ('1660','65','登录系统','192.168.1.105','2016-11-13 13:31:39','0','管理用户:ls 登录系统','ls 登录系统'), ('1661','65','退出系统','192.168.1.105','2016-11-13 13:32:20','0','管理用户:ls 退出系统','ls 退出系统'), ('1662','65','登录系统','192.168.1.105','2016-11-13 13:32:25','0','管理用户:ls 登录系统','ls 登录系统'), ('1663','65','登录系统','192.168.1.105','2016-11-13 13:35:12','0','管理用户:ls 登录系统','ls 登录系统'), ('1664','65','登录系统','192.168.112.102','2016-11-13 22:49:05','0','管理用户:ls 登录系统','ls 登录系统'), ('1665','65','登录系统','192.168.112.102','2016-11-13 23:06:49','0','管理用户:ls 登录系统','ls 登录系统'), ('1666','65','登录系统','192.168.1.104','2016-11-20 13:16:01','0','管理用户:ls 登录系统','ls 登录系统'), ('1667','65','退出系统','192.168.1.104','2016-11-20 13:21:10','0','管理用户:ls 退出系统','ls 退出系统'), ('1668','65','登录系统','192.168.1.104','2016-11-20 13:21:19','0','管理用户:ls 登录系统','ls 登录系统'), ('1669','65','退出系统','192.168.1.104','2016-11-20 13:21:28','0','管理用户:ls 退出系统','ls 退出系统'), ('1670','63','登录系统','192.168.1.104','2016-11-20 13:21:37','0','管理用户:jsh 登录系统','jsh 登录系统'), ('1671','63','增加用户','192.168.1.104','2016-11-20 13:22:07','0','增加用户名称为 cdy 成功!','增加用户成功'), ('1672','63','批量删除用户','192.168.1.104','2016-11-20 13:24:19','0','批量删除用户ID为 66 成功!','批量删除用户成功'), ('1673','63','增加用户','192.168.1.104','2016-11-20 13:24:41','0','增加用户名称为 啊啊啊啊 成功!','增加用户成功'); INSERT INTO `jsh_material` VALUES ('485','1','棉线','A21-4321','米色','码',''), ('487','1','网布','12343','红色','码',''), ('498','2','蕾丝','B123','蓝色','码',''); INSERT INTO `jsh_materialcategory` VALUES ('1','根目录','1','1'), ('2','花边分类','1','1'); INSERT INTO `jsh_person` VALUES ('1','1','仓管员','张三'), ('2','1','采购人','李四'); INSERT INTO `jsh_role` VALUES ('4','管理员'), ('5','仓管员'); INSERT INTO `jsh_supplier` VALUES ('1','上海某某花边工厂','','','','','1','供应商','\0'), ('2','客户AAAA','','','','','1','客户','\0'); -INSERT INTO `jsh_user` VALUES ('63','季圣华','jsh','4QrcOUm6Wau+VuBX8g+IPg==','','','','','1','1','-1','',NULL), ('64','张三','zs','4QrcOUm6Wau+VuBX8g+IPg==','','销售','','','1','1',NULL,'',NULL), ('65','李四','ls','4QrcOUm6Wau+VuBX8g+IPg==','','销售','','','1','1',NULL,'',NULL); +INSERT INTO `jsh_user` VALUES ('63','季圣华','jsh','e10adc3949ba59abbe56e057f20f883e','','','','','1','1','-1','',NULL), ('64','张三','zs','e10adc3949ba59abbe56e057f20f883e','','销售','','','1','1',NULL,'',NULL), ('65','李四','ls','e10adc3949ba59abbe56e057f20f883e','','销售','','','1','1',NULL,'',NULL); INSERT INTO `jsh_userbusiness` VALUES ('1','RoleAPP','4','[21][1][8][11][10][19][16][15][12][7][17][20][18][3][6][22][23][24][25]'), ('2','RoleAPP','5','[8][7][3][6]'), ('3','RoleAPP','6','[21][1][8]'), ('4','RoleAPP','7','[21][1][8][11]'), ('5','RoleFunctions','4','[168][13][12][16][14][15][189][18][19][132][22][23][25][26][27][31][33][34][35][36][37][39][40][41][42][43][46][47][48][49][50][51][193][52][53][54][55][56][57][192][59][60][61][62][63][65][66][68][69][70][71][73][74][76][77][79][191][81][82][83][85][89][161][86][176][165][160][28][134][91][92][29][94][95][97][104][99][100][101][102][105][107][108][110][111][113][114][116][117][118][120][121][131][135][123][122][20][130][146][147][138][148][149][153][140][145][184][152][143][170][171][169][166][167][163][164][172][173][179][178][181][182][183][186][187][188]'), ('6','RoleFunctions','5','[22][23][25][26][27][31][33][41][46][193][52][55][59]'), ('7','RoleFunctions','6','[168][13][12][16][14][15][189][18][19]'), ('8','RoleAPP','8','[21][1][8][11][10]'), ('9','RoleFunctions','7','[168][13][12][16][14][15][189][18][19][132]'), ('10','RoleFunctions','8','[168][13][12][16][14][15][189][18][19][132][22][23][25][26][27][157][158][155][156][125][31][127][126][128][33][34][35][36][37][39][40][41][42][43][46][47][48][49][50][51][52][53][54][55][56][57][192][59][60][61][62][63][65][66][68][69][70][71][73][74][76][77][79][191][81][82][83][85][89][161][86][176][165][160][28][134][91][92][29][94][95][97][104][99][100][101][102][105][107][108][110][111][113][114][116][117][118][120][121][131][135][123][122][20][130][146][147][138][148][149][153][140][145][184][152][143][170][171][169][166][167][163][164][172][173][179][178][181][182][183][186][187]'), ('11','RoleFunctions','9','[168][13][12][16][14][15][189][18][19][132][22][23][25][26][27][157][158][155][156][125][31][127][126][128][33][34][35][36][37][39][40][41][42][43][46][47][48][49][50][51][52][53][54][55][56][57][192][59][60][61][62][63][65][66][68][69][70][71][73][74][76][77][79][191][81][82][83][85][89][161][86][176][165][160][28][134][91][92][29][94][95][97][104][99][100][101][102][105][107][108][110][111][113][114][116][117][118][120][121][131][135][123][122][20][130][146][147][138][148][149][153][140][145][184][152][143][170][171][169][166][167][163][164][172][173][179][178][181][182][183][186][187][188]'), ('12','UserRole','1','[5]'), ('13','UserRole','2','[6][7]'), ('14','UserDepot','2','[1][2][6][7]'), ('15','UserDepot','1','[1][2][5][6][7][10][12][14][15][17]'), ('16','UserRole','63','[4]'), ('17','RoleFunctions','13','[46][47][48][49]'), ('18','UserDepot','63','[1][6][45][46][50][51]'), ('19','UserDepot','5','[6][45][46][50]'), ('20','UserRole','5','[5]'), ('21','UserRole','64','[5]'), ('22','UserDepot','64','[1]'), ('23','UserRole','65','[5]'), ('24','UserDepot','65','[1]'); diff --git a/src/com/jsh/action/asset/AssetAction.java b/src/com/jsh/action/asset/AssetAction.java index 87b0708c..5170c216 100644 --- a/src/com/jsh/action/asset/AssetAction.java +++ b/src/com/jsh/action/asset/AssetAction.java @@ -1,517 +1,517 @@ -package com.jsh.action.asset; - -import java.io.IOException; -import java.io.InputStream; -import java.sql.Timestamp; -import java.text.ParseException; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - -import org.springframework.dao.DataAccessException; - -import com.jsh.base.BaseAction; -import com.jsh.base.Log; -import com.jsh.constants.asset.AssetConstants; -import com.jsh.exception.AmsException; -import com.jsh.model.po.Asset; -import com.jsh.model.po.Assetname; -import com.jsh.model.po.Basicuser; -import com.jsh.model.po.Logdetails; -import com.jsh.model.po.Supplier; -import com.jsh.model.vo.asset.AssetModel; -import com.jsh.service.asset.AssetIService; -import com.jsh.service.basic.AssetNameIService; -import com.jsh.service.basic.CategoryIService; -import com.jsh.service.basic.SupplierIService; -import com.jsh.service.basic.UserIService; -import com.jsh.util.common.PageUtil; -import com.jsh.util.common.Tools; - -@SuppressWarnings("serial") -public class AssetAction extends BaseAction -{ - private AssetModel model = new AssetModel(); - private AssetIService assetService; - private CategoryIService categoryService; - private SupplierIService supplierService; - private UserIService userService; - private AssetNameIService assetnameService; - - @SuppressWarnings({ "rawtypes", "unchecked" }) - public String getBasicData() - { - Map mapData = model.getShowModel().getMap(); - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(0); - pageUtil.setCurPage(0); - try - { - Map condition = pageUtil.getAdvSearch(); - condition.put("id_s_order", "desc"); - categoryService.find(pageUtil); - mapData.put("categoryList", pageUtil.getPageList()); - supplierService.find(pageUtil); - mapData.put("supplierList", pageUtil.getPageList()); - - condition.put("isystem_n_eq", 1); - condition.put("id_s_order", "desc"); - userService.find(pageUtil); - mapData.put("userList", pageUtil.getPageList()); - - //清除搜索条件 防止对查询有影响 - condition.remove("isystem_n_eq"); - - assetnameService.find(pageUtil); - mapData.put("assetnameList", pageUtil.getPageList()); - } - catch (Exception e) - { - Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e); - model.getShowModel().setMsgTip("exceptoin"); - } - return SUCCESS; - } - - /** - * 增加资产 - * @return - */ - public void create() - { - Log.infoFileSync("==================开始调用增加资产方法==================="); - Boolean flag = false; - try - { - Asset asset = new Asset(); - //添加设置 - asset.setAssetname(new Assetname(model.getAssetNameID())); - - asset.setLocation(model.getLocation()); - asset.setStatus(model.getStatus()); - asset.setPrice(model.getPrice()); - - if(null != model.getUserID()) - { - asset.setUser( new Basicuser(model.getUserID())); - } - try - { - //购买日期 - asset.setPurchasedate(new Timestamp(Tools.parse(model.getPurchasedate(), "yyyy-MM-dd").getTime())); - //有效日期 - asset.setPeriodofvalidity(new Timestamp(Tools.parse(model.getPeriodofvalidity(), "yyyy-MM-dd").getTime())); - //保修日期 - asset.setWarrantydate(new Timestamp(Tools.parse(model.getWarrantydate(), "yyyy-MM-dd").getTime())); - } - catch (ParseException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>解析购买日期格式异常", e); - } - - asset.setAssetnum(model.getAssetnum()); - asset.setSerialnum(model.getSerialnum()); - asset.setLabels(model.getLabels()); - - asset.setSupplier( new Supplier(model.getSupplierID())); - asset.setDescription(model.getDescription()); - - asset.setCreatetime(new Timestamp(new Date().getTime())); - asset.setCreator(getUser()); - asset.setUpdatetime(new Timestamp(new Date().getTime())); - asset.setUpdator(getUser()); - asset.setAddMonth(Tools.getCurrentMonth()); - assetService.create(asset); - //========标识位=========== - flag = true; - //记录操作日志使用 - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加资产异常", e); - flag = false; - tipMsg = "失败"; - tipType = 1; - } - finally - { - try - { - toClient(flag.toString()); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>增加资产回写客户端结果异常", e); - } - } - - logService.create(new Logdetails(getUser(), "增加资产", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "增加资产名称ID为 "+ model.getAssetNameID() + " " + tipMsg + "!", "增加资产" + tipMsg)); - Log.infoFileSync("==================结束调用增加资产方法==================="); - } - - /** - * 删除资产 - * @return - */ - public String delete() - { - Log.infoFileSync("====================开始调用删除资产信息方法delete()================"); - try - { - assetService.delete(model.getAssetID()); - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getAssetID() + " 的资产异常", e); - tipMsg = "失败"; - tipType = 1; - } - model.getShowModel().setMsgTip(tipMsg); - logService.create(new Logdetails(getUser(), "删除资产", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "删除资产ID为 "+ model.getAssetID() + " " + tipMsg + "!", "删除资产" + tipMsg)); - Log.infoFileSync("====================结束调用删除资产信息方法delete()================"); - return SUCCESS; - } - - /** - * 更新资产 - * @return - */ - public void update() - { - Boolean flag = false; - try - { - Asset asset = assetService.get(model.getAssetID()); - - //设置要更新的熟悉值 - asset.setAssetname(new Assetname(model.getAssetNameID())); - - asset.setLocation(model.getLocation()); - asset.setStatus(model.getStatus()); - asset.setPrice(model.getPrice()); - - if(null != model.getUserID()) - asset.setUser(new Basicuser(model.getUserID())); - else - asset.setUser(null); - try - { - //购买日期 - asset.setPurchasedate(new Timestamp(Tools.parse(model.getPurchasedate(), "yyyy-MM-dd").getTime())); - //有效日期 - asset.setPeriodofvalidity(new Timestamp(Tools.parse(model.getPeriodofvalidity(), "yyyy-MM-dd").getTime())); - //保修日期 - asset.setWarrantydate(new Timestamp(Tools.parse(model.getWarrantydate(), "yyyy-MM-dd").getTime())); - } - catch (ParseException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>解析购买日期格式异常", e); - } - - asset.setAssetnum(model.getAssetnum()); - asset.setSerialnum(model.getSerialnum()); - asset.setLabels(model.getLabels()); - - asset.setSupplier(new Supplier(model.getSupplierID())); - asset.setDescription(model.getDescription()); - - asset.setUpdatetime(new Timestamp(new Date().getTime())); - asset.setUpdator(getUser()); - assetService.update(asset); - flag = true; - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>修改资产ID为 : " + model.getAssetID() + "信息失败", e); - flag = false; - tipMsg = "失败"; - tipType = 1; - } - finally - { - try - { - toClient(flag.toString()); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>修改资产回写客户端结果异常", e); - } - } - logService.create(new Logdetails(getUser(), "更新资产", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "更新资产ID为 "+ model.getAssetID() + " " + tipMsg + "!", "更新资产" + tipMsg)); - } - - /** - * 批量删除指定ID资产 - * @return - */ - public String batchDelete() - { - try - { - assetService.batchDelete(model.getAssetIDs()); - model.getShowModel().setMsgTip("成功"); - //记录操作日志使用 - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>批量删除资产ID为:" + model.getAssetIDs() + "信息异常", e); - tipMsg = "失败"; - tipType = 1; - } - - logService.create(new Logdetails(getUser(), "批量删除资产", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "批量删除资产ID为 "+ model.getAssetIDs() + " " + tipMsg + "!", "批量删除资产" + tipMsg)); - return SUCCESS; - } - - /** - * 查找资产信息 - * @return - */ - public void findBy() - { - try - { - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(model.getPageSize()); - pageUtil.setCurPage(model.getPageNo()); - pageUtil.setAdvSearch(getCondition()); - assetService.find(pageUtil); - - getSession().put("pageUtil", pageUtil); - List dataList = pageUtil.getPageList(); - - //开始拼接json数据 -// {"total":28,"rows":[ -// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"} -// ]} - JSONObject outer = new JSONObject(); - outer.put("total", pageUtil.getTotalCount()); - //存放数据json数组 - JSONArray dataArray = new JSONArray(); - if(null != dataList) - { - for(Asset asset:dataList) - { - JSONObject item = new JSONObject(); - item.put("id", asset.getId()); - //添加资产属性 - item.put("assetname", asset.getAssetname().getAssetname()); - item.put("assetnameID", asset.getAssetname().getId()); - //单价 - item.put("price", Tools.dealNullStr(asset.getPrice() + "")); - //分类 - item.put("category", asset.getAssetname().getCategory().getAssetname()); - item.put("categoryID", asset.getAssetname().getCategory().getId()); - //资产的状态:0==在库,1==在用,2==消费 - item.put("status", getStatusInfo(asset.getStatus())); - item.put("statushort", asset.getStatus()); - //在用用户名称 - item.put("username", asset.getUser()==null?"":asset.getUser().getUsername()); - item.put("userID", asset.getUser()==null?"":asset.getUser().getId()); - //位置 - item.put("location", Tools.dealNullStr(asset.getLocation())); - - //购买日期 - item.put("purchasedate", asset.getPurchasedate()==null?"":Tools.getCurrentMonth(asset.getPurchasedate())); - //有效日期 - item.put("periodofvalidity", asset.getPeriodofvalidity()==null?"":Tools.getCurrentMonth(asset.getPeriodofvalidity())); - //保修日期 - item.put("warrantydate", asset.getWarrantydate()==null?"":Tools.getCurrentMonth(asset.getWarrantydate())); - //资产编号 - item.put("assetnum", Tools.dealNullStr(asset.getAssetnum())); - //资产序列号 - item.put("serialnum", Tools.dealNullStr(asset.getSerialnum())); - //供应商 - item.put("supplier", asset.getSupplier()==null?"":asset.getSupplier().getSupplier()); - //供应商 - item.put("supplierID", asset.getSupplier()==null?"":asset.getSupplier().getId()); - //标签 - item.put("labels", Tools.dealNullStr(asset.getLabels())); - item.put("description", Tools.dealNullStr(asset.getDescription())); - item.put("op", 1); - dataArray.add(item); - } - } - outer.put("rows", dataArray); - //回写查询结果 - toClient(outer.toString()); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>查找资产信息异常", e); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>回写查询资产信息结果异常", e); - } - } - - /** - * 导出excel表格 - * @return - */ - @SuppressWarnings("unchecked") - public String exportExcel() - { - Log.infoFileSync("===================调用导出资产信息action方法exportExcel开始======================="); - try - { - PageUtil pageUtil = (PageUtil)getSession().get("pageUtil"); - - pageUtil.setPageSize(model.getPageSize()); - pageUtil.setCurPage(model.getPageNo()); - //pageUtil.setAdvSearch(getCondition()); - String isCurrentPage = model.getIsAllData(); - model.setFileName(Tools.changeUnicode(model.getFileName() + ".xls",model.getBrowserType())); - model.setExcelStream(assetService.exmportExcel(isCurrentPage,pageUtil)); - } - catch (Exception e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>调用导出资产信息action方法exportExcel异常",e); - model.getShowModel().setMsgTip("export excel exception"); - } - Log.infoFileSync("===================调用导出资产信息action方法exportExcel结束=================="); - return AssetConstants.BusinessForExcel.EXCEL; - } - - - /** - * 导入资产excel表格内容 - */ - public String importExcel() - { - //资产excel表格file - Boolean result = false; - String returnStr = ""; - try - { - InputStream in = assetService.importExcel(model.getAssetFile(), model.getIsCheck()); - - if(null != in) - { - model.setFileName(Tools.getRandomChar() + Tools.getNow2(Calendar.getInstance().getTime()) + "_wrong.xls"); - model.setExcelStream(in); - returnStr = AssetConstants.BusinessForExcel.EXCEL; - } - else - { - result = true; - try - { - toClient(result.toString()); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>回写导入资产信息结果异常", e); - } - //导入数据成功 - returnStr = SUCCESS; - } - - } - catch (AmsException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>导入excel表格信息异常", e); - } - return returnStr; - } - - /** - * 拼接搜索条件 - * @return - */ - private Map getCondition() - { - /** - * 拼接搜索条件 - */ - Map condition = new HashMap(); - condition.put("assetname.id_n_eq", model.getAssetNameID()); - condition.put("assetname.category.id_n_eq", model.getAssetCategoryID()); - condition.put("user.id_n_eq", model.getUserID()); - condition.put("status_n_eq", model.getStatus()); - condition.put("supplier.id_n_eq", model.getSupplierID()); - condition.put("createtime_s_order", "desc"); - return condition; - } - - /** - * 根据状态码转化成说明字符串 - * 资产的状态:0==在库,1==在用,2==消费 - * @param statusCode - * @return - */ - private String getStatusInfo(short statusCode) - { - String statusInfo = ""; - switch(statusCode) - { - case AssetConstants.BusinessForExcel.EXCEl_STATUS_ZAIKU: - statusInfo = "在库"; - break; - - case AssetConstants.BusinessForExcel.EXCEl_STATUS_INUSE: - statusInfo = "在用"; - break; - - case AssetConstants.BusinessForExcel.EXCEl_STATUS_CONSUME: - statusInfo = "消费"; - break; - } - return statusInfo; - } - - //=========Spring注入以及model驱动公共方法=========== - public void setAssetService(AssetIService assetService) - { - this.assetService = assetService; - } - - public void setCategoryService(CategoryIService categoryService) - { - this.categoryService = categoryService; - } - - public void setSupplierService(SupplierIService supplierService) - { - this.supplierService = supplierService; - } - - public void setUserService(UserIService userService) - { - this.userService = userService; - } - - public void setAssetnameService(AssetNameIService assetnameService) - { - this.assetnameService = assetnameService; - } - - @Override - public AssetModel getModel() - { - return model; - } -} +package com.jsh.action.asset; + +import java.io.IOException; +import java.io.InputStream; +import java.sql.Timestamp; +import java.text.ParseException; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import org.springframework.dao.DataAccessException; + +import com.jsh.base.BaseAction; +import com.jsh.base.Log; +import com.jsh.constants.asset.AssetConstants; +import com.jsh.exception.JshException; +import com.jsh.model.po.Asset; +import com.jsh.model.po.Assetname; +import com.jsh.model.po.Basicuser; +import com.jsh.model.po.Logdetails; +import com.jsh.model.po.Supplier; +import com.jsh.model.vo.asset.AssetModel; +import com.jsh.service.asset.AssetIService; +import com.jsh.service.basic.AssetNameIService; +import com.jsh.service.basic.CategoryIService; +import com.jsh.service.basic.SupplierIService; +import com.jsh.service.basic.UserIService; +import com.jsh.util.common.PageUtil; +import com.jsh.util.common.Tools; + +@SuppressWarnings("serial") +public class AssetAction extends BaseAction +{ + private AssetModel model = new AssetModel(); + private AssetIService assetService; + private CategoryIService categoryService; + private SupplierIService supplierService; + private UserIService userService; + private AssetNameIService assetnameService; + + @SuppressWarnings({ "rawtypes", "unchecked" }) + public String getBasicData() + { + Map mapData = model.getShowModel().getMap(); + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(0); + pageUtil.setCurPage(0); + try + { + Map condition = pageUtil.getAdvSearch(); + condition.put("id_s_order", "desc"); + categoryService.find(pageUtil); + mapData.put("categoryList", pageUtil.getPageList()); + supplierService.find(pageUtil); + mapData.put("supplierList", pageUtil.getPageList()); + + condition.put("isystem_n_eq", 1); + condition.put("id_s_order", "desc"); + userService.find(pageUtil); + mapData.put("userList", pageUtil.getPageList()); + + //清除搜索条件 防止对查询有影响 + condition.remove("isystem_n_eq"); + + assetnameService.find(pageUtil); + mapData.put("assetnameList", pageUtil.getPageList()); + } + catch (Exception e) + { + Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e); + model.getShowModel().setMsgTip("exceptoin"); + } + return SUCCESS; + } + + /** + * 增加资产 + * @return + */ + public void create() + { + Log.infoFileSync("==================开始调用增加资产方法==================="); + Boolean flag = false; + try + { + Asset asset = new Asset(); + //添加设置 + asset.setAssetname(new Assetname(model.getAssetNameID())); + + asset.setLocation(model.getLocation()); + asset.setStatus(model.getStatus()); + asset.setPrice(model.getPrice()); + + if(null != model.getUserID()) + { + asset.setUser( new Basicuser(model.getUserID())); + } + try + { + //购买日期 + asset.setPurchasedate(new Timestamp(Tools.parse(model.getPurchasedate(), "yyyy-MM-dd").getTime())); + //有效日期 + asset.setPeriodofvalidity(new Timestamp(Tools.parse(model.getPeriodofvalidity(), "yyyy-MM-dd").getTime())); + //保修日期 + asset.setWarrantydate(new Timestamp(Tools.parse(model.getWarrantydate(), "yyyy-MM-dd").getTime())); + } + catch (ParseException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>解析购买日期格式异常", e); + } + + asset.setAssetnum(model.getAssetnum()); + asset.setSerialnum(model.getSerialnum()); + asset.setLabels(model.getLabels()); + + asset.setSupplier( new Supplier(model.getSupplierID())); + asset.setDescription(model.getDescription()); + + asset.setCreatetime(new Timestamp(new Date().getTime())); + asset.setCreator(getUser()); + asset.setUpdatetime(new Timestamp(new Date().getTime())); + asset.setUpdator(getUser()); + asset.setAddMonth(Tools.getCurrentMonth()); + assetService.create(asset); + //========标识位=========== + flag = true; + //记录操作日志使用 + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加资产异常", e); + flag = false; + tipMsg = "失败"; + tipType = 1; + } + finally + { + try + { + toClient(flag.toString()); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>增加资产回写客户端结果异常", e); + } + } + + logService.create(new Logdetails(getUser(), "增加资产", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "增加资产名称ID为 "+ model.getAssetNameID() + " " + tipMsg + "!", "增加资产" + tipMsg)); + Log.infoFileSync("==================结束调用增加资产方法==================="); + } + + /** + * 删除资产 + * @return + */ + public String delete() + { + Log.infoFileSync("====================开始调用删除资产信息方法delete()================"); + try + { + assetService.delete(model.getAssetID()); + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getAssetID() + " 的资产异常", e); + tipMsg = "失败"; + tipType = 1; + } + model.getShowModel().setMsgTip(tipMsg); + logService.create(new Logdetails(getUser(), "删除资产", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "删除资产ID为 "+ model.getAssetID() + " " + tipMsg + "!", "删除资产" + tipMsg)); + Log.infoFileSync("====================结束调用删除资产信息方法delete()================"); + return SUCCESS; + } + + /** + * 更新资产 + * @return + */ + public void update() + { + Boolean flag = false; + try + { + Asset asset = assetService.get(model.getAssetID()); + + //设置要更新的熟悉值 + asset.setAssetname(new Assetname(model.getAssetNameID())); + + asset.setLocation(model.getLocation()); + asset.setStatus(model.getStatus()); + asset.setPrice(model.getPrice()); + + if(null != model.getUserID()) + asset.setUser(new Basicuser(model.getUserID())); + else + asset.setUser(null); + try + { + //购买日期 + asset.setPurchasedate(new Timestamp(Tools.parse(model.getPurchasedate(), "yyyy-MM-dd").getTime())); + //有效日期 + asset.setPeriodofvalidity(new Timestamp(Tools.parse(model.getPeriodofvalidity(), "yyyy-MM-dd").getTime())); + //保修日期 + asset.setWarrantydate(new Timestamp(Tools.parse(model.getWarrantydate(), "yyyy-MM-dd").getTime())); + } + catch (ParseException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>解析购买日期格式异常", e); + } + + asset.setAssetnum(model.getAssetnum()); + asset.setSerialnum(model.getSerialnum()); + asset.setLabels(model.getLabels()); + + asset.setSupplier(new Supplier(model.getSupplierID())); + asset.setDescription(model.getDescription()); + + asset.setUpdatetime(new Timestamp(new Date().getTime())); + asset.setUpdator(getUser()); + assetService.update(asset); + flag = true; + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>修改资产ID为 : " + model.getAssetID() + "信息失败", e); + flag = false; + tipMsg = "失败"; + tipType = 1; + } + finally + { + try + { + toClient(flag.toString()); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>修改资产回写客户端结果异常", e); + } + } + logService.create(new Logdetails(getUser(), "更新资产", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "更新资产ID为 "+ model.getAssetID() + " " + tipMsg + "!", "更新资产" + tipMsg)); + } + + /** + * 批量删除指定ID资产 + * @return + */ + public String batchDelete() + { + try + { + assetService.batchDelete(model.getAssetIDs()); + model.getShowModel().setMsgTip("成功"); + //记录操作日志使用 + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>批量删除资产ID为:" + model.getAssetIDs() + "信息异常", e); + tipMsg = "失败"; + tipType = 1; + } + + logService.create(new Logdetails(getUser(), "批量删除资产", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "批量删除资产ID为 "+ model.getAssetIDs() + " " + tipMsg + "!", "批量删除资产" + tipMsg)); + return SUCCESS; + } + + /** + * 查找资产信息 + * @return + */ + public void findBy() + { + try + { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(model.getPageSize()); + pageUtil.setCurPage(model.getPageNo()); + pageUtil.setAdvSearch(getCondition()); + assetService.find(pageUtil); + + getSession().put("pageUtil", pageUtil); + List dataList = pageUtil.getPageList(); + + //开始拼接json数据 +// {"total":28,"rows":[ +// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"} +// ]} + JSONObject outer = new JSONObject(); + outer.put("total", pageUtil.getTotalCount()); + //存放数据json数组 + JSONArray dataArray = new JSONArray(); + if(null != dataList) + { + for(Asset asset:dataList) + { + JSONObject item = new JSONObject(); + item.put("id", asset.getId()); + //添加资产属性 + item.put("assetname", asset.getAssetname().getAssetname()); + item.put("assetnameID", asset.getAssetname().getId()); + //单价 + item.put("price", Tools.dealNullStr(asset.getPrice() + "")); + //分类 + item.put("category", asset.getAssetname().getCategory().getAssetname()); + item.put("categoryID", asset.getAssetname().getCategory().getId()); + //资产的状态:0==在库,1==在用,2==消费 + item.put("status", getStatusInfo(asset.getStatus())); + item.put("statushort", asset.getStatus()); + //在用用户名称 + item.put("username", asset.getUser()==null?"":asset.getUser().getUsername()); + item.put("userID", asset.getUser()==null?"":asset.getUser().getId()); + //位置 + item.put("location", Tools.dealNullStr(asset.getLocation())); + + //购买日期 + item.put("purchasedate", asset.getPurchasedate()==null?"":Tools.getCurrentMonth(asset.getPurchasedate())); + //有效日期 + item.put("periodofvalidity", asset.getPeriodofvalidity()==null?"":Tools.getCurrentMonth(asset.getPeriodofvalidity())); + //保修日期 + item.put("warrantydate", asset.getWarrantydate()==null?"":Tools.getCurrentMonth(asset.getWarrantydate())); + //资产编号 + item.put("assetnum", Tools.dealNullStr(asset.getAssetnum())); + //资产序列号 + item.put("serialnum", Tools.dealNullStr(asset.getSerialnum())); + //供应商 + item.put("supplier", asset.getSupplier()==null?"":asset.getSupplier().getSupplier()); + //供应商 + item.put("supplierID", asset.getSupplier()==null?"":asset.getSupplier().getId()); + //标签 + item.put("labels", Tools.dealNullStr(asset.getLabels())); + item.put("description", Tools.dealNullStr(asset.getDescription())); + item.put("op", 1); + dataArray.add(item); + } + } + outer.put("rows", dataArray); + //回写查询结果 + toClient(outer.toString()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>查找资产信息异常", e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>回写查询资产信息结果异常", e); + } + } + + /** + * 导出excel表格 + * @return + */ + @SuppressWarnings("unchecked") + public String exportExcel() + { + Log.infoFileSync("===================调用导出资产信息action方法exportExcel开始======================="); + try + { + PageUtil pageUtil = (PageUtil)getSession().get("pageUtil"); + + pageUtil.setPageSize(model.getPageSize()); + pageUtil.setCurPage(model.getPageNo()); + //pageUtil.setAdvSearch(getCondition()); + String isCurrentPage = model.getIsAllData(); + model.setFileName(Tools.changeUnicode(model.getFileName() + ".xls",model.getBrowserType())); + model.setExcelStream(assetService.exmportExcel(isCurrentPage,pageUtil)); + } + catch (Exception e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>调用导出资产信息action方法exportExcel异常",e); + model.getShowModel().setMsgTip("export excel exception"); + } + Log.infoFileSync("===================调用导出资产信息action方法exportExcel结束=================="); + return AssetConstants.BusinessForExcel.EXCEL; + } + + + /** + * 导入资产excel表格内容 + */ + public String importExcel() + { + //资产excel表格file + Boolean result = false; + String returnStr = ""; + try + { + InputStream in = assetService.importExcel(model.getAssetFile(), model.getIsCheck()); + + if(null != in) + { + model.setFileName(Tools.getRandomChar() + Tools.getNow2(Calendar.getInstance().getTime()) + "_wrong.xls"); + model.setExcelStream(in); + returnStr = AssetConstants.BusinessForExcel.EXCEL; + } + else + { + result = true; + try + { + toClient(result.toString()); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>回写导入资产信息结果异常", e); + } + //导入数据成功 + returnStr = SUCCESS; + } + + } + catch (JshException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>导入excel表格信息异常", e); + } + return returnStr; + } + + /** + * 拼接搜索条件 + * @return + */ + private Map getCondition() + { + /** + * 拼接搜索条件 + */ + Map condition = new HashMap(); + condition.put("assetname.id_n_eq", model.getAssetNameID()); + condition.put("assetname.category.id_n_eq", model.getAssetCategoryID()); + condition.put("user.id_n_eq", model.getUserID()); + condition.put("status_n_eq", model.getStatus()); + condition.put("supplier.id_n_eq", model.getSupplierID()); + condition.put("createtime_s_order", "desc"); + return condition; + } + + /** + * 根据状态码转化成说明字符串 + * 资产的状态:0==在库,1==在用,2==消费 + * @param statusCode + * @return + */ + private String getStatusInfo(short statusCode) + { + String statusInfo = ""; + switch(statusCode) + { + case AssetConstants.BusinessForExcel.EXCEl_STATUS_ZAIKU: + statusInfo = "在库"; + break; + + case AssetConstants.BusinessForExcel.EXCEl_STATUS_INUSE: + statusInfo = "在用"; + break; + + case AssetConstants.BusinessForExcel.EXCEl_STATUS_CONSUME: + statusInfo = "消费"; + break; + } + return statusInfo; + } + + //=========Spring注入以及model驱动公共方法=========== + public void setAssetService(AssetIService assetService) + { + this.assetService = assetService; + } + + public void setCategoryService(CategoryIService categoryService) + { + this.categoryService = categoryService; + } + + public void setSupplierService(SupplierIService supplierService) + { + this.supplierService = supplierService; + } + + public void setUserService(UserIService userService) + { + this.userService = userService; + } + + public void setAssetnameService(AssetNameIService assetnameService) + { + this.assetnameService = assetnameService; + } + + @Override + public AssetModel getModel() + { + return model; + } +} diff --git a/src/com/jsh/action/asset/ReportAction.java b/src/com/jsh/action/asset/ReportAction.java index 831347cb..07437077 100644 --- a/src/com/jsh/action/asset/ReportAction.java +++ b/src/com/jsh/action/asset/ReportAction.java @@ -1,120 +1,120 @@ -package com.jsh.action.asset; - -import java.util.HashMap; -import java.util.Map; - -import com.jsh.base.BaseAction; -import com.jsh.base.Log; -import com.jsh.exception.AmsException; -import com.jsh.model.po.Asset; -import com.jsh.model.vo.asset.ReportModel; -import com.jsh.service.asset.ReportIService; -import com.jsh.util.common.PageUtil; - -@SuppressWarnings("serial") -public class ReportAction extends BaseAction -{ - private ReportModel model = new ReportModel(); - private ReportIService reportService; - - /** - * 查找资产信息 - * @return - */ - public String find() - { - try - { - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(0); - pageUtil.setCurPage(0); - pageUtil.setAdvSearch(getCondition()); - String reportType = getReportType(new HashMap()); - reportService.find(pageUtil,reportType.split("_")[0],reportType.split("_")[1]); - model.getShowModel().setReportData(pageUtil.getPageList()); - } - catch (AmsException e) - { - Log.errorFileSync(">>>>>>>>>查找资产信息异常", e); - model.getShowModel().setMsgTip("get report data exception"); - } - return SUCCESS; - } - - /** - * 拼接搜索条件 - * @return - */ - private Map getCondition() - { - /** - * 拼接搜索条件 - */ - Map condition = new HashMap(); - condition.put("assetname.id_n_eq", model.getAssetNameID()); - condition.put("assetname.category.id_n_eq", model.getAssetCategoryID()); - condition.put("user.id_n_eq", model.getUsernameID()); - condition.put("status_n_eq", model.getStatus()); - condition.put("supplier.id_n_eq", model.getSupplierID()); - condition.put("dataSum_s_order","desc"); - //拼接统计数据条件 - getReportType(condition); - return condition; - } - - /** - * 获取统计条件 - * @param condition - */ - private String getReportType(Map condition) - { -// -// -// -// -// - int reportType = model.getReportType(); - String reportTypeInfo = ""; - String reportTypeName = ""; - switch(reportType) - { - case 0: - condition.put("status_s_gb", "group"); - reportTypeInfo = "status"; - reportTypeName = "status"; - break; - case 1: - condition.put("assetname.category.id_s_gb", "group"); - reportTypeInfo = "assetname.category.id"; - reportTypeName = "assetname.category.assetname"; - break; - case 2: - condition.put("supplier.id_s_gb", "group"); - reportTypeInfo = "supplier.id"; - reportTypeName = "supplier.supplier"; - break; - case 3: - condition.put("assetname.id_s_gb", "group"); - reportTypeInfo = "assetname.id"; - reportTypeName = "assetname.assetname"; - break; - case 4: - condition.put("user.id_s_gb", "group"); - reportTypeInfo = "user.id"; - reportTypeName = "user.username"; - break; - } - return reportTypeInfo + "_" + reportTypeName; - } - //=========Spring注入以及model驱动公共方法=========== - public void setReportService(ReportIService reportService) - { - this.reportService = reportService; - } - - @Override - public ReportModel getModel() - { - return model; - } -} +package com.jsh.action.asset; + +import java.util.HashMap; +import java.util.Map; + +import com.jsh.base.BaseAction; +import com.jsh.base.Log; +import com.jsh.exception.JshException; +import com.jsh.model.po.Asset; +import com.jsh.model.vo.asset.ReportModel; +import com.jsh.service.asset.ReportIService; +import com.jsh.util.common.PageUtil; + +@SuppressWarnings("serial") +public class ReportAction extends BaseAction +{ + private ReportModel model = new ReportModel(); + private ReportIService reportService; + + /** + * 查找资产信息 + * @return + */ + public String find() + { + try + { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(0); + pageUtil.setCurPage(0); + pageUtil.setAdvSearch(getCondition()); + String reportType = getReportType(new HashMap()); + reportService.find(pageUtil,reportType.split("_")[0],reportType.split("_")[1]); + model.getShowModel().setReportData(pageUtil.getPageList()); + } + catch (JshException e) + { + Log.errorFileSync(">>>>>>>>>查找资产信息异常", e); + model.getShowModel().setMsgTip("get report data exception"); + } + return SUCCESS; + } + + /** + * 拼接搜索条件 + * @return + */ + private Map getCondition() + { + /** + * 拼接搜索条件 + */ + Map condition = new HashMap(); + condition.put("assetname.id_n_eq", model.getAssetNameID()); + condition.put("assetname.category.id_n_eq", model.getAssetCategoryID()); + condition.put("user.id_n_eq", model.getUsernameID()); + condition.put("status_n_eq", model.getStatus()); + condition.put("supplier.id_n_eq", model.getSupplierID()); + condition.put("dataSum_s_order","desc"); + //拼接统计数据条件 + getReportType(condition); + return condition; + } + + /** + * 获取统计条件 + * @param condition + */ + private String getReportType(Map condition) + { +// +// +// +// +// + int reportType = model.getReportType(); + String reportTypeInfo = ""; + String reportTypeName = ""; + switch(reportType) + { + case 0: + condition.put("status_s_gb", "group"); + reportTypeInfo = "status"; + reportTypeName = "status"; + break; + case 1: + condition.put("assetname.category.id_s_gb", "group"); + reportTypeInfo = "assetname.category.id"; + reportTypeName = "assetname.category.assetname"; + break; + case 2: + condition.put("supplier.id_s_gb", "group"); + reportTypeInfo = "supplier.id"; + reportTypeName = "supplier.supplier"; + break; + case 3: + condition.put("assetname.id_s_gb", "group"); + reportTypeInfo = "assetname.id"; + reportTypeName = "assetname.assetname"; + break; + case 4: + condition.put("user.id_s_gb", "group"); + reportTypeInfo = "user.id"; + reportTypeName = "user.username"; + break; + } + return reportTypeInfo + "_" + reportTypeName; + } + //=========Spring注入以及model驱动公共方法=========== + public void setReportService(ReportIService reportService) + { + this.reportService = reportService; + } + + @Override + public ReportModel getModel() + { + return model; + } +} diff --git a/src/com/jsh/action/basic/AppAction.java b/src/com/jsh/action/basic/AppAction.java index 6a9e1fe6..b6cd1321 100644 --- a/src/com/jsh/action/basic/AppAction.java +++ b/src/com/jsh/action/basic/AppAction.java @@ -1,544 +1,544 @@ -package com.jsh.action.basic; - - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import java.sql.Timestamp; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - -import org.apache.struts2.ServletActionContext; -import org.springframework.dao.DataAccessException; - -import com.jsh.base.BaseAction; -import com.jsh.base.Log; -import com.jsh.exception.AmsException; -import com.jsh.model.po.App; -import com.jsh.model.po.Logdetails; -import com.jsh.model.vo.basic.AppModel; -import com.jsh.service.basic.AppIService; -import com.jsh.service.basic.UserBusinessIService; -import com.jsh.util.common.PageUtil; -//import com.opensymphony.xwork2.ActionContext; - -@SuppressWarnings("serial") -public class AppAction extends BaseAction -{ - private AppIService appService; - private UserBusinessIService userBusinessService; - private AppModel model = new AppModel(); - - - /** - * 增加应用 - * @return - */ - public void create() - { - Log.infoFileSync("==================开始调用增加应用方法create()==================="); - Boolean flag = false; - try - { - App app = new App(); - app.setNumber(model.getNumber()); - app.setName(model.getName()); - app.setType(model.getType()); - - try { - if(model.getIcon()!=null) - { - String path = ServletActionContext.getServletContext().getRealPath("/upload/images/deskIcon"); - String iconName=model.getIcon(); - File file1 = new File(iconName); //文件 - String FileName = file1.getName(); //获取文件名 - app.setIcon(FileName); //设置图片ICON - InputStream is = new FileInputStream(iconName); - File file = new File(path, FileName); - OutputStream os = new FileOutputStream(file); - byte[] b = new byte[1024]; - int bs = 0; - while ((bs = is.read(b)) > 0) { - os.write(b, 0, bs); - } - is.close(); - os.close(); - } - - } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - app.setURL(model.getURL()); - app.setWidth(model.getWidth()); - app.setHeight(model.getHeight()); - app.setReSize(model.getReSize()); - app.setOpenMax(model.getOpenMax()); - app.setFlash(model.getFlash()); - app.setZL(model.getZL()); - app.setSort(model.getSort()); - app.setRemark(model.getRemark()); - app.setEnabled(model.getEnabled()); - appService.create(app); - - //========标识位=========== - flag = true; - //记录操作日志使用 - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加应用异常", e); - flag = false; - tipMsg = "失败"; - tipType = 1; - } - finally - { - try - { - toClient(flag.toString()); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>增加应用回写客户端结果异常", e); - } - } - - logService.create(new Logdetails(getUser(), "增加应用", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "增加应用名称为 "+ model.getName() + " " + tipMsg + "!", "增加应用" + tipMsg)); - Log.infoFileSync("==================结束调用增加应用方法create()==================="); - } - - /** - * 删除应用 - * @return - */ - public String delete() - { - Log.infoFileSync("====================开始调用删除应用方法delete()================"); - try - { - appService.delete(model.getAppID()); - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getAppID() + " 的应用异常", e); - tipMsg = "失败"; - tipType = 1; - } - model.getShowModel().setMsgTip(tipMsg); - logService.create(new Logdetails(getUser(), "删除应用", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "删除应用ID为 "+ model.getAppID() + " " + tipMsg + "!", "删除应用" + tipMsg)); - Log.infoFileSync("====================结束调用删除应用方法delete()================"); - return SUCCESS; - } - - /** - * 更新仓库 - * @return - */ - public void update() - { - Boolean flag = false; - try - { - App app = appService.get(model.getAppID()); - app.setNumber(model.getNumber()); - app.setName(model.getName()); - app.setType(model.getType()); - //app.setIcon(model.getIcon()); - app.setURL(model.getURL()); - app.setWidth(model.getWidth()); - app.setHeight(model.getHeight()); - app.setReSize(model.getReSize()); - app.setOpenMax(model.getOpenMax()); - app.setFlash(model.getFlash()); - app.setZL(model.getZL()); - app.setSort(model.getSort()); - app.setRemark(model.getRemark()); - app.setEnabled(model.getEnabled()); - appService.update(app); - - flag = true; - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>修改应用ID为 : " + model.getAppID() + "信息失败", e); - flag = false; - tipMsg = "失败"; - tipType = 1; - } - finally - { - try - { - toClient(flag.toString()); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>修改应用回写客户端结果异常", e); - } - } - logService.create(new Logdetails(getUser(), "更新应用", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "更新应用ID为 "+ model.getAppID() + " " + tipMsg + "!", "更新应用" + tipMsg)); - } - - /** - * 批量删除指定ID应用 - * @return - */ - public String batchDelete() - { - try - { - appService.batchDelete(model.getAppIDs()); - model.getShowModel().setMsgTip("成功"); - //记录操作日志使用 - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>批量删除应用ID为:" + model.getAppIDs() + "信息异常", e); - tipMsg = "失败"; - tipType = 1; - } - - logService.create(new Logdetails(getUser(), "批量删除应用", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "批量删除应用ID为 "+ model.getAppIDs() + " " + tipMsg + "!", "批量删除应用" + tipMsg)); - return SUCCESS; - } - - /** - * 检查输入名称是否存在 - */ - public void checkIsNameExist() - { - Boolean flag = false; - try - { - flag = appService.checkIsNameExist("name",model.getName(),"Id", model.getAppID()); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>检查应用名称为:" + model.getName() + " ID为: " + model.getAppID() + " 是否存在异常!"); - } - finally - { - try - { - toClient(flag.toString()); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>回写检查应用名称为:" + model.getName() + " ID为: " + model.getAppID() + " 是否存在异常!",e); - } - } - } - - /** - * 查找应用信息 - * @return - */ - public void findBy() - { - try - { - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(model.getPageSize()); - pageUtil.setCurPage(model.getPageNo()); - pageUtil.setAdvSearch(getCondition()); - appService.find(pageUtil); - List dataList = pageUtil.getPageList(); - - //开始拼接json数据 -// {"total":28,"rows":[ -// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"} -// ]} - JSONObject outer = new JSONObject(); - outer.put("total", pageUtil.getTotalCount()); - //存放数据json数组 - JSONArray dataArray = new JSONArray(); - if(null != dataList) - { - for(App app:dataList) - { - JSONObject item = new JSONObject(); - item.put("Id", app.getId()); - //应用名称 - item.put("Number", app.getNumber()); - item.put("Name", app.getName()); - item.put("Type", app.getType()); - item.put("Icon", app.getIcon()); - item.put("URL", app.getURL()); - item.put("Width", app.getWidth()); - item.put("Height", app.getHeight()); - item.put("ReSize", app.getReSize()); - item.put("OpenMax", app.getOpenMax()); - item.put("Flash", app.getFlash()); - item.put("ZL", app.getZL()); - item.put("Sort", app.getSort()); - item.put("Remark", app.getRemark()); - item.put("Enabled", app.getEnabled()); - item.put("op", 1); - dataArray.add(item); - } - } - outer.put("rows", dataArray); - //回写查询结果 - toClient(outer.toString()); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找应用异常", e); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询应用结果异常", e); - } - } - - /** - * 桌面应用显示 - * @return - */ - public void findDesk() - { - try - { - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(100); - //pageUtil.setCurPage(model.getPageNo()); - - JSONObject outer = new JSONObject(); - - //下面是dock - pageUtil.setAdvSearch(getCondition_dock()); - appService.find(pageUtil); - List dataList1 = pageUtil.getPageList(); - - //开始拼接json数据 - //存放数据json数组 - JSONArray dataArray1 = new JSONArray(); - if(null != dataList1) - { - for(App app:dataList1) - { - JSONObject item = new JSONObject(); - item.put("id", app.getId()); - item.put("title", app.getName()); - item.put("type", app.getType()); - item.put("icon", "../../upload/images/deskIcon/"+app.getIcon()); - item.put("url", app.getURL()); - item.put("width", app.getWidth()); - item.put("height", app.getHeight()); - item.put("isresize", app.getReSize()); - item.put("isopenmax", app.getOpenMax()); - item.put("isflash", app.getFlash()); - dataArray1.add(item); - } - } - outer.put("dock", dataArray1); - - //下面是desk - pageUtil.setAdvSearch(getCondition_desk()); - appService.find(pageUtil); - List dataList2 = pageUtil.getPageList(); - - //开始拼接json数据 - //存放数据json数组 - JSONArray dataArray2 = new JSONArray(); - if(null != dataList2) - { - for(App app:dataList2) - { - JSONObject item = new JSONObject(); - item.put("id", app.getId()); - item.put("title", app.getName()); - item.put("type", app.getType()); - item.put("icon", "../../upload/images/deskIcon/"+app.getIcon()); - item.put("url", "../../pages/common/menu.jsp?appID="+app.getNumber()+"&id="+app.getId()); - item.put("width", app.getWidth()); - item.put("height", app.getHeight()); - item.put("isresize", app.getReSize()); - item.put("isopenmax", app.getOpenMax()); - item.put("isflash", app.getFlash()); - dataArray2.add(item); - } - } - outer.put("desk", dataArray2); - //回写查询结果 - toClient(outer.toString()); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找应用异常", e); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询应用结果异常", e); - } - } - - - /** - * 角色对应应用显示 - * @return - */ - public void findRoleAPP() - { - try - { - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(100); - //pageUtil.setCurPage(model.getPageNo()); - - pageUtil.setAdvSearch(getCondition_RoleAPP()); - appService.find(pageUtil); - List dataList = pageUtil.getPageList(); - - //开始拼接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(App app:dataList) - { - JSONObject item = new JSONObject(); - item.put("id", app.getId()); - item.put("text", app.getName()); - //勾选判断1 - Boolean flag = false; - try - { - flag = userBusinessService.checkIsUserBusinessExist("Type",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+app.getId().toString()+"]"); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>设置角色对应的应用:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!"); - } - if (flag==true){item.put("checked", true);} - //结束 - dataArray.add(item); - } - } - outer.put("children", dataArray); - //回写查询结果 - toClient("["+outer.toString()+"]"); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找应用异常", e); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询应用结果异常", e); - } - } - - /** - * 拼接搜索条件 - * @return - */ - private Map getCondition() - { - /** - * 拼接搜索条件 - */ - Map condition = new HashMap(); - condition.put("Name_s_like", model.getName()); - condition.put("Type_s_like", model.getType()); - condition.put("Sort_s_order", "asc"); - return condition; - } - - /** - * 拼接搜索条件-桌面dock - * @return - */ - private Map getCondition_dock() - { - /** - * 拼接搜索条件 - */ - Map condition = new HashMap(); - condition.put("ZL_s_eq", "dock"); - condition.put("Enabled_n_eq", 1); - condition.put("Sort_s_order", "asc"); - return condition; - } - - /** - * 拼接搜索条件-桌面desk - * @return - */ - private Map getCondition_desk() - { - /** - * 拼接搜索条件 - */ - Map condition = new HashMap(); - condition.put("ZL_s_eq", "desk"); - condition.put("Enabled_n_eq", 1); - condition.put("Sort_s_order", "asc"); - return condition; - } - - /** - * 拼接搜索条件-角色对应应用 - * @return - */ - private Map getCondition_RoleAPP() - { - /** - * 拼接搜索条件 - */ - Map condition = new HashMap(); - condition.put("Enabled_n_eq", 1); - condition.put("Sort_s_order", "asc"); - return condition; - } - - //=============以下spring注入以及Model驱动公共方法,与Action处理无关================== - @Override - public AppModel getModel() - { - return model; - } - public void setAppService(AppIService appService) - { - this.appService = appService; - } - - public void setUserBusinessService(UserBusinessIService userBusinessService) { - this.userBusinessService = userBusinessService; - } - -} +package com.jsh.action.basic; + + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import java.sql.Timestamp; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import org.apache.struts2.ServletActionContext; +import org.springframework.dao.DataAccessException; + +import com.jsh.base.BaseAction; +import com.jsh.base.Log; +import com.jsh.exception.JshException; +import com.jsh.model.po.App; +import com.jsh.model.po.Logdetails; +import com.jsh.model.vo.basic.AppModel; +import com.jsh.service.basic.AppIService; +import com.jsh.service.basic.UserBusinessIService; +import com.jsh.util.common.PageUtil; +//import com.opensymphony.xwork2.ActionContext; + +@SuppressWarnings("serial") +public class AppAction extends BaseAction +{ + private AppIService appService; + private UserBusinessIService userBusinessService; + private AppModel model = new AppModel(); + + + /** + * 增加应用 + * @return + */ + public void create() + { + Log.infoFileSync("==================开始调用增加应用方法create()==================="); + Boolean flag = false; + try + { + App app = new App(); + app.setNumber(model.getNumber()); + app.setName(model.getName()); + app.setType(model.getType()); + + try { + if(model.getIcon()!=null) + { + String path = ServletActionContext.getServletContext().getRealPath("/upload/images/deskIcon"); + String iconName=model.getIcon(); + File file1 = new File(iconName); //文件 + String FileName = file1.getName(); //获取文件名 + app.setIcon(FileName); //设置图片ICON + InputStream is = new FileInputStream(iconName); + File file = new File(path, FileName); + OutputStream os = new FileOutputStream(file); + byte[] b = new byte[1024]; + int bs = 0; + while ((bs = is.read(b)) > 0) { + os.write(b, 0, bs); + } + is.close(); + os.close(); + } + + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + app.setURL(model.getURL()); + app.setWidth(model.getWidth()); + app.setHeight(model.getHeight()); + app.setReSize(model.getReSize()); + app.setOpenMax(model.getOpenMax()); + app.setFlash(model.getFlash()); + app.setZL(model.getZL()); + app.setSort(model.getSort()); + app.setRemark(model.getRemark()); + app.setEnabled(model.getEnabled()); + appService.create(app); + + //========标识位=========== + flag = true; + //记录操作日志使用 + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加应用异常", e); + flag = false; + tipMsg = "失败"; + tipType = 1; + } + finally + { + try + { + toClient(flag.toString()); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>增加应用回写客户端结果异常", e); + } + } + + logService.create(new Logdetails(getUser(), "增加应用", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "增加应用名称为 "+ model.getName() + " " + tipMsg + "!", "增加应用" + tipMsg)); + Log.infoFileSync("==================结束调用增加应用方法create()==================="); + } + + /** + * 删除应用 + * @return + */ + public String delete() + { + Log.infoFileSync("====================开始调用删除应用方法delete()================"); + try + { + appService.delete(model.getAppID()); + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getAppID() + " 的应用异常", e); + tipMsg = "失败"; + tipType = 1; + } + model.getShowModel().setMsgTip(tipMsg); + logService.create(new Logdetails(getUser(), "删除应用", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "删除应用ID为 "+ model.getAppID() + " " + tipMsg + "!", "删除应用" + tipMsg)); + Log.infoFileSync("====================结束调用删除应用方法delete()================"); + return SUCCESS; + } + + /** + * 更新仓库 + * @return + */ + public void update() + { + Boolean flag = false; + try + { + App app = appService.get(model.getAppID()); + app.setNumber(model.getNumber()); + app.setName(model.getName()); + app.setType(model.getType()); + //app.setIcon(model.getIcon()); + app.setURL(model.getURL()); + app.setWidth(model.getWidth()); + app.setHeight(model.getHeight()); + app.setReSize(model.getReSize()); + app.setOpenMax(model.getOpenMax()); + app.setFlash(model.getFlash()); + app.setZL(model.getZL()); + app.setSort(model.getSort()); + app.setRemark(model.getRemark()); + app.setEnabled(model.getEnabled()); + appService.update(app); + + flag = true; + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>修改应用ID为 : " + model.getAppID() + "信息失败", e); + flag = false; + tipMsg = "失败"; + tipType = 1; + } + finally + { + try + { + toClient(flag.toString()); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>修改应用回写客户端结果异常", e); + } + } + logService.create(new Logdetails(getUser(), "更新应用", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "更新应用ID为 "+ model.getAppID() + " " + tipMsg + "!", "更新应用" + tipMsg)); + } + + /** + * 批量删除指定ID应用 + * @return + */ + public String batchDelete() + { + try + { + appService.batchDelete(model.getAppIDs()); + model.getShowModel().setMsgTip("成功"); + //记录操作日志使用 + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>批量删除应用ID为:" + model.getAppIDs() + "信息异常", e); + tipMsg = "失败"; + tipType = 1; + } + + logService.create(new Logdetails(getUser(), "批量删除应用", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "批量删除应用ID为 "+ model.getAppIDs() + " " + tipMsg + "!", "批量删除应用" + tipMsg)); + return SUCCESS; + } + + /** + * 检查输入名称是否存在 + */ + public void checkIsNameExist() + { + Boolean flag = false; + try + { + flag = appService.checkIsNameExist("name",model.getName(),"Id", model.getAppID()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>检查应用名称为:" + model.getName() + " ID为: " + model.getAppID() + " 是否存在异常!"); + } + finally + { + try + { + toClient(flag.toString()); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>回写检查应用名称为:" + model.getName() + " ID为: " + model.getAppID() + " 是否存在异常!",e); + } + } + } + + /** + * 查找应用信息 + * @return + */ + public void findBy() + { + try + { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(model.getPageSize()); + pageUtil.setCurPage(model.getPageNo()); + pageUtil.setAdvSearch(getCondition()); + appService.find(pageUtil); + List dataList = pageUtil.getPageList(); + + //开始拼接json数据 +// {"total":28,"rows":[ +// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"} +// ]} + JSONObject outer = new JSONObject(); + outer.put("total", pageUtil.getTotalCount()); + //存放数据json数组 + JSONArray dataArray = new JSONArray(); + if(null != dataList) + { + for(App app:dataList) + { + JSONObject item = new JSONObject(); + item.put("Id", app.getId()); + //应用名称 + item.put("Number", app.getNumber()); + item.put("Name", app.getName()); + item.put("Type", app.getType()); + item.put("Icon", app.getIcon()); + item.put("URL", app.getURL()); + item.put("Width", app.getWidth()); + item.put("Height", app.getHeight()); + item.put("ReSize", app.getReSize()); + item.put("OpenMax", app.getOpenMax()); + item.put("Flash", app.getFlash()); + item.put("ZL", app.getZL()); + item.put("Sort", app.getSort()); + item.put("Remark", app.getRemark()); + item.put("Enabled", app.getEnabled()); + item.put("op", 1); + dataArray.add(item); + } + } + outer.put("rows", dataArray); + //回写查询结果 + toClient(outer.toString()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找应用异常", e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询应用结果异常", e); + } + } + + /** + * 桌面应用显示 + * @return + */ + public void findDesk() + { + try + { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(100); + //pageUtil.setCurPage(model.getPageNo()); + + JSONObject outer = new JSONObject(); + + //下面是dock + pageUtil.setAdvSearch(getCondition_dock()); + appService.find(pageUtil); + List dataList1 = pageUtil.getPageList(); + + //开始拼接json数据 + //存放数据json数组 + JSONArray dataArray1 = new JSONArray(); + if(null != dataList1) + { + for(App app:dataList1) + { + JSONObject item = new JSONObject(); + item.put("id", app.getId()); + item.put("title", app.getName()); + item.put("type", app.getType()); + item.put("icon", "../../upload/images/deskIcon/"+app.getIcon()); + item.put("url", app.getURL()); + item.put("width", app.getWidth()); + item.put("height", app.getHeight()); + item.put("isresize", app.getReSize()); + item.put("isopenmax", app.getOpenMax()); + item.put("isflash", app.getFlash()); + dataArray1.add(item); + } + } + outer.put("dock", dataArray1); + + //下面是desk + pageUtil.setAdvSearch(getCondition_desk()); + appService.find(pageUtil); + List dataList2 = pageUtil.getPageList(); + + //开始拼接json数据 + //存放数据json数组 + JSONArray dataArray2 = new JSONArray(); + if(null != dataList2) + { + for(App app:dataList2) + { + JSONObject item = new JSONObject(); + item.put("id", app.getId()); + item.put("title", app.getName()); + item.put("type", app.getType()); + item.put("icon", "../../upload/images/deskIcon/"+app.getIcon()); + item.put("url", "../../pages/common/menu.jsp?appID="+app.getNumber()+"&id="+app.getId()); + item.put("width", app.getWidth()); + item.put("height", app.getHeight()); + item.put("isresize", app.getReSize()); + item.put("isopenmax", app.getOpenMax()); + item.put("isflash", app.getFlash()); + dataArray2.add(item); + } + } + outer.put("desk", dataArray2); + //回写查询结果 + toClient(outer.toString()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找应用异常", e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询应用结果异常", e); + } + } + + + /** + * 角色对应应用显示 + * @return + */ + public void findRoleAPP() + { + try + { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(100); + //pageUtil.setCurPage(model.getPageNo()); + + pageUtil.setAdvSearch(getCondition_RoleAPP()); + appService.find(pageUtil); + List dataList = pageUtil.getPageList(); + + //开始拼接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(App app:dataList) + { + JSONObject item = new JSONObject(); + item.put("id", app.getId()); + item.put("text", app.getName()); + //勾选判断1 + Boolean flag = false; + try + { + flag = userBusinessService.checkIsUserBusinessExist("Type",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+app.getId().toString()+"]"); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>设置角色对应的应用:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!"); + } + if (flag==true){item.put("checked", true);} + //结束 + dataArray.add(item); + } + } + outer.put("children", dataArray); + //回写查询结果 + toClient("["+outer.toString()+"]"); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找应用异常", e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询应用结果异常", e); + } + } + + /** + * 拼接搜索条件 + * @return + */ + private Map getCondition() + { + /** + * 拼接搜索条件 + */ + Map condition = new HashMap(); + condition.put("Name_s_like", model.getName()); + condition.put("Type_s_like", model.getType()); + condition.put("Sort_s_order", "asc"); + return condition; + } + + /** + * 拼接搜索条件-桌面dock + * @return + */ + private Map getCondition_dock() + { + /** + * 拼接搜索条件 + */ + Map condition = new HashMap(); + condition.put("ZL_s_eq", "dock"); + condition.put("Enabled_n_eq", 1); + condition.put("Sort_s_order", "asc"); + return condition; + } + + /** + * 拼接搜索条件-桌面desk + * @return + */ + private Map getCondition_desk() + { + /** + * 拼接搜索条件 + */ + Map condition = new HashMap(); + condition.put("ZL_s_eq", "desk"); + condition.put("Enabled_n_eq", 1); + condition.put("Sort_s_order", "asc"); + return condition; + } + + /** + * 拼接搜索条件-角色对应应用 + * @return + */ + private Map getCondition_RoleAPP() + { + /** + * 拼接搜索条件 + */ + Map condition = new HashMap(); + condition.put("Enabled_n_eq", 1); + condition.put("Sort_s_order", "asc"); + return condition; + } + + //=============以下spring注入以及Model驱动公共方法,与Action处理无关================== + @Override + public AppModel getModel() + { + return model; + } + public void setAppService(AppIService appService) + { + this.appService = appService; + } + + public void setUserBusinessService(UserBusinessIService userBusinessService) { + this.userBusinessService = userBusinessService; + } + +} diff --git a/src/com/jsh/action/basic/DepotAction.java b/src/com/jsh/action/basic/DepotAction.java index 391f5c48..d48ff7f6 100644 --- a/src/com/jsh/action/basic/DepotAction.java +++ b/src/com/jsh/action/basic/DepotAction.java @@ -1,380 +1,380 @@ -package com.jsh.action.basic; - -import java.io.IOException; -import java.sql.Timestamp; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - -import org.springframework.dao.DataAccessException; - -import com.jsh.base.BaseAction; -import com.jsh.base.Log; -import com.jsh.exception.AmsException; -import com.jsh.model.po.Depot; -import com.jsh.model.po.Logdetails; -import com.jsh.model.po.Role; -import com.jsh.model.vo.basic.DepotModel; -import com.jsh.service.basic.DepotIService; -import com.jsh.service.basic.UserBusinessIService; -import com.jsh.util.common.PageUtil; - -@SuppressWarnings("serial") -public class DepotAction extends BaseAction -{ - private DepotIService depotService; - private UserBusinessIService userBusinessService; - private DepotModel model = new DepotModel(); - - - @SuppressWarnings({ "rawtypes", "unchecked" }) - public String getBasicData() - { - Map mapData = model.getShowModel().getMap(); - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(0); - pageUtil.setCurPage(0); - try - { - Map condition = pageUtil.getAdvSearch(); - condition.put("id_s_order", "asc"); - depotService.find(pageUtil); - mapData.put("depotList", pageUtil.getPageList()); - } - catch (Exception e) - { - Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e); - model.getShowModel().setMsgTip("exceptoin"); - } - return SUCCESS; - } - - /** - * 增加仓库 - * @return - */ - public void create() - { - Log.infoFileSync("==================开始调用增加仓库信息方法create()==================="); - Boolean flag = false; - try - { - Depot depot = new Depot(); - depot.setName(model.getName()); - depot.setSort(model.getSort()); - depot.setRemark(model.getRemark()); - depotService.create(depot); - - //========标识位=========== - flag = true; - //记录操作日志使用 - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加仓库信息异常", e); - flag = false; - tipMsg = "失败"; - tipType = 1; - } - finally - { - try - { - toClient(flag.toString()); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>增加仓库信息回写客户端结果异常", e); - } - } - - logService.create(new Logdetails(getUser(), "增加仓库", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "增加仓库名称为 "+ model.getName() + " " + tipMsg + "!", "增加仓库" + tipMsg)); - Log.infoFileSync("==================结束调用增加仓库方法create()==================="); - } - - /** - * 删除仓库 - * @return - */ - public String delete() - { - Log.infoFileSync("====================开始调用删除仓库信息方法delete()================"); - try - { - depotService.delete(model.getDepotID()); - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getDepotID() + " 的仓库异常", e); - tipMsg = "失败"; - tipType = 1; - } - model.getShowModel().setMsgTip(tipMsg); - logService.create(new Logdetails(getUser(), "删除仓库", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "删除仓库ID为 "+ model.getDepotID() + " " + tipMsg + "!", "删除仓库" + tipMsg)); - Log.infoFileSync("====================结束调用删除仓库信息方法delete()================"); - return SUCCESS; - } - - /** - * 更新仓库 - * @return - */ - public void update() - { - Boolean flag = false; - try - { - Depot depot = depotService.get(model.getDepotID()); - depot.setName(model.getName()); - depot.setSort(model.getSort()); - depot.setRemark(model.getRemark()); - depotService.update(depot); - - flag = true; - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>修改仓库ID为 : " + model.getDepotID() + "信息失败", e); - flag = false; - tipMsg = "失败"; - tipType = 1; - } - finally - { - try - { - toClient(flag.toString()); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>修改仓库回写客户端结果异常", e); - } - } - logService.create(new Logdetails(getUser(), "更新仓库", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "更新仓库ID为 "+ model.getDepotID() + " " + tipMsg + "!", "更新仓库" + tipMsg)); - } - - /** - * 批量删除指定ID仓库 - * @return - */ - public String batchDelete() - { - try - { - depotService.batchDelete(model.getDepotIDs()); - model.getShowModel().setMsgTip("成功"); - //记录操作日志使用 - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>批量删除仓库ID为:" + model.getDepotIDs() + "信息异常", e); - tipMsg = "失败"; - tipType = 1; - } - - logService.create(new Logdetails(getUser(), "批量删除仓库", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "批量删除仓库ID为 "+ model.getDepotIDs() + " " + tipMsg + "!", "批量删除仓库" + tipMsg)); - return SUCCESS; - } - - /** - * 检查输入名称是否存在 - */ - public void checkIsNameExist() - { - Boolean flag = false; - try - { - flag = depotService.checkIsNameExist("name",model.getName(),"id", model.getDepotID()); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>检查仓库名称为:" + model.getName() + " ID为: " + model.getDepotID() + " 是否存在异常!"); - } - finally - { - try - { - toClient(flag.toString()); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>回写检查仓库名称为:" + model.getName() + " ID为: " + model.getDepotID() + " 是否存在异常!",e); - } - } - } - - /** - * 查找仓库信息 - * @return - */ - public void findBy() - { - try - { - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(model.getPageSize()); - pageUtil.setCurPage(model.getPageNo()); - pageUtil.setAdvSearch(getCondition()); - depotService.find(pageUtil); - List dataList = pageUtil.getPageList(); - - //开始拼接json数据 -// {"total":28,"rows":[ -// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"} -// ]} - JSONObject outer = new JSONObject(); - outer.put("total", pageUtil.getTotalCount()); - //存放数据json数组 - JSONArray dataArray = new JSONArray(); - if(null != dataList) - { - for(Depot depot:dataList) - { - JSONObject item = new JSONObject(); - item.put("id", depot.getId()); - //供应商名称 - item.put("name", depot.getName()); - item.put("sort", depot.getSort()); - item.put("remark", depot.getRemark()); - item.put("op", 1); - dataArray.add(item); - } - } - outer.put("rows", dataArray); - //回写查询结果 - toClient(outer.toString()); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓库信息异常", e); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓库信息结果异常", e); - } - } - - /** - * 用户对应部门显示 - * @return - */ - public void findUserDepot() - { - try - { - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(100); - //pageUtil.setCurPage(model.getPageNo()); - - pageUtil.setAdvSearch(getCondition_UserDepot()); - depotService.find(pageUtil); - List dataList = pageUtil.getPageList(); - - //开始拼接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",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+depot.getId().toString()+"]"); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>设置用户对应的部门:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!"); - } - if (flag==true){item.put("checked", true);} - //结束 - dataArray.add(item); - } - } - outer.put("children", dataArray); - //回写查询结果 - toClient("["+outer.toString()+"]"); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找部门异常", e); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询部门结果异常", e); - } - } - - /** - * 拼接搜索条件 - * @return - */ - private Map getCondition() - { - /** - * 拼接搜索条件 - */ - Map condition = new HashMap(); - condition.put("name_s_like", model.getName()); - condition.put("remark_s_like", model.getRemark()); - condition.put("sort_s_order", "asc"); - return condition; - } - - /** - * 拼接搜索条件-用户对应部门 - * @return - */ - private Map getCondition_UserDepot() - { - /** - * 拼接搜索条件 - */ - Map condition = new HashMap(); - condition.put("Id_s_order", "asc"); - return condition; - } - - //=============以下spring注入以及Model驱动公共方法,与Action处理无关================== - @Override - public DepotModel getModel() - { - return model; - } - public void setDepotService(DepotIService depotService) - { - this.depotService = depotService; - } - - public void setUserBusinessService(UserBusinessIService userBusinessService) { - this.userBusinessService = userBusinessService; - } - -} +package com.jsh.action.basic; + +import java.io.IOException; +import java.sql.Timestamp; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import org.springframework.dao.DataAccessException; + +import com.jsh.base.BaseAction; +import com.jsh.base.Log; +import com.jsh.exception.JshException; +import com.jsh.model.po.Depot; +import com.jsh.model.po.Logdetails; +import com.jsh.model.po.Role; +import com.jsh.model.vo.basic.DepotModel; +import com.jsh.service.basic.DepotIService; +import com.jsh.service.basic.UserBusinessIService; +import com.jsh.util.common.PageUtil; + +@SuppressWarnings("serial") +public class DepotAction extends BaseAction +{ + private DepotIService depotService; + private UserBusinessIService userBusinessService; + private DepotModel model = new DepotModel(); + + + @SuppressWarnings({ "rawtypes", "unchecked" }) + public String getBasicData() + { + Map mapData = model.getShowModel().getMap(); + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(0); + pageUtil.setCurPage(0); + try + { + Map condition = pageUtil.getAdvSearch(); + condition.put("id_s_order", "asc"); + depotService.find(pageUtil); + mapData.put("depotList", pageUtil.getPageList()); + } + catch (Exception e) + { + Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e); + model.getShowModel().setMsgTip("exceptoin"); + } + return SUCCESS; + } + + /** + * 增加仓库 + * @return + */ + public void create() + { + Log.infoFileSync("==================开始调用增加仓库信息方法create()==================="); + Boolean flag = false; + try + { + Depot depot = new Depot(); + depot.setName(model.getName()); + depot.setSort(model.getSort()); + depot.setRemark(model.getRemark()); + depotService.create(depot); + + //========标识位=========== + flag = true; + //记录操作日志使用 + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加仓库信息异常", e); + flag = false; + tipMsg = "失败"; + tipType = 1; + } + finally + { + try + { + toClient(flag.toString()); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>增加仓库信息回写客户端结果异常", e); + } + } + + logService.create(new Logdetails(getUser(), "增加仓库", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "增加仓库名称为 "+ model.getName() + " " + tipMsg + "!", "增加仓库" + tipMsg)); + Log.infoFileSync("==================结束调用增加仓库方法create()==================="); + } + + /** + * 删除仓库 + * @return + */ + public String delete() + { + Log.infoFileSync("====================开始调用删除仓库信息方法delete()================"); + try + { + depotService.delete(model.getDepotID()); + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getDepotID() + " 的仓库异常", e); + tipMsg = "失败"; + tipType = 1; + } + model.getShowModel().setMsgTip(tipMsg); + logService.create(new Logdetails(getUser(), "删除仓库", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "删除仓库ID为 "+ model.getDepotID() + " " + tipMsg + "!", "删除仓库" + tipMsg)); + Log.infoFileSync("====================结束调用删除仓库信息方法delete()================"); + return SUCCESS; + } + + /** + * 更新仓库 + * @return + */ + public void update() + { + Boolean flag = false; + try + { + Depot depot = depotService.get(model.getDepotID()); + depot.setName(model.getName()); + depot.setSort(model.getSort()); + depot.setRemark(model.getRemark()); + depotService.update(depot); + + flag = true; + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>修改仓库ID为 : " + model.getDepotID() + "信息失败", e); + flag = false; + tipMsg = "失败"; + tipType = 1; + } + finally + { + try + { + toClient(flag.toString()); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>修改仓库回写客户端结果异常", e); + } + } + logService.create(new Logdetails(getUser(), "更新仓库", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "更新仓库ID为 "+ model.getDepotID() + " " + tipMsg + "!", "更新仓库" + tipMsg)); + } + + /** + * 批量删除指定ID仓库 + * @return + */ + public String batchDelete() + { + try + { + depotService.batchDelete(model.getDepotIDs()); + model.getShowModel().setMsgTip("成功"); + //记录操作日志使用 + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>批量删除仓库ID为:" + model.getDepotIDs() + "信息异常", e); + tipMsg = "失败"; + tipType = 1; + } + + logService.create(new Logdetails(getUser(), "批量删除仓库", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "批量删除仓库ID为 "+ model.getDepotIDs() + " " + tipMsg + "!", "批量删除仓库" + tipMsg)); + return SUCCESS; + } + + /** + * 检查输入名称是否存在 + */ + public void checkIsNameExist() + { + Boolean flag = false; + try + { + flag = depotService.checkIsNameExist("name",model.getName(),"id", model.getDepotID()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>检查仓库名称为:" + model.getName() + " ID为: " + model.getDepotID() + " 是否存在异常!"); + } + finally + { + try + { + toClient(flag.toString()); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>回写检查仓库名称为:" + model.getName() + " ID为: " + model.getDepotID() + " 是否存在异常!",e); + } + } + } + + /** + * 查找仓库信息 + * @return + */ + public void findBy() + { + try + { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(model.getPageSize()); + pageUtil.setCurPage(model.getPageNo()); + pageUtil.setAdvSearch(getCondition()); + depotService.find(pageUtil); + List dataList = pageUtil.getPageList(); + + //开始拼接json数据 +// {"total":28,"rows":[ +// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"} +// ]} + JSONObject outer = new JSONObject(); + outer.put("total", pageUtil.getTotalCount()); + //存放数据json数组 + JSONArray dataArray = new JSONArray(); + if(null != dataList) + { + for(Depot depot:dataList) + { + JSONObject item = new JSONObject(); + item.put("id", depot.getId()); + //供应商名称 + item.put("name", depot.getName()); + item.put("sort", depot.getSort()); + item.put("remark", depot.getRemark()); + item.put("op", 1); + dataArray.add(item); + } + } + outer.put("rows", dataArray); + //回写查询结果 + toClient(outer.toString()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓库信息异常", e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓库信息结果异常", e); + } + } + + /** + * 用户对应部门显示 + * @return + */ + public void findUserDepot() + { + try + { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(100); + //pageUtil.setCurPage(model.getPageNo()); + + pageUtil.setAdvSearch(getCondition_UserDepot()); + depotService.find(pageUtil); + List dataList = pageUtil.getPageList(); + + //开始拼接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",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+depot.getId().toString()+"]"); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>设置用户对应的部门:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!"); + } + if (flag==true){item.put("checked", true);} + //结束 + dataArray.add(item); + } + } + outer.put("children", dataArray); + //回写查询结果 + toClient("["+outer.toString()+"]"); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找部门异常", e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询部门结果异常", e); + } + } + + /** + * 拼接搜索条件 + * @return + */ + private Map getCondition() + { + /** + * 拼接搜索条件 + */ + Map condition = new HashMap(); + condition.put("name_s_like", model.getName()); + condition.put("remark_s_like", model.getRemark()); + condition.put("sort_s_order", "asc"); + return condition; + } + + /** + * 拼接搜索条件-用户对应部门 + * @return + */ + private Map getCondition_UserDepot() + { + /** + * 拼接搜索条件 + */ + Map condition = new HashMap(); + condition.put("Id_s_order", "asc"); + return condition; + } + + //=============以下spring注入以及Model驱动公共方法,与Action处理无关================== + @Override + public DepotModel getModel() + { + return model; + } + public void setDepotService(DepotIService depotService) + { + this.depotService = depotService; + } + + public void setUserBusinessService(UserBusinessIService userBusinessService) { + this.userBusinessService = userBusinessService; + } + +} diff --git a/src/com/jsh/action/basic/FunctionsAction.java b/src/com/jsh/action/basic/FunctionsAction.java index 9aa5470f..6e2c1ff6 100644 --- a/src/com/jsh/action/basic/FunctionsAction.java +++ b/src/com/jsh/action/basic/FunctionsAction.java @@ -1,588 +1,588 @@ -package com.jsh.action.basic; - -import java.io.IOException; -import java.sql.Timestamp; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - -import org.springframework.dao.DataAccessException; - -import com.jsh.base.BaseAction; -import com.jsh.base.Log; -import com.jsh.exception.AmsException; -import com.jsh.model.po.App; -import com.jsh.model.po.Functions; -import com.jsh.model.po.Logdetails; -import com.jsh.model.vo.basic.FunctionsModel; -import com.jsh.service.basic.FunctionsIService; -import com.jsh.service.basic.UserBusinessIService; -import com.jsh.util.common.PageUtil; - -@SuppressWarnings("serial") -public class FunctionsAction extends BaseAction -{ - private FunctionsIService functionsService; - private UserBusinessIService userBusinessService; - private FunctionsModel model = new FunctionsModel(); - /** - * 增加功能 - * @return - */ - public void create() - { - Log.infoFileSync("==================开始调用增加功能信息方法create()==================="); - Boolean flag = false; - try - { - Functions functions = new Functions(); - functions.setNumber(model.getNumber()); - functions.setName(model.getName()); - functions.setPNumber(model.getPNumber()); - functions.setURL(model.getURL()); - functions.setState(model.getState()); - functions.setSort(model.getSort()); - functions.setEnabled(model.getEnabled()); - functions.setType(model.getType()); - - functionsService.create(functions); - - //========标识位=========== - flag = true; - //记录操作日志使用 - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加功能信息异常", e); - flag = false; - tipMsg = "失败"; - tipType = 1; - } - finally - { - try - { - toClient(flag.toString()); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>增加功能信息回写客户端结果异常", e); - } - } - - logService.create(new Logdetails(getUser(), "增加功能", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "增加功能名称为 "+ model.getName() + " " + tipMsg + "!", "增加功能" + tipMsg)); - Log.infoFileSync("==================结束调用增加功能方法create()==================="); - } - - /** - * 删除功能 - * @return - */ - public String delete() - { - Log.infoFileSync("====================开始调用删除功能信息方法delete()================"); - try - { - functionsService.delete(model.getFunctionsID()); - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getFunctionsID() + " 的功能异常", e); - tipMsg = "失败"; - tipType = 1; - } - model.getShowModel().setMsgTip(tipMsg); - logService.create(new Logdetails(getUser(), "删除功能", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "删除功能ID为 "+ model.getFunctionsID() + " " + tipMsg + "!", "删除功能" + tipMsg)); - Log.infoFileSync("====================结束调用删除功能信息方法delete()================"); - return SUCCESS; - } - - /** - * 更新功能 - * @return - */ - public void update() - { - Boolean flag = false; - try - { - Functions functions = functionsService.get(model.getFunctionsID()); - functions.setNumber(model.getNumber()); - functions.setName(model.getName()); - functions.setPNumber(model.getPNumber()); - functions.setURL(model.getURL()); - functions.setState(model.getState()); - functions.setSort(model.getSort()); - functions.setEnabled(model.getEnabled()); - functions.setType(model.getType()); - functionsService.update(functions); - - flag = true; - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>修改功能ID为 : " + model.getFunctionsID() + "信息失败", e); - flag = false; - tipMsg = "失败"; - tipType = 1; - } - finally - { - try - { - toClient(flag.toString()); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>修改功能回写客户端结果异常", e); - } - } - logService.create(new Logdetails(getUser(), "更新功能", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "更新功能ID为 "+ model.getFunctionsID() + " " + tipMsg + "!", "更新功能" + tipMsg)); - } - - /** - * 批量删除指定ID功能 - * @return - */ - public String batchDelete() - { - try - { - functionsService.batchDelete(model.getFunctionsIDs()); - model.getShowModel().setMsgTip("成功"); - //记录操作日志使用 - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>批量删除功能ID为:" + model.getFunctionsIDs() + "信息异常", e); - tipMsg = "失败"; - tipType = 1; - } - - logService.create(new Logdetails(getUser(), "批量删除功能", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "批量删除功能ID为 "+ model.getFunctionsIDs() + " " + tipMsg + "!", "批量删除功能" + tipMsg)); - return SUCCESS; - } - - /** - * 检查输入名称是否存在 - */ - public void checkIsNameExist() - { - Boolean flag = false; - try - { - flag = functionsService.checkIsNameExist("Name",model.getName(),"Id", model.getFunctionsID()); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>检查功能名称为:" + model.getName() + " ID为: " + model.getFunctionsID() + " 是否存在异常!"); - } - finally - { - try - { - toClient(flag.toString()); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>回写检查功能名称为:" + model.getName() + " ID为: " + model.getFunctionsID() + " 是否存在异常!",e); - } - } - } - - /** - * 查找功能信息 - * @return - */ - public void findBy() - { - try - { - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(model.getPageSize()); - pageUtil.setCurPage(model.getPageNo()); - pageUtil.setAdvSearch(getCondition()); - functionsService.find(pageUtil); - List dataList = pageUtil.getPageList(); - - //开始拼接json数据 -// {"total":28,"rows":[ -// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"} -// ]} - JSONObject outer = new JSONObject(); - outer.put("total", pageUtil.getTotalCount()); - //存放数据json数组 - JSONArray dataArray = new JSONArray(); - if(null != dataList) - { - for(Functions functions:dataList) - { - JSONObject item = new JSONObject(); - item.put("Id", functions.getId()); - item.put("Number", functions.getNumber()); - item.put("Name", functions.getName()); - item.put("PNumber", functions.getPNumber()); - item.put("URL", functions.getURL()); - item.put("State", functions.getState()); - item.put("Sort", functions.getSort()); - item.put("Enabled", functions.getEnabled()); - item.put("Type", functions.getType()); - item.put("op", 1); - dataArray.add(item); - } - } - outer.put("rows", dataArray); - //回写查询结果 - toClient(outer.toString()); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找功能信息异常", e); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询功能信息结果异常", e); - } - } - - - /** - * 角色对应功能显示 - * @return - */ - public void findRoleFunctions() - { - try - { - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(200); - pageUtil.setAdvSearch(getCondition_RoleFunctions("0")); - functionsService.find(pageUtil); - List dataList = pageUtil.getPageList(); - - //开始拼接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(Functions functions:dataList) - { - JSONObject item = new JSONObject(); - item.put("id", functions.getId()); - item.put("text", functions.getName()); - - //勾选判断1 - Boolean flag = false; - try - { - flag = userBusinessService.checkIsUserBusinessExist("Type",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+functions.getId().toString()+"]"); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!"); - } - if (flag==true){item.put("checked", true);} - //结束 - - pageUtil.setAdvSearch(getCondition_RoleFunctions(functions.getNumber())); - functionsService.find(pageUtil); - List dataList1 = pageUtil.getPageList(); - JSONArray dataArray1 = new JSONArray(); - if(null != dataList1) - { - - for(Functions functions1:dataList1) - { - item.put("state", "open"); //如果不为空,节点不展开 - JSONObject item1 = new JSONObject(); - item1.put("id", functions1.getId()); - item1.put("text", functions1.getName()); - - //勾选判断2 - //Boolean flag = false; - try - { - flag = userBusinessService.checkIsUserBusinessExist("Type",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+functions1.getId().toString()+"]"); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!"); - } - if (flag==true){item1.put("checked", true);} - //结束 - - pageUtil.setAdvSearch(getCondition_RoleFunctions(functions1.getNumber())); - functionsService.find(pageUtil); - List dataList2 = pageUtil.getPageList(); - JSONArray dataArray2 = new JSONArray(); - if(null != dataList2) - { - - for(Functions functions2:dataList2) - { - item1.put("state", "closed"); //如果不为空,节点不展开 - JSONObject item2 = new JSONObject(); - item2.put("id", functions2.getId()); - item2.put("text", functions2.getName()); - - //勾选判断3 - //Boolean flag = false; - try - { - flag = userBusinessService.checkIsUserBusinessExist("Type",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+functions2.getId().toString()+"]"); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!"); - } - if (flag==true){item2.put("checked", true);} - //结束 - - pageUtil.setAdvSearch(getCondition_RoleFunctions(functions2.getNumber())); - functionsService.find(pageUtil); - List dataList3 = pageUtil.getPageList(); - JSONArray dataArray3 = new JSONArray(); - if(null != dataList3) - { - - for(Functions functions3:dataList3) - { - item2.put("state", "closed"); //如果不为空,节点不展开 - JSONObject item3 = new JSONObject(); - item3.put("id", functions3.getId()); - item3.put("text", functions3.getName()); - - //勾选判断4 - //Boolean flag = false; - try - { - flag = userBusinessService.checkIsUserBusinessExist("Type",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+functions3.getId().toString()+"]"); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!"); - } - if (flag==true){item3.put("checked", true);} - //结束 - - dataArray3.add(item3); - item2.put("children", dataArray3); - } - } - - dataArray2.add(item2); - item1.put("children", dataArray2); - } - } - - dataArray1.add(item1); - item.put("children", dataArray1); - } - - } - - dataArray.add(item); - } - outer.put("children", dataArray); - } - //回写查询结果 - toClient("["+outer.toString()+"]"); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找应用异常", e); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询应用结果异常", e); - } - } - - - /** - * 页面显示菜单 - * @return - */ - public void findMenu() - { - try - { - String fc=model.getHasFunctions(); //当前用户所拥有的功能列表,格式如:[1][2][5] - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(200); - pageUtil.setAdvSearch(getCondition_RoleFunctions(model.getPNumber())); - functionsService.find(pageUtil); - List dataList = pageUtil.getPageList(); - - //存放数据json数组 - JSONArray dataArray = new JSONArray(); - if(null != dataList) - { - for(Functions functions:dataList) - { - JSONObject item = new JSONObject(); - item.put("id", functions.getId()); - - pageUtil.setAdvSearch(getCondition_RoleFunctions(functions.getNumber())); - functionsService.find(pageUtil); - List dataList1 = pageUtil.getPageList(); - JSONArray dataArray1 = new JSONArray(); - if(dataList1.size()!=0) - { - item.put("text", functions.getName()); //是目录就没链接 - for(Functions functions1:dataList1) - { - item.put("state", "open"); //如果不为空,节点展开 - JSONObject item1 = new JSONObject(); - - pageUtil.setAdvSearch(getCondition_RoleFunctions(functions1.getNumber())); - functionsService.find(pageUtil); - List dataList2 = pageUtil.getPageList(); - if(fc.indexOf("["+functions1.getId().toString()+"]")!=-1||dataList2.size()!=0) - { - item1.put("id", functions1.getId()); - JSONArray dataArray2 = new JSONArray(); - if(dataList2.size()!=0) - { - item1.put("text", functions1.getName());//是目录就没链接 - for(Functions functions2:dataList2) - { - item1.put("state", "closed"); //如果不为空,节点不展开 - JSONObject item2 = new JSONObject(); - - pageUtil.setAdvSearch(getCondition_RoleFunctions(functions2.getNumber())); - functionsService.find(pageUtil); - List dataList3 = pageUtil.getPageList(); - if(fc.indexOf("["+functions2.getId().toString()+"]")!=-1||dataList3.size()!=0) - { - item2.put("id", functions2.getId()); - JSONArray dataArray3 = new JSONArray(); - if(dataList3.size()!=0) - { - item2.put("text", functions2.getName());//是目录就没链接 - for(Functions functions3:dataList3) - { - item2.put("state", "closed"); //如果不为空,节点不展开 - JSONObject item3 = new JSONObject(); - item3.put("id", functions3.getId()); - item3.put("text", functions3.getName()); - // - dataArray3.add(item3); - item2.put("children", dataArray3); - } - } - else - { - //不是目录,有链接 - item2.put("text", ""+functions2.getName()+""); - } - - dataArray2.add(item2); - item1.put("children", dataArray2); - } - } - } - else - { - //不是目录,有链接 - item1.put("text", ""+functions1.getName()+""); - } - - dataArray1.add(item1); - item.put("children", dataArray1); - } - } - } - else - { - //不是目录,有链接 - item.put("text", ""+functions.getName()+""); - } - - dataArray.add(item); - } - } - //回写查询结果 - toClient(dataArray.toString()); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找应用异常", e); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询应用结果异常", e); - } - } - - /** - * 拼接搜索条件 - * @return - */ - private Map getCondition() - { - /** - * 拼接搜索条件 - */ - Map condition = new HashMap(); - condition.put("Name_s_like", model.getName()); - condition.put("Type_s_eq", model.getType()); - condition.put("Sort_s_order", "asc"); - return condition; - } - - /** - * 拼接搜索条件-角色对应功能 - * @return - */ - private Map getCondition_RoleFunctions(String num) - { - /** - * 拼接搜索条件 - */ - Map condition = new HashMap(); - condition.put("Enabled_n_eq", 1); - condition.put("PNumber_s_eq", num); - condition.put("Sort_s_order", "asc"); - return condition; - } - - //=============以下spring注入以及Model驱动公共方法,与Action处理无关================== - @Override - public FunctionsModel getModel() - { - return model; - } - public void setFunctionsService(FunctionsIService functionsService) - { - this.functionsService = functionsService; - } - - public void setUserBusinessService(UserBusinessIService userBusinessService) { - this.userBusinessService = userBusinessService; - } - -} +package com.jsh.action.basic; + +import java.io.IOException; +import java.sql.Timestamp; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import org.springframework.dao.DataAccessException; + +import com.jsh.base.BaseAction; +import com.jsh.base.Log; +import com.jsh.exception.JshException; +import com.jsh.model.po.App; +import com.jsh.model.po.Functions; +import com.jsh.model.po.Logdetails; +import com.jsh.model.vo.basic.FunctionsModel; +import com.jsh.service.basic.FunctionsIService; +import com.jsh.service.basic.UserBusinessIService; +import com.jsh.util.common.PageUtil; + +@SuppressWarnings("serial") +public class FunctionsAction extends BaseAction +{ + private FunctionsIService functionsService; + private UserBusinessIService userBusinessService; + private FunctionsModel model = new FunctionsModel(); + /** + * 增加功能 + * @return + */ + public void create() + { + Log.infoFileSync("==================开始调用增加功能信息方法create()==================="); + Boolean flag = false; + try + { + Functions functions = new Functions(); + functions.setNumber(model.getNumber()); + functions.setName(model.getName()); + functions.setPNumber(model.getPNumber()); + functions.setURL(model.getURL()); + functions.setState(model.getState()); + functions.setSort(model.getSort()); + functions.setEnabled(model.getEnabled()); + functions.setType(model.getType()); + + functionsService.create(functions); + + //========标识位=========== + flag = true; + //记录操作日志使用 + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加功能信息异常", e); + flag = false; + tipMsg = "失败"; + tipType = 1; + } + finally + { + try + { + toClient(flag.toString()); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>增加功能信息回写客户端结果异常", e); + } + } + + logService.create(new Logdetails(getUser(), "增加功能", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "增加功能名称为 "+ model.getName() + " " + tipMsg + "!", "增加功能" + tipMsg)); + Log.infoFileSync("==================结束调用增加功能方法create()==================="); + } + + /** + * 删除功能 + * @return + */ + public String delete() + { + Log.infoFileSync("====================开始调用删除功能信息方法delete()================"); + try + { + functionsService.delete(model.getFunctionsID()); + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getFunctionsID() + " 的功能异常", e); + tipMsg = "失败"; + tipType = 1; + } + model.getShowModel().setMsgTip(tipMsg); + logService.create(new Logdetails(getUser(), "删除功能", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "删除功能ID为 "+ model.getFunctionsID() + " " + tipMsg + "!", "删除功能" + tipMsg)); + Log.infoFileSync("====================结束调用删除功能信息方法delete()================"); + return SUCCESS; + } + + /** + * 更新功能 + * @return + */ + public void update() + { + Boolean flag = false; + try + { + Functions functions = functionsService.get(model.getFunctionsID()); + functions.setNumber(model.getNumber()); + functions.setName(model.getName()); + functions.setPNumber(model.getPNumber()); + functions.setURL(model.getURL()); + functions.setState(model.getState()); + functions.setSort(model.getSort()); + functions.setEnabled(model.getEnabled()); + functions.setType(model.getType()); + functionsService.update(functions); + + flag = true; + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>修改功能ID为 : " + model.getFunctionsID() + "信息失败", e); + flag = false; + tipMsg = "失败"; + tipType = 1; + } + finally + { + try + { + toClient(flag.toString()); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>修改功能回写客户端结果异常", e); + } + } + logService.create(new Logdetails(getUser(), "更新功能", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "更新功能ID为 "+ model.getFunctionsID() + " " + tipMsg + "!", "更新功能" + tipMsg)); + } + + /** + * 批量删除指定ID功能 + * @return + */ + public String batchDelete() + { + try + { + functionsService.batchDelete(model.getFunctionsIDs()); + model.getShowModel().setMsgTip("成功"); + //记录操作日志使用 + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>批量删除功能ID为:" + model.getFunctionsIDs() + "信息异常", e); + tipMsg = "失败"; + tipType = 1; + } + + logService.create(new Logdetails(getUser(), "批量删除功能", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "批量删除功能ID为 "+ model.getFunctionsIDs() + " " + tipMsg + "!", "批量删除功能" + tipMsg)); + return SUCCESS; + } + + /** + * 检查输入名称是否存在 + */ + public void checkIsNameExist() + { + Boolean flag = false; + try + { + flag = functionsService.checkIsNameExist("Name",model.getName(),"Id", model.getFunctionsID()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>检查功能名称为:" + model.getName() + " ID为: " + model.getFunctionsID() + " 是否存在异常!"); + } + finally + { + try + { + toClient(flag.toString()); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>回写检查功能名称为:" + model.getName() + " ID为: " + model.getFunctionsID() + " 是否存在异常!",e); + } + } + } + + /** + * 查找功能信息 + * @return + */ + public void findBy() + { + try + { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(model.getPageSize()); + pageUtil.setCurPage(model.getPageNo()); + pageUtil.setAdvSearch(getCondition()); + functionsService.find(pageUtil); + List dataList = pageUtil.getPageList(); + + //开始拼接json数据 +// {"total":28,"rows":[ +// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"} +// ]} + JSONObject outer = new JSONObject(); + outer.put("total", pageUtil.getTotalCount()); + //存放数据json数组 + JSONArray dataArray = new JSONArray(); + if(null != dataList) + { + for(Functions functions:dataList) + { + JSONObject item = new JSONObject(); + item.put("Id", functions.getId()); + item.put("Number", functions.getNumber()); + item.put("Name", functions.getName()); + item.put("PNumber", functions.getPNumber()); + item.put("URL", functions.getURL()); + item.put("State", functions.getState()); + item.put("Sort", functions.getSort()); + item.put("Enabled", functions.getEnabled()); + item.put("Type", functions.getType()); + item.put("op", 1); + dataArray.add(item); + } + } + outer.put("rows", dataArray); + //回写查询结果 + toClient(outer.toString()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找功能信息异常", e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询功能信息结果异常", e); + } + } + + + /** + * 角色对应功能显示 + * @return + */ + public void findRoleFunctions() + { + try + { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(200); + pageUtil.setAdvSearch(getCondition_RoleFunctions("0")); + functionsService.find(pageUtil); + List dataList = pageUtil.getPageList(); + + //开始拼接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(Functions functions:dataList) + { + JSONObject item = new JSONObject(); + item.put("id", functions.getId()); + item.put("text", functions.getName()); + + //勾选判断1 + Boolean flag = false; + try + { + flag = userBusinessService.checkIsUserBusinessExist("Type",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+functions.getId().toString()+"]"); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!"); + } + if (flag==true){item.put("checked", true);} + //结束 + + pageUtil.setAdvSearch(getCondition_RoleFunctions(functions.getNumber())); + functionsService.find(pageUtil); + List dataList1 = pageUtil.getPageList(); + JSONArray dataArray1 = new JSONArray(); + if(null != dataList1) + { + + for(Functions functions1:dataList1) + { + item.put("state", "open"); //如果不为空,节点不展开 + JSONObject item1 = new JSONObject(); + item1.put("id", functions1.getId()); + item1.put("text", functions1.getName()); + + //勾选判断2 + //Boolean flag = false; + try + { + flag = userBusinessService.checkIsUserBusinessExist("Type",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+functions1.getId().toString()+"]"); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!"); + } + if (flag==true){item1.put("checked", true);} + //结束 + + pageUtil.setAdvSearch(getCondition_RoleFunctions(functions1.getNumber())); + functionsService.find(pageUtil); + List dataList2 = pageUtil.getPageList(); + JSONArray dataArray2 = new JSONArray(); + if(null != dataList2) + { + + for(Functions functions2:dataList2) + { + item1.put("state", "closed"); //如果不为空,节点不展开 + JSONObject item2 = new JSONObject(); + item2.put("id", functions2.getId()); + item2.put("text", functions2.getName()); + + //勾选判断3 + //Boolean flag = false; + try + { + flag = userBusinessService.checkIsUserBusinessExist("Type",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+functions2.getId().toString()+"]"); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!"); + } + if (flag==true){item2.put("checked", true);} + //结束 + + pageUtil.setAdvSearch(getCondition_RoleFunctions(functions2.getNumber())); + functionsService.find(pageUtil); + List dataList3 = pageUtil.getPageList(); + JSONArray dataArray3 = new JSONArray(); + if(null != dataList3) + { + + for(Functions functions3:dataList3) + { + item2.put("state", "closed"); //如果不为空,节点不展开 + JSONObject item3 = new JSONObject(); + item3.put("id", functions3.getId()); + item3.put("text", functions3.getName()); + + //勾选判断4 + //Boolean flag = false; + try + { + flag = userBusinessService.checkIsUserBusinessExist("Type",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+functions3.getId().toString()+"]"); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!"); + } + if (flag==true){item3.put("checked", true);} + //结束 + + dataArray3.add(item3); + item2.put("children", dataArray3); + } + } + + dataArray2.add(item2); + item1.put("children", dataArray2); + } + } + + dataArray1.add(item1); + item.put("children", dataArray1); + } + + } + + dataArray.add(item); + } + outer.put("children", dataArray); + } + //回写查询结果 + toClient("["+outer.toString()+"]"); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找应用异常", e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询应用结果异常", e); + } + } + + + /** + * 页面显示菜单 + * @return + */ + public void findMenu() + { + try + { + String fc=model.getHasFunctions(); //当前用户所拥有的功能列表,格式如:[1][2][5] + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(200); + pageUtil.setAdvSearch(getCondition_RoleFunctions(model.getPNumber())); + functionsService.find(pageUtil); + List dataList = pageUtil.getPageList(); + + //存放数据json数组 + JSONArray dataArray = new JSONArray(); + if(null != dataList) + { + for(Functions functions:dataList) + { + JSONObject item = new JSONObject(); + item.put("id", functions.getId()); + + pageUtil.setAdvSearch(getCondition_RoleFunctions(functions.getNumber())); + functionsService.find(pageUtil); + List dataList1 = pageUtil.getPageList(); + JSONArray dataArray1 = new JSONArray(); + if(dataList1.size()!=0) + { + item.put("text", functions.getName()); //是目录就没链接 + for(Functions functions1:dataList1) + { + item.put("state", "open"); //如果不为空,节点展开 + JSONObject item1 = new JSONObject(); + + pageUtil.setAdvSearch(getCondition_RoleFunctions(functions1.getNumber())); + functionsService.find(pageUtil); + List dataList2 = pageUtil.getPageList(); + if(fc.indexOf("["+functions1.getId().toString()+"]")!=-1||dataList2.size()!=0) + { + item1.put("id", functions1.getId()); + JSONArray dataArray2 = new JSONArray(); + if(dataList2.size()!=0) + { + item1.put("text", functions1.getName());//是目录就没链接 + for(Functions functions2:dataList2) + { + item1.put("state", "closed"); //如果不为空,节点不展开 + JSONObject item2 = new JSONObject(); + + pageUtil.setAdvSearch(getCondition_RoleFunctions(functions2.getNumber())); + functionsService.find(pageUtil); + List dataList3 = pageUtil.getPageList(); + if(fc.indexOf("["+functions2.getId().toString()+"]")!=-1||dataList3.size()!=0) + { + item2.put("id", functions2.getId()); + JSONArray dataArray3 = new JSONArray(); + if(dataList3.size()!=0) + { + item2.put("text", functions2.getName());//是目录就没链接 + for(Functions functions3:dataList3) + { + item2.put("state", "closed"); //如果不为空,节点不展开 + JSONObject item3 = new JSONObject(); + item3.put("id", functions3.getId()); + item3.put("text", functions3.getName()); + // + dataArray3.add(item3); + item2.put("children", dataArray3); + } + } + else + { + //不是目录,有链接 + item2.put("text", ""+functions2.getName()+""); + } + + dataArray2.add(item2); + item1.put("children", dataArray2); + } + } + } + else + { + //不是目录,有链接 + item1.put("text", ""+functions1.getName()+""); + } + + dataArray1.add(item1); + item.put("children", dataArray1); + } + } + } + else + { + //不是目录,有链接 + item.put("text", ""+functions.getName()+""); + } + + dataArray.add(item); + } + } + //回写查询结果 + toClient(dataArray.toString()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找应用异常", e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询应用结果异常", e); + } + } + + /** + * 拼接搜索条件 + * @return + */ + private Map getCondition() + { + /** + * 拼接搜索条件 + */ + Map condition = new HashMap(); + condition.put("Name_s_like", model.getName()); + condition.put("Type_s_eq", model.getType()); + condition.put("Sort_s_order", "asc"); + return condition; + } + + /** + * 拼接搜索条件-角色对应功能 + * @return + */ + private Map getCondition_RoleFunctions(String num) + { + /** + * 拼接搜索条件 + */ + Map condition = new HashMap(); + condition.put("Enabled_n_eq", 1); + condition.put("PNumber_s_eq", num); + condition.put("Sort_s_order", "asc"); + return condition; + } + + //=============以下spring注入以及Model驱动公共方法,与Action处理无关================== + @Override + public FunctionsModel getModel() + { + return model; + } + public void setFunctionsService(FunctionsIService functionsService) + { + this.functionsService = functionsService; + } + + public void setUserBusinessService(UserBusinessIService userBusinessService) { + this.userBusinessService = userBusinessService; + } + +} diff --git a/src/com/jsh/action/basic/RoleAction.java b/src/com/jsh/action/basic/RoleAction.java index eb703031..18067b7f 100644 --- a/src/com/jsh/action/basic/RoleAction.java +++ b/src/com/jsh/action/basic/RoleAction.java @@ -1,347 +1,347 @@ -package com.jsh.action.basic; - -import java.io.IOException; -import java.sql.Timestamp; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - -import org.springframework.dao.DataAccessException; - -import com.jsh.base.BaseAction; -import com.jsh.base.Log; -import com.jsh.exception.AmsException; -import com.jsh.model.po.App; -import com.jsh.model.po.Role; -import com.jsh.model.po.Logdetails; -import com.jsh.model.vo.basic.RoleModel; -import com.jsh.service.basic.RoleIService; -import com.jsh.service.basic.UserBusinessIService; -import com.jsh.util.common.PageUtil; - -@SuppressWarnings("serial") -public class RoleAction extends BaseAction -{ - private RoleIService roleService; - private UserBusinessIService userBusinessService; - private RoleModel model = new RoleModel(); - /** - * 增加角色 - * @return - */ - public void create() - { - Log.infoFileSync("==================开始调用增加角色信息方法create()==================="); - Boolean flag = false; - try - { - Role role = new Role(); - role.setName(model.getName()); - roleService.create(role); - - //========标识位=========== - flag = true; - //记录操作日志使用 - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加角色信息异常", e); - flag = false; - tipMsg = "失败"; - tipType = 1; - } - finally - { - try - { - toClient(flag.toString()); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>增加角色信息回写客户端结果异常", e); - } - } - - logService.create(new Logdetails(getUser(), "增加角色", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "增加角色名称为 "+ model.getName() + " " + tipMsg + "!", "增加角色" + tipMsg)); - Log.infoFileSync("==================结束调用增加角色方法create()==================="); - } - - /** - * 删除角色 - * @return - */ - public String delete() - { - Log.infoFileSync("====================开始调用删除角色信息方法delete()================"); - try - { - roleService.delete(model.getRoleID()); - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getRoleID() + " 的角色异常", e); - tipMsg = "失败"; - tipType = 1; - } - model.getShowModel().setMsgTip(tipMsg); - logService.create(new Logdetails(getUser(), "删除角色", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "删除角色ID为 "+ model.getRoleID() + " " + tipMsg + "!", "删除角色" + tipMsg)); - Log.infoFileSync("====================结束调用删除角色信息方法delete()================"); - return SUCCESS; - } - - /** - * 更新角色 - * @return - */ - public void update() - { - Boolean flag = false; - try - { - Role role = roleService.get(model.getRoleID()); - role.setName(model.getName()); - roleService.update(role); - - flag = true; - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>修改角色ID为 : " + model.getRoleID() + "信息失败", e); - flag = false; - tipMsg = "失败"; - tipType = 1; - } - finally - { - try - { - toClient(flag.toString()); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>修改角色回写客户端结果异常", e); - } - } - logService.create(new Logdetails(getUser(), "更新角色", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "更新角色ID为 "+ model.getRoleID() + " " + tipMsg + "!", "更新角色" + tipMsg)); - } - - /** - * 批量删除指定ID角色 - * @return - */ - public String batchDelete() - { - try - { - roleService.batchDelete(model.getRoleIDs()); - model.getShowModel().setMsgTip("成功"); - //记录操作日志使用 - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>批量删除角色ID为:" + model.getRoleIDs() + "信息异常", e); - tipMsg = "失败"; - tipType = 1; - } - - logService.create(new Logdetails(getUser(), "批量删除角色", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "批量删除角色ID为 "+ model.getRoleIDs() + " " + tipMsg + "!", "批量删除角色" + tipMsg)); - return SUCCESS; - } - - /** - * 检查输入名称是否存在 - */ - public void checkIsNameExist() - { - Boolean flag = false; - try - { - flag = roleService.checkIsNameExist("name",model.getName(),"Id", model.getRoleID()); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>检查角色名称为:" + model.getName() + " ID为: " + model.getRoleID() + " 是否存在异常!"); - } - finally - { - try - { - toClient(flag.toString()); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>回写检查角色名称为:" + model.getName() + " ID为: " + model.getRoleID() + " 是否存在异常!",e); - } - } - } - - /** - * 查找角色信息 - * @return - */ - public void findBy() - { - try - { - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(model.getPageSize()); - pageUtil.setCurPage(model.getPageNo()); - pageUtil.setAdvSearch(getCondition()); - roleService.find(pageUtil); - List dataList = pageUtil.getPageList(); - - //开始拼接json数据 -// {"total":28,"rows":[ -// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"} -// ]} - JSONObject outer = new JSONObject(); - outer.put("total", pageUtil.getTotalCount()); - //存放数据json数组 - JSONArray dataArray = new JSONArray(); - if(null != dataList) - { - for(Role role:dataList) - { - JSONObject item = new JSONObject(); - item.put("Id", role.getId()); - //供应商名称 - item.put("Name", role.getName()); - item.put("op", 1); - dataArray.add(item); - } - } - outer.put("rows", dataArray); - //回写查询结果 - toClient(outer.toString()); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找角色信息异常", e); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询角色信息结果异常", e); - } - } - - /** - * 用户对应角色显示 - * @return - */ - public void findUserRole() - { - try - { - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(100); - //pageUtil.setCurPage(model.getPageNo()); - - pageUtil.setAdvSearch(getCondition_UserRole()); - roleService.find(pageUtil); - List dataList = pageUtil.getPageList(); - - //开始拼接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(Role role:dataList) - { - JSONObject item = new JSONObject(); - item.put("id", role.getId()); - item.put("text", role.getName()); - //勾选判断1 - Boolean flag = false; - try - { - flag = userBusinessService.checkIsUserBusinessExist("Type",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+role.getId().toString()+"]"); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>设置用户对应的角色:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!"); - } - if (flag==true){item.put("checked", true);} - //结束 - dataArray.add(item); - } - } - outer.put("children", dataArray); - //回写查询结果 - toClient("["+outer.toString()+"]"); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找角色异常", e); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询角色结果异常", e); - } - } - - /** - * 拼接搜索条件 - * @return - */ - private Map getCondition() - { - /** - * 拼接搜索条件 - */ - Map condition = new HashMap(); - condition.put("Name_s_like", model.getName()); - condition.put("Id_s_order", "asc"); - return condition; - } - - /** - * 拼接搜索条件-用户对应角色 - * @return - */ - private Map getCondition_UserRole() - { - /** - * 拼接搜索条件 - */ - Map condition = new HashMap(); - condition.put("Id_s_order", "asc"); - return condition; - } - - //=============以下spring注入以及Model驱动公共方法,与Action处理无关================== - @Override - public RoleModel getModel() - { - return model; - } - public void setRoleService(RoleIService roleService) - { - this.roleService = roleService; - } - public void setUserBusinessService(UserBusinessIService userBusinessService) { - this.userBusinessService = userBusinessService; - } -} +package com.jsh.action.basic; + +import java.io.IOException; +import java.sql.Timestamp; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import org.springframework.dao.DataAccessException; + +import com.jsh.base.BaseAction; +import com.jsh.base.Log; +import com.jsh.exception.JshException; +import com.jsh.model.po.App; +import com.jsh.model.po.Role; +import com.jsh.model.po.Logdetails; +import com.jsh.model.vo.basic.RoleModel; +import com.jsh.service.basic.RoleIService; +import com.jsh.service.basic.UserBusinessIService; +import com.jsh.util.common.PageUtil; + +@SuppressWarnings("serial") +public class RoleAction extends BaseAction +{ + private RoleIService roleService; + private UserBusinessIService userBusinessService; + private RoleModel model = new RoleModel(); + /** + * 增加角色 + * @return + */ + public void create() + { + Log.infoFileSync("==================开始调用增加角色信息方法create()==================="); + Boolean flag = false; + try + { + Role role = new Role(); + role.setName(model.getName()); + roleService.create(role); + + //========标识位=========== + flag = true; + //记录操作日志使用 + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加角色信息异常", e); + flag = false; + tipMsg = "失败"; + tipType = 1; + } + finally + { + try + { + toClient(flag.toString()); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>增加角色信息回写客户端结果异常", e); + } + } + + logService.create(new Logdetails(getUser(), "增加角色", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "增加角色名称为 "+ model.getName() + " " + tipMsg + "!", "增加角色" + tipMsg)); + Log.infoFileSync("==================结束调用增加角色方法create()==================="); + } + + /** + * 删除角色 + * @return + */ + public String delete() + { + Log.infoFileSync("====================开始调用删除角色信息方法delete()================"); + try + { + roleService.delete(model.getRoleID()); + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getRoleID() + " 的角色异常", e); + tipMsg = "失败"; + tipType = 1; + } + model.getShowModel().setMsgTip(tipMsg); + logService.create(new Logdetails(getUser(), "删除角色", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "删除角色ID为 "+ model.getRoleID() + " " + tipMsg + "!", "删除角色" + tipMsg)); + Log.infoFileSync("====================结束调用删除角色信息方法delete()================"); + return SUCCESS; + } + + /** + * 更新角色 + * @return + */ + public void update() + { + Boolean flag = false; + try + { + Role role = roleService.get(model.getRoleID()); + role.setName(model.getName()); + roleService.update(role); + + flag = true; + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>修改角色ID为 : " + model.getRoleID() + "信息失败", e); + flag = false; + tipMsg = "失败"; + tipType = 1; + } + finally + { + try + { + toClient(flag.toString()); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>修改角色回写客户端结果异常", e); + } + } + logService.create(new Logdetails(getUser(), "更新角色", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "更新角色ID为 "+ model.getRoleID() + " " + tipMsg + "!", "更新角色" + tipMsg)); + } + + /** + * 批量删除指定ID角色 + * @return + */ + public String batchDelete() + { + try + { + roleService.batchDelete(model.getRoleIDs()); + model.getShowModel().setMsgTip("成功"); + //记录操作日志使用 + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>批量删除角色ID为:" + model.getRoleIDs() + "信息异常", e); + tipMsg = "失败"; + tipType = 1; + } + + logService.create(new Logdetails(getUser(), "批量删除角色", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "批量删除角色ID为 "+ model.getRoleIDs() + " " + tipMsg + "!", "批量删除角色" + tipMsg)); + return SUCCESS; + } + + /** + * 检查输入名称是否存在 + */ + public void checkIsNameExist() + { + Boolean flag = false; + try + { + flag = roleService.checkIsNameExist("name",model.getName(),"Id", model.getRoleID()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>检查角色名称为:" + model.getName() + " ID为: " + model.getRoleID() + " 是否存在异常!"); + } + finally + { + try + { + toClient(flag.toString()); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>回写检查角色名称为:" + model.getName() + " ID为: " + model.getRoleID() + " 是否存在异常!",e); + } + } + } + + /** + * 查找角色信息 + * @return + */ + public void findBy() + { + try + { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(model.getPageSize()); + pageUtil.setCurPage(model.getPageNo()); + pageUtil.setAdvSearch(getCondition()); + roleService.find(pageUtil); + List dataList = pageUtil.getPageList(); + + //开始拼接json数据 +// {"total":28,"rows":[ +// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"} +// ]} + JSONObject outer = new JSONObject(); + outer.put("total", pageUtil.getTotalCount()); + //存放数据json数组 + JSONArray dataArray = new JSONArray(); + if(null != dataList) + { + for(Role role:dataList) + { + JSONObject item = new JSONObject(); + item.put("Id", role.getId()); + //供应商名称 + item.put("Name", role.getName()); + item.put("op", 1); + dataArray.add(item); + } + } + outer.put("rows", dataArray); + //回写查询结果 + toClient(outer.toString()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找角色信息异常", e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询角色信息结果异常", e); + } + } + + /** + * 用户对应角色显示 + * @return + */ + public void findUserRole() + { + try + { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(100); + //pageUtil.setCurPage(model.getPageNo()); + + pageUtil.setAdvSearch(getCondition_UserRole()); + roleService.find(pageUtil); + List dataList = pageUtil.getPageList(); + + //开始拼接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(Role role:dataList) + { + JSONObject item = new JSONObject(); + item.put("id", role.getId()); + item.put("text", role.getName()); + //勾选判断1 + Boolean flag = false; + try + { + flag = userBusinessService.checkIsUserBusinessExist("Type",model.getUBType(),"KeyId",model.getUBKeyId(),"Value","["+role.getId().toString()+"]"); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>设置用户对应的角色:类型" + model.getUBType() + " KeyId为: " + model.getUBKeyId() + " 存在异常!"); + } + if (flag==true){item.put("checked", true);} + //结束 + dataArray.add(item); + } + } + outer.put("children", dataArray); + //回写查询结果 + toClient("["+outer.toString()+"]"); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找角色异常", e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询角色结果异常", e); + } + } + + /** + * 拼接搜索条件 + * @return + */ + private Map getCondition() + { + /** + * 拼接搜索条件 + */ + Map condition = new HashMap(); + condition.put("Name_s_like", model.getName()); + condition.put("Id_s_order", "asc"); + return condition; + } + + /** + * 拼接搜索条件-用户对应角色 + * @return + */ + private Map getCondition_UserRole() + { + /** + * 拼接搜索条件 + */ + Map condition = new HashMap(); + condition.put("Id_s_order", "asc"); + return condition; + } + + //=============以下spring注入以及Model驱动公共方法,与Action处理无关================== + @Override + public RoleModel getModel() + { + return model; + } + public void setRoleService(RoleIService roleService) + { + this.roleService = roleService; + } + public void setUserBusinessService(UserBusinessIService userBusinessService) { + this.userBusinessService = userBusinessService; + } +} diff --git a/src/com/jsh/action/basic/UserAction.java b/src/com/jsh/action/basic/UserAction.java index f4332da7..813fc23b 100644 --- a/src/com/jsh/action/basic/UserAction.java +++ b/src/com/jsh/action/basic/UserAction.java @@ -41,6 +41,7 @@ public class UserAction extends BaseAction try { password = Tools.md5Encryp(password); + System.out.println(password); } catch (NoSuchAlgorithmException e) { @@ -136,7 +137,7 @@ public class UserAction extends BaseAction user.setIsystem((short)1); user.setIsmanager((short)1); user.setLoginame(model.getLoginame()); - String password ="00000000"; + String password ="123456"; //因密码用MD5加密,需要对密码进行转化 try { diff --git a/src/com/jsh/action/materials/BuildingAction.java b/src/com/jsh/action/materials/BuildingAction.java index 8dce4739..a6b8e06c 100644 --- a/src/com/jsh/action/materials/BuildingAction.java +++ b/src/com/jsh/action/materials/BuildingAction.java @@ -1,277 +1,277 @@ -package com.jsh.action.materials; - -import java.io.IOException; -import java.sql.Timestamp; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - -import org.springframework.dao.DataAccessException; - -import com.jsh.base.BaseAction; -import com.jsh.base.Log; -import com.jsh.model.po.Depot; -import com.jsh.model.po.Building; -import com.jsh.model.po.Logdetails; -import com.jsh.model.vo.materials.BuildingModel; -import com.jsh.service.materials.BuildingIService; -import com.jsh.util.common.PageUtil; - -@SuppressWarnings("serial") -public class BuildingAction extends BaseAction -{ - private BuildingIService buildingService; - private BuildingModel model = new BuildingModel(); - - - @SuppressWarnings({ "rawtypes", "unchecked" }) - public String getBasicData() - { - Map mapData = model.getShowModel().getMap(); - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(0); - pageUtil.setCurPage(0); - try - { - Map condition = pageUtil.getAdvSearch(); - condition.put("ProjectId_n_eq", model.getProjectId()); - condition.put("Id_s_order", "asc"); - buildingService.find(pageUtil); - mapData.put("buildingList", pageUtil.getPageList()); - } - catch (Exception e) - { - Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e); - model.getShowModel().setMsgTip("exceptoin"); - } - return SUCCESS; - } - /** - * 增加单元 - * @return - */ - public void create() - { - Log.infoFileSync("==================开始调用增加单元信息方法create()==================="); - Boolean flag = false; - try - { - Building building = new Building(); - building.setDepot(new Depot(model.getProjectId())); - - building.setName(model.getName()); - building.setRemark(model.getRemark()); - building.setEnabled(model.getEnabled()); - buildingService.create(building); - - //========标识位=========== - flag = true; - //记录操作日志使用 - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加单元信息异常", e); - flag = false; - tipMsg = "失败"; - tipType = 1; - } - finally - { - try - { - toClient(flag.toString()); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>增加单元信息回写客户端结果异常", e); - } - } - - logService.create(new Logdetails(getUser(), "增加单元", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "增加单元名称为 "+ model.getName() + " " + tipMsg + "!", "增加单元" + tipMsg)); - Log.infoFileSync("==================结束调用增加单元方法create()==================="); - } - - /** - * 删除单元 - * @return - */ - public String delete() - { - Log.infoFileSync("====================开始调用删除单元信息方法delete()================"); - try - { - buildingService.delete(model.getBuildingID()); - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getBuildingID() + " 的单元异常", e); - tipMsg = "失败"; - tipType = 1; - } - model.getShowModel().setMsgTip(tipMsg); - logService.create(new Logdetails(getUser(), "删除单元", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "删除单元ID为 "+ model.getBuildingID() + " " + tipMsg + "!", "删除单元" + tipMsg)); - Log.infoFileSync("====================结束调用删除单元信息方法delete()================"); - return SUCCESS; - } - - /** - * 更新单元 - * @return - */ - public void update() - { - Boolean flag = false; - try - { - Building building = buildingService.get(model.getBuildingID()); - building.setDepot(new Depot(model.getProjectId())); - - building.setName(model.getName()); - building.setRemark(model.getRemark()); - building.setEnabled(model.getEnabled()); - buildingService.update(building); - - flag = true; - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>修改单元ID为 : " + model.getBuildingID() + "信息失败", e); - flag = false; - tipMsg = "失败"; - tipType = 1; - } - finally - { - try - { - toClient(flag.toString()); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>修改单元回写客户端结果异常", e); - } - } - logService.create(new Logdetails(getUser(), "更新单元", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "更新单元ID为 "+ model.getBuildingID() + " " + tipMsg + "!", "更新单元" + tipMsg)); - } - - /** - * 批量删除指定ID单元 - * @return - */ - public String batchDelete() - { - try - { - buildingService.batchDelete(model.getBuildingIDs()); - model.getShowModel().setMsgTip("成功"); - //记录操作日志使用 - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>批量删除单元ID为:" + model.getBuildingIDs() + "信息异常", e); - tipMsg = "失败"; - tipType = 1; - } - - logService.create(new Logdetails(getUser(), "批量删除单元", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "批量删除单元ID为 "+ model.getBuildingIDs() + " " + tipMsg + "!", "批量删除单元" + tipMsg)); - return SUCCESS; - } - - /** - * 查找单元信息 - * @return - */ - public void findBy() - { - try - { - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(model.getPageSize()); - pageUtil.setCurPage(model.getPageNo()); - pageUtil.setAdvSearch(getCondition()); - buildingService.find(pageUtil); - List dataList = pageUtil.getPageList(); - - //开始拼接json数据 -// {"total":28,"rows":[ -// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"} -// ]} - JSONObject outer = new JSONObject(); - outer.put("total", pageUtil.getTotalCount()); - //存放数据json数组 - JSONArray dataArray = new JSONArray(); - if(null != dataList) - { - for(Building building:dataList) - { - JSONObject item = new JSONObject(); - item.put("Id", building.getId()); - item.put("ProjectId", building.getDepot().getId()); - item.put("ProjectName", building.getDepot().getName()); - item.put("Name", building.getName()); - item.put("Remark", building.getRemark()); - item.put("Enabled", building.getEnabled()); - item.put("op", 1); - dataArray.add(item); - } - } - outer.put("rows", dataArray); - //回写查询结果 - toClient(outer.toString()); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找单元信息异常", e); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询单元信息结果异常", e); - } - } - - /** - * 拼接搜索条件 - * @return - */ - private Map getCondition() - { - /** - * 拼接搜索条件 - */ - Map condition = new HashMap(); - condition.put("ProjectId_n_eq", model.getProjectId()); - condition.put("Name_s_like", model.getName()); - condition.put("Id_s_order", "asc"); - return condition; - } - - //=============以下spring注入以及Model驱动公共方法,与Action处理无关================== - @Override - public BuildingModel getModel() - { - return model; - } - public void setBuildingService(BuildingIService buildingService) - { - this.buildingService = buildingService; - } -} +package com.jsh.action.materials; + +import java.io.IOException; +import java.sql.Timestamp; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import org.springframework.dao.DataAccessException; + +import com.jsh.base.BaseAction; +import com.jsh.base.Log; +import com.jsh.model.po.Depot; +import com.jsh.model.po.Building; +import com.jsh.model.po.Logdetails; +import com.jsh.model.vo.materials.BuildingModel; +import com.jsh.service.materials.BuildingIService; +import com.jsh.util.common.PageUtil; + +@SuppressWarnings("serial") +public class BuildingAction extends BaseAction +{ + private BuildingIService buildingService; + private BuildingModel model = new BuildingModel(); + + + @SuppressWarnings({ "rawtypes", "unchecked" }) + public String getBasicData() + { + Map mapData = model.getShowModel().getMap(); + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(0); + pageUtil.setCurPage(0); + try + { + Map condition = pageUtil.getAdvSearch(); + condition.put("ProjectId_n_eq", model.getProjectId()); + condition.put("Id_s_order", "asc"); + buildingService.find(pageUtil); + mapData.put("buildingList", pageUtil.getPageList()); + } + catch (Exception e) + { + Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e); + model.getShowModel().setMsgTip("exceptoin"); + } + return SUCCESS; + } + /** + * 增加单元 + * @return + */ + public void create() + { + Log.infoFileSync("==================开始调用增加单元信息方法create()==================="); + Boolean flag = false; + try + { + Building building = new Building(); + building.setDepot(new Depot(model.getProjectId())); + + building.setName(model.getName()); + building.setRemark(model.getRemark()); + building.setEnabled(model.getEnabled()); + buildingService.create(building); + + //========标识位=========== + flag = true; + //记录操作日志使用 + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>增加单元信息异常", e); + flag = false; + tipMsg = "失败"; + tipType = 1; + } + finally + { + try + { + toClient(flag.toString()); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>增加单元信息回写客户端结果异常", e); + } + } + + logService.create(new Logdetails(getUser(), "增加单元", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "增加单元名称为 "+ model.getName() + " " + tipMsg + "!", "增加单元" + tipMsg)); + Log.infoFileSync("==================结束调用增加单元方法create()==================="); + } + + /** + * 删除单元 + * @return + */ + public String delete() + { + Log.infoFileSync("====================开始调用删除单元信息方法delete()================"); + try + { + buildingService.delete(model.getBuildingID()); + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>删除ID为 " + model.getBuildingID() + " 的单元异常", e); + tipMsg = "失败"; + tipType = 1; + } + model.getShowModel().setMsgTip(tipMsg); + logService.create(new Logdetails(getUser(), "删除单元", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "删除单元ID为 "+ model.getBuildingID() + " " + tipMsg + "!", "删除单元" + tipMsg)); + Log.infoFileSync("====================结束调用删除单元信息方法delete()================"); + return SUCCESS; + } + + /** + * 更新单元 + * @return + */ + public void update() + { + Boolean flag = false; + try + { + Building building = buildingService.get(model.getBuildingID()); + building.setDepot(new Depot(model.getProjectId())); + + building.setName(model.getName()); + building.setRemark(model.getRemark()); + building.setEnabled(model.getEnabled()); + buildingService.update(building); + + flag = true; + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>修改单元ID为 : " + model.getBuildingID() + "信息失败", e); + flag = false; + tipMsg = "失败"; + tipType = 1; + } + finally + { + try + { + toClient(flag.toString()); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>修改单元回写客户端结果异常", e); + } + } + logService.create(new Logdetails(getUser(), "更新单元", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "更新单元ID为 "+ model.getBuildingID() + " " + tipMsg + "!", "更新单元" + tipMsg)); + } + + /** + * 批量删除指定ID单元 + * @return + */ + public String batchDelete() + { + try + { + buildingService.batchDelete(model.getBuildingIDs()); + model.getShowModel().setMsgTip("成功"); + //记录操作日志使用 + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>批量删除单元ID为:" + model.getBuildingIDs() + "信息异常", e); + tipMsg = "失败"; + tipType = 1; + } + + logService.create(new Logdetails(getUser(), "批量删除单元", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "批量删除单元ID为 "+ model.getBuildingIDs() + " " + tipMsg + "!", "批量删除单元" + tipMsg)); + return SUCCESS; + } + + /** + * 查找单元信息 + * @return + */ + public void findBy() + { + try + { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(model.getPageSize()); + pageUtil.setCurPage(model.getPageNo()); + pageUtil.setAdvSearch(getCondition()); + buildingService.find(pageUtil); + List dataList = pageUtil.getPageList(); + + //开始拼接json数据 +// {"total":28,"rows":[ +// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"} +// ]} + JSONObject outer = new JSONObject(); + outer.put("total", pageUtil.getTotalCount()); + //存放数据json数组 + JSONArray dataArray = new JSONArray(); + if(null != dataList) + { + for(Building building:dataList) + { + JSONObject item = new JSONObject(); + item.put("Id", building.getId()); + item.put("ProjectId", building.getDepot().getId()); + item.put("ProjectName", building.getDepot().getName()); + item.put("Name", building.getName()); + item.put("Remark", building.getRemark()); + item.put("Enabled", building.getEnabled()); + item.put("op", 1); + dataArray.add(item); + } + } + outer.put("rows", dataArray); + //回写查询结果 + toClient(outer.toString()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找单元信息异常", e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询单元信息结果异常", e); + } + } + + /** + * 拼接搜索条件 + * @return + */ + private Map getCondition() + { + /** + * 拼接搜索条件 + */ + Map condition = new HashMap(); + condition.put("ProjectId_n_eq", model.getProjectId()); + condition.put("Name_s_like", model.getName()); + condition.put("Id_s_order", "asc"); + return condition; + } + + //=============以下spring注入以及Model驱动公共方法,与Action处理无关================== + @Override + public BuildingModel getModel() + { + return model; + } + public void setBuildingService(BuildingIService buildingService) + { + this.buildingService = buildingService; + } +} diff --git a/src/com/jsh/action/materials/DepotItemAction.java b/src/com/jsh/action/materials/DepotItemAction.java index 944edcb6..ada1ba3b 100644 --- a/src/com/jsh/action/materials/DepotItemAction.java +++ b/src/com/jsh/action/materials/DepotItemAction.java @@ -1,395 +1,395 @@ -package com.jsh.action.materials; - -import java.io.File; -import java.io.IOException; -import java.sql.Timestamp; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletResponse; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - -import org.springframework.dao.DataAccessException; - -import com.jsh.base.BaseAction; -import com.jsh.base.Log; -import com.jsh.constants.asset.AssetConstants; -import com.jsh.exception.AmsException; -import com.jsh.model.po.Asset; -import com.jsh.model.po.DepotHead; -import com.jsh.model.po.DepotItem; -import com.jsh.model.po.Logdetails; -import com.jsh.model.po.Material; -import com.jsh.model.vo.materials.DepotItemModel; -import com.jsh.service.materials.DepotHeadIService; -import com.jsh.service.materials.DepotItemIService; -import com.jsh.util.common.PageUtil; -import com.jsh.util.common.Tools; - -@SuppressWarnings("serial") -public class DepotItemAction extends BaseAction -{ - private DepotItemIService depotItemService; - private DepotItemModel model = new DepotItemModel(); - /** - * action返回excel结果 - */ - public static final String EXCEL = "excel"; - - /** - * 保存明细 - * @return - */ - public void saveDetials() - { - Log.infoFileSync("==================开始调用保存仓管通明细信息方法saveDetials()==================="); - Boolean flag = false; - try - { - Long headerId=model.getHeaderId(); - String inserted=model.getInserted(); - String deleted=model.getDeleted(); - String updated=model.getUpdated(); - //转为json - JSONArray insertedJson = JSONArray.fromObject(inserted); - JSONArray deletedJson = JSONArray.fromObject(deleted); - JSONArray updatedJson = JSONArray.fromObject(updated); - if(null != insertedJson) - { - for(int i = 0;i < insertedJson.size(); i++) - { - DepotItem depotItem = new DepotItem(); - JSONObject tempInsertedJson = JSONObject.fromObject(insertedJson.get(i)); - depotItem.setHeaderId(new DepotHead(headerId)); - depotItem.setMaterialId(new Material(tempInsertedJson.getLong("MaterialId"))); - depotItem.setOperNumber(tempInsertedJson.getDouble("OperNumber")); - if(tempInsertedJson.get("UnitPrice")!=null){depotItem.setUnitPrice(tempInsertedJson.getDouble("UnitPrice"));} - if(tempInsertedJson.get("Incidentals")!=null){depotItem.setIncidentals(0.0);} - depotItem.setRemark(tempInsertedJson.getString("Remark")); - depotItem.setImg(tempInsertedJson.getString("Img")); - depotItemService.create(depotItem); - } - } - if(null != deletedJson) - { - for(int i = 0;i < deletedJson.size(); i++) - { - JSONObject tempDeletedJson = JSONObject.fromObject(deletedJson.get(i)); - depotItemService.delete(tempDeletedJson.getLong("Id")); - } - } - if(null != updatedJson) - { - for(int i = 0;i < updatedJson.size(); i++) - { - JSONObject tempUpdatedJson = JSONObject.fromObject(updatedJson.get(i)); - DepotItem depotItem = depotItemService.get(tempUpdatedJson.getLong("Id")); - depotItem.setMaterialId(new Material(tempUpdatedJson.getLong("MaterialId"))); - depotItem.setOperNumber(tempUpdatedJson.getDouble("OperNumber")); - if(tempUpdatedJson.get("UnitPrice")!=null){depotItem.setUnitPrice(tempUpdatedJson.getDouble("UnitPrice"));} - if(tempUpdatedJson.get("Incidentals")!=null){depotItem.setIncidentals(0.0);} - depotItem.setRemark(tempUpdatedJson.getString("Remark")); - depotItem.setImg(tempUpdatedJson.getString("Img")); - depotItemService.create(depotItem); - } - } - - //========标识位=========== - flag = true; - //记录操作日志使用 - tipMsg = "成功"; - tipType = 0; - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>保存仓管通明细信息异常", e); - flag = false; - tipMsg = "失败"; - tipType = 1; - } - finally - { - try - { - toClient(flag.toString()); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>保存仓管通明细信息回写客户端结果异常", e); - } - } - - logService.create(new Logdetails(getUser(), "保存仓管通明细", model.getClientIp(), - new Timestamp(System.currentTimeMillis()) - , tipType, "保存仓管通明细对应主表编号为 "+ model.getHeaderId() + " " + tipMsg + "!", "保存仓管通明细" + tipMsg)); - Log.infoFileSync("==================结束调用保存仓管通明细方法saveDetials()==================="); - } - - - /** - * 查找仓管通信息 - * @return - */ - public void findBy() - { - try - { - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(model.getPageSize()); - pageUtil.setCurPage(model.getPageNo()); - pageUtil.setAdvSearch(getCondition()); - depotItemService.find(pageUtil); - List dataList = pageUtil.getPageList(); - - //开始拼接json数据 -// {"total":28,"rows":[ -// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"} -// ]} - JSONObject outer = new JSONObject(); - outer.put("total", pageUtil.getTotalCount()); - //存放数据json数组 - JSONArray dataArray = new JSONArray(); - if(null != dataList) - { - for(DepotItem depotItem:dataList) - { - JSONObject item = new JSONObject(); - item.put("Id", depotItem.getId()); - item.put("MaterialId", depotItem.getMaterialId()==null?"":depotItem.getMaterialId().getId()); - item.put("MaterialName", ((depotItem.getMaterialId().getModel().equals(""))?"":""+depotItem.getMaterialId().getModel())+" "+depotItem.getMaterialId().getName()+((depotItem.getMaterialId().getColor() == null)?"(":"("+depotItem.getMaterialId().getColor()) + ")"); - item.put("OperNumber", depotItem.getOperNumber()); - item.put("UnitPrice", depotItem.getUnitPrice()); - item.put("Incidentals", depotItem.getIncidentals()); - item.put("Remark", depotItem.getRemark()); - item.put("Img", depotItem.getImg()); - item.put("op", 1); - dataArray.add(item); - } - } - outer.put("rows", dataArray); - //回写查询结果 - toClient(outer.toString()); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓管通信息异常", e); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓管通信息结果异常", e); - } - } - - /** - * 查找进销存 - * @return - */ - public void findByAll() - { - try - { - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(model.getPageSize()); - pageUtil.setCurPage(model.getPageNo()); - pageUtil.setAdvSearch(getConditionALL()); - depotItemService.find(pageUtil); - List dataList = pageUtil.getPageList(); - - JSONObject outer = new JSONObject(); - outer.put("total", pageUtil.getTotalCount()); - //存放数据json数组 - JSONArray dataArray = new JSONArray(); - if(null != dataList) - { - for(DepotItem depotItem:dataList) - { - JSONObject item = new JSONObject(); - Integer prevSum = sumNumber("入库",depotItem.getMaterialId().getId(),model.getMonthTime(),true) - sumNumber("出库",depotItem.getMaterialId().getId(),model.getMonthTime(),true); - Integer InSum = sumNumber("入库",depotItem.getMaterialId().getId(),model.getMonthTime(),false); - Integer OutSum = sumNumber("出库",depotItem.getMaterialId().getId(),model.getMonthTime(),false); - item.put("Id", depotItem.getId()); - item.put("MaterialId", depotItem.getMaterialId()==null?"":depotItem.getMaterialId().getId()); - item.put("MaterialName", depotItem.getMaterialId().getName()); - item.put("MaterialModel", depotItem.getMaterialId().getModel()); - item.put("MaterialColor", depotItem.getMaterialId().getColor()); - item.put("prevSum", prevSum); - item.put("InSum", InSum); - item.put("OutSum", OutSum); - item.put("thisSum", prevSum + InSum - OutSum); - item.put("thisAllPrice", depotItem.getUnitPrice() * (prevSum + InSum - OutSum)); - item.put("UnitPrice", depotItem.getUnitPrice()); - dataArray.add(item); - } - } - outer.put("rows", dataArray); - //回写查询结果 - toClient(outer.toString()); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找信息异常", e); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e); - } - } - - /** - * 统计总计金额 - * @return - */ - public void totalCountMoney() - { - try - { - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(0); - pageUtil.setCurPage(0); - pageUtil.setAdvSearch(getConditionALL()); - depotItemService.find(pageUtil); - List dataList = pageUtil.getPageList(); - - JSONObject outer = new JSONObject(); - Double thisAllPrice = 0.0; - if(null != dataList) - { - for(DepotItem depotItem:dataList) - { - Integer prevSum = sumNumber("入库",depotItem.getMaterialId().getId(),model.getMonthTime(),true) - sumNumber("出库",depotItem.getMaterialId().getId(),model.getMonthTime(),true); - Integer InSum = sumNumber("入库",depotItem.getMaterialId().getId(),model.getMonthTime(),false); - Integer OutSum = sumNumber("出库",depotItem.getMaterialId().getId(),model.getMonthTime(),false); - thisAllPrice = thisAllPrice + depotItem.getUnitPrice() * (prevSum + InSum - OutSum); - } - } - outer.put("totalCount", thisAllPrice); - //回写查询结果 - toClient(outer.toString()); - } - catch (DataAccessException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找信息异常", e); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e); - } - } - - /** - * 导出excel表格 - * @return - */ - @SuppressWarnings("unchecked") - public String exportExcel() - { - Log.infoFileSync("===================调用导出信息action方法exportExcel开始======================="); - try - { - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(model.getPageSize()); - pageUtil.setCurPage(model.getPageNo()); - pageUtil.setAdvSearch(getConditionALL()); - depotItemService.find(pageUtil); - List dataList = pageUtil.getPageList(); - - //存放数据json数组 - JSONArray dataArray = new JSONArray(); - if(null != dataList) - { - for(DepotItem depotItem:dataList) - { - JSONObject item = new JSONObject(); - Integer prevSum = sumNumber("入库",depotItem.getMaterialId().getId(),model.getMonthTime(),true) - sumNumber("出库",depotItem.getMaterialId().getId(),model.getMonthTime(),true); - Integer InSum = sumNumber("入库",depotItem.getMaterialId().getId(),model.getMonthTime(),false); - Integer OutSum = sumNumber("出库",depotItem.getMaterialId().getId(),model.getMonthTime(),false); - item.put("Id", depotItem.getId()); - item.put("MaterialId", depotItem.getMaterialId()==null?"":depotItem.getMaterialId().getId()); - item.put("MaterialName", depotItem.getMaterialId().getName()); - item.put("MaterialModel", depotItem.getMaterialId().getModel()); - item.put("MaterialColor", depotItem.getMaterialId().getColor()); - item.put("prevSum", prevSum); - item.put("InSum", InSum); - item.put("OutSum", OutSum); - item.put("thisSum", prevSum + InSum - OutSum); - item.put("thisAllPrice", depotItem.getUnitPrice() * (prevSum + InSum - OutSum)); - item.put("UnitPrice", depotItem.getUnitPrice()); - dataArray.add(item); - } - } - String isCurrentPage = "allPage"; - model.setFileName(Tools.changeUnicode("report.xls",model.getBrowserType())); - model.setExcelStream(depotItemService.exmportExcel(isCurrentPage,dataArray)); - } - catch (Exception e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>调用导出信息action方法exportExcel异常",e); - model.getShowModel().setMsgTip("export excel exception"); - } - Log.infoFileSync("===================调用导出信息action方法exportExcel结束=================="); - return EXCEL; - } - - @SuppressWarnings("unchecked") - public Integer sumNumber(String type,Long MId,String MonthTime, Boolean isPrev) { - Integer sumNumber = 0; - String allNumber = ""; - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(0); - pageUtil.setCurPage(0); - try { - depotItemService.findByType(pageUtil, type, MId, MonthTime, isPrev); - allNumber = pageUtil.getPageList().toString(); - allNumber = allNumber.substring(1,allNumber.length()-1); - if(allNumber.equals("null")){ - allNumber = "0"; - } - allNumber = allNumber.replace(".0", ""); - } catch (AmsException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - sumNumber = Integer.parseInt(allNumber); - return sumNumber; - } - /** - * 拼接搜索条件 - * @return - */ - private Map getCondition() - { - /** - * 拼接搜索条件 - */ - Map condition = new HashMap(); - condition.put("HeaderId_n_eq", model.getHeaderId()); - condition.put("Id_s_order","asc"); - return condition; - } - - private Map getConditionALL() - { - /** - * 拼接搜索条件 - */ - Map condition = new HashMap(); - condition.put("HeaderId_s_in", model.getHeadIds()); - condition.put("MaterialId_s_in", model.getMaterialIds()); - condition.put("MaterialId_s_gb","aaa"); - return condition; - } - - //=============以下spring注入以及Model驱动公共方法,与Action处理无关================== - @Override - public DepotItemModel getModel() - { - return model; - } - public void setDepotItemService(DepotItemIService depotItemService) - { - this.depotItemService = depotItemService; - } -} +package com.jsh.action.materials; + +import java.io.File; +import java.io.IOException; +import java.sql.Timestamp; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletResponse; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import org.springframework.dao.DataAccessException; + +import com.jsh.base.BaseAction; +import com.jsh.base.Log; +import com.jsh.constants.asset.AssetConstants; +import com.jsh.exception.JshException; +import com.jsh.model.po.Asset; +import com.jsh.model.po.DepotHead; +import com.jsh.model.po.DepotItem; +import com.jsh.model.po.Logdetails; +import com.jsh.model.po.Material; +import com.jsh.model.vo.materials.DepotItemModel; +import com.jsh.service.materials.DepotHeadIService; +import com.jsh.service.materials.DepotItemIService; +import com.jsh.util.common.PageUtil; +import com.jsh.util.common.Tools; + +@SuppressWarnings("serial") +public class DepotItemAction extends BaseAction +{ + private DepotItemIService depotItemService; + private DepotItemModel model = new DepotItemModel(); + /** + * action返回excel结果 + */ + public static final String EXCEL = "excel"; + + /** + * 保存明细 + * @return + */ + public void saveDetials() + { + Log.infoFileSync("==================开始调用保存仓管通明细信息方法saveDetials()==================="); + Boolean flag = false; + try + { + Long headerId=model.getHeaderId(); + String inserted=model.getInserted(); + String deleted=model.getDeleted(); + String updated=model.getUpdated(); + //转为json + JSONArray insertedJson = JSONArray.fromObject(inserted); + JSONArray deletedJson = JSONArray.fromObject(deleted); + JSONArray updatedJson = JSONArray.fromObject(updated); + if(null != insertedJson) + { + for(int i = 0;i < insertedJson.size(); i++) + { + DepotItem depotItem = new DepotItem(); + JSONObject tempInsertedJson = JSONObject.fromObject(insertedJson.get(i)); + depotItem.setHeaderId(new DepotHead(headerId)); + depotItem.setMaterialId(new Material(tempInsertedJson.getLong("MaterialId"))); + depotItem.setOperNumber(tempInsertedJson.getDouble("OperNumber")); + if(tempInsertedJson.get("UnitPrice")!=null){depotItem.setUnitPrice(tempInsertedJson.getDouble("UnitPrice"));} + if(tempInsertedJson.get("Incidentals")!=null){depotItem.setIncidentals(0.0);} + depotItem.setRemark(tempInsertedJson.getString("Remark")); + depotItem.setImg(tempInsertedJson.getString("Img")); + depotItemService.create(depotItem); + } + } + if(null != deletedJson) + { + for(int i = 0;i < deletedJson.size(); i++) + { + JSONObject tempDeletedJson = JSONObject.fromObject(deletedJson.get(i)); + depotItemService.delete(tempDeletedJson.getLong("Id")); + } + } + if(null != updatedJson) + { + for(int i = 0;i < updatedJson.size(); i++) + { + JSONObject tempUpdatedJson = JSONObject.fromObject(updatedJson.get(i)); + DepotItem depotItem = depotItemService.get(tempUpdatedJson.getLong("Id")); + depotItem.setMaterialId(new Material(tempUpdatedJson.getLong("MaterialId"))); + depotItem.setOperNumber(tempUpdatedJson.getDouble("OperNumber")); + if(tempUpdatedJson.get("UnitPrice")!=null){depotItem.setUnitPrice(tempUpdatedJson.getDouble("UnitPrice"));} + if(tempUpdatedJson.get("Incidentals")!=null){depotItem.setIncidentals(0.0);} + depotItem.setRemark(tempUpdatedJson.getString("Remark")); + depotItem.setImg(tempUpdatedJson.getString("Img")); + depotItemService.create(depotItem); + } + } + + //========标识位=========== + flag = true; + //记录操作日志使用 + tipMsg = "成功"; + tipType = 0; + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>保存仓管通明细信息异常", e); + flag = false; + tipMsg = "失败"; + tipType = 1; + } + finally + { + try + { + toClient(flag.toString()); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>保存仓管通明细信息回写客户端结果异常", e); + } + } + + logService.create(new Logdetails(getUser(), "保存仓管通明细", model.getClientIp(), + new Timestamp(System.currentTimeMillis()) + , tipType, "保存仓管通明细对应主表编号为 "+ model.getHeaderId() + " " + tipMsg + "!", "保存仓管通明细" + tipMsg)); + Log.infoFileSync("==================结束调用保存仓管通明细方法saveDetials()==================="); + } + + + /** + * 查找仓管通信息 + * @return + */ + public void findBy() + { + try + { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(model.getPageSize()); + pageUtil.setCurPage(model.getPageNo()); + pageUtil.setAdvSearch(getCondition()); + depotItemService.find(pageUtil); + List dataList = pageUtil.getPageList(); + + //开始拼接json数据 +// {"total":28,"rows":[ +// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"} +// ]} + JSONObject outer = new JSONObject(); + outer.put("total", pageUtil.getTotalCount()); + //存放数据json数组 + JSONArray dataArray = new JSONArray(); + if(null != dataList) + { + for(DepotItem depotItem:dataList) + { + JSONObject item = new JSONObject(); + item.put("Id", depotItem.getId()); + item.put("MaterialId", depotItem.getMaterialId()==null?"":depotItem.getMaterialId().getId()); + item.put("MaterialName", ((depotItem.getMaterialId().getModel().equals(""))?"":""+depotItem.getMaterialId().getModel())+" "+depotItem.getMaterialId().getName()+((depotItem.getMaterialId().getColor() == null)?"(":"("+depotItem.getMaterialId().getColor()) + ")"); + item.put("OperNumber", depotItem.getOperNumber()); + item.put("UnitPrice", depotItem.getUnitPrice()); + item.put("Incidentals", depotItem.getIncidentals()); + item.put("Remark", depotItem.getRemark()); + item.put("Img", depotItem.getImg()); + item.put("op", 1); + dataArray.add(item); + } + } + outer.put("rows", dataArray); + //回写查询结果 + toClient(outer.toString()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找仓管通信息异常", e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询仓管通信息结果异常", e); + } + } + + /** + * 查找进销存 + * @return + */ + public void findByAll() + { + try + { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(model.getPageSize()); + pageUtil.setCurPage(model.getPageNo()); + pageUtil.setAdvSearch(getConditionALL()); + depotItemService.find(pageUtil); + List dataList = pageUtil.getPageList(); + + JSONObject outer = new JSONObject(); + outer.put("total", pageUtil.getTotalCount()); + //存放数据json数组 + JSONArray dataArray = new JSONArray(); + if(null != dataList) + { + for(DepotItem depotItem:dataList) + { + JSONObject item = new JSONObject(); + Integer prevSum = sumNumber("入库",depotItem.getMaterialId().getId(),model.getMonthTime(),true) - sumNumber("出库",depotItem.getMaterialId().getId(),model.getMonthTime(),true); + Integer InSum = sumNumber("入库",depotItem.getMaterialId().getId(),model.getMonthTime(),false); + Integer OutSum = sumNumber("出库",depotItem.getMaterialId().getId(),model.getMonthTime(),false); + item.put("Id", depotItem.getId()); + item.put("MaterialId", depotItem.getMaterialId()==null?"":depotItem.getMaterialId().getId()); + item.put("MaterialName", depotItem.getMaterialId().getName()); + item.put("MaterialModel", depotItem.getMaterialId().getModel()); + item.put("MaterialColor", depotItem.getMaterialId().getColor()); + item.put("prevSum", prevSum); + item.put("InSum", InSum); + item.put("OutSum", OutSum); + item.put("thisSum", prevSum + InSum - OutSum); + item.put("thisAllPrice", depotItem.getUnitPrice() * (prevSum + InSum - OutSum)); + item.put("UnitPrice", depotItem.getUnitPrice()); + dataArray.add(item); + } + } + outer.put("rows", dataArray); + //回写查询结果 + toClient(outer.toString()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找信息异常", e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e); + } + } + + /** + * 统计总计金额 + * @return + */ + public void totalCountMoney() + { + try + { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(0); + pageUtil.setCurPage(0); + pageUtil.setAdvSearch(getConditionALL()); + depotItemService.find(pageUtil); + List dataList = pageUtil.getPageList(); + + JSONObject outer = new JSONObject(); + Double thisAllPrice = 0.0; + if(null != dataList) + { + for(DepotItem depotItem:dataList) + { + Integer prevSum = sumNumber("入库",depotItem.getMaterialId().getId(),model.getMonthTime(),true) - sumNumber("出库",depotItem.getMaterialId().getId(),model.getMonthTime(),true); + Integer InSum = sumNumber("入库",depotItem.getMaterialId().getId(),model.getMonthTime(),false); + Integer OutSum = sumNumber("出库",depotItem.getMaterialId().getId(),model.getMonthTime(),false); + thisAllPrice = thisAllPrice + depotItem.getUnitPrice() * (prevSum + InSum - OutSum); + } + } + outer.put("totalCount", thisAllPrice); + //回写查询结果 + toClient(outer.toString()); + } + catch (DataAccessException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找信息异常", e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e); + } + } + + /** + * 导出excel表格 + * @return + */ + @SuppressWarnings("unchecked") + public String exportExcel() + { + Log.infoFileSync("===================调用导出信息action方法exportExcel开始======================="); + try + { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(model.getPageSize()); + pageUtil.setCurPage(model.getPageNo()); + pageUtil.setAdvSearch(getConditionALL()); + depotItemService.find(pageUtil); + List dataList = pageUtil.getPageList(); + + //存放数据json数组 + JSONArray dataArray = new JSONArray(); + if(null != dataList) + { + for(DepotItem depotItem:dataList) + { + JSONObject item = new JSONObject(); + Integer prevSum = sumNumber("入库",depotItem.getMaterialId().getId(),model.getMonthTime(),true) - sumNumber("出库",depotItem.getMaterialId().getId(),model.getMonthTime(),true); + Integer InSum = sumNumber("入库",depotItem.getMaterialId().getId(),model.getMonthTime(),false); + Integer OutSum = sumNumber("出库",depotItem.getMaterialId().getId(),model.getMonthTime(),false); + item.put("Id", depotItem.getId()); + item.put("MaterialId", depotItem.getMaterialId()==null?"":depotItem.getMaterialId().getId()); + item.put("MaterialName", depotItem.getMaterialId().getName()); + item.put("MaterialModel", depotItem.getMaterialId().getModel()); + item.put("MaterialColor", depotItem.getMaterialId().getColor()); + item.put("prevSum", prevSum); + item.put("InSum", InSum); + item.put("OutSum", OutSum); + item.put("thisSum", prevSum + InSum - OutSum); + item.put("thisAllPrice", depotItem.getUnitPrice() * (prevSum + InSum - OutSum)); + item.put("UnitPrice", depotItem.getUnitPrice()); + dataArray.add(item); + } + } + String isCurrentPage = "allPage"; + model.setFileName(Tools.changeUnicode("report.xls",model.getBrowserType())); + model.setExcelStream(depotItemService.exmportExcel(isCurrentPage,dataArray)); + } + catch (Exception e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>调用导出信息action方法exportExcel异常",e); + model.getShowModel().setMsgTip("export excel exception"); + } + Log.infoFileSync("===================调用导出信息action方法exportExcel结束=================="); + return EXCEL; + } + + @SuppressWarnings("unchecked") + public Integer sumNumber(String type,Long MId,String MonthTime, Boolean isPrev) { + Integer sumNumber = 0; + String allNumber = ""; + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(0); + pageUtil.setCurPage(0); + try { + depotItemService.findByType(pageUtil, type, MId, MonthTime, isPrev); + allNumber = pageUtil.getPageList().toString(); + allNumber = allNumber.substring(1,allNumber.length()-1); + if(allNumber.equals("null")){ + allNumber = "0"; + } + allNumber = allNumber.replace(".0", ""); + } catch (JshException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + sumNumber = Integer.parseInt(allNumber); + return sumNumber; + } + /** + * 拼接搜索条件 + * @return + */ + private Map getCondition() + { + /** + * 拼接搜索条件 + */ + Map condition = new HashMap(); + condition.put("HeaderId_n_eq", model.getHeaderId()); + condition.put("Id_s_order","asc"); + return condition; + } + + private Map getConditionALL() + { + /** + * 拼接搜索条件 + */ + Map condition = new HashMap(); + condition.put("HeaderId_s_in", model.getHeadIds()); + condition.put("MaterialId_s_in", model.getMaterialIds()); + condition.put("MaterialId_s_gb","aaa"); + return condition; + } + + //=============以下spring注入以及Model驱动公共方法,与Action处理无关================== + @Override + public DepotItemModel getModel() + { + return model; + } + public void setDepotItemService(DepotItemIService depotItemService) + { + this.depotItemService = depotItemService; + } +} diff --git a/src/com/jsh/base/BaseAction.java b/src/com/jsh/base/BaseAction.java index 3a5df3c9..a2c6faeb 100644 --- a/src/com/jsh/base/BaseAction.java +++ b/src/com/jsh/base/BaseAction.java @@ -1,116 +1,116 @@ -package com.jsh.base; - -import java.io.IOException; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.struts2.ServletActionContext; - -import com.opensymphony.xwork2.ActionContext; -import com.opensymphony.xwork2.ActionSupport; -import com.opensymphony.xwork2.ModelDriven; -import com.jsh.model.po.Basicuser; -import com.jsh.service.basic.LogIService; -/** - * struts2工具类 - * @author andy - * struts2 base action 一些常用方法获取 - */ -@SuppressWarnings("serial") -public abstract class BaseAction extends ActionSupport implements ModelDriven -{ - public LogIService logService; - - /** - * 操作日志使用 是否成功表示 - */ - public String tipMsg = "成功"; - - /** - * 操作日志使用 是否成功表示 0 ==成功 1==失败 - */ - public short tipType = 0; - - public void setLogService(LogIService logService) - { - this.logService = logService; - } - - /** - * 获取session - * @return - */ - public static Map getSession() - { - return ActionContext.getContext().getSession(); - } - - /** - * 获取request - * @return - */ - public static HttpServletRequest getRequest() - { - return ServletActionContext.getRequest(); - } - /** - * 获取response - * @return response - */ - public static HttpServletResponse getResponse() - { - return ServletActionContext.getResponse(); - } - - /** - * 添加错误信息 - * @param anErrorMessage - */ - public void addActionError(String anErrorMessage) - { - super.addActionError(anErrorMessage); - } - - /** - * 添加消息 - * @param aMessage - */ - public void addActionMessage(String aMessage) - { - clearErrorsAndMessages(); - super.addActionMessage(aMessage); - } - - /** - * 添加字段错误 - * @param fieldName - * @param errorMessage - */ - public void addFieldError(String fieldName, String errorMessage) - { - clearErrorsAndMessages(); - super.addFieldError(fieldName, errorMessage); - } - - /** - * 登录用户信息 - * @return 登录用户对象 - */ - public Basicuser getUser() - { - return (Basicuser)getSession().get("user"); - } - - /** - * 回写客户端数据 - * @throws IOException - */ - public void toClient(String jsonData) throws IOException - { - HttpServletResponse response = ServletActionContext.getResponse(); - response.setContentType("text/html;charset=utf-8"); - response.getWriter().print(jsonData); - } -} \ No newline at end of file +package com.jsh.base; + +import java.io.IOException; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts2.ServletActionContext; + +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.ActionSupport; +import com.opensymphony.xwork2.ModelDriven; +import com.jsh.model.po.Basicuser; +import com.jsh.service.basic.LogIService; +/** + * struts2工具类 + * @author jishenghua + * struts2 base action 一些常用方法获取 + */ +@SuppressWarnings("serial") +public abstract class BaseAction extends ActionSupport implements ModelDriven +{ + public LogIService logService; + + /** + * 操作日志使用 是否成功表示 + */ + public String tipMsg = "成功"; + + /** + * 操作日志使用 是否成功表示 0 ==成功 1==失败 + */ + public short tipType = 0; + + public void setLogService(LogIService logService) + { + this.logService = logService; + } + + /** + * 获取session + * @return + */ + public static Map getSession() + { + return ActionContext.getContext().getSession(); + } + + /** + * 获取request + * @return + */ + public static HttpServletRequest getRequest() + { + return ServletActionContext.getRequest(); + } + /** + * 获取response + * @return response + */ + public static HttpServletResponse getResponse() + { + return ServletActionContext.getResponse(); + } + + /** + * 添加错误信息 + * @param anErrorMessage + */ + public void addActionError(String anErrorMessage) + { + super.addActionError(anErrorMessage); + } + + /** + * 添加消息 + * @param aMessage + */ + public void addActionMessage(String aMessage) + { + clearErrorsAndMessages(); + super.addActionMessage(aMessage); + } + + /** + * 添加字段错误 + * @param fieldName + * @param errorMessage + */ + public void addFieldError(String fieldName, String errorMessage) + { + clearErrorsAndMessages(); + super.addFieldError(fieldName, errorMessage); + } + + /** + * 登录用户信息 + * @return 登录用户对象 + */ + public Basicuser getUser() + { + return (Basicuser)getSession().get("user"); + } + + /** + * 回写客户端数据 + * @throws IOException + */ + public void toClient(String jsonData) throws IOException + { + HttpServletResponse response = ServletActionContext.getResponse(); + response.setContentType("text/html;charset=utf-8"); + response.getWriter().print(jsonData); + } +} diff --git a/src/com/jsh/base/BaseIDAO.java b/src/com/jsh/base/BaseIDAO.java index 4fe52bf2..562cdaae 100644 --- a/src/com/jsh/base/BaseIDAO.java +++ b/src/com/jsh/base/BaseIDAO.java @@ -1,124 +1,124 @@ -package com.jsh.base; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -import org.springframework.dao.DataAccessException; - -import com.jsh.util.common.PageUtil; - -/** - * 常用增删改查操作 - * @author andy - * @param - */ -public interface BaseIDAO -{ - - /** - * 设置操作类对象 - * @param paramClass - */ - void setPoJoClass(Class paramClass); - - /** - * 增加 - * @param t 对象 - * @throws DataAccessException - */ - Serializable create(T t)throws DataAccessException; - - /** - * 增加 - * @param t 对象 - * @throws DataAccessException - */ - void save(T t)throws DataAccessException; - - /** - * 删除 - * @param t 对象 - * @throws DataAccessException - */ - void delete(T t)throws DataAccessException; - - /** - * 获取 - * @param objID ID - * @return 对象 - * @throws DataAccessException - */ - T get(Long objID)throws DataAccessException; - - /** - * 修改信息 - * @param t 要修改的对象 - * @throws DataAccessException - */ - void update(T t)throws DataAccessException; - - /** - * 批量删除信息 - * @param 以逗号分割的ID - * @throws DataAccessException - */ - void batchDelete(String objIDs)throws DataAccessException; - - /** - * 查找列表 - * @param pageUtil 分页工具类 - * @throws DataAccessException - */ - void find(PageUtil pageUtil)throws DataAccessException; - - /** - * 根据条件查询列表--没有分页信息 - * @param conditon 查询条件 - * @return 查询列表数据 - */ - List find(Map conditon)throws DataAccessException; - - /** - * 根据hql查询 --没有分页信息 - * @param hql hibernate查询 - * @return 查询列表数据 - */ - List find(String hql)throws DataAccessException; - - /** - * 根据搜索条件查询--分页 - * @param conditon 查询条件 - * @param pageSize 每页个数 - * @param pageNo 页码 - * @return 查询列表数据 - * @throws DataAccessException - */ - List find(Map conditon,int pageSize,int pageNo)throws DataAccessException; - - /** - * 根据hql查询--分页 - * @param hql hibernate查询语句 - * @param pageSize 每页个数 - * @param pageNo 页码 - * @return 查询列表数据 - * @throws DataAccessException - */ - List find(String hql,int pageSize,int pageNo)throws DataAccessException; - - /** - * 查找符合条件的总数 - * @param conditon - * @return - * @throws DataAccessException - */ - Integer countSum(Map conditon)throws DataAccessException; - - /** - * 查找符合条件的总数 - * @param hql - * @return - * @throws DataAccessException - */ - Integer countSum(String hql)throws DataAccessException; -} +package com.jsh.base; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +import org.springframework.dao.DataAccessException; + +import com.jsh.util.common.PageUtil; + +/** + * 常用增删改查操作 + * @author jishenghua + * @param + */ +public interface BaseIDAO +{ + + /** + * 设置操作类对象 + * @param paramClass + */ + void setPoJoClass(Class paramClass); + + /** + * 增加 + * @param t 对象 + * @throws DataAccessException + */ + Serializable create(T t)throws DataAccessException; + + /** + * 增加 + * @param t 对象 + * @throws DataAccessException + */ + void save(T t)throws DataAccessException; + + /** + * 删除 + * @param t 对象 + * @throws DataAccessException + */ + void delete(T t)throws DataAccessException; + + /** + * 获取 + * @param objID ID + * @return 对象 + * @throws DataAccessException + */ + T get(Long objID)throws DataAccessException; + + /** + * 修改信息 + * @param t 要修改的对象 + * @throws DataAccessException + */ + void update(T t)throws DataAccessException; + + /** + * 批量删除信息 + * @param 以逗号分割的ID + * @throws DataAccessException + */ + void batchDelete(String objIDs)throws DataAccessException; + + /** + * 查找列表 + * @param pageUtil 分页工具类 + * @throws DataAccessException + */ + void find(PageUtil pageUtil)throws DataAccessException; + + /** + * 根据条件查询列表--没有分页信息 + * @param conditon 查询条件 + * @return 查询列表数据 + */ + List find(Map conditon)throws DataAccessException; + + /** + * 根据hql查询 --没有分页信息 + * @param hql hibernate查询 + * @return 查询列表数据 + */ + List find(String hql)throws DataAccessException; + + /** + * 根据搜索条件查询--分页 + * @param conditon 查询条件 + * @param pageSize 每页个数 + * @param pageNo 页码 + * @return 查询列表数据 + * @throws DataAccessException + */ + List find(Map conditon,int pageSize,int pageNo)throws DataAccessException; + + /** + * 根据hql查询--分页 + * @param hql hibernate查询语句 + * @param pageSize 每页个数 + * @param pageNo 页码 + * @return 查询列表数据 + * @throws DataAccessException + */ + List find(String hql,int pageSize,int pageNo)throws DataAccessException; + + /** + * 查找符合条件的总数 + * @param conditon + * @return + * @throws DataAccessException + */ + Integer countSum(Map conditon)throws DataAccessException; + + /** + * 查找符合条件的总数 + * @param hql + * @return + * @throws DataAccessException + */ + Integer countSum(String hql)throws DataAccessException; +} diff --git a/src/com/jsh/base/BaseService.java b/src/com/jsh/base/BaseService.java index e47b2948..dfdf9748 100644 --- a/src/com/jsh/base/BaseService.java +++ b/src/com/jsh/base/BaseService.java @@ -1,137 +1,137 @@ -package com.jsh.base; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.springframework.dao.DataAccessException; - -import com.jsh.exception.AmsException; -import com.jsh.model.po.Basicuser; -import com.jsh.util.common.PageUtil; - -public abstract class BaseService implements BaseIService -{ - /** - * Dao对象 - */ - private BaseIDAO baseDao; - - protected Class entityClass; - - public void setBaseDao(BaseIDAO baseDao) - { - this.baseDao = baseDao; - setPoJoClass(getEntityClass()); - } - - protected BaseIDAO getBaseDao() - { - return this.baseDao; - } - - private void setPoJoClass(Class c) - { - this.baseDao.setPoJoClass(c); - } - - protected abstract Class getEntityClass(); - - @Override - public Serializable create(T t) throws DataAccessException - { - return baseDao.create(t); - } - - @Override - public void save(T t) throws DataAccessException - { - baseDao.save(t); - } - - @Override - public void delete(T t) throws DataAccessException - { - baseDao.delete(t); - } - - @Override - public void delete(Long id) throws DataAccessException - { - baseDao.batchDelete(id.toString()); - } - - @Override - public T get(Long objID) throws DataAccessException - { - return baseDao.get(objID); - } - - @Override - public void update(T t) throws DataAccessException - { - baseDao.update(t); - } - - @Override - public void batchDelete(String objIDs) throws DataAccessException - { - baseDao.batchDelete(objIDs); - } - - @Override - public void find(PageUtil pageUtil) throws DataAccessException - { - baseDao.find(pageUtil); - } - - @Override - public Boolean checkIsNameExist(String filedName, String filedVale,String idFiled,Long objectID) throws DataAccessException - { - PageUtil pageUtil = new PageUtil(); - Map condition = new HashMap(); - condition.put(filedName + "_s_eq", filedVale); - condition.put(idFiled + "_n_neq", objectID); - pageUtil.setAdvSearch(condition); - baseDao.find(pageUtil); - - List dataList = pageUtil.getPageList(); - if(null != dataList && dataList.size() > 0) - return true; - return false; - } - - @Override - public Boolean checkIsUserBusinessExist(String TypeName,String TypeVale,String KeyIdName,String KeyIdValue,String UBName,String UBValue) throws DataAccessException - { - PageUtil pageUtil = new PageUtil(); - Map condition = new HashMap(); - condition.put(TypeName + "_s_eq", TypeVale); - condition.put(KeyIdName + "_s_eq", KeyIdValue); - condition.put(UBName + "_s_like", UBValue); - pageUtil.setAdvSearch(condition); - baseDao.find(pageUtil); - - List dataList = pageUtil.getPageList(); - if(null != dataList && dataList.size() > 0) - return true; - return false; - } - - @Override - public Boolean checkIsValueExist(String TypeName, String TypeVale, String KeyIdName, String KeyIdValue) throws DataAccessException - { - PageUtil pageUtil = new PageUtil(); - Map condition = new HashMap(); - condition.put(TypeName + "_s_eq", TypeVale); - condition.put(KeyIdName + "_s_eq", KeyIdValue); - pageUtil.setAdvSearch(condition); - baseDao.find(pageUtil); - - List dataList = pageUtil.getPageList(); - if(null != dataList && dataList.size() > 0) - return true; - return false; - } -} +package com.jsh.base; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.springframework.dao.DataAccessException; + +import com.jsh.exception.JshException; +import com.jsh.model.po.Basicuser; +import com.jsh.util.common.PageUtil; + +public abstract class BaseService implements BaseIService +{ + /** + * Dao对象 + */ + private BaseIDAO baseDao; + + protected Class entityClass; + + public void setBaseDao(BaseIDAO baseDao) + { + this.baseDao = baseDao; + setPoJoClass(getEntityClass()); + } + + protected BaseIDAO getBaseDao() + { + return this.baseDao; + } + + private void setPoJoClass(Class c) + { + this.baseDao.setPoJoClass(c); + } + + protected abstract Class getEntityClass(); + + @Override + public Serializable create(T t) throws DataAccessException + { + return baseDao.create(t); + } + + @Override + public void save(T t) throws DataAccessException + { + baseDao.save(t); + } + + @Override + public void delete(T t) throws DataAccessException + { + baseDao.delete(t); + } + + @Override + public void delete(Long id) throws DataAccessException + { + baseDao.batchDelete(id.toString()); + } + + @Override + public T get(Long objID) throws DataAccessException + { + return baseDao.get(objID); + } + + @Override + public void update(T t) throws DataAccessException + { + baseDao.update(t); + } + + @Override + public void batchDelete(String objIDs) throws DataAccessException + { + baseDao.batchDelete(objIDs); + } + + @Override + public void find(PageUtil pageUtil) throws DataAccessException + { + baseDao.find(pageUtil); + } + + @Override + public Boolean checkIsNameExist(String filedName, String filedVale,String idFiled,Long objectID) throws DataAccessException + { + PageUtil pageUtil = new PageUtil(); + Map condition = new HashMap(); + condition.put(filedName + "_s_eq", filedVale); + condition.put(idFiled + "_n_neq", objectID); + pageUtil.setAdvSearch(condition); + baseDao.find(pageUtil); + + List dataList = pageUtil.getPageList(); + if(null != dataList && dataList.size() > 0) + return true; + return false; + } + + @Override + public Boolean checkIsUserBusinessExist(String TypeName,String TypeVale,String KeyIdName,String KeyIdValue,String UBName,String UBValue) throws DataAccessException + { + PageUtil pageUtil = new PageUtil(); + Map condition = new HashMap(); + condition.put(TypeName + "_s_eq", TypeVale); + condition.put(KeyIdName + "_s_eq", KeyIdValue); + condition.put(UBName + "_s_like", UBValue); + pageUtil.setAdvSearch(condition); + baseDao.find(pageUtil); + + List dataList = pageUtil.getPageList(); + if(null != dataList && dataList.size() > 0) + return true; + return false; + } + + @Override + public Boolean checkIsValueExist(String TypeName, String TypeVale, String KeyIdName, String KeyIdValue) throws DataAccessException + { + PageUtil pageUtil = new PageUtil(); + Map condition = new HashMap(); + condition.put(TypeName + "_s_eq", TypeVale); + condition.put(KeyIdName + "_s_eq", KeyIdValue); + pageUtil.setAdvSearch(condition); + baseDao.find(pageUtil); + + List dataList = pageUtil.getPageList(); + if(null != dataList && dataList.size() > 0) + return true; + return false; + } +} diff --git a/src/com/jsh/base/Log.java b/src/com/jsh/base/Log.java index dbd51db8..eb3a23af 100644 --- a/src/com/jsh/base/Log.java +++ b/src/com/jsh/base/Log.java @@ -1,174 +1,174 @@ -package com.jsh.base; - -import org.apache.log4j.Logger; - -/** - * 封装log4j日志信息,打印日志信息类 - * @author andy - * @since 2014-01-22 - */ -public class Log -{ - /** - * 根据异常信息获取调用类的信息 - */ - private static final Exception ex = new Exception(); - - /** - * 获取Log4j实例 - */ - private static final Logger log = Logger.getLogger("ams"); - - /** - * Info级别日志前缀 - */ - public static final String LOG_INFO_PREFIX = "=========="; - - /** - * error级别日志前缀 - */ - public static final String LOG_ERROR_PREFIX = ">>>>>>>>>>"; - - /** - * debug级别日志前缀 - */ - public static final String LOG_DEBUG_PREFIX = "-----------"; - - /** - * fatal级别日志前缀 - */ - public static final String LOG_FATAL_PREFIX = "$$$$$$$$$$"; - - /** - * warn级别日志前缀 - */ - public static final String LOG_WARN_PREFIX = "##########"; - - /** - * 打印deug日期信息 - * @param msg 日志信息 - */ - public static void debugFileSync(Object msg) - { - log.debug(getLogDetail(msg)); - } - - /** - * 打印debug异常信息 - * @param msg 日志信息 - * @param e 异常堆栈 - */ - public static void debugFileSync(Object msg, Throwable e) - { - log.debug(getLogDetail(msg), e); - } - - /** - * 打印info日志信息 - * @param msg 日志信息 - */ - public static void infoFileSync(Object msg) - { - log.info(getLogDetail(msg)); - } - - /** - * 打印 info日志带异常信息 - * @param msg 日志信息 - * @param e 异常堆栈 - */ - public static void infoFileSync(Object msg, Throwable e) - { - log.info(getLogDetail(msg), e); - } - - /** - * 打印warn日期信息 - * @param msg 日志信息 - */ - public static void warnFileSync(Object msg) - { - log.warn(getLogDetail(msg)); - } - - /** - * 打印warn日志信息带异常 - * @param msg日志信息 - * @param e 异常堆栈 - */ - public static void warnFileSync(Object msg, Throwable e) - { - log.warn(getLogDetail(msg), e); - } - - /** - * 打印error日志信息 - * @param msg 日志信息 - */ - public static void errorFileSync(Object msg) - { - log.error(getLogDetail(msg)); - } - - /** - * 打印error日志信息带异常 - * @param msg 日志信息 - * @param e 异常堆栈 - */ - public static void errorFileSync(Object msg, Throwable e) - { - log.error(getLogDetail(msg), e); - } - - /** - * 打印fatal日志信息 - * @param msg 日志信息 - */ - public static void fatalFileSync(Object msg) - { - log.fatal(getLogDetail(msg)); - } - - /** - * 打印fatal日志信息带异常 - * @param msg 日志信息 - * @param e 异常堆栈 - */ - public static void fatalFileSync(Object msg, Throwable e) - { - log.fatal(getLogDetail(msg), e); - } - - /** - * 拼装日志详细信息 - * @param message 要打印的日志信息 - * @return 封装后的日志详细信息 - */ - private static synchronized String getLogDetail(Object message) - { - String msg = ""; - if (null != message) - msg = message.toString(); - StringBuffer bf = new StringBuffer(); - try - { - ex.fillInStackTrace(); - throw ex; - } - catch (Exception ex) - { - StackTraceElement[] trace = ex.getStackTrace(); - //获取异常堆栈中的调用类信息 - final int pos = 2; - bf.append(msg); - bf.append(" [class:"); - bf.append(trace[pos].getClassName()); - bf.append(" method:"); - bf.append(trace[pos].getMethodName()); - bf.append(" line:"); - bf.append(trace[pos].getLineNumber()); - bf.append("]"); - } - return bf.toString(); - } -} \ No newline at end of file +package com.jsh.base; + +import org.apache.log4j.Logger; + +/** + * 封装log4j日志信息,打印日志信息类 + * @author jishenghua + * @since 2014-01-22 + */ +public class Log +{ + /** + * 根据异常信息获取调用类的信息 + */ + private static final Exception ex = new Exception(); + + /** + * 获取Log4j实例 + */ + private static final Logger log = Logger.getLogger("ams"); + + /** + * Info级别日志前缀 + */ + public static final String LOG_INFO_PREFIX = "=========="; + + /** + * error级别日志前缀 + */ + public static final String LOG_ERROR_PREFIX = ">>>>>>>>>>"; + + /** + * debug级别日志前缀 + */ + public static final String LOG_DEBUG_PREFIX = "-----------"; + + /** + * fatal级别日志前缀 + */ + public static final String LOG_FATAL_PREFIX = "$$$$$$$$$$"; + + /** + * warn级别日志前缀 + */ + public static final String LOG_WARN_PREFIX = "##########"; + + /** + * 打印deug日期信息 + * @param msg 日志信息 + */ + public static void debugFileSync(Object msg) + { + log.debug(getLogDetail(msg)); + } + + /** + * 打印debug异常信息 + * @param msg 日志信息 + * @param e 异常堆栈 + */ + public static void debugFileSync(Object msg, Throwable e) + { + log.debug(getLogDetail(msg), e); + } + + /** + * 打印info日志信息 + * @param msg 日志信息 + */ + public static void infoFileSync(Object msg) + { + log.info(getLogDetail(msg)); + } + + /** + * 打印 info日志带异常信息 + * @param msg 日志信息 + * @param e 异常堆栈 + */ + public static void infoFileSync(Object msg, Throwable e) + { + log.info(getLogDetail(msg), e); + } + + /** + * 打印warn日期信息 + * @param msg 日志信息 + */ + public static void warnFileSync(Object msg) + { + log.warn(getLogDetail(msg)); + } + + /** + * 打印warn日志信息带异常 + * @param msg日志信息 + * @param e 异常堆栈 + */ + public static void warnFileSync(Object msg, Throwable e) + { + log.warn(getLogDetail(msg), e); + } + + /** + * 打印error日志信息 + * @param msg 日志信息 + */ + public static void errorFileSync(Object msg) + { + log.error(getLogDetail(msg)); + } + + /** + * 打印error日志信息带异常 + * @param msg 日志信息 + * @param e 异常堆栈 + */ + public static void errorFileSync(Object msg, Throwable e) + { + log.error(getLogDetail(msg), e); + } + + /** + * 打印fatal日志信息 + * @param msg 日志信息 + */ + public static void fatalFileSync(Object msg) + { + log.fatal(getLogDetail(msg)); + } + + /** + * 打印fatal日志信息带异常 + * @param msg 日志信息 + * @param e 异常堆栈 + */ + public static void fatalFileSync(Object msg, Throwable e) + { + log.fatal(getLogDetail(msg), e); + } + + /** + * 拼装日志详细信息 + * @param message 要打印的日志信息 + * @return 封装后的日志详细信息 + */ + private static synchronized String getLogDetail(Object message) + { + String msg = ""; + if (null != message) + msg = message.toString(); + StringBuffer bf = new StringBuffer(); + try + { + ex.fillInStackTrace(); + throw ex; + } + catch (Exception ex) + { + StackTraceElement[] trace = ex.getStackTrace(); + //获取异常堆栈中的调用类信息 + final int pos = 2; + bf.append(msg); + bf.append(" [class:"); + bf.append(trace[pos].getClassName()); + bf.append(" method:"); + bf.append(trace[pos].getMethodName()); + bf.append(" line:"); + bf.append(trace[pos].getLineNumber()); + bf.append("]"); + } + return bf.toString(); + } +} diff --git a/src/com/jsh/constants/asset/AssetConstants.java b/src/com/jsh/constants/asset/AssetConstants.java index 943b24dd..96cc9718 100644 --- a/src/com/jsh/constants/asset/AssetConstants.java +++ b/src/com/jsh/constants/asset/AssetConstants.java @@ -1,119 +1,119 @@ -package com.jsh.constants.asset; - -/** - * 定义资产管理常量 - * @author andy - */ -public interface AssetConstants -{ - /** - * 公共常量 - * @author andy - */ - public class Common - { - - } - - /** - * 资产常量--导入导出excel表格业务相关 - * @author andy - */ - public class BusinessForExcel - { - /** - * 资产名称常量 - */ - public static final int EXCEL_ASSETNAME = 0; - - /** - * 资产类型常量 - */ - public static final int EXCEL_CATEGORY = 1; - - /** - * 资产单价 - */ - public static final int EXCEL_PRICE = 2; - - /** - * 用户 - */ - public static final int EXCEL_USER = 3; - - /** - * 购买日期 - */ - public static final int EXCEL_PURCHASE_DATE = 4; - - /** - * 资产状态 - */ - public static final int EXCEL_STATUS = 5; - - /** - * 位置 - */ - public static final int EXCEL_LOCATION = 6; - - /** - * 资产编号 - */ - public static final int EXCEL_NUM = 7; - - /** - * 序列号 - */ - public static final int EXCEL_SERIALNO = 8; - - /** - * 有效日期 - */ - public static final int EXCEL_EXPIRATION_DATE = 9; - - /** - * 保修日期 - */ - public static final int EXCEL_WARRANTY_DATE = 10; - - /** - * 供应商 - */ - public static final int EXCEL_SUPPLIER = 11; - - /** - * 标签 - */ - public static final int EXCEL_LABLE = 12; - - /** - * 描述 - */ - public static final int EXCEL_DESC = 13; - - /** - * 表头 - */ - public static final int EXCEL_TABLE_HEAD = 0; - - /** - * 状态 --在库 - */ - public static final int EXCEl_STATUS_ZAIKU = 0; - - /** - * 状态 --在用 - */ - public static final int EXCEl_STATUS_INUSE = 1; - - /** - * 状态 -- 消费 - */ - public static final int EXCEl_STATUS_CONSUME = 2; - - /** - * action返回excel结果 - */ - public static final String EXCEL = "excel"; - } -} +package com.jsh.constants.asset; + +/** + * 定义资产管理常量 + * @author jishenghua + */ +public interface AssetConstants +{ + /** + * 公共常量 + * @author jishenghua + */ + public class Common + { + + } + + /** + * 资产常量--导入导出excel表格业务相关 + * @author jishenghua + */ + public class BusinessForExcel + { + /** + * 资产名称常量 + */ + public static final int EXCEL_ASSETNAME = 0; + + /** + * 资产类型常量 + */ + public static final int EXCEL_CATEGORY = 1; + + /** + * 资产单价 + */ + public static final int EXCEL_PRICE = 2; + + /** + * 用户 + */ + public static final int EXCEL_USER = 3; + + /** + * 购买日期 + */ + public static final int EXCEL_PURCHASE_DATE = 4; + + /** + * 资产状态 + */ + public static final int EXCEL_STATUS = 5; + + /** + * 位置 + */ + public static final int EXCEL_LOCATION = 6; + + /** + * 资产编号 + */ + public static final int EXCEL_NUM = 7; + + /** + * 序列号 + */ + public static final int EXCEL_SERIALNO = 8; + + /** + * 有效日期 + */ + public static final int EXCEL_EXPIRATION_DATE = 9; + + /** + * 保修日期 + */ + public static final int EXCEL_WARRANTY_DATE = 10; + + /** + * 供应商 + */ + public static final int EXCEL_SUPPLIER = 11; + + /** + * 标签 + */ + public static final int EXCEL_LABLE = 12; + + /** + * 描述 + */ + public static final int EXCEL_DESC = 13; + + /** + * 表头 + */ + public static final int EXCEL_TABLE_HEAD = 0; + + /** + * 状态 --在库 + */ + public static final int EXCEl_STATUS_ZAIKU = 0; + + /** + * 状态 --在用 + */ + public static final int EXCEl_STATUS_INUSE = 1; + + /** + * 状态 -- 消费 + */ + public static final int EXCEl_STATUS_CONSUME = 2; + + /** + * action返回excel结果 + */ + public static final String EXCEL = "excel"; + } +} diff --git a/src/com/jsh/constants/common/AmsConstants.java b/src/com/jsh/constants/common/AmsConstants.java index c5acce52..c9e49c7d 100644 --- a/src/com/jsh/constants/common/AmsConstants.java +++ b/src/com/jsh/constants/common/AmsConstants.java @@ -1,36 +1,36 @@ -package com.jsh.constants.common; - -public interface AmsConstants -{ - /** - * 定义资产管理公共常量 - * @author andy - */ - public class Common - { - /** - * Info级别日志前缀 - */ - public static final String LOG_INFO_PREFIX = "=========="; - - /** - * error级别日志前缀 - */ - public static final String LOG_ERROR_PREFIX = ">>>>>>>>>>"; - - /** - * debug级别日志前缀 - */ - public static final String LOG_DEBUG_PREFIX = "-----------"; - - /** - * fatal级别日志前缀 - */ - public static final String LOG_FATAL_PREFIX = "$$$$$$$$$$"; - - /** - * warn级别日志前缀 - */ - public static final String LOG_WARN_PREFIX = "##########"; - } -} +package com.jsh.constants.common; + +public interface AmsConstants +{ + /** + * 定义资产管理公共常量 + * @author jishenghua + */ + public class Common + { + /** + * Info级别日志前缀 + */ + public static final String LOG_INFO_PREFIX = "=========="; + + /** + * error级别日志前缀 + */ + public static final String LOG_ERROR_PREFIX = ">>>>>>>>>>"; + + /** + * debug级别日志前缀 + */ + public static final String LOG_DEBUG_PREFIX = "-----------"; + + /** + * fatal级别日志前缀 + */ + public static final String LOG_FATAL_PREFIX = "$$$$$$$$$$"; + + /** + * warn级别日志前缀 + */ + public static final String LOG_WARN_PREFIX = "##########"; + } +} diff --git a/src/com/jsh/constants/common/LogModuleConstants.java b/src/com/jsh/constants/common/LogModuleConstants.java index 36f9c063..c4aaf35b 100644 --- a/src/com/jsh/constants/common/LogModuleConstants.java +++ b/src/com/jsh/constants/common/LogModuleConstants.java @@ -1,65 +1,65 @@ -package com.jsh.constants.common; - -public interface LogModuleConstants -{ - /** - * 系统管理模块名称定义 - * @author andy - */ - public class ManageModuleNameCode - { - /** - * 管理模块资产名称 - */ - public static final String MODULE_MANAGE_ASSETNAME = "资产名称"; - - /** - * 管理模块供应商 - */ - public static final String MODULE_MANAGE_SUPPLIER = "供应商"; - - /** - * 管理模块资产类型 - */ - public static final String MODULE_MANAGE_CATEGORY = "资产类型"; - - /** - * 管理模块用户管理 - */ - public static final String MODULE_MANAGE_USER = "用户管理"; - } - - /** - * 资产管理模块名称定义 - * @author andy - */ - public class AssetModuleNameCode - { - /** - * 资产管理模块资产管理 - */ - public static final String MODULE_ASSET_MANAGE = "资产管理"; - - /** - * 资产管理模块资产报表 - */ - public static final String MODULE_ASSET_REPORT = "资产报表"; - - /** - * 资产管理模块资产概况 - */ - public static final String MODULE_ASSET_GENERAL = "资产概况"; - } - - /** - * 日志管理模块名称定义 - * @author andy - */ - public class LogModuleNameCode - { - /** - * 日志管理模块日志管理 - */ - public static final String MODULE_LOG_MANAGE = "日志管理"; - } -} \ No newline at end of file +package com.jsh.constants.common; + +public interface LogModuleConstants +{ + /** + * 系统管理模块名称定义 + * @author jishenghua + */ + public class ManageModuleNameCode + { + /** + * 管理模块资产名称 + */ + public static final String MODULE_MANAGE_ASSETNAME = "资产名称"; + + /** + * 管理模块供应商 + */ + public static final String MODULE_MANAGE_SUPPLIER = "供应商"; + + /** + * 管理模块资产类型 + */ + public static final String MODULE_MANAGE_CATEGORY = "资产类型"; + + /** + * 管理模块用户管理 + */ + public static final String MODULE_MANAGE_USER = "用户管理"; + } + + /** + * 资产管理模块名称定义 + * @author jishenghua + */ + public class AssetModuleNameCode + { + /** + * 资产管理模块资产管理 + */ + public static final String MODULE_ASSET_MANAGE = "资产管理"; + + /** + * 资产管理模块资产报表 + */ + public static final String MODULE_ASSET_REPORT = "资产报表"; + + /** + * 资产管理模块资产概况 + */ + public static final String MODULE_ASSET_GENERAL = "资产概况"; + } + + /** + * 日志管理模块名称定义 + * @author jishenghua + */ + public class LogModuleNameCode + { + /** + * 日志管理模块日志管理 + */ + public static final String MODULE_LOG_MANAGE = "日志管理"; + } +} diff --git a/src/com/jsh/dao/asset/ReportDAO.java b/src/com/jsh/dao/asset/ReportDAO.java index 6eb6b4e9..e379916a 100644 --- a/src/com/jsh/dao/asset/ReportDAO.java +++ b/src/com/jsh/dao/asset/ReportDAO.java @@ -1,21 +1,21 @@ -package com.jsh.dao.asset; - -import org.hibernate.Query; -import org.springframework.orm.hibernate3.support.HibernateDaoSupport; - -import com.jsh.exception.AmsException; -import com.jsh.model.po.Asset; -import com.jsh.util.common.PageUtil; -import com.jsh.util.common.SearchConditionUtil; - -public class ReportDAO extends HibernateDaoSupport implements ReportIDAO -{ - @SuppressWarnings("unchecked") - @Override - public void find(PageUtil pageUtil,String reportType,String reportName) throws AmsException - { - Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select count(" + reportType +") as dataSum, " + reportName + " from Asset asset where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); - pageUtil.setTotalCount(query.list().size()); - pageUtil.setPageList(query.list()); - } -} +package com.jsh.dao.asset; + +import org.hibernate.Query; +import org.springframework.orm.hibernate3.support.HibernateDaoSupport; + +import com.jsh.exception.JshException; +import com.jsh.model.po.Asset; +import com.jsh.util.common.PageUtil; +import com.jsh.util.common.SearchConditionUtil; + +public class ReportDAO extends HibernateDaoSupport implements ReportIDAO +{ + @SuppressWarnings("unchecked") + @Override + public void find(PageUtil pageUtil,String reportType,String reportName) throws JshException + { + Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select count(" + reportType +") as dataSum, " + reportName + " from Asset asset where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); + pageUtil.setTotalCount(query.list().size()); + pageUtil.setPageList(query.list()); + } +} diff --git a/src/com/jsh/dao/asset/ReportIDAO.java b/src/com/jsh/dao/asset/ReportIDAO.java index 6df8b1c4..4065e75d 100644 --- a/src/com/jsh/dao/asset/ReportIDAO.java +++ b/src/com/jsh/dao/asset/ReportIDAO.java @@ -1,16 +1,16 @@ -package com.jsh.dao.asset; - -import com.jsh.exception.AmsException; -import com.jsh.model.po.Asset; -import com.jsh.util.common.PageUtil; - -public interface ReportIDAO -{ - /** - * 查找资产列表 - * @param pageUtil 分页工具类 - * @param reportType 报表统计字段 - * @throws AmsException - */ - void find(PageUtil pageUtil,String reportType,String reportName) throws AmsException; -} +package com.jsh.dao.asset; + +import com.jsh.exception.JshException; +import com.jsh.model.po.Asset; +import com.jsh.util.common.PageUtil; + +public interface ReportIDAO +{ + /** + * 查找资产列表 + * @param pageUtil 分页工具类 + * @param reportType 报表统计字段 + * @throws JshException + */ + void find(PageUtil pageUtil,String reportType,String reportName) throws JshException; +} diff --git a/src/com/jsh/dao/basic/UserBusinessDAO.java b/src/com/jsh/dao/basic/UserBusinessDAO.java index 7766efd0..4f006a7f 100644 --- a/src/com/jsh/dao/basic/UserBusinessDAO.java +++ b/src/com/jsh/dao/basic/UserBusinessDAO.java @@ -1,32 +1,32 @@ -package com.jsh.dao.basic; - -import org.hibernate.Query; - -import com.jsh.base.BaseDAO; -import com.jsh.exception.AmsException; -import com.jsh.model.po.Asset; -import com.jsh.model.po.UserBusiness; -import com.jsh.util.common.PageUtil; -import com.jsh.util.common.SearchConditionUtil; - -public class UserBusinessDAO extends BaseDAO implements UserBusinessIDAO -{ - /** - * 设置dao映射基类 - * @return - */ - @Override - public Class getEntityClass() - { - return UserBusiness.class; - } - - @SuppressWarnings("unchecked") - @Override - public void find(PageUtil pageUtil,String ceshi) throws AmsException - { - Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select count(id),sum(id) from UserBusiness userBusiness where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); - pageUtil.setTotalCount(query.list().size()); - pageUtil.setPageList(query.list()); - } -} +package com.jsh.dao.basic; + +import org.hibernate.Query; + +import com.jsh.base.BaseDAO; +import com.jsh.exception.JshException; +import com.jsh.model.po.Asset; +import com.jsh.model.po.UserBusiness; +import com.jsh.util.common.PageUtil; +import com.jsh.util.common.SearchConditionUtil; + +public class UserBusinessDAO extends BaseDAO implements UserBusinessIDAO +{ + /** + * 设置dao映射基类 + * @return + */ + @Override + public Class getEntityClass() + { + return UserBusiness.class; + } + + @SuppressWarnings("unchecked") + @Override + public void find(PageUtil pageUtil,String ceshi) throws JshException + { + Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select count(id),sum(id) from UserBusiness userBusiness where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); + pageUtil.setTotalCount(query.list().size()); + pageUtil.setPageList(query.list()); + } +} diff --git a/src/com/jsh/dao/basic/UserBusinessIDAO.java b/src/com/jsh/dao/basic/UserBusinessIDAO.java index 72f5e9b9..c07e3e93 100644 --- a/src/com/jsh/dao/basic/UserBusinessIDAO.java +++ b/src/com/jsh/dao/basic/UserBusinessIDAO.java @@ -1,14 +1,14 @@ -package com.jsh.dao.basic; - -import com.jsh.base.BaseIDAO; -import com.jsh.exception.AmsException; -import com.jsh.model.po.UserBusiness; -import com.jsh.util.common.PageUtil; - -public interface UserBusinessIDAO extends BaseIDAO -{ - /* - * 测试hql语句 - */ - void find(PageUtil pageUtil,String ceshi) throws AmsException; -} +package com.jsh.dao.basic; + +import com.jsh.base.BaseIDAO; +import com.jsh.exception.JshException; +import com.jsh.model.po.UserBusiness; +import com.jsh.util.common.PageUtil; + +public interface UserBusinessIDAO extends BaseIDAO +{ + /* + * 测试hql语句 + */ + void find(PageUtil pageUtil,String ceshi) throws JshException; +} diff --git a/src/com/jsh/dao/materials/DepotHeadDAO.java b/src/com/jsh/dao/materials/DepotHeadDAO.java index 50ce9f3a..20bc6f94 100644 --- a/src/com/jsh/dao/materials/DepotHeadDAO.java +++ b/src/com/jsh/dao/materials/DepotHeadDAO.java @@ -1,32 +1,32 @@ -package com.jsh.dao.materials; - -import org.hibernate.Query; - -import com.jsh.base.BaseDAO; -import com.jsh.exception.AmsException; -import com.jsh.model.po.DepotHead; -import com.jsh.model.po.UserBusiness; -import com.jsh.util.common.PageUtil; -import com.jsh.util.common.SearchConditionUtil; - -public class DepotHeadDAO extends BaseDAO implements DepotHeadIDAO -{ - /** - * 设置dao映射基类 - * @return - */ - @Override - public Class getEntityClass() - { - return DepotHead.class; - } - - @SuppressWarnings("unchecked") - @Override - public void find(PageUtil pageUtil,String maxid) throws AmsException - { - Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select max(Id) as Id from DepotHead depotHead where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); - pageUtil.setTotalCount(query.list().size()); - pageUtil.setPageList(query.list()); - } -} +package com.jsh.dao.materials; + +import org.hibernate.Query; + +import com.jsh.base.BaseDAO; +import com.jsh.exception.JshException; +import com.jsh.model.po.DepotHead; +import com.jsh.model.po.UserBusiness; +import com.jsh.util.common.PageUtil; +import com.jsh.util.common.SearchConditionUtil; + +public class DepotHeadDAO extends BaseDAO implements DepotHeadIDAO +{ + /** + * 设置dao映射基类 + * @return + */ + @Override + public Class getEntityClass() + { + return DepotHead.class; + } + + @SuppressWarnings("unchecked") + @Override + public void find(PageUtil pageUtil,String maxid) throws JshException + { + Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery("select max(Id) as Id from DepotHead depotHead where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); + pageUtil.setTotalCount(query.list().size()); + pageUtil.setPageList(query.list()); + } +} diff --git a/src/com/jsh/dao/materials/DepotHeadIDAO.java b/src/com/jsh/dao/materials/DepotHeadIDAO.java index a2eec1a9..95e207b0 100644 --- a/src/com/jsh/dao/materials/DepotHeadIDAO.java +++ b/src/com/jsh/dao/materials/DepotHeadIDAO.java @@ -1,15 +1,15 @@ -package com.jsh.dao.materials; - -import com.jsh.base.BaseIDAO; -import com.jsh.exception.AmsException; -import com.jsh.model.po.DepotHead; -import com.jsh.model.po.UserBusiness; -import com.jsh.util.common.PageUtil; - -public interface DepotHeadIDAO extends BaseIDAO -{ - /* - * 获取MaxId - */ - void find(PageUtil pageUtil,String maxid) throws AmsException; -} +package com.jsh.dao.materials; + +import com.jsh.base.BaseIDAO; +import com.jsh.exception.JshException; +import com.jsh.model.po.DepotHead; +import com.jsh.model.po.UserBusiness; +import com.jsh.util.common.PageUtil; + +public interface DepotHeadIDAO extends BaseIDAO +{ + /* + * 获取MaxId + */ + void find(PageUtil pageUtil,String maxid) throws JshException; +} diff --git a/src/com/jsh/dao/materials/DepotItemDAO.java b/src/com/jsh/dao/materials/DepotItemDAO.java index c8937009..189551b4 100644 --- a/src/com/jsh/dao/materials/DepotItemDAO.java +++ b/src/com/jsh/dao/materials/DepotItemDAO.java @@ -1,59 +1,59 @@ -package com.jsh.dao.materials; - -import org.hibernate.Query; - -import com.jsh.base.BaseDAO; -import com.jsh.exception.AmsException; -import com.jsh.model.po.DepotHead; -import com.jsh.model.po.DepotItem; -import com.jsh.util.common.PageUtil; -import com.jsh.util.common.SearchConditionUtil; - -public class DepotItemDAO extends BaseDAO implements DepotItemIDAO -{ - /** - * 设置dao映射基类 - * @return - */ - @Override - public Class getEntityClass() - { - return DepotItem.class; - } - - @SuppressWarnings("unchecked") - @Override - public void findByType(PageUtil pageUtil,String type,Long MId,String MonthTime,Boolean isPrev) throws AmsException - { - //多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便 - Query query; - if(isPrev) { - query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"' and MaterialId ="+ MId + " and jsh_depothead.OperTime <'"+ MonthTime +"-01 00:00:00' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); - } - else { - query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"' and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 00:00:00' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); - } - pageUtil.setTotalCount(query.list().size()); - pageUtil.setPageList(query.list()); - } - - - @SuppressWarnings("unchecked") - @Override - public void findOrderByMaterial(PageUtil pageUtil) throws AmsException - { - //多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便 - Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select * from jsh_depotitem where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); - pageUtil.setTotalCount(query.list().size()); - - // 分页查询 - int pageNo = pageUtil.getCurPage(); - int pageSize = pageUtil.getPageSize(); - if (0 != pageNo && 0 != pageSize) - { - query.setFirstResult((pageNo - 1) * pageSize); - query.setMaxResults(pageSize); - } - pageUtil.setPageList(query.list()); - } -} +package com.jsh.dao.materials; + +import org.hibernate.Query; + +import com.jsh.base.BaseDAO; +import com.jsh.exception.JshException; +import com.jsh.model.po.DepotHead; +import com.jsh.model.po.DepotItem; +import com.jsh.util.common.PageUtil; +import com.jsh.util.common.SearchConditionUtil; + +public class DepotItemDAO extends BaseDAO implements DepotItemIDAO +{ + /** + * 设置dao映射基类 + * @return + */ + @Override + public Class getEntityClass() + { + return DepotItem.class; + } + + @SuppressWarnings("unchecked") + @Override + public void findByType(PageUtil pageUtil,String type,Long MId,String MonthTime,Boolean isPrev) throws JshException + { + //多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便 + Query query; + if(isPrev) { + query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"' and MaterialId ="+ MId + " and jsh_depothead.OperTime <'"+ MonthTime +"-01 00:00:00' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); + } + else { + query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select sum(OperNumber) as OperNumber from jsh_depotitem,jsh_depothead where jsh_depotitem.HeaderId = jsh_depothead.id and type='" + type +"' and MaterialId ="+ MId + " and jsh_depothead.OperTime >='"+ MonthTime +"-01 00:00:00' and jsh_depothead.OperTime <='"+ MonthTime +"-31 00:00:00' " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); + } + pageUtil.setTotalCount(query.list().size()); + pageUtil.setPageList(query.list()); + } + + + @SuppressWarnings("unchecked") + @Override + public void findOrderByMaterial(PageUtil pageUtil) throws JshException + { + //多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便 + Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery("select * from jsh_depotitem where 1=1 " + SearchConditionUtil.getCondition(pageUtil.getAdvSearch())); + pageUtil.setTotalCount(query.list().size()); + + // 分页查询 + int pageNo = pageUtil.getCurPage(); + int pageSize = pageUtil.getPageSize(); + if (0 != pageNo && 0 != pageSize) + { + query.setFirstResult((pageNo - 1) * pageSize); + query.setMaxResults(pageSize); + } + pageUtil.setPageList(query.list()); + } +} diff --git a/src/com/jsh/dao/materials/DepotItemIDAO.java b/src/com/jsh/dao/materials/DepotItemIDAO.java index a1a72e0b..d67838f0 100644 --- a/src/com/jsh/dao/materials/DepotItemIDAO.java +++ b/src/com/jsh/dao/materials/DepotItemIDAO.java @@ -1,14 +1,14 @@ -package com.jsh.dao.materials; - -import com.jsh.base.BaseIDAO; -import com.jsh.exception.AmsException; -import com.jsh.model.po.DepotHead; -import com.jsh.model.po.DepotItem; -import com.jsh.util.common.PageUtil; - -public interface DepotItemIDAO extends BaseIDAO -{ - void findByType(PageUtil pageUtil,String type,Long MId, String MonthTime,Boolean isPrev) throws AmsException; - - void findOrderByMaterial(PageUtil pageUtil) throws AmsException; -} +package com.jsh.dao.materials; + +import com.jsh.base.BaseIDAO; +import com.jsh.exception.JshException; +import com.jsh.model.po.DepotHead; +import com.jsh.model.po.DepotItem; +import com.jsh.util.common.PageUtil; + +public interface DepotItemIDAO extends BaseIDAO +{ + void findByType(PageUtil pageUtil,String type,Long MId, String MonthTime,Boolean isPrev) throws JshException; + + void findOrderByMaterial(PageUtil pageUtil) throws JshException; +} diff --git a/src/com/jsh/exception/AmsException.java b/src/com/jsh/exception/JshException.java similarity index 61% rename from src/com/jsh/exception/AmsException.java rename to src/com/jsh/exception/JshException.java index 94bde3b2..58fe5d50 100644 --- a/src/com/jsh/exception/AmsException.java +++ b/src/com/jsh/exception/JshException.java @@ -1,73 +1,73 @@ -package com.jsh.exception; - -/** - * @title: 平台异常基类 - * @description: 用于包装一些异常信息,打印日志等服务 - * @author andy - * @since: 2014-01-24 - */ -@SuppressWarnings("serial") -public class AmsException extends Exception -{ - public long errorCode = -1; - - public String message ; - - public AmsException() - { - super(); - } - - public AmsException(String message) - { - super(message); - this.message = message; - } - - public AmsException(String message, Throwable cause) - { - super(message, cause); - this.message = message; - } - - public AmsException(Throwable cause) - { - super(cause); - } - - public AmsException(long errorCode) - { - super(); - this.errorCode = errorCode; - } - - public AmsException(String message, long errorCode) - { - super(message); - this.errorCode = errorCode; - this.message = message; - } - - public AmsException(String message, long errorCode, Throwable cause) - { - super(message, cause); - this.errorCode = errorCode; - this.message = message; - } - - public AmsException(long errorCode, Throwable cause) - { - super(cause); - this.errorCode = errorCode; - } - - public long getErrorCode() - { - return errorCode; - } - - public String getMessage() - { - return message; - } -} +package com.jsh.exception; + +/** + * @title: 平台异常基类 + * @description: 用于包装一些异常信息,打印日志等服务 + * @author jishenghua + * @since: 2014-01-24 + */ +@SuppressWarnings("serial") +public class JshException extends Exception +{ + public long errorCode = -1; + + public String message ; + + public JshException() + { + super(); + } + + public JshException(String message) + { + super(message); + this.message = message; + } + + public JshException(String message, Throwable cause) + { + super(message, cause); + this.message = message; + } + + public JshException(Throwable cause) + { + super(cause); + } + + public JshException(long errorCode) + { + super(); + this.errorCode = errorCode; + } + + public JshException(String message, long errorCode) + { + super(message); + this.errorCode = errorCode; + this.message = message; + } + + public JshException(String message, long errorCode, Throwable cause) + { + super(message, cause); + this.errorCode = errorCode; + this.message = message; + } + + public JshException(long errorCode, Throwable cause) + { + super(cause); + this.errorCode = errorCode; + } + + public long getErrorCode() + { + return errorCode; + } + + public String getMessage() + { + return message; + } +} diff --git a/src/com/jsh/filter/user/UserFilter.java b/src/com/jsh/filter/user/UserFilter.java index 79f91cf7..8c9efa17 100644 --- a/src/com/jsh/filter/user/UserFilter.java +++ b/src/com/jsh/filter/user/UserFilter.java @@ -1,83 +1,83 @@ -package com.jsh.filter.user; - -import java.io.IOException; -import java.io.PrintWriter; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; -/** - * 用户登录session处理类 - * 过滤session是否超时 - * @author andy - * @version [版本号, 2012-3-6] - * @see [相关类/方法] - * @since - */ -public class UserFilter implements Filter -{ - /** - * 初始化过滤器 暂不处理 - * 重载方法 - * @param arg0 - * @throws ServletException - */ - - public void init(FilterConfig arg0) - throws ServletException - { - - } - /** - * 判断用户session是否存在 不存在则跳转到登录页面 - * 重载方法 - * @param srequest - * @param sresponse - * @param chain - * @throws IOException - * @throws ServletException - */ - public void doFilter(ServletRequest srequest, ServletResponse sresponse, FilterChain chain) - throws IOException, ServletException - { - HttpServletRequest request = (HttpServletRequest) srequest; - HttpServletResponse response = (HttpServletResponse) sresponse; - HttpSession session = request.getSession(); -// //定义登录页面不被过滤===后续考虑 -// List notFilterFile = new ArrayList(); -// notFilterFile.add("/login.jsp"); -// notFilterFile.add("/logout.jsp"); -// notFilterFile.add("/css/*"); -// notFilterFile.add("/css/zTreeStyle/*"); -// notFilterFile.add("/css/zTreeStyle/img/*"); -// notFilterFile.add("/css/zTreeStyle/img/diy/*"); - - //获取工程路径 - String path = request.getContextPath(); - String requestURl = request.getRequestURI(); - - //提示用户没有权限操作 -// response.setCharacterEncoding("utf-8"); -// PrintWriter pw=response.getWriter(); -// pw.write(""); - //session中有值则不进行处理 - if(requestURl.contains("/pages") &&null != session.getAttribute("user")) - chain.doFilter(request, response); - else - response.sendRedirect(path + "/logout.jsp"); - } - - /** - * 销毁过滤器 - */ - public void destroy() - { - - } -} \ No newline at end of file +package com.jsh.filter.user; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +/** + * 用户登录session处理类 + * 过滤session是否超时 + * @author jishenghua + * @version [版本号, 2012-3-6] + * @see [相关类/方法] + * @since + */ +public class UserFilter implements Filter +{ + /** + * 初始化过滤器 暂不处理 + * 重载方法 + * @param arg0 + * @throws ServletException + */ + + public void init(FilterConfig arg0) + throws ServletException + { + + } + /** + * 判断用户session是否存在 不存在则跳转到登录页面 + * 重载方法 + * @param srequest + * @param sresponse + * @param chain + * @throws IOException + * @throws ServletException + */ + public void doFilter(ServletRequest srequest, ServletResponse sresponse, FilterChain chain) + throws IOException, ServletException + { + HttpServletRequest request = (HttpServletRequest) srequest; + HttpServletResponse response = (HttpServletResponse) sresponse; + HttpSession session = request.getSession(); +// //定义登录页面不被过滤===后续考虑 +// List notFilterFile = new ArrayList(); +// notFilterFile.add("/login.jsp"); +// notFilterFile.add("/logout.jsp"); +// notFilterFile.add("/css/*"); +// notFilterFile.add("/css/zTreeStyle/*"); +// notFilterFile.add("/css/zTreeStyle/img/*"); +// notFilterFile.add("/css/zTreeStyle/img/diy/*"); + + //获取工程路径 + String path = request.getContextPath(); + String requestURl = request.getRequestURI(); + + //提示用户没有权限操作 +// response.setCharacterEncoding("utf-8"); +// PrintWriter pw=response.getWriter(); +// pw.write(""); + //session中有值则不进行处理 + if(requestURl.contains("/pages") &&null != session.getAttribute("user")) + chain.doFilter(request, response); + else + response.sendRedirect(path + "/logout.jsp"); + } + + /** + * 销毁过滤器 + */ + public void destroy() + { + + } +} diff --git a/src/com/jsh/model/po/Basicuser.hbm.xml b/src/com/jsh/model/po/Basicuser.hbm.xml index 5b7a04eb..e6abb717 100644 --- a/src/com/jsh/model/po/Basicuser.hbm.xml +++ b/src/com/jsh/model/po/Basicuser.hbm.xml @@ -18,7 +18,7 @@ - + 登陆密码 diff --git a/src/com/jsh/model/vo/materials/DepotHeadModel.java b/src/com/jsh/model/vo/materials/DepotHeadModel.java index 5860f703..584df683 100644 --- a/src/com/jsh/model/vo/materials/DepotHeadModel.java +++ b/src/com/jsh/model/vo/materials/DepotHeadModel.java @@ -1,257 +1,256 @@ -package com.jsh.model.vo.materials; - -import java.io.Serializable; -import com.sun.jmx.snmp.Timestamp; - -@SuppressWarnings("serial") -public class DepotHeadModel implements Serializable -{ - private DepotHeadShowModel showModel = new DepotHeadShowModel(); - - /**======开始接受页面参数=================**/ - private String Type = ""; - private String SubType = ""; - private Long ProjectId; - private String Number = ""; - private String OperPersonName = ""; - private String OperTime; - private Long OrganId; - private Long HandsPersonId; - private Long WareHousePersonId; - private String SettlementWay = ""; - private Long BuildingId; - private Long AllocationProjectId; - private String Remark = ""; - private String State = ""; - private String ReAuditPersonName = ""; - private String Reason = ""; - - private String BeginTime; //查询开始时间 - private String EndTime; //查询结束时间 - private String MonthTime; //查询月份 - /** - * 分类ID - */ - private Long depotHeadID = 0l; - - /** - * 分类IDs 批量操作使用 - */ - private String depotHeadIDs = ""; - - /** - * 每页显示的个数 - */ - private int pageSize = 10; - - /** - * 当前页码 - */ - private int pageNo = 1; - - /** - * 用户IP,用户记录操作日志 - */ - private String clientIp = ""; - - public DepotHeadShowModel getShowModel() { - return showModel; - } - - public void setShowModel(DepotHeadShowModel showModel) { - this.showModel = showModel; - } - - public String getType() { - return Type; - } - - public void setType(String type) { - Type = type; - } - - public String getSubType() { - return SubType; - } - - public void setSubType(String subType) { - SubType = subType; - } - - public Long getProjectId() { - return ProjectId; - } - - public void setProjectId(Long projectId) { - ProjectId = projectId; - } - - public String getNumber() { - return Number; - } - - public void setNumber(String number) { - Number = number; - } - - public String getOperPersonName() { - return OperPersonName; - } - - public void setOperPersonName(String operPersonName) { - OperPersonName = operPersonName; - } - - public Long getOrganId() { - return OrganId; - } - - public void setOrganId(Long organId) { - OrganId = organId; - } - - public Long getHandsPersonId() { - return HandsPersonId; - } - - public void setHandsPersonId(Long handsPersonId) { - HandsPersonId = handsPersonId; - } - - public Long getWareHousePersonId() { - return WareHousePersonId; - } - - public void setWareHousePersonId(Long wareHousePersonId) { - WareHousePersonId = wareHousePersonId; - } - - public String getSettlementWay() { - return SettlementWay; - } - - public void setSettlementWay(String settlementWay) { - SettlementWay = settlementWay; - } - - public Long getBuildingId() { - return BuildingId; - } - - public void setBuildingId(Long buildingId) { - BuildingId = buildingId; - } - - public Long getAllocationProjectId() { - return AllocationProjectId; - } - - public void setAllocationProjectId(Long allocationProjectId) { - AllocationProjectId = allocationProjectId; - } - - public String getRemark() { - return Remark; - } - - public void setRemark(String remark) { - Remark = remark; - } - - public String getState() { - return State; - } - - public void setState(String state) { - State = state; - } - - public String getReAuditPersonName() { - return ReAuditPersonName; - } - - public void setReAuditPersonName(String reAuditPersonName) { - ReAuditPersonName = reAuditPersonName; - } - - public String getReason() { - return Reason; - } - - public void setReason(String reason) { - Reason = reason; - } - - public Long getDepotHeadID() { - return depotHeadID; - } - - public void setDepotHeadID(Long depotHeadID) { - this.depotHeadID = depotHeadID; - } - - public String getDepotHeadIDs() { - return depotHeadIDs; - } - - public void setDepotHeadIDs(String depotHeadIDs) { - this.depotHeadIDs = depotHeadIDs; - } - - public int getPageSize() { - return pageSize; - } - - public void setPageSize(int pageSize) { - this.pageSize = pageSize; - } - - public int getPageNo() { - return pageNo; - } - - public void setPageNo(int pageNo) { - this.pageNo = pageNo; - } - - public String getClientIp() { - return clientIp; - } - - public void setClientIp(String clientIp) { - this.clientIp = clientIp; - } - - public String getBeginTime() { - return BeginTime; - } - - public void setBeginTime(String beginTime) { - BeginTime = beginTime; - } - - public String getEndTime() { - return EndTime; - } - - public void setEndTime(String endTime) { - EndTime = endTime; - } - - public String getOperTime() { - return OperTime; - } - - public void setOperTime(String operTime) { - OperTime = operTime; - } - - public String getMonthTime() { - return MonthTime; - } - - public void setMonthTime(String monthTime) { - MonthTime = monthTime; - } - -} +package com.jsh.model.vo.materials; + +import java.io.Serializable; + +@SuppressWarnings("serial") +public class DepotHeadModel implements Serializable +{ + private DepotHeadShowModel showModel = new DepotHeadShowModel(); + + /**======开始接受页面参数=================**/ + private String Type = ""; + private String SubType = ""; + private Long ProjectId; + private String Number = ""; + private String OperPersonName = ""; + private String OperTime; + private Long OrganId; + private Long HandsPersonId; + private Long WareHousePersonId; + private String SettlementWay = ""; + private Long BuildingId; + private Long AllocationProjectId; + private String Remark = ""; + private String State = ""; + private String ReAuditPersonName = ""; + private String Reason = ""; + + private String BeginTime; //查询开始时间 + private String EndTime; //查询结束时间 + private String MonthTime; //查询月份 + /** + * 分类ID + */ + private Long depotHeadID = 0l; + + /** + * 分类IDs 批量操作使用 + */ + private String depotHeadIDs = ""; + + /** + * 每页显示的个数 + */ + private int pageSize = 10; + + /** + * 当前页码 + */ + private int pageNo = 1; + + /** + * 用户IP,用户记录操作日志 + */ + private String clientIp = ""; + + public DepotHeadShowModel getShowModel() { + return showModel; + } + + public void setShowModel(DepotHeadShowModel showModel) { + this.showModel = showModel; + } + + public String getType() { + return Type; + } + + public void setType(String type) { + Type = type; + } + + public String getSubType() { + return SubType; + } + + public void setSubType(String subType) { + SubType = subType; + } + + public Long getProjectId() { + return ProjectId; + } + + public void setProjectId(Long projectId) { + ProjectId = projectId; + } + + public String getNumber() { + return Number; + } + + public void setNumber(String number) { + Number = number; + } + + public String getOperPersonName() { + return OperPersonName; + } + + public void setOperPersonName(String operPersonName) { + OperPersonName = operPersonName; + } + + public Long getOrganId() { + return OrganId; + } + + public void setOrganId(Long organId) { + OrganId = organId; + } + + public Long getHandsPersonId() { + return HandsPersonId; + } + + public void setHandsPersonId(Long handsPersonId) { + HandsPersonId = handsPersonId; + } + + public Long getWareHousePersonId() { + return WareHousePersonId; + } + + public void setWareHousePersonId(Long wareHousePersonId) { + WareHousePersonId = wareHousePersonId; + } + + public String getSettlementWay() { + return SettlementWay; + } + + public void setSettlementWay(String settlementWay) { + SettlementWay = settlementWay; + } + + public Long getBuildingId() { + return BuildingId; + } + + public void setBuildingId(Long buildingId) { + BuildingId = buildingId; + } + + public Long getAllocationProjectId() { + return AllocationProjectId; + } + + public void setAllocationProjectId(Long allocationProjectId) { + AllocationProjectId = allocationProjectId; + } + + public String getRemark() { + return Remark; + } + + public void setRemark(String remark) { + Remark = remark; + } + + public String getState() { + return State; + } + + public void setState(String state) { + State = state; + } + + public String getReAuditPersonName() { + return ReAuditPersonName; + } + + public void setReAuditPersonName(String reAuditPersonName) { + ReAuditPersonName = reAuditPersonName; + } + + public String getReason() { + return Reason; + } + + public void setReason(String reason) { + Reason = reason; + } + + public Long getDepotHeadID() { + return depotHeadID; + } + + public void setDepotHeadID(Long depotHeadID) { + this.depotHeadID = depotHeadID; + } + + public String getDepotHeadIDs() { + return depotHeadIDs; + } + + public void setDepotHeadIDs(String depotHeadIDs) { + this.depotHeadIDs = depotHeadIDs; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageNo() { + return pageNo; + } + + public void setPageNo(int pageNo) { + this.pageNo = pageNo; + } + + public String getClientIp() { + return clientIp; + } + + public void setClientIp(String clientIp) { + this.clientIp = clientIp; + } + + public String getBeginTime() { + return BeginTime; + } + + public void setBeginTime(String beginTime) { + BeginTime = beginTime; + } + + public String getEndTime() { + return EndTime; + } + + public void setEndTime(String endTime) { + EndTime = endTime; + } + + public String getOperTime() { + return OperTime; + } + + public void setOperTime(String operTime) { + OperTime = operTime; + } + + public String getMonthTime() { + return MonthTime; + } + + public void setMonthTime(String monthTime) { + MonthTime = monthTime; + } + +} diff --git a/src/com/jsh/service/asset/AssetIService.java b/src/com/jsh/service/asset/AssetIService.java index c0724497..b446229a 100644 --- a/src/com/jsh/service/asset/AssetIService.java +++ b/src/com/jsh/service/asset/AssetIService.java @@ -1,30 +1,30 @@ -package com.jsh.service.asset; - -import java.io.File; -import java.io.InputStream; - -import com.jsh.base.BaseIService; -import com.jsh.exception.AmsException; -import com.jsh.model.po.Asset; -import com.jsh.util.common.PageUtil; - -public interface AssetIService extends BaseIService -{ - /** - * 导出信息 - * @return - */ - InputStream exmportExcel(String isAllPage,PageUtil pageUtil)throws AmsException; - - /** - * 导入资产excel文件--表格格式 同 媒资列表 || 资产名称-资产类型-单价-用户-购买时间-状态-位置-资产编号-序列号-有效日期-保修日期-供应商-标签-描述 - * 业务规则:导入时,检查资产名称是否存在,如存在就不考虑表格中资产类型。如资产名不存在,就新建资产名,类型用表格中的,但类型必须是系统中存在的,不存在的不能导入。 - * 资产名称,用户可以添加,其他的应该不能填 - * - * @param assetFile excel表格文件 - * @param isCheck 是否检查 0--手工确定 1--直接导入数据库中 - * @return 错误的表格数据 - * @throws AmsException - */ - InputStream importExcel(File assetFile,int isCheck)throws AmsException; -} +package com.jsh.service.asset; + +import java.io.File; +import java.io.InputStream; + +import com.jsh.base.BaseIService; +import com.jsh.exception.JshException; +import com.jsh.model.po.Asset; +import com.jsh.util.common.PageUtil; + +public interface AssetIService extends BaseIService +{ + /** + * 导出信息 + * @return + */ + InputStream exmportExcel(String isAllPage,PageUtil pageUtil)throws JshException; + + /** + * 导入资产excel文件--表格格式 同 媒资列表 || 资产名称-资产类型-单价-用户-购买时间-状态-位置-资产编号-序列号-有效日期-保修日期-供应商-标签-描述 + * 业务规则:导入时,检查资产名称是否存在,如存在就不考虑表格中资产类型。如资产名不存在,就新建资产名,类型用表格中的,但类型必须是系统中存在的,不存在的不能导入。 + * 资产名称,用户可以添加,其他的应该不能填 + * + * @param assetFile excel表格文件 + * @param isCheck 是否检查 0--手工确定 1--直接导入数据库中 + * @return 错误的表格数据 + * @throws JshException + */ + InputStream importExcel(File assetFile,int isCheck)throws JshException; +} diff --git a/src/com/jsh/service/asset/AssetService.java b/src/com/jsh/service/asset/AssetService.java index 2be7bf25..28a76e12 100644 --- a/src/com/jsh/service/asset/AssetService.java +++ b/src/com/jsh/service/asset/AssetService.java @@ -1,746 +1,746 @@ -package com.jsh.service.asset; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.sql.Timestamp; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import jxl.Workbook; -import jxl.format.Colour; -import jxl.write.Label; -import jxl.write.WritableCellFormat; -import jxl.write.WritableSheet; -import jxl.write.WritableWorkbook; -import jxl.write.WriteException; - -import org.apache.poi.hssf.usermodel.HSSFSheet; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.DateUtil; -import org.apache.poi.ss.usermodel.Row; - -import com.jsh.base.BaseService; -import com.jsh.base.Log; -import com.jsh.constants.asset.AssetConstants; -import com.jsh.dao.asset.AssetIDAO; -import com.jsh.dao.basic.AssetNameIDAO; -import com.jsh.dao.basic.CategoryIDAO; -import com.jsh.dao.basic.SupplierIDAO; -import com.jsh.dao.basic.UserIDAO; -import com.jsh.exception.AmsException; -import com.jsh.model.po.Asset; -import com.jsh.model.po.Assetname; -import com.jsh.model.po.Category; -import com.jsh.model.po.Supplier; -import com.jsh.util.common.PageUtil; -import com.jsh.util.common.Tools; - -public class AssetService extends BaseService implements AssetIService -{ - private AssetIDAO assetDao; - - private AssetNameIDAO assetNameDao; - - private CategoryIDAO categoryDao; - - private SupplierIDAO supplierDao; - - private UserIDAO userDao; - - /** - * 初始化加载所有系统基础数据 - */ - @SuppressWarnings({"rawtypes"}) - private static Map mapData = new HashMap(); - - /** - * 错误的表格数据 - */ - private static List wrongData = new ArrayList(); - - /** - * 导出Excel表格 - */ - @Override - public InputStream exmportExcel(String isAllPage,PageUtil pageUtil)throws AmsException - { - try - { - if("currentPage".equals(isAllPage)) - { - assetDao.find(pageUtil); - } - else - { - pageUtil.setCurPage(0); - pageUtil.setPageSize(0); - assetDao.find(pageUtil); - } - - //将OutputStream转化为InputStream - ByteArrayOutputStream out = new ByteArrayOutputStream(); - putDataOnOutputStream(out,pageUtil.getPageList()); - return new ByteArrayInputStream(out.toByteArray()); - } - catch (Exception e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>>导出资产信息为excel表格异常", e); - throw new AmsException("export asset info to excel exception",e); - } - } - - @Override - public InputStream importExcel(File assetFile,int isCheck) throws AmsException - { - //全局变量--每次调用前需要清空数据 - mapData.clear(); - //1、加载系统基础数据 - loadSystemData(); - //2、解析文件成资产数据 - parseFile(assetFile); - - if(null != wrongData && wrongData.size()>0) - { - //将OutputStream转化为InputStream - ByteArrayOutputStream out = new ByteArrayOutputStream(); - putDataOnOutputStream(out,wrongData); - return new ByteArrayInputStream(out.toByteArray()); - } - else - return null; - //2、是否直接插入数据库中 -// if(0 == isCheck) -// System.out.println("手动检查"); -// else -// System.out.println("自动检查插入"); - } - - /** - * 初始加载系统基础数据--导入过程中,不用频繁查询数据库内容,影响系统性能。 - * @throws AmsException - */ - @SuppressWarnings({ "unchecked", "rawtypes" }) - private void loadSystemData()throws AmsException - { - PageUtil pageUtil = new PageUtil(); - pageUtil.setPageSize(0); - pageUtil.setCurPage(0); - try - { - Map condition = pageUtil.getAdvSearch(); - condition.put("id_s_order", "desc"); - categoryDao.find(pageUtil); - mapData.put("categoryList", pageUtil.getPageList()); - - supplierDao.find(pageUtil); - mapData.put("supplierList", pageUtil.getPageList()); - - condition.put("isystem_n_eq", 1); - condition.put("id_s_order", "desc"); - userDao.find(pageUtil); - mapData.put("userList", pageUtil.getPageList()); - - //清除搜索条件 防止对查询有影响 - condition.remove("isystem_n_eq"); - - assetNameDao.find(pageUtil); - mapData.put("assetnameList", pageUtil.getPageList()); - } - catch (Exception e) - { - Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e); - } - } - - /** - * 解析excel表格 - * @param assetFile - */ - @SuppressWarnings("unchecked") - private void parseFile(File assetFile) - { - //每次调用前清空 - wrongData.clear(); - int totalRow = 0; - try - { - //创建对Excel工作簿文件的引用 - HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(assetFile)); - //创建对工作表的引用,获取第一个工作表的内容 - HSSFSheet sheet = workbook.getSheetAt(0); - /** - * ===================================== - * 1、此处要增加文件的验证,如果不是资产文件需要进行特殊的处理,13列 - * 2、文件内容为空处理 - * 3、如果是修改过的文件内容 - */ - Iterator itsheet = sheet.rowIterator(); - while(itsheet.hasNext()) - { - //获取当前行数据 - Row row = itsheet.next(); - //获取一行有多少单元格 -// System.out.println(row.getLastCellNum()); - - //excel表格第几行数据 从1开始 0 是表头 - int rowNum = row.getRowNum(); - /** - * 表头跳过不读 - */ - if(AssetConstants.BusinessForExcel.EXCEL_TABLE_HEAD == rowNum) - continue; - - //开始处理excel表格内容 --每行数据读取,同时统计总共行数 - totalRow ++; - - //获取excel表格的每格数据内容 - Iterator it = row.cellIterator(); - //资产子类型--添加了一些excel表格数据 - Asset asset = new Asset(); - //保存每个单元格错误类型 - Map cellType = new HashMap(); - - //名称需要类型字段 - Assetname nameModel = null; - //资产名称 - @SuppressWarnings("unused") - String assetname = ""; - - //资产类型 - String categoryStr = ""; - //设置列号 - asset.setRowLineNum(rowNum); - - Cell cell = null; - //判断列号--从零开始 - int cellIndex = 0; - while(it.hasNext()) - { - //获取每个单元格对象 - cell = it.next(); - //获取列号 - cellIndex = cell.getColumnIndex(); - //设置此单元格为字符串类型 - cell.setCellType(Cell.CELL_TYPE_STRING); - - Log.infoFileSync("==================excel表格中第" + totalRow + "行的第 " + cellIndex + "列的值为" + cell.getStringCellValue()); - - //每行中数据顺序 资产名称-资产类型-单价-用户-购买时间-状态-位置-资产编号-序列号-有效日期-保修日期-供应商-标签-描述 - switch(cellIndex) - { - case AssetConstants.BusinessForExcel.EXCEL_ASSETNAME : - //资产名称是否存在 - boolean isAssetnameExist = false; - //此处添加资产名称处理 - String nameValue = cell.getStringCellValue(); - if(null == nameValue || "".equals(nameValue)) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>资产名称没有填写"); - cellType.put(cellIndex, "wrong"); - break; - } - assetname = nameValue; - - List nameList = mapData.get("assetnameList"); - for(Assetname name:nameList) - { - //表示名称存在--直接进行保存,不需要判断类型字段 - if(nameValue.equals(name.getAssetname())) - { - isAssetnameExist = true; - //直接进行设置 - asset.setAssetname(name); - break; - } - } - //名称不存在 重新创建 - if(!isAssetnameExist) - { - isAssetnameExist = false; - nameModel = new Assetname(); - nameModel.setAssetname(nameValue); - nameModel.setIsconsumables((short)0); - nameModel.setIsystem((short)1); - nameModel.setDescription(""); - - asset.setAssetnameStr(nameValue); - } - break; - case AssetConstants.BusinessForExcel.EXCEL_CATEGORY : - //此处添加资产类型处理 - //类型信息是否存在 - boolean isCategoryExist = false; - String categoryValue = cell.getStringCellValue(); - if((null == categoryValue || "".equals(categoryValue)) && null != nameModel) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>资产名称没有指定类型"); - cellType.put(cellIndex, "wrong"); - break; - } - categoryStr = categoryValue; - - List categoryList = mapData.get("categoryList"); - for(Category category:categoryList) - { - //表示新创建 --名称设置过 不需要再进行处理 - if(category.getAssetname().equals(categoryValue) && null != nameModel) - { - isCategoryExist = true; - nameModel.setCategory(category); - asset.setAssetname(nameModel); - assetNameDao.create(nameModel); - break; - } - } - //重新创建 - if(null != nameModel && !isCategoryExist) - { - //首先创建类型信息 - Category canew = new Category(); - canew.setAssetname(categoryValue); - canew.setIsystem((short)1); - canew.setDescription(""); - categoryDao.create(canew); - - nameModel.setCategory(canew); - - assetNameDao.create(nameModel); - - asset.setAssetname(nameModel); - } - //nameModel为空表示 已经处理过类型信息 --此处不需要进行处理 - else - { - asset.setCategory(categoryStr); - } - break; - case AssetConstants.BusinessForExcel.EXCEL_PRICE: - //此处添加单价处理 - String priceValue = cell.getStringCellValue(); - //String priceValue = getCellFormatValue(cell); - if(null == priceValue || "".equals(priceValue)) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>资产没有填写单价"); - break; - } - //解析价格 - if(Tools.checkStrIsNum(priceValue)) - asset.setPrice(Double.parseDouble(priceValue)); - else - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>资产价格不是数字格式"); - cellType.put(cellIndex, "wrong"); - asset.setPrice(0.00d); - asset.setPriceStr(priceValue); - } - break; - case AssetConstants.BusinessForExcel.EXCEL_USER : - //此处添加用户处理--用户信息不需要进行处理 - break; - case AssetConstants.BusinessForExcel.EXCEL_PURCHASE_DATE : - //此处添加购买时间处理--时间不需要处理 - String purchaseValue = cell.getStringCellValue(); - if(null == purchaseValue || "".equals(purchaseValue)) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>资产没有填写购买日期"); - break; - } - try - { - asset.setPurchasedate(new Timestamp(Tools.parse(purchaseValue, "yyyy-MM-dd").getTime())); - } - catch (ParseException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>解析购买日期异常", e); - try - { - asset.setPurchasedate(new Timestamp(DateUtil.getJavaDate(Double.parseDouble(purchaseValue)).getTime())); - } - catch (Exception t) - { - asset.setPurchasedateStr(purchaseValue); - cellType.put(cellIndex, "wrong"); - } - } - break; - case AssetConstants.BusinessForExcel.EXCEL_STATUS : - //此处添加状态处理--默认为在库状态 - asset.setStatus((short)0); - break; - case AssetConstants.BusinessForExcel.EXCEL_LOCATION : - //此处添加位置处理--不需要进行处理 - String locationValue = cell.getStringCellValue(); - if(null == locationValue || "".equals(locationValue)) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>资产没有填写位置信息"); - break; - } - asset.setLocation(locationValue); - break; - case AssetConstants.BusinessForExcel.EXCEL_NUM : - //此处添加资产编号处理 - String assetnumValue = cell.getStringCellValue(); - if(null == assetnumValue || "".equals(assetnumValue)) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>资产没有填写资产编号"); - break; - } - //设置资产编号 - asset.setAssetnum(assetnumValue); - break; - case AssetConstants.BusinessForExcel.EXCEL_SERIALNO : - //此处添加序列号处理 - String assetseriValue = cell.getStringCellValue(); - if(null == assetseriValue || "".equals(assetseriValue)) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>资产没有填写序列号"); - break; - } - //设置资产编号 - asset.setSerialnum(assetseriValue); - break; - case AssetConstants.BusinessForExcel.EXCEL_EXPIRATION_DATE : - //此处添加有效日期处理--不需要处理 - String expirationValue = cell.getStringCellValue(); - if(null == expirationValue || "".equals(expirationValue)) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>资产没有有效日期"); - break; - } - - try - { - asset.setPeriodofvalidity(new Timestamp(Tools.parse(expirationValue, "yyyy-MM-dd").getTime())); - } - catch (ParseException e) - { - try - { - asset.setPeriodofvalidity(new Timestamp(DateUtil.getJavaDate(Double.parseDouble(expirationValue)).getTime())); - } - catch (Exception t) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>解析有效日期异常", t); - asset.setPeriodofvalidityStr(expirationValue); - cellType.put(cellIndex, "wrong"); - } - } - break; - case AssetConstants.BusinessForExcel.EXCEL_WARRANTY_DATE : - //此处添加保修日期处理--不需要处理 - String warrantyValue = cell.getStringCellValue(); - if(null == warrantyValue || "".equals(warrantyValue)) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>资产没有保修日期"); - break; - } - try - { - asset.setWarrantydate(new Timestamp(Tools.parse(warrantyValue, "yyyy-MM-dd").getTime())); - } - catch (ParseException e) - { - try - { - asset.setWarrantydate(new Timestamp(DateUtil.getJavaDate(Double.parseDouble(warrantyValue)).getTime())); - } - catch (Exception t) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>解析保修日期异常", t); - asset.setWarrantydateStr(warrantyValue); - cellType.put(cellIndex, "wrong"); - } - } - break; - case AssetConstants.BusinessForExcel.EXCEL_SUPPLIER : - //此处添加供应商处理 - - String supplierValue = cell.getStringCellValue(); - if(null == supplierValue || "".equals(supplierValue)) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>资产没有填写供应商"); - cellType.put(cellIndex, "wrong"); - break; - } - //供应商 - List supplierList = mapData.get("supplierList"); - boolean isSupplerExist =false; - for(Supplier supplier:supplierList) - { - if(supplierValue.equals(supplier.getSupplier())) - { - isSupplerExist =true; - asset.setSupplier(supplier); - break; - } - } - if(!isSupplerExist) - { - Supplier sup = new Supplier(); - sup.setIsystem((short)1); - sup.setSupplier(supplierValue); - sup.setDescription(""); - supplierDao.create(sup); - //保存供应商信息 - asset.setSupplier(sup); - } - break; - case AssetConstants.BusinessForExcel.EXCEL_LABLE : - //此处添加标签处理 - String lableValue = cell.getStringCellValue(); - if(null == lableValue || "".equals(lableValue)) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>资产没有填写标签信息"); - break; - } - asset.setLabels(lableValue); - break; - case AssetConstants.BusinessForExcel.EXCEL_DESC : - //此处添加描述信息处理 - String descValue = cell.getStringCellValue(); - if(null == descValue || "".equals(descValue)) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>资产没有填写描述信息"); - break; - } - asset.setDescription(descValue); - break; - } - } - asset.setCreatetime(new Timestamp(Calendar.getInstance().getTime().getTime())); - asset.setUpdatetime(new Timestamp(Calendar.getInstance().getTime().getTime())); - asset.setCellInfo(cellType); - - Log.infoFileSync(totalRow + "行总共有" + cellIndex + "列"); - //资产文件为13列,否则不是资产模板文件--不输入的时候 判断会有问题 暂时去掉 -// if(cellIndex != 13) -// { -// Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>导入文件格式不合法,请重新选择文件进行操作!"); -// return; -// } - - //判断完成后增加数据 - if((null!=cellType && cellType.size() >0) - || asset.getAssetname() == null || asset.getAssetname().getCategory() == null) - wrongData.add(asset); - else - { - if(null == asset.getStatus()) - asset.setStatus((short)0); - assetDao.save(asset); - } - } - } - catch (FileNotFoundException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>读取excel文件异常:找不到指定文件!",e); - } - catch (IOException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>读取excel文件异常,请确认文件格式是否正确 !",e); - } - Log.infoFileSync("===================excel表格总共有 " + totalRow + " 条记录!"); - } - - /** - * 生成excel表格 - * @param os - */ - private void putDataOnOutputStream(OutputStream os,List dataList) - { - WritableWorkbook workbook = null; - try - { - workbook = Workbook.createWorkbook(os); - WritableSheet sheet = workbook.createSheet("资产详细信息", 0); - //增加列头 - int[] colunmWidth = {30,30,10,15,20,10,30,30,30,20,20,20,30,80}; - String[] colunmName = {"资产名称","资产类型","单价","用户","购买时间","状态","位置","资产编号","序列号","有效日期","保修日期","供应商","标签","描述"}; - for(int i = 0 ;i < colunmWidth.length;i ++) - { - sheet.setColumnView(i,colunmWidth[i]); - sheet.addCell(new Label(i, 0, colunmName[i])); - } - - if (null != dataList &&dataList.size() > 0) - { - int i = 1; - for (Asset asset: dataList) - { - int j = 0; - Map cellInfo = asset.getCellInfo(); - - //第一列,填充 数据, Label(列,行,值) - sheet.addCell(getLabelInfo(cellInfo,j++,i,asset.getAssetname() == null ?"":asset.getAssetname().getAssetname(),asset)); - sheet.addCell(getLabelInfo(cellInfo,j++,i,asset.getAssetname() == null || asset.getAssetname().getCategory() == null ?"":asset.getAssetname().getCategory().getAssetname(),asset)); - sheet.addCell(getLabelInfo(cellInfo,j++,i,asset.getPrice() == null?"":asset.getPrice().toString(),asset)); - sheet.addCell(new Label(j++, i, asset.getUser()==null?"":asset.getUser().getUsername())); - sheet.addCell(getLabelInfo(cellInfo,j++,i,asset.getPurchasedate() == null ?"":Tools.getCurrentMonth(asset.getPurchasedate()),asset)); - Short status = asset.getStatus(); - if(null == status) - status = 0 ; - if(AssetConstants.BusinessForExcel.EXCEl_STATUS_ZAIKU == status) - sheet.addCell(new Label(j++, i, "在库")); - else if(AssetConstants.BusinessForExcel.EXCEl_STATUS_INUSE == status) - sheet.addCell(new Label(j++, i, "在用")); - else if(AssetConstants.BusinessForExcel.EXCEl_STATUS_CONSUME == status) - sheet.addCell(new Label(j++, i, "消费")); - sheet.addCell(new Label(j++, i, asset.getLocation())); - sheet.addCell(new Label(j++, i, asset.getAssetnum())); - sheet.addCell(new Label(j++, i, asset.getSerialnum())); - sheet.addCell(getLabelInfo(cellInfo,j++,i, asset.getPeriodofvalidity() == null ?"":Tools.getCurrentMonth(asset.getPeriodofvalidity()),asset)); - sheet.addCell(getLabelInfo(cellInfo,j++,i,asset.getWarrantydate() == null ?"":Tools.getCurrentMonth(asset.getWarrantydate()),asset)); - sheet.addCell(new Label(j++, i, asset.getSupplier()==null?"":asset.getSupplier().getSupplier())); - sheet.addCell(new Label(j++, i, asset.getLabels())); - sheet.addCell(new Label(j++, i, asset.getDescription())); - - i++; - } - } - workbook.write(); - workbook.close(); - } - catch (Exception e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>>导出资产信息为excel表格异常", e); - } - } - - /** - * 根据错误信息进行提示--execel表格背景设置为红色,表示导入信息有误 - * @param cellInfo - * @param cellNum - * @param columnNum - * @param value - * @return - */ - private Label getLabelInfo(Map cellInfo,int cellNum,int columnNum,String value,Asset asset) - { - Label label = null; - - //设置背景颜色 - WritableCellFormat cellFormat = new WritableCellFormat(); - try - { - cellFormat.setBackground(Colour.RED); - } - catch (WriteException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>设置单元格背景颜色错误", e); - } - - if(null == cellInfo || cellInfo.size() == 0) - { - if(cellNum == AssetConstants.BusinessForExcel.EXCEL_ASSETNAME) - { - if(null == asset.getAssetname() && null != asset.getAssetnameStr()) - label = new Label(cellNum, columnNum,asset.getAssetnameStr()); - else if(null != asset.getAssetname()) - label = new Label(cellNum, columnNum, value); - else - label = new Label(cellNum, columnNum, null,cellFormat); - } - else if(cellNum == AssetConstants.BusinessForExcel.EXCEL_CATEGORY) - { - if(null != asset.getAssetnameStr() && null == asset.getAssetname()) - label = new Label(cellNum, columnNum, null,cellFormat); - else if(null == asset.getAssetnameStr() && null == asset.getAssetname() - && asset.getCategory() != null &&asset.getCategory().length()>0) - label = new Label(cellNum, columnNum, asset.getCategory()); - else - label = new Label(cellNum, columnNum, value); - } - else - label = new Label(cellNum, columnNum, value); - } - else - { - //表示此单元格有错误 - if(cellInfo.containsKey(cellNum)) - { - if(cellNum == AssetConstants.BusinessForExcel.EXCEL_ASSETNAME) - { - if(null == asset.getAssetname() && null != asset.getAssetnameStr()) - label = new Label(cellNum, columnNum,asset.getAssetnameStr()); - if(null != asset.getAssetname()) - label = new Label(cellNum, columnNum,asset.getAssetname().getAssetname()); - else - label = new Label(cellNum, columnNum, value,cellFormat); - } - else if(cellNum == AssetConstants.BusinessForExcel.EXCEL_CATEGORY) - { - if(null != asset.getAssetnameStr() && null == asset.getAssetname()) - label = new Label(cellNum, columnNum, null,cellFormat); - else if(null == asset.getAssetnameStr() && null == asset.getAssetname() - && asset.getCategory() != null &&asset.getCategory().length()>0) - label = new Label(cellNum, columnNum, asset.getCategory()); - } - else if(cellNum == AssetConstants.BusinessForExcel.EXCEL_PRICE) - label = new Label(cellNum, columnNum,asset.getPriceStr(),cellFormat); - else if(cellNum == AssetConstants.BusinessForExcel.EXCEL_PURCHASE_DATE) - label = new Label(cellNum, columnNum,asset.getPurchasedateStr(),cellFormat); - else if(cellNum == AssetConstants.BusinessForExcel.EXCEL_WARRANTY_DATE) - label = new Label(cellNum, columnNum,asset.getWarrantydateStr(),cellFormat); - else if(cellNum == AssetConstants.BusinessForExcel.EXCEL_EXPIRATION_DATE) - label = new Label(cellNum, columnNum,asset.getPeriodofvalidityStr(),cellFormat); - else - label = new Label(cellNum, columnNum, value,cellFormat); - } - else - { - if(null == asset.getAssetname() && null != asset.getAssetnameStr()&& cellNum == 0) - label = new Label(cellNum, columnNum,asset.getAssetnameStr()); - else if(null == asset.getAssetnameStr() && null == asset.getAssetname() - && asset.getCategory() != null &&asset.getCategory().length()>0&& cellNum == 1) - label = new Label(cellNum, columnNum, asset.getCategory()); - else - label = new Label(cellNum, columnNum, value); - } - } - return label; - } - - /*=====================以下处理与业务无关的共用方法=================================*/ - public void setAssetDao(AssetIDAO assetDao) - { - this.assetDao = assetDao; - } - - public void setAssetNameDao(AssetNameIDAO assetNameDao) - { - this.assetNameDao = assetNameDao; - } - - public void setCategoryDao(CategoryIDAO categoryDao) - { - this.categoryDao = categoryDao; - } - - public void setSupplierDao(SupplierIDAO supplierDao) - { - this.supplierDao = supplierDao; - } - - public void setUserDao(UserIDAO userDao) - { - this.userDao = userDao; - } - - @Override - protected Class getEntityClass() - { - return Asset.class; - } -} +package com.jsh.service.asset; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.sql.Timestamp; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import jxl.Workbook; +import jxl.format.Colour; +import jxl.write.Label; +import jxl.write.WritableCellFormat; +import jxl.write.WritableSheet; +import jxl.write.WritableWorkbook; +import jxl.write.WriteException; + +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.ss.usermodel.Row; + +import com.jsh.base.BaseService; +import com.jsh.base.Log; +import com.jsh.constants.asset.AssetConstants; +import com.jsh.dao.asset.AssetIDAO; +import com.jsh.dao.basic.AssetNameIDAO; +import com.jsh.dao.basic.CategoryIDAO; +import com.jsh.dao.basic.SupplierIDAO; +import com.jsh.dao.basic.UserIDAO; +import com.jsh.exception.JshException; +import com.jsh.model.po.Asset; +import com.jsh.model.po.Assetname; +import com.jsh.model.po.Category; +import com.jsh.model.po.Supplier; +import com.jsh.util.common.PageUtil; +import com.jsh.util.common.Tools; + +public class AssetService extends BaseService implements AssetIService +{ + private AssetIDAO assetDao; + + private AssetNameIDAO assetNameDao; + + private CategoryIDAO categoryDao; + + private SupplierIDAO supplierDao; + + private UserIDAO userDao; + + /** + * 初始化加载所有系统基础数据 + */ + @SuppressWarnings({"rawtypes"}) + private static Map mapData = new HashMap(); + + /** + * 错误的表格数据 + */ + private static List wrongData = new ArrayList(); + + /** + * 导出Excel表格 + */ + @Override + public InputStream exmportExcel(String isAllPage,PageUtil pageUtil)throws JshException + { + try + { + if("currentPage".equals(isAllPage)) + { + assetDao.find(pageUtil); + } + else + { + pageUtil.setCurPage(0); + pageUtil.setPageSize(0); + assetDao.find(pageUtil); + } + + //将OutputStream转化为InputStream + ByteArrayOutputStream out = new ByteArrayOutputStream(); + putDataOnOutputStream(out,pageUtil.getPageList()); + return new ByteArrayInputStream(out.toByteArray()); + } + catch (Exception e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>>导出资产信息为excel表格异常", e); + throw new JshException("export asset info to excel exception",e); + } + } + + @Override + public InputStream importExcel(File assetFile,int isCheck) throws JshException + { + //全局变量--每次调用前需要清空数据 + mapData.clear(); + //1、加载系统基础数据 + loadSystemData(); + //2、解析文件成资产数据 + parseFile(assetFile); + + if(null != wrongData && wrongData.size()>0) + { + //将OutputStream转化为InputStream + ByteArrayOutputStream out = new ByteArrayOutputStream(); + putDataOnOutputStream(out,wrongData); + return new ByteArrayInputStream(out.toByteArray()); + } + else + return null; + //2、是否直接插入数据库中 +// if(0 == isCheck) +// System.out.println("手动检查"); +// else +// System.out.println("自动检查插入"); + } + + /** + * 初始加载系统基础数据--导入过程中,不用频繁查询数据库内容,影响系统性能。 + * @throws JshException + */ + @SuppressWarnings({ "unchecked", "rawtypes" }) + private void loadSystemData()throws JshException + { + PageUtil pageUtil = new PageUtil(); + pageUtil.setPageSize(0); + pageUtil.setCurPage(0); + try + { + Map condition = pageUtil.getAdvSearch(); + condition.put("id_s_order", "desc"); + categoryDao.find(pageUtil); + mapData.put("categoryList", pageUtil.getPageList()); + + supplierDao.find(pageUtil); + mapData.put("supplierList", pageUtil.getPageList()); + + condition.put("isystem_n_eq", 1); + condition.put("id_s_order", "desc"); + userDao.find(pageUtil); + mapData.put("userList", pageUtil.getPageList()); + + //清除搜索条件 防止对查询有影响 + condition.remove("isystem_n_eq"); + + assetNameDao.find(pageUtil); + mapData.put("assetnameList", pageUtil.getPageList()); + } + catch (Exception e) + { + Log.errorFileSync(">>>>>>>>>>>>>查找系统基础数据信息异常", e); + } + } + + /** + * 解析excel表格 + * @param assetFile + */ + @SuppressWarnings("unchecked") + private void parseFile(File assetFile) + { + //每次调用前清空 + wrongData.clear(); + int totalRow = 0; + try + { + //创建对Excel工作簿文件的引用 + HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(assetFile)); + //创建对工作表的引用,获取第一个工作表的内容 + HSSFSheet sheet = workbook.getSheetAt(0); + /** + * ===================================== + * 1、此处要增加文件的验证,如果不是资产文件需要进行特殊的处理,13列 + * 2、文件内容为空处理 + * 3、如果是修改过的文件内容 + */ + Iterator itsheet = sheet.rowIterator(); + while(itsheet.hasNext()) + { + //获取当前行数据 + Row row = itsheet.next(); + //获取一行有多少单元格 +// System.out.println(row.getLastCellNum()); + + //excel表格第几行数据 从1开始 0 是表头 + int rowNum = row.getRowNum(); + /** + * 表头跳过不读 + */ + if(AssetConstants.BusinessForExcel.EXCEL_TABLE_HEAD == rowNum) + continue; + + //开始处理excel表格内容 --每行数据读取,同时统计总共行数 + totalRow ++; + + //获取excel表格的每格数据内容 + Iterator it = row.cellIterator(); + //资产子类型--添加了一些excel表格数据 + Asset asset = new Asset(); + //保存每个单元格错误类型 + Map cellType = new HashMap(); + + //名称需要类型字段 + Assetname nameModel = null; + //资产名称 + @SuppressWarnings("unused") + String assetname = ""; + + //资产类型 + String categoryStr = ""; + //设置列号 + asset.setRowLineNum(rowNum); + + Cell cell = null; + //判断列号--从零开始 + int cellIndex = 0; + while(it.hasNext()) + { + //获取每个单元格对象 + cell = it.next(); + //获取列号 + cellIndex = cell.getColumnIndex(); + //设置此单元格为字符串类型 + cell.setCellType(Cell.CELL_TYPE_STRING); + + Log.infoFileSync("==================excel表格中第" + totalRow + "行的第 " + cellIndex + "列的值为" + cell.getStringCellValue()); + + //每行中数据顺序 资产名称-资产类型-单价-用户-购买时间-状态-位置-资产编号-序列号-有效日期-保修日期-供应商-标签-描述 + switch(cellIndex) + { + case AssetConstants.BusinessForExcel.EXCEL_ASSETNAME : + //资产名称是否存在 + boolean isAssetnameExist = false; + //此处添加资产名称处理 + String nameValue = cell.getStringCellValue(); + if(null == nameValue || "".equals(nameValue)) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>资产名称没有填写"); + cellType.put(cellIndex, "wrong"); + break; + } + assetname = nameValue; + + List nameList = mapData.get("assetnameList"); + for(Assetname name:nameList) + { + //表示名称存在--直接进行保存,不需要判断类型字段 + if(nameValue.equals(name.getAssetname())) + { + isAssetnameExist = true; + //直接进行设置 + asset.setAssetname(name); + break; + } + } + //名称不存在 重新创建 + if(!isAssetnameExist) + { + isAssetnameExist = false; + nameModel = new Assetname(); + nameModel.setAssetname(nameValue); + nameModel.setIsconsumables((short)0); + nameModel.setIsystem((short)1); + nameModel.setDescription(""); + + asset.setAssetnameStr(nameValue); + } + break; + case AssetConstants.BusinessForExcel.EXCEL_CATEGORY : + //此处添加资产类型处理 + //类型信息是否存在 + boolean isCategoryExist = false; + String categoryValue = cell.getStringCellValue(); + if((null == categoryValue || "".equals(categoryValue)) && null != nameModel) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>资产名称没有指定类型"); + cellType.put(cellIndex, "wrong"); + break; + } + categoryStr = categoryValue; + + List categoryList = mapData.get("categoryList"); + for(Category category:categoryList) + { + //表示新创建 --名称设置过 不需要再进行处理 + if(category.getAssetname().equals(categoryValue) && null != nameModel) + { + isCategoryExist = true; + nameModel.setCategory(category); + asset.setAssetname(nameModel); + assetNameDao.create(nameModel); + break; + } + } + //重新创建 + if(null != nameModel && !isCategoryExist) + { + //首先创建类型信息 + Category canew = new Category(); + canew.setAssetname(categoryValue); + canew.setIsystem((short)1); + canew.setDescription(""); + categoryDao.create(canew); + + nameModel.setCategory(canew); + + assetNameDao.create(nameModel); + + asset.setAssetname(nameModel); + } + //nameModel为空表示 已经处理过类型信息 --此处不需要进行处理 + else + { + asset.setCategory(categoryStr); + } + break; + case AssetConstants.BusinessForExcel.EXCEL_PRICE: + //此处添加单价处理 + String priceValue = cell.getStringCellValue(); + //String priceValue = getCellFormatValue(cell); + if(null == priceValue || "".equals(priceValue)) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>资产没有填写单价"); + break; + } + //解析价格 + if(Tools.checkStrIsNum(priceValue)) + asset.setPrice(Double.parseDouble(priceValue)); + else + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>资产价格不是数字格式"); + cellType.put(cellIndex, "wrong"); + asset.setPrice(0.00d); + asset.setPriceStr(priceValue); + } + break; + case AssetConstants.BusinessForExcel.EXCEL_USER : + //此处添加用户处理--用户信息不需要进行处理 + break; + case AssetConstants.BusinessForExcel.EXCEL_PURCHASE_DATE : + //此处添加购买时间处理--时间不需要处理 + String purchaseValue = cell.getStringCellValue(); + if(null == purchaseValue || "".equals(purchaseValue)) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>资产没有填写购买日期"); + break; + } + try + { + asset.setPurchasedate(new Timestamp(Tools.parse(purchaseValue, "yyyy-MM-dd").getTime())); + } + catch (ParseException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>解析购买日期异常", e); + try + { + asset.setPurchasedate(new Timestamp(DateUtil.getJavaDate(Double.parseDouble(purchaseValue)).getTime())); + } + catch (Exception t) + { + asset.setPurchasedateStr(purchaseValue); + cellType.put(cellIndex, "wrong"); + } + } + break; + case AssetConstants.BusinessForExcel.EXCEL_STATUS : + //此处添加状态处理--默认为在库状态 + asset.setStatus((short)0); + break; + case AssetConstants.BusinessForExcel.EXCEL_LOCATION : + //此处添加位置处理--不需要进行处理 + String locationValue = cell.getStringCellValue(); + if(null == locationValue || "".equals(locationValue)) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>资产没有填写位置信息"); + break; + } + asset.setLocation(locationValue); + break; + case AssetConstants.BusinessForExcel.EXCEL_NUM : + //此处添加资产编号处理 + String assetnumValue = cell.getStringCellValue(); + if(null == assetnumValue || "".equals(assetnumValue)) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>资产没有填写资产编号"); + break; + } + //设置资产编号 + asset.setAssetnum(assetnumValue); + break; + case AssetConstants.BusinessForExcel.EXCEL_SERIALNO : + //此处添加序列号处理 + String assetseriValue = cell.getStringCellValue(); + if(null == assetseriValue || "".equals(assetseriValue)) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>资产没有填写序列号"); + break; + } + //设置资产编号 + asset.setSerialnum(assetseriValue); + break; + case AssetConstants.BusinessForExcel.EXCEL_EXPIRATION_DATE : + //此处添加有效日期处理--不需要处理 + String expirationValue = cell.getStringCellValue(); + if(null == expirationValue || "".equals(expirationValue)) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>资产没有有效日期"); + break; + } + + try + { + asset.setPeriodofvalidity(new Timestamp(Tools.parse(expirationValue, "yyyy-MM-dd").getTime())); + } + catch (ParseException e) + { + try + { + asset.setPeriodofvalidity(new Timestamp(DateUtil.getJavaDate(Double.parseDouble(expirationValue)).getTime())); + } + catch (Exception t) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>解析有效日期异常", t); + asset.setPeriodofvalidityStr(expirationValue); + cellType.put(cellIndex, "wrong"); + } + } + break; + case AssetConstants.BusinessForExcel.EXCEL_WARRANTY_DATE : + //此处添加保修日期处理--不需要处理 + String warrantyValue = cell.getStringCellValue(); + if(null == warrantyValue || "".equals(warrantyValue)) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>资产没有保修日期"); + break; + } + try + { + asset.setWarrantydate(new Timestamp(Tools.parse(warrantyValue, "yyyy-MM-dd").getTime())); + } + catch (ParseException e) + { + try + { + asset.setWarrantydate(new Timestamp(DateUtil.getJavaDate(Double.parseDouble(warrantyValue)).getTime())); + } + catch (Exception t) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>解析保修日期异常", t); + asset.setWarrantydateStr(warrantyValue); + cellType.put(cellIndex, "wrong"); + } + } + break; + case AssetConstants.BusinessForExcel.EXCEL_SUPPLIER : + //此处添加供应商处理 + + String supplierValue = cell.getStringCellValue(); + if(null == supplierValue || "".equals(supplierValue)) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>资产没有填写供应商"); + cellType.put(cellIndex, "wrong"); + break; + } + //供应商 + List supplierList = mapData.get("supplierList"); + boolean isSupplerExist =false; + for(Supplier supplier:supplierList) + { + if(supplierValue.equals(supplier.getSupplier())) + { + isSupplerExist =true; + asset.setSupplier(supplier); + break; + } + } + if(!isSupplerExist) + { + Supplier sup = new Supplier(); + sup.setIsystem((short)1); + sup.setSupplier(supplierValue); + sup.setDescription(""); + supplierDao.create(sup); + //保存供应商信息 + asset.setSupplier(sup); + } + break; + case AssetConstants.BusinessForExcel.EXCEL_LABLE : + //此处添加标签处理 + String lableValue = cell.getStringCellValue(); + if(null == lableValue || "".equals(lableValue)) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>资产没有填写标签信息"); + break; + } + asset.setLabels(lableValue); + break; + case AssetConstants.BusinessForExcel.EXCEL_DESC : + //此处添加描述信息处理 + String descValue = cell.getStringCellValue(); + if(null == descValue || "".equals(descValue)) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>资产没有填写描述信息"); + break; + } + asset.setDescription(descValue); + break; + } + } + asset.setCreatetime(new Timestamp(Calendar.getInstance().getTime().getTime())); + asset.setUpdatetime(new Timestamp(Calendar.getInstance().getTime().getTime())); + asset.setCellInfo(cellType); + + Log.infoFileSync(totalRow + "行总共有" + cellIndex + "列"); + //资产文件为13列,否则不是资产模板文件--不输入的时候 判断会有问题 暂时去掉 +// if(cellIndex != 13) +// { +// Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>导入文件格式不合法,请重新选择文件进行操作!"); +// return; +// } + + //判断完成后增加数据 + if((null!=cellType && cellType.size() >0) + || asset.getAssetname() == null || asset.getAssetname().getCategory() == null) + wrongData.add(asset); + else + { + if(null == asset.getStatus()) + asset.setStatus((short)0); + assetDao.save(asset); + } + } + } + catch (FileNotFoundException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>读取excel文件异常:找不到指定文件!",e); + } + catch (IOException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>读取excel文件异常,请确认文件格式是否正确 !",e); + } + Log.infoFileSync("===================excel表格总共有 " + totalRow + " 条记录!"); + } + + /** + * 生成excel表格 + * @param os + */ + private void putDataOnOutputStream(OutputStream os,List dataList) + { + WritableWorkbook workbook = null; + try + { + workbook = Workbook.createWorkbook(os); + WritableSheet sheet = workbook.createSheet("资产详细信息", 0); + //增加列头 + int[] colunmWidth = {30,30,10,15,20,10,30,30,30,20,20,20,30,80}; + String[] colunmName = {"资产名称","资产类型","单价","用户","购买时间","状态","位置","资产编号","序列号","有效日期","保修日期","供应商","标签","描述"}; + for(int i = 0 ;i < colunmWidth.length;i ++) + { + sheet.setColumnView(i,colunmWidth[i]); + sheet.addCell(new Label(i, 0, colunmName[i])); + } + + if (null != dataList &&dataList.size() > 0) + { + int i = 1; + for (Asset asset: dataList) + { + int j = 0; + Map cellInfo = asset.getCellInfo(); + + //第一列,填充 数据, Label(列,行,值) + sheet.addCell(getLabelInfo(cellInfo,j++,i,asset.getAssetname() == null ?"":asset.getAssetname().getAssetname(),asset)); + sheet.addCell(getLabelInfo(cellInfo,j++,i,asset.getAssetname() == null || asset.getAssetname().getCategory() == null ?"":asset.getAssetname().getCategory().getAssetname(),asset)); + sheet.addCell(getLabelInfo(cellInfo,j++,i,asset.getPrice() == null?"":asset.getPrice().toString(),asset)); + sheet.addCell(new Label(j++, i, asset.getUser()==null?"":asset.getUser().getUsername())); + sheet.addCell(getLabelInfo(cellInfo,j++,i,asset.getPurchasedate() == null ?"":Tools.getCurrentMonth(asset.getPurchasedate()),asset)); + Short status = asset.getStatus(); + if(null == status) + status = 0 ; + if(AssetConstants.BusinessForExcel.EXCEl_STATUS_ZAIKU == status) + sheet.addCell(new Label(j++, i, "在库")); + else if(AssetConstants.BusinessForExcel.EXCEl_STATUS_INUSE == status) + sheet.addCell(new Label(j++, i, "在用")); + else if(AssetConstants.BusinessForExcel.EXCEl_STATUS_CONSUME == status) + sheet.addCell(new Label(j++, i, "消费")); + sheet.addCell(new Label(j++, i, asset.getLocation())); + sheet.addCell(new Label(j++, i, asset.getAssetnum())); + sheet.addCell(new Label(j++, i, asset.getSerialnum())); + sheet.addCell(getLabelInfo(cellInfo,j++,i, asset.getPeriodofvalidity() == null ?"":Tools.getCurrentMonth(asset.getPeriodofvalidity()),asset)); + sheet.addCell(getLabelInfo(cellInfo,j++,i,asset.getWarrantydate() == null ?"":Tools.getCurrentMonth(asset.getWarrantydate()),asset)); + sheet.addCell(new Label(j++, i, asset.getSupplier()==null?"":asset.getSupplier().getSupplier())); + sheet.addCell(new Label(j++, i, asset.getLabels())); + sheet.addCell(new Label(j++, i, asset.getDescription())); + + i++; + } + } + workbook.write(); + workbook.close(); + } + catch (Exception e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>>导出资产信息为excel表格异常", e); + } + } + + /** + * 根据错误信息进行提示--execel表格背景设置为红色,表示导入信息有误 + * @param cellInfo + * @param cellNum + * @param columnNum + * @param value + * @return + */ + private Label getLabelInfo(Map cellInfo,int cellNum,int columnNum,String value,Asset asset) + { + Label label = null; + + //设置背景颜色 + WritableCellFormat cellFormat = new WritableCellFormat(); + try + { + cellFormat.setBackground(Colour.RED); + } + catch (WriteException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>设置单元格背景颜色错误", e); + } + + if(null == cellInfo || cellInfo.size() == 0) + { + if(cellNum == AssetConstants.BusinessForExcel.EXCEL_ASSETNAME) + { + if(null == asset.getAssetname() && null != asset.getAssetnameStr()) + label = new Label(cellNum, columnNum,asset.getAssetnameStr()); + else if(null != asset.getAssetname()) + label = new Label(cellNum, columnNum, value); + else + label = new Label(cellNum, columnNum, null,cellFormat); + } + else if(cellNum == AssetConstants.BusinessForExcel.EXCEL_CATEGORY) + { + if(null != asset.getAssetnameStr() && null == asset.getAssetname()) + label = new Label(cellNum, columnNum, null,cellFormat); + else if(null == asset.getAssetnameStr() && null == asset.getAssetname() + && asset.getCategory() != null &&asset.getCategory().length()>0) + label = new Label(cellNum, columnNum, asset.getCategory()); + else + label = new Label(cellNum, columnNum, value); + } + else + label = new Label(cellNum, columnNum, value); + } + else + { + //表示此单元格有错误 + if(cellInfo.containsKey(cellNum)) + { + if(cellNum == AssetConstants.BusinessForExcel.EXCEL_ASSETNAME) + { + if(null == asset.getAssetname() && null != asset.getAssetnameStr()) + label = new Label(cellNum, columnNum,asset.getAssetnameStr()); + if(null != asset.getAssetname()) + label = new Label(cellNum, columnNum,asset.getAssetname().getAssetname()); + else + label = new Label(cellNum, columnNum, value,cellFormat); + } + else if(cellNum == AssetConstants.BusinessForExcel.EXCEL_CATEGORY) + { + if(null != asset.getAssetnameStr() && null == asset.getAssetname()) + label = new Label(cellNum, columnNum, null,cellFormat); + else if(null == asset.getAssetnameStr() && null == asset.getAssetname() + && asset.getCategory() != null &&asset.getCategory().length()>0) + label = new Label(cellNum, columnNum, asset.getCategory()); + } + else if(cellNum == AssetConstants.BusinessForExcel.EXCEL_PRICE) + label = new Label(cellNum, columnNum,asset.getPriceStr(),cellFormat); + else if(cellNum == AssetConstants.BusinessForExcel.EXCEL_PURCHASE_DATE) + label = new Label(cellNum, columnNum,asset.getPurchasedateStr(),cellFormat); + else if(cellNum == AssetConstants.BusinessForExcel.EXCEL_WARRANTY_DATE) + label = new Label(cellNum, columnNum,asset.getWarrantydateStr(),cellFormat); + else if(cellNum == AssetConstants.BusinessForExcel.EXCEL_EXPIRATION_DATE) + label = new Label(cellNum, columnNum,asset.getPeriodofvalidityStr(),cellFormat); + else + label = new Label(cellNum, columnNum, value,cellFormat); + } + else + { + if(null == asset.getAssetname() && null != asset.getAssetnameStr()&& cellNum == 0) + label = new Label(cellNum, columnNum,asset.getAssetnameStr()); + else if(null == asset.getAssetnameStr() && null == asset.getAssetname() + && asset.getCategory() != null &&asset.getCategory().length()>0&& cellNum == 1) + label = new Label(cellNum, columnNum, asset.getCategory()); + else + label = new Label(cellNum, columnNum, value); + } + } + return label; + } + + /*=====================以下处理与业务无关的共用方法=================================*/ + public void setAssetDao(AssetIDAO assetDao) + { + this.assetDao = assetDao; + } + + public void setAssetNameDao(AssetNameIDAO assetNameDao) + { + this.assetNameDao = assetNameDao; + } + + public void setCategoryDao(CategoryIDAO categoryDao) + { + this.categoryDao = categoryDao; + } + + public void setSupplierDao(SupplierIDAO supplierDao) + { + this.supplierDao = supplierDao; + } + + public void setUserDao(UserIDAO userDao) + { + this.userDao = userDao; + } + + @Override + protected Class getEntityClass() + { + return Asset.class; + } +} diff --git a/src/com/jsh/service/asset/ReportIService.java b/src/com/jsh/service/asset/ReportIService.java index a62e5705..d4694bfc 100644 --- a/src/com/jsh/service/asset/ReportIService.java +++ b/src/com/jsh/service/asset/ReportIService.java @@ -1,15 +1,15 @@ -package com.jsh.service.asset; - -import com.jsh.exception.AmsException; -import com.jsh.model.po.Asset; -import com.jsh.util.common.PageUtil; - -public interface ReportIService -{ - /** - * 查找报表数据 - * @param asset - * @throws AmsException - */ - void find(PageUtil asset,String reportType,String reportName)throws AmsException; -} +package com.jsh.service.asset; + +import com.jsh.exception.JshException; +import com.jsh.model.po.Asset; +import com.jsh.util.common.PageUtil; + +public interface ReportIService +{ + /** + * 查找报表数据 + * @param asset + * @throws JshException + */ + void find(PageUtil asset,String reportType,String reportName)throws JshException; +} diff --git a/src/com/jsh/service/asset/ReportService.java b/src/com/jsh/service/asset/ReportService.java index a8a01a55..e37ec85b 100644 --- a/src/com/jsh/service/asset/ReportService.java +++ b/src/com/jsh/service/asset/ReportService.java @@ -1,23 +1,23 @@ -package com.jsh.service.asset; - -import com.jsh.dao.asset.ReportIDAO; -import com.jsh.exception.AmsException; -import com.jsh.model.po.Asset; -import com.jsh.util.common.PageUtil; - -public class ReportService implements ReportIService -{ - private ReportIDAO reportDao; - - public void setReportDao(ReportIDAO reportDao) - { - this.reportDao = reportDao; - } - - @Override - public void find(PageUtil pageUtil, String reportType,String reportName) throws AmsException - { - reportDao.find(pageUtil, reportType,reportName); - } - -} +package com.jsh.service.asset; + +import com.jsh.dao.asset.ReportIDAO; +import com.jsh.exception.JshException; +import com.jsh.model.po.Asset; +import com.jsh.util.common.PageUtil; + +public class ReportService implements ReportIService +{ + private ReportIDAO reportDao; + + public void setReportDao(ReportIDAO reportDao) + { + this.reportDao = reportDao; + } + + @Override + public void find(PageUtil pageUtil, String reportType,String reportName) throws JshException + { + reportDao.find(pageUtil, reportType,reportName); + } + +} diff --git a/src/com/jsh/service/basic/LogIService.java b/src/com/jsh/service/basic/LogIService.java index b9effc18..596b5fe7 100644 --- a/src/com/jsh/service/basic/LogIService.java +++ b/src/com/jsh/service/basic/LogIService.java @@ -1,16 +1,16 @@ -package com.jsh.service.basic; - -import com.jsh.base.BaseIService; -import com.jsh.exception.AmsException; -import com.jsh.model.po.Logdetails; - -public interface LogIService extends BaseIService -{ - /** - * 增加 - * @param t 对象 - * @throws AmsException - */ - @Override - void save(Logdetails t); -} +package com.jsh.service.basic; + +import com.jsh.base.BaseIService; +import com.jsh.exception.JshException; +import com.jsh.model.po.Logdetails; + +public interface LogIService extends BaseIService +{ + /** + * 增加 + * @param t 对象 + * @throws JshException + */ + @Override + void save(Logdetails t); +} diff --git a/src/com/jsh/service/basic/UserBusinessIService.java b/src/com/jsh/service/basic/UserBusinessIService.java index 8935951c..26c63baf 100644 --- a/src/com/jsh/service/basic/UserBusinessIService.java +++ b/src/com/jsh/service/basic/UserBusinessIService.java @@ -1,15 +1,15 @@ -package com.jsh.service.basic; - -import com.jsh.base.BaseIService; -import com.jsh.exception.AmsException; -import com.jsh.model.po.UserBusiness; -import com.jsh.util.common.PageUtil; - -public interface UserBusinessIService extends BaseIService -{ - /* - * 测试一下自定义hql语句 - */ - void find(PageUtil userBusiness,String ceshi)throws AmsException; - -} +package com.jsh.service.basic; + +import com.jsh.base.BaseIService; +import com.jsh.exception.JshException; +import com.jsh.model.po.UserBusiness; +import com.jsh.util.common.PageUtil; + +public interface UserBusinessIService extends BaseIService +{ + /* + * 测试一下自定义hql语句 + */ + void find(PageUtil userBusiness,String ceshi)throws JshException; + +} diff --git a/src/com/jsh/service/basic/UserBusinessService.java b/src/com/jsh/service/basic/UserBusinessService.java index 6d7ada92..37b89f26 100644 --- a/src/com/jsh/service/basic/UserBusinessService.java +++ b/src/com/jsh/service/basic/UserBusinessService.java @@ -1,32 +1,32 @@ -package com.jsh.service.basic; - -import com.jsh.base.BaseService; -import com.jsh.dao.basic.UserBusinessIDAO; -import com.jsh.exception.AmsException; -import com.jsh.model.po.UserBusiness; -import com.jsh.util.common.PageUtil; - -public class UserBusinessService extends BaseService implements UserBusinessIService -{ - @SuppressWarnings("unused") - private UserBusinessIDAO userBusinessDao; - - public void setUserBusinessDao(UserBusinessIDAO userBusinessDao) - { - this.userBusinessDao = userBusinessDao; - } - - @Override - protected Class getEntityClass() - { - return UserBusiness.class; - } - - @Override - public void find(PageUtil pageUtil, String ceshi) throws AmsException - { - userBusinessDao.find(pageUtil, ceshi); - } - - -} +package com.jsh.service.basic; + +import com.jsh.base.BaseService; +import com.jsh.dao.basic.UserBusinessIDAO; +import com.jsh.exception.JshException; +import com.jsh.model.po.UserBusiness; +import com.jsh.util.common.PageUtil; + +public class UserBusinessService extends BaseService implements UserBusinessIService +{ + @SuppressWarnings("unused") + private UserBusinessIDAO userBusinessDao; + + public void setUserBusinessDao(UserBusinessIDAO userBusinessDao) + { + this.userBusinessDao = userBusinessDao; + } + + @Override + protected Class getEntityClass() + { + return UserBusiness.class; + } + + @Override + public void find(PageUtil pageUtil, String ceshi) throws JshException + { + userBusinessDao.find(pageUtil, ceshi); + } + + +} diff --git a/src/com/jsh/service/basic/UserIService.java b/src/com/jsh/service/basic/UserIService.java index 34b59de9..8bbca757 100644 --- a/src/com/jsh/service/basic/UserIService.java +++ b/src/com/jsh/service/basic/UserIService.java @@ -1,33 +1,33 @@ -package com.jsh.service.basic; - -import com.jsh.base.BaseIService; -import com.jsh.exception.AmsException; -import com.jsh.model.po.Basicuser; - -public interface UserIService extends BaseIService -{ - /** - * 判断用户名是否符合登录条件 - * @param username 用户名 String password - * @return int 1、用户名不存在 2、密码不正确 3、黑名单用户 4、符合条件 5、访问后台异常 - */ - int validateUser(String username,String password)throws AmsException; - - /** - * 获取用户信息 - * @param username - * @return 用户信息 - * @throws AmsException - */ - public Basicuser getUser(String username) throws AmsException; - - /** - * 检查用户名称是否存在 - * @param field 用户属性 - * @param username 用户名称 - * @param userID 供应商ID - * @return true==存在重名 false==不存在 - * @throws AmsException - */ - Boolean checkIsNameExist(String field,String username,Long userID)throws AmsException; -} +package com.jsh.service.basic; + +import com.jsh.base.BaseIService; +import com.jsh.exception.JshException; +import com.jsh.model.po.Basicuser; + +public interface UserIService extends BaseIService +{ + /** + * 判断用户名是否符合登录条件 + * @param username 用户名 String password + * @return int 1、用户名不存在 2、密码不正确 3、黑名单用户 4、符合条件 5、访问后台异常 + */ + int validateUser(String username,String password)throws JshException; + + /** + * 获取用户信息 + * @param username + * @return 用户信息 + * @throws JshException + */ + public Basicuser getUser(String username) throws JshException; + + /** + * 检查用户名称是否存在 + * @param field 用户属性 + * @param username 用户名称 + * @param userID 供应商ID + * @return true==存在重名 false==不存在 + * @throws JshException + */ + Boolean checkIsNameExist(String field,String username,Long userID)throws JshException; +} diff --git a/src/com/jsh/service/basic/UserService.java b/src/com/jsh/service/basic/UserService.java index eabe5788..3ec6faf8 100644 --- a/src/com/jsh/service/basic/UserService.java +++ b/src/com/jsh/service/basic/UserService.java @@ -1,114 +1,114 @@ -package com.jsh.service.basic; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.jsh.base.BaseService; -import com.jsh.base.Log; -import com.jsh.constants.common.ExceptionCodeConstants; -import com.jsh.dao.basic.UserBusinessIDAO; -import com.jsh.dao.basic.UserIDAO; -import com.jsh.exception.AmsException; -import com.jsh.model.po.Basicuser; -import com.jsh.util.common.PageUtil; - -public class UserService extends BaseService implements UserIService -{ - private PageUtil pageUtil = new PageUtil(); - private Map condition = new HashMap(); - private UserIDAO userDao; - - @Override - public int validateUser(String username, String password)throws AmsException - { - try - { - //全局变量 每次使用前清除 - condition.clear(); - - /**默认是可以登录的*/ - List list = null ; - try - { - - condition.put("loginame_s_eq", username); - pageUtil.setAdvSearch(condition); - userDao.find(pageUtil); - list = pageUtil.getPageList(); - } - catch (Exception e) - { - Log.errorFileSync(">>>>>>>>访问验证用户姓名是否存在后台信息异常",e); - return ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION; - } - - if(null !=list && list.size() == 0) - return ExceptionCodeConstants.UserExceptionCode.USER_NOT_EXIST ; - - try - { - condition.put("loginame_s_eq", username); - condition.put("password_s_eq", password); - pageUtil.setAdvSearch(condition); - userDao.find(pageUtil); - list = pageUtil.getPageList(); - } - catch (Exception e) - { - Log.errorFileSync(">>>>>>>>>>访问验证用户密码后台信息异常",e); - return ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION; - } - - if(null !=list && list.size() == 0) - return ExceptionCodeConstants.UserExceptionCode.USER_PASSWORD_ERROR; - return ExceptionCodeConstants.UserExceptionCode.USER_CONDITION_FIT; - } - catch (Exception e) - { - throw new AmsException("unknown exception",e); - } - } - - @Override - public Basicuser getUser(String username) throws AmsException - { - //全局变量 每次使用前清除 - condition.clear(); - condition.put("loginame_s_eq", username); - pageUtil.setAdvSearch(condition); - userDao.find(pageUtil); - List list = pageUtil.getPageList(); - if(null != list && list.size() >0) - return list.get(0); - else - throw new AmsException("no username exist"); - } - - @Override - public Boolean checkIsNameExist(String field,String username, Long userID)throws AmsException - { - condition.clear(); - condition.put(field + "_s_eq", username); - condition.put("id_n_neq", userID); - pageUtil.setAdvSearch(condition); - userDao.find(pageUtil); - - List dataList = pageUtil.getPageList(); - if(null != dataList && dataList.size() > 0) - return true; - return false; - } - - //==============spring注入等公共方法,与业务无关========================= - public void setUserDao(UserIDAO userDao) - { - this.userDao = userDao; - } - - @Override - protected Class getEntityClass() - { - return Basicuser.class; - } -} +package com.jsh.service.basic; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.jsh.base.BaseService; +import com.jsh.base.Log; +import com.jsh.constants.common.ExceptionCodeConstants; +import com.jsh.dao.basic.UserBusinessIDAO; +import com.jsh.dao.basic.UserIDAO; +import com.jsh.exception.JshException; +import com.jsh.model.po.Basicuser; +import com.jsh.util.common.PageUtil; + +public class UserService extends BaseService implements UserIService +{ + private PageUtil pageUtil = new PageUtil(); + private Map condition = new HashMap(); + private UserIDAO userDao; + + @Override + public int validateUser(String username, String password)throws JshException + { + try + { + //全局变量 每次使用前清除 + condition.clear(); + + /**默认是可以登录的*/ + List list = null ; + try + { + + condition.put("loginame_s_eq", username); + pageUtil.setAdvSearch(condition); + userDao.find(pageUtil); + list = pageUtil.getPageList(); + } + catch (Exception e) + { + Log.errorFileSync(">>>>>>>>访问验证用户姓名是否存在后台信息异常",e); + return ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION; + } + + if(null !=list && list.size() == 0) + return ExceptionCodeConstants.UserExceptionCode.USER_NOT_EXIST ; + + try + { + condition.put("loginame_s_eq", username); + condition.put("password_s_eq", password); + pageUtil.setAdvSearch(condition); + userDao.find(pageUtil); + list = pageUtil.getPageList(); + } + catch (Exception e) + { + Log.errorFileSync(">>>>>>>>>>访问验证用户密码后台信息异常",e); + return ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION; + } + + if(null !=list && list.size() == 0) + return ExceptionCodeConstants.UserExceptionCode.USER_PASSWORD_ERROR; + return ExceptionCodeConstants.UserExceptionCode.USER_CONDITION_FIT; + } + catch (Exception e) + { + throw new JshException("unknown exception",e); + } + } + + @Override + public Basicuser getUser(String username) throws JshException + { + //全局变量 每次使用前清除 + condition.clear(); + condition.put("loginame_s_eq", username); + pageUtil.setAdvSearch(condition); + userDao.find(pageUtil); + List list = pageUtil.getPageList(); + if(null != list && list.size() >0) + return list.get(0); + else + throw new JshException("no username exist"); + } + + @Override + public Boolean checkIsNameExist(String field,String username, Long userID)throws JshException + { + condition.clear(); + condition.put(field + "_s_eq", username); + condition.put("id_n_neq", userID); + pageUtil.setAdvSearch(condition); + userDao.find(pageUtil); + + List dataList = pageUtil.getPageList(); + if(null != dataList && dataList.size() > 0) + return true; + return false; + } + + //==============spring注入等公共方法,与业务无关========================= + public void setUserDao(UserIDAO userDao) + { + this.userDao = userDao; + } + + @Override + protected Class getEntityClass() + { + return Basicuser.class; + } +} diff --git a/src/com/jsh/service/materials/DepotHeadIService.java b/src/com/jsh/service/materials/DepotHeadIService.java index b80d4c39..6356f278 100644 --- a/src/com/jsh/service/materials/DepotHeadIService.java +++ b/src/com/jsh/service/materials/DepotHeadIService.java @@ -1,15 +1,15 @@ -package com.jsh.service.materials; - -import com.jsh.base.BaseIService; -import com.jsh.exception.AmsException; -import com.jsh.model.po.DepotHead; -import com.jsh.model.po.UserBusiness; -import com.jsh.util.common.PageUtil; - -public interface DepotHeadIService extends BaseIService -{ - /* - * 获取MaxId - */ - void find(PageUtil depotHead,String maxid)throws AmsException; -} +package com.jsh.service.materials; + +import com.jsh.base.BaseIService; +import com.jsh.exception.JshException; +import com.jsh.model.po.DepotHead; +import com.jsh.model.po.UserBusiness; +import com.jsh.util.common.PageUtil; + +public interface DepotHeadIService extends BaseIService +{ + /* + * 获取MaxId + */ + void find(PageUtil depotHead,String maxid)throws JshException; +} diff --git a/src/com/jsh/service/materials/DepotHeadService.java b/src/com/jsh/service/materials/DepotHeadService.java index 3bdd15ab..4e2c66cf 100644 --- a/src/com/jsh/service/materials/DepotHeadService.java +++ b/src/com/jsh/service/materials/DepotHeadService.java @@ -1,32 +1,32 @@ -package com.jsh.service.materials; - -import com.jsh.base.BaseService; -import com.jsh.dao.materials.DepotHeadIDAO; -import com.jsh.exception.AmsException; -import com.jsh.model.po.DepotHead; -import com.jsh.model.po.UserBusiness; -import com.jsh.util.common.PageUtil; - -public class DepotHeadService extends BaseService implements DepotHeadIService -{ - @SuppressWarnings("unused") - private DepotHeadIDAO depotHeadDao; - - - public void setDepotHeadDao(DepotHeadIDAO depotHeadDao) { - this.depotHeadDao = depotHeadDao; - } - - - @Override - protected Class getEntityClass() - { - return DepotHead.class; - } - - @Override - public void find(PageUtil pageUtil, String maxid) throws AmsException - { - depotHeadDao.find(pageUtil, maxid); - } -} +package com.jsh.service.materials; + +import com.jsh.base.BaseService; +import com.jsh.dao.materials.DepotHeadIDAO; +import com.jsh.exception.JshException; +import com.jsh.model.po.DepotHead; +import com.jsh.model.po.UserBusiness; +import com.jsh.util.common.PageUtil; + +public class DepotHeadService extends BaseService implements DepotHeadIService +{ + @SuppressWarnings("unused") + private DepotHeadIDAO depotHeadDao; + + + public void setDepotHeadDao(DepotHeadIDAO depotHeadDao) { + this.depotHeadDao = depotHeadDao; + } + + + @Override + protected Class getEntityClass() + { + return DepotHead.class; + } + + @Override + public void find(PageUtil pageUtil, String maxid) throws JshException + { + depotHeadDao.find(pageUtil, maxid); + } +} diff --git a/src/com/jsh/service/materials/DepotItemIService.java b/src/com/jsh/service/materials/DepotItemIService.java index dcf591e4..087eed3f 100644 --- a/src/com/jsh/service/materials/DepotItemIService.java +++ b/src/com/jsh/service/materials/DepotItemIService.java @@ -1,26 +1,26 @@ -package com.jsh.service.materials; - -import java.io.InputStream; -import java.util.List; - -import net.sf.json.JSONArray; - -import com.jsh.base.BaseIService; -import com.jsh.exception.AmsException; -import com.jsh.model.po.Asset; -import com.jsh.model.po.DepotHead; -import com.jsh.model.po.DepotItem; -import com.jsh.util.common.PageUtil; - -public interface DepotItemIService extends BaseIService -{ - void findByType(PageUtil depotItem, String type, Long MId, String MonthTime,Boolean isPrev)throws AmsException; - - void findOrderByMaterial(PageUtil depotItem)throws AmsException; - - /** - * 导出信息 - * @return - */ - InputStream exmportExcel(String isAllPage,JSONArray dataArray)throws AmsException; -} +package com.jsh.service.materials; + +import java.io.InputStream; +import java.util.List; + +import net.sf.json.JSONArray; + +import com.jsh.base.BaseIService; +import com.jsh.exception.JshException; +import com.jsh.model.po.Asset; +import com.jsh.model.po.DepotHead; +import com.jsh.model.po.DepotItem; +import com.jsh.util.common.PageUtil; + +public interface DepotItemIService extends BaseIService +{ + void findByType(PageUtil depotItem, String type, Long MId, String MonthTime,Boolean isPrev)throws JshException; + + void findOrderByMaterial(PageUtil depotItem)throws JshException; + + /** + * 导出信息 + * @return + */ + InputStream exmportExcel(String isAllPage,JSONArray dataArray)throws JshException; +} diff --git a/src/com/jsh/service/materials/DepotItemService.java b/src/com/jsh/service/materials/DepotItemService.java index b89fec38..18c25dc3 100644 --- a/src/com/jsh/service/materials/DepotItemService.java +++ b/src/com/jsh/service/materials/DepotItemService.java @@ -1,124 +1,124 @@ -package com.jsh.service.materials; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.text.DecimalFormat; -import java.util.List; -import java.util.Map; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - -import jxl.Workbook; -import jxl.write.Label; -import jxl.write.WritableSheet; -import jxl.write.WritableWorkbook; - -import com.jsh.base.BaseService; -import com.jsh.base.Log; -import com.jsh.constants.asset.AssetConstants; -import com.jsh.dao.materials.DepotItemIDAO; -import com.jsh.exception.AmsException; -import com.jsh.model.po.Asset; -import com.jsh.model.po.DepotHead; -import com.jsh.model.po.DepotItem; -import com.jsh.util.common.PageUtil; -import com.jsh.util.common.Tools; - -public class DepotItemService extends BaseService implements DepotItemIService -{ - @SuppressWarnings("unused") - private DepotItemIDAO depotItemDao; - - - public void setDepotItemDao(DepotItemIDAO depotItemDao) { - this.depotItemDao = depotItemDao; - } - - - @Override - protected Class getEntityClass() - { - return DepotItem.class; - } - - @Override - public void findByType(PageUtil pageUtil, String type,Long MId, String MonthTime,Boolean isPrev) throws AmsException - { - depotItemDao.findByType(pageUtil, type, MId, MonthTime,isPrev); - } - - @Override - public void findOrderByMaterial(PageUtil pageUtil) throws AmsException - { - depotItemDao.findOrderByMaterial(pageUtil); - } - - /** - * 导出Excel表格 - */ - @Override - public InputStream exmportExcel(String isAllPage,JSONArray dataArray)throws AmsException - { - try - { - //将OutputStream转化为InputStream - ByteArrayOutputStream out = new ByteArrayOutputStream(); - putDataOnOutputStream(out,dataArray); - return new ByteArrayInputStream(out.toByteArray()); - } - catch (Exception e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>>导出信息为excel表格异常", e); - throw new AmsException("export asset info to excel exception",e); - } - } - - /** - * 生成excel表格 - * @param os - */ - @SuppressWarnings("deprecation") - private void putDataOnOutputStream(OutputStream os,JSONArray dataArray) - { - WritableWorkbook workbook = null; - try - { - workbook = Workbook.createWorkbook(os); - WritableSheet sheet = workbook.createSheet("进销存报表", 0); - //增加列头 - int[] colunmWidth = {10,10,10,10,15,15,15,15,15}; - String[] colunmName = {"名称","款号","颜色","单价","上月结存数量","入库数量","出库数量","本月结存数量","结存金额"}; - for(int i = 0 ;i < colunmWidth.length;i ++) - { - sheet.setColumnView(i,colunmWidth[i]); - sheet.addCell(new Label(i, 0, colunmName[i])); - } - if (null != dataArray &&dataArray.size() > 0) - { - for(int j=0; j < dataArray.size(); j++){ - JSONObject jo = JSONObject.fromObject(dataArray.get(j)); - sheet.addCell(new Label(0, j+1, jo.getString("MaterialName"))); - sheet.addCell(new Label(1, j+1, jo.getString("MaterialModel"))); - sheet.addCell(new Label(2, j+1, jo.getString("MaterialColor"))); - sheet.addCell(new Label(3, j+1, jo.getString("UnitPrice"))); - sheet.addCell(new Label(4, j+1, jo.getString("prevSum"))); - sheet.addCell(new Label(5, j+1, jo.getString("InSum"))); - sheet.addCell(new Label(6, j+1, jo.getString("OutSum"))); - sheet.addCell(new Label(7, j+1, jo.getString("thisSum"))); - double d = Double.parseDouble(jo.getString("thisAllPrice").toString()); - String s1 = String.format("%.2f", d); - sheet.addCell(new Label(8, j+1, s1)); - } - } - workbook.write(); - workbook.close(); - } - catch (Exception e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>>导出资产信息为excel表格异常", e); - } - } -} +package com.jsh.service.materials; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.text.DecimalFormat; +import java.util.List; +import java.util.Map; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import jxl.Workbook; +import jxl.write.Label; +import jxl.write.WritableSheet; +import jxl.write.WritableWorkbook; + +import com.jsh.base.BaseService; +import com.jsh.base.Log; +import com.jsh.constants.asset.AssetConstants; +import com.jsh.dao.materials.DepotItemIDAO; +import com.jsh.exception.JshException; +import com.jsh.model.po.Asset; +import com.jsh.model.po.DepotHead; +import com.jsh.model.po.DepotItem; +import com.jsh.util.common.PageUtil; +import com.jsh.util.common.Tools; + +public class DepotItemService extends BaseService implements DepotItemIService +{ + @SuppressWarnings("unused") + private DepotItemIDAO depotItemDao; + + + public void setDepotItemDao(DepotItemIDAO depotItemDao) { + this.depotItemDao = depotItemDao; + } + + + @Override + protected Class getEntityClass() + { + return DepotItem.class; + } + + @Override + public void findByType(PageUtil pageUtil, String type,Long MId, String MonthTime,Boolean isPrev) throws JshException + { + depotItemDao.findByType(pageUtil, type, MId, MonthTime,isPrev); + } + + @Override + public void findOrderByMaterial(PageUtil pageUtil) throws JshException + { + depotItemDao.findOrderByMaterial(pageUtil); + } + + /** + * 导出Excel表格 + */ + @Override + public InputStream exmportExcel(String isAllPage,JSONArray dataArray)throws JshException + { + try + { + //将OutputStream转化为InputStream + ByteArrayOutputStream out = new ByteArrayOutputStream(); + putDataOnOutputStream(out,dataArray); + return new ByteArrayInputStream(out.toByteArray()); + } + catch (Exception e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>>导出信息为excel表格异常", e); + throw new JshException("export asset info to excel exception",e); + } + } + + /** + * 生成excel表格 + * @param os + */ + @SuppressWarnings("deprecation") + private void putDataOnOutputStream(OutputStream os,JSONArray dataArray) + { + WritableWorkbook workbook = null; + try + { + workbook = Workbook.createWorkbook(os); + WritableSheet sheet = workbook.createSheet("进销存报表", 0); + //增加列头 + int[] colunmWidth = {10,10,10,10,15,15,15,15,15}; + String[] colunmName = {"名称","款号","颜色","单价","上月结存数量","入库数量","出库数量","本月结存数量","结存金额"}; + for(int i = 0 ;i < colunmWidth.length;i ++) + { + sheet.setColumnView(i,colunmWidth[i]); + sheet.addCell(new Label(i, 0, colunmName[i])); + } + if (null != dataArray &&dataArray.size() > 0) + { + for(int j=0; j < dataArray.size(); j++){ + JSONObject jo = JSONObject.fromObject(dataArray.get(j)); + sheet.addCell(new Label(0, j+1, jo.getString("MaterialName"))); + sheet.addCell(new Label(1, j+1, jo.getString("MaterialModel"))); + sheet.addCell(new Label(2, j+1, jo.getString("MaterialColor"))); + sheet.addCell(new Label(3, j+1, jo.getString("UnitPrice"))); + sheet.addCell(new Label(4, j+1, jo.getString("prevSum"))); + sheet.addCell(new Label(5, j+1, jo.getString("InSum"))); + sheet.addCell(new Label(6, j+1, jo.getString("OutSum"))); + sheet.addCell(new Label(7, j+1, jo.getString("thisSum"))); + double d = Double.parseDouble(jo.getString("thisAllPrice").toString()); + String s1 = String.format("%.2f", d); + sheet.addCell(new Label(8, j+1, s1)); + } + } + workbook.write(); + workbook.close(); + } + catch (Exception e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>>导出资产信息为excel表格异常", e); + } + } +} diff --git a/src/com/jsh/util/common/BeanFactoryUtil.java b/src/com/jsh/util/common/BeanFactoryUtil.java index 5d5a3171..dfeb77a4 100644 --- a/src/com/jsh/util/common/BeanFactoryUtil.java +++ b/src/com/jsh/util/common/BeanFactoryUtil.java @@ -1,135 +1,126 @@ -/** - * 项 目 名:HiTV - * 包 名:com.suma.hitv.utils - * 文 件 名:BeanFactoryUtil.java - * 版本信息:V1.0 - * 日 期:2011-12-30-下午01:25:00 - * Copyright (c) 2000-2011北京数码视讯有限公司版权所有 - * - */ -package com.jsh.util.common; - -import java.util.HashMap; -import java.util.Map; - -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.context.support.FileSystemXmlApplicationContext; - -/** - * 获取spring配置中的bean对象,是单例,只会加载一次,请注意使用 - * 注意:此工具类默认处理UI组件WEB-INF目录下的applicationContext.xml配置文件,请注意文件 名和路径 - * @author andy - * @version V1.0 - */ -public class BeanFactoryUtil -{ - private static BeanFactoryUtil defaultBeanFactory; - - private ApplicationContext defaultAC = null; - - //private ApplicationContext autoLoadAC = null; - - private static BeanFactoryUtil specialBeanFactory; - - private ApplicationContext specialAC = null; - - private static Map beanMap = new HashMap(); - - //private Logger log = Logger.getLogger(BeanFactoryUtil.class); - - /** - * 私有构造函数,默认为UI组件WEB-INF目录下的applicationContext.xml配置文件 - */ - private BeanFactoryUtil() - { - String fileUrl = PathTool.getWebinfPath(); - //这里只对UI组件WEB-INF目录下的applicationContext.xml配置文件 - defaultAC = new FileSystemXmlApplicationContext( new - String[]{fileUrl - + "spring/basic-applicationContext.xml", - fileUrl + "spring/dao-applicationContext.xml"}); - } - - /** - * 私有构造函数,带有文件的classpath路径,可能是非applicationContext.xml文件 - */ - private BeanFactoryUtil(String fileClassPath) - { - specialAC = new ClassPathXmlApplicationContext("classpath:" - + fileClassPath); - } - - /** - * 非web.xml方式加载spring配置文件方式的实体实例获取方式 - * @param fileClassPath - * @param beanName - * @return - */ - public synchronized static Object getBeanByClassPathAndBeanName( - String fileClassPath, String beanName) - { - ApplicationContext ac = beanMap.get(fileClassPath); - if (null == ac) - { - ac = new ClassPathXmlApplicationContext("classpath:" - + fileClassPath); - beanMap.put(fileClassPath, ac); - } - return ac.getBean(beanName); - } - - /** - * 获取类实例 - * 默认加载UI组件WEB-INF目录下的applicationContext.xml配置文件 - * @return - * - */ - public synchronized static BeanFactoryUtil getInstance() - { - if (null == defaultBeanFactory) - { - defaultBeanFactory = new BeanFactoryUtil(); - } - return defaultBeanFactory; - } - - /** - * 获取类实例,这种情况一定是在依赖其他组件时没有在applicationContext.xml加载器spring文件时使用 - * 这种情况请少用 - * @param fileClassPath - * @return - */ - @Deprecated - public synchronized static BeanFactoryUtil getInstance(String fileClassPath) - { - if (null == specialBeanFactory) - { - specialBeanFactory = new BeanFactoryUtil(fileClassPath); - } - return specialBeanFactory; - } - - /** - * 获取UI组件WEB-INF目录下的applicationContext.xml配置文件中配置的bean实例 - * @param beanName - * @return - */ - public Object getBean(String beanName) - { - return defaultAC.getBean(beanName); - } - - /** - * 获取没有在applicationContext.xml配置文件中引入的spring配置文件,即没有用容器加载过的配置文件 - * 这里为特殊情况下使用,不推荐使用 - * 推荐在applicationContext.xml配置文件中引入需要使用的spring配置文件,然后使用BeanFactoryUtil.getInstance().getBean("")方法 - * @param beanName - * @return - */ - @Deprecated - public Object getSpecialBean(String beanName) - { - return specialAC.getBean(beanName); - } -} +package com.jsh.util.common; + +import java.util.HashMap; +import java.util.Map; + +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.context.support.FileSystemXmlApplicationContext; + +/** + * 获取spring配置中的bean对象,是单例,只会加载一次,请注意使用 + * 注意:此工具类默认处理UI组件WEB-INF目录下的applicationContext.xml配置文件,请注意文件 名和路径 + * @author jishenghua + * @version V1.0 + */ +public class BeanFactoryUtil +{ + private static BeanFactoryUtil defaultBeanFactory; + + private ApplicationContext defaultAC = null; + + //private ApplicationContext autoLoadAC = null; + + private static BeanFactoryUtil specialBeanFactory; + + private ApplicationContext specialAC = null; + + private static Map beanMap = new HashMap(); + + //private Logger log = Logger.getLogger(BeanFactoryUtil.class); + + /** + * 私有构造函数,默认为UI组件WEB-INF目录下的applicationContext.xml配置文件 + */ + private BeanFactoryUtil() + { + String fileUrl = PathTool.getWebinfPath(); + //这里只对UI组件WEB-INF目录下的applicationContext.xml配置文件 + defaultAC = new FileSystemXmlApplicationContext( new + String[]{fileUrl + + "spring/basic-applicationContext.xml", + fileUrl + "spring/dao-applicationContext.xml"}); + } + + /** + * 私有构造函数,带有文件的classpath路径,可能是非applicationContext.xml文件 + */ + private BeanFactoryUtil(String fileClassPath) + { + specialAC = new ClassPathXmlApplicationContext("classpath:" + + fileClassPath); + } + + /** + * 非web.xml方式加载spring配置文件方式的实体实例获取方式 + * @param fileClassPath + * @param beanName + * @return + */ + public synchronized static Object getBeanByClassPathAndBeanName( + String fileClassPath, String beanName) + { + ApplicationContext ac = beanMap.get(fileClassPath); + if (null == ac) + { + ac = new ClassPathXmlApplicationContext("classpath:" + + fileClassPath); + beanMap.put(fileClassPath, ac); + } + return ac.getBean(beanName); + } + + /** + * 获取类实例 + * 默认加载UI组件WEB-INF目录下的applicationContext.xml配置文件 + * @return + * + */ + public synchronized static BeanFactoryUtil getInstance() + { + if (null == defaultBeanFactory) + { + defaultBeanFactory = new BeanFactoryUtil(); + } + return defaultBeanFactory; + } + + /** + * 获取类实例,这种情况一定是在依赖其他组件时没有在applicationContext.xml加载器spring文件时使用 + * 这种情况请少用 + * @param fileClassPath + * @return + */ + @Deprecated + public synchronized static BeanFactoryUtil getInstance(String fileClassPath) + { + if (null == specialBeanFactory) + { + specialBeanFactory = new BeanFactoryUtil(fileClassPath); + } + return specialBeanFactory; + } + + /** + * 获取UI组件WEB-INF目录下的applicationContext.xml配置文件中配置的bean实例 + * @param beanName + * @return + */ + public Object getBean(String beanName) + { + return defaultAC.getBean(beanName); + } + + /** + * 获取没有在applicationContext.xml配置文件中引入的spring配置文件,即没有用容器加载过的配置文件 + * 这里为特殊情况下使用,不推荐使用 + * 推荐在applicationContext.xml配置文件中引入需要使用的spring配置文件,然后使用BeanFactoryUtil.getInstance().getBean("")方法 + * @param beanName + * @return + */ + @Deprecated + public Object getSpecialBean(String beanName) + { + return specialAC.getBean(beanName); + } +} diff --git a/src/com/jsh/util/common/PageUtil.java b/src/com/jsh/util/common/PageUtil.java index e9596e06..4d5e2628 100644 --- a/src/com/jsh/util/common/PageUtil.java +++ b/src/com/jsh/util/common/PageUtil.java @@ -1,198 +1,198 @@ -package com.jsh.util.common; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; -/** - * 分页工具类,实现分页功能 - * @author andy - * @version [版本号version01, 2012-1-25] - */ -@SuppressWarnings("serial") -public class PageUtil implements Serializable -{ - /** - * 总页数,根据总数和单页显示个数进行计算 - */ - private int totalPage = 0; - - /** - * 总个数 - */ - private int totalCount = 0 ; - - /** - * 当前页码 - */ - private int curPage = 1; - - /** - * 每页显示个数 - */ - private int pageSize = 10; - - /** - * 是否为第一页 - */ - private boolean isFirstPage = false; - /** - * 是否是最后一页 - */ - private boolean isLastPage = false; - - /** - * 是否有上一页 - */ - private boolean hasPrevious = false; - - /** - * 是否有下一页 - */ - private boolean hasNext = false; - - /** - * 返回页面list数组 - */ - private List pageList = new ArrayList(); - - /** - * 页面搜索条件,用map来实现 - */ - private Map advSearch = new Hashtable(); - - public PageUtil() - { - - } - - public PageUtil(int totalCount,int pageSize,int curPage,Map adv) - { - init(totalCount,pageSize,curPage,adv); - } - /** - * 初始化页面显示参数 - * @param totalCount 总数 - * @param pageSize 页面显示个数 - * @param curPage 当前页面 - */ - public void init(int totalCount,int pageSize,int curPage,Map adv) - { - this.totalCount = totalCount; - this.pageSize = pageSize ; - this.curPage = curPage; - this.advSearch = adv; - //计算总页数 - if(pageSize != 0) - { - this.totalPage = (totalCount+pageSize-1)/pageSize; - } - if(curPage <1) - { - this.curPage = 1; - } - if(curPage>this.totalPage) - { - this.curPage = this.totalPage; - } - if(curPage>0&&this.totalPage!=1&&curPage0&&this.totalPage!=1&&curPage>1&&curPage<=this.totalPage) - { - this.hasPrevious = true; - } - if(curPage == 1) - { - this.isFirstPage = true ; - } - if(curPage == this.totalPage) - { - this.isLastPage = true; - } - } - public int getTotalPage() - { - return totalPage; - } - public void setTotalPage(int totalPage) - { - this.totalPage = totalPage; - } - public int getTotalCount() - { - return totalCount; - } - public void setTotalCount(int totalCount) - { - this.totalCount = totalCount; - } - public int getCurPage() - { - return curPage; - } - public void setCurPage(int curPage) - { - this.curPage = curPage; - } - public int getPageSize() - { - return pageSize; - } - public void setPageSize(int pageSize) - { - this.pageSize = pageSize; - } - public boolean isFirstPage() - { - return isFirstPage; - } - public void setFirstPage(boolean isFirstPage) - { - this.isFirstPage = isFirstPage; - } - public boolean isLastPage() - { - return isLastPage; - } - public void setLastPage(boolean isLastPage) - { - this.isLastPage = isLastPage; - } - public boolean isHasPrevious() - { - return hasPrevious; - } - public void setHasPrevious(boolean hasPrevious) - { - this.hasPrevious = hasPrevious; - } - public boolean isHasNext() - { - return hasNext; - } - public void setHasNext(boolean hasNext) - { - this.hasNext = hasNext; - } - - public List getPageList() - { - return pageList; - } - public void setPageList(List pageList) - { - this.pageList = pageList; - } - - public Map getAdvSearch() - { - return advSearch; - } - public void setAdvSearch(Map advSearch) - { - this.advSearch = advSearch; - } -} \ No newline at end of file +package com.jsh.util.common; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +/** + * 分页工具类,实现分页功能 + * @author jishenghua + * @version [版本号version01, 2012-1-25] + */ +@SuppressWarnings("serial") +public class PageUtil implements Serializable +{ + /** + * 总页数,根据总数和单页显示个数进行计算 + */ + private int totalPage = 0; + + /** + * 总个数 + */ + private int totalCount = 0 ; + + /** + * 当前页码 + */ + private int curPage = 1; + + /** + * 每页显示个数 + */ + private int pageSize = 10; + + /** + * 是否为第一页 + */ + private boolean isFirstPage = false; + /** + * 是否是最后一页 + */ + private boolean isLastPage = false; + + /** + * 是否有上一页 + */ + private boolean hasPrevious = false; + + /** + * 是否有下一页 + */ + private boolean hasNext = false; + + /** + * 返回页面list数组 + */ + private List pageList = new ArrayList(); + + /** + * 页面搜索条件,用map来实现 + */ + private Map advSearch = new Hashtable(); + + public PageUtil() + { + + } + + public PageUtil(int totalCount,int pageSize,int curPage,Map adv) + { + init(totalCount,pageSize,curPage,adv); + } + /** + * 初始化页面显示参数 + * @param totalCount 总数 + * @param pageSize 页面显示个数 + * @param curPage 当前页面 + */ + public void init(int totalCount,int pageSize,int curPage,Map adv) + { + this.totalCount = totalCount; + this.pageSize = pageSize ; + this.curPage = curPage; + this.advSearch = adv; + //计算总页数 + if(pageSize != 0) + { + this.totalPage = (totalCount+pageSize-1)/pageSize; + } + if(curPage <1) + { + this.curPage = 1; + } + if(curPage>this.totalPage) + { + this.curPage = this.totalPage; + } + if(curPage>0&&this.totalPage!=1&&curPage0&&this.totalPage!=1&&curPage>1&&curPage<=this.totalPage) + { + this.hasPrevious = true; + } + if(curPage == 1) + { + this.isFirstPage = true ; + } + if(curPage == this.totalPage) + { + this.isLastPage = true; + } + } + public int getTotalPage() + { + return totalPage; + } + public void setTotalPage(int totalPage) + { + this.totalPage = totalPage; + } + public int getTotalCount() + { + return totalCount; + } + public void setTotalCount(int totalCount) + { + this.totalCount = totalCount; + } + public int getCurPage() + { + return curPage; + } + public void setCurPage(int curPage) + { + this.curPage = curPage; + } + public int getPageSize() + { + return pageSize; + } + public void setPageSize(int pageSize) + { + this.pageSize = pageSize; + } + public boolean isFirstPage() + { + return isFirstPage; + } + public void setFirstPage(boolean isFirstPage) + { + this.isFirstPage = isFirstPage; + } + public boolean isLastPage() + { + return isLastPage; + } + public void setLastPage(boolean isLastPage) + { + this.isLastPage = isLastPage; + } + public boolean isHasPrevious() + { + return hasPrevious; + } + public void setHasPrevious(boolean hasPrevious) + { + this.hasPrevious = hasPrevious; + } + public boolean isHasNext() + { + return hasNext; + } + public void setHasNext(boolean hasNext) + { + this.hasNext = hasNext; + } + + public List getPageList() + { + return pageList; + } + public void setPageList(List pageList) + { + this.pageList = pageList; + } + + public Map getAdvSearch() + { + return advSearch; + } + public void setAdvSearch(Map advSearch) + { + this.advSearch = advSearch; + } +} diff --git a/src/com/jsh/util/common/PathTool.java b/src/com/jsh/util/common/PathTool.java index 2c32f8a2..14a23b0e 100644 --- a/src/com/jsh/util/common/PathTool.java +++ b/src/com/jsh/util/common/PathTool.java @@ -1,84 +1,84 @@ -package com.jsh.util.common; - -import java.io.File; -import java.net.URISyntaxException; -import java.net.URL; - -import com.jsh.base.Log; - -/** - * 获取应用系统路径 - * @author andy - */ -public class PathTool -{ - - /** - * 获取WEB-INF的绝对路径 - * @return - */ - public static String getWebinfPath() - { - String webinfPath = ""; - //获取URL对象 - URL url = PathTool.class.getClassLoader().getResource(""); - try - { - //获取路径 - webinfPath = url.toURI().getPath(); - //截取路径到WEB-INF结束 -// webinfPath = path.substring(0, path.indexOf("/WEB-INF") + 8); - } - catch (URISyntaxException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>>路径获取异常", e); - } - return webinfPath; - } - - /** - * 获取webapp的绝对路径 - * @return - */ - public static String getWebappPath() - { - //先获取工程路径 - String projectPath = getProjectPath(); - //获取工程路径的上级路径 - File f = new File(projectPath); - //路径不存在就返回 - if (!f.exists()) - { - return projectPath; - } - else - { - //返回webapp路径 - return f.getParent(); - } - } - - /** - * 获取工程的绝对路径 - * @return - */ - public static String getProjectPath() - { - String projectPath = ""; - //获取URL对象 - URL url = PathTool.class.getClassLoader().getResource(""); - String path = null; - try - { - //获取路径 - path = url.toURI().getPath(); - //截取webapp路径 - projectPath = path.substring(0, path.indexOf("/WEB-INF")); - } - catch (URISyntaxException e) - { - Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>>路径获取异常", e); - } - return projectPath; - } -} +package com.jsh.util.common; + +import java.io.File; +import java.net.URISyntaxException; +import java.net.URL; + +import com.jsh.base.Log; + +/** + * 获取应用系统路径 + * @author jishenghua + */ +public class PathTool +{ + + /** + * 获取WEB-INF的绝对路径 + * @return + */ + public static String getWebinfPath() + { + String webinfPath = ""; + //获取URL对象 + URL url = PathTool.class.getClassLoader().getResource(""); + try + { + //获取路径 + webinfPath = url.toURI().getPath(); + //截取路径到WEB-INF结束 +// webinfPath = path.substring(0, path.indexOf("/WEB-INF") + 8); + } + catch (URISyntaxException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>>路径获取异常", e); + } + return webinfPath; + } + + /** + * 获取webapp的绝对路径 + * @return + */ + public static String getWebappPath() + { + //先获取工程路径 + String projectPath = getProjectPath(); + //获取工程路径的上级路径 + File f = new File(projectPath); + //路径不存在就返回 + if (!f.exists()) + { + return projectPath; + } + else + { + //返回webapp路径 + return f.getParent(); + } + } + + /** + * 获取工程的绝对路径 + * @return + */ + public static String getProjectPath() + { + String projectPath = ""; + //获取URL对象 + URL url = PathTool.class.getClassLoader().getResource(""); + String path = null; + try + { + //获取路径 + path = url.toURI().getPath(); + //截取webapp路径 + projectPath = path.substring(0, path.indexOf("/WEB-INF")); + } + catch (URISyntaxException e) + { + Log.errorFileSync(">>>>>>>>>>>>>>>>>>>>>>>路径获取异常", e); + } + return projectPath; + } +} diff --git a/src/com/jsh/util/common/SearchConditionUtil.java b/src/com/jsh/util/common/SearchConditionUtil.java index 0f553bdf..bdd0d470 100644 --- a/src/com/jsh/util/common/SearchConditionUtil.java +++ b/src/com/jsh/util/common/SearchConditionUtil.java @@ -1,127 +1,127 @@ -package com.jsh.util.common; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -/** - * 根据搜索条件拼装成查询hql语句 - * @author andy - */ -public class SearchConditionUtil -{ - //拼接字符串的前缀空格字符串 - private static final String emptyPrefix = " and "; - - /** - * 根据搜索条件自动拼接成hql搜索语句 - * @param condition 搜索条件 规则: - * 1、类型 n--数字 s--字符串 - * 2、属性 eq--等于 neq--不等于 like--像'%XX%' llike--左像'%XX' rlike--右像'XX%' in--包含 gt--大于 gteq--大于等于 lt--小于 lteq--小于等于 - * order--value desc asc gy-- group by - * 示例: - * Map condition = new HashMap(); - * condition.put("supplier_s_like", "aaa"); - * condition.put("contacts_s_llike", "186"); - * condition.put("contacts_s_rlike", "186"); - * condition.put("phonenum_s_eq", null); - * condition.put("email_n_neq", 23); - * condition.put("description_s_order", "desc"); - * @return 封装后的字符串 - */ - public static String getCondition(Map condition) - { - StringBuffer hql = new StringBuffer(); - Set key = condition.keySet(); - String groupbyInfo = ""; - String orderInfo = ""; - for(String keyInfo:key) - { - /* - * 1、数组为三个 第一个为对象实例的字段 第二个为字段类型 第三个为属性 - * 2、根据分解后的数组拼接搜索条件 - */ - Object valueInfo = condition.get(keyInfo); - if(null != valueInfo &&valueInfo.toString().length()>0) - { - String[] searchCondition = keyInfo.split("_"); - if(searchCondition[1].equals("n")) - hql.append(emptyPrefix + searchCondition[0] + getType(searchCondition[2]) + valueInfo); - else if(searchCondition[1].equals("s")) - { - if(searchCondition[2].equals("like")) - hql.append(emptyPrefix + searchCondition[0] + getType(searchCondition[2]) + "'%" + valueInfo + "%'"); - else if(searchCondition[2].equals("llike")) - hql.append(emptyPrefix + searchCondition[0] + getType(searchCondition[2]) + "'%" + valueInfo + "'"); - else if(searchCondition[2].equals("rlike")) - hql.append(emptyPrefix + searchCondition[0] + getType(searchCondition[2]) + "'" + valueInfo + "%'"); - else if(searchCondition[2].equals("in")) - hql.append(emptyPrefix + searchCondition[0] + getType(searchCondition[2]) + "(" + valueInfo + ")"); - else if(searchCondition[2].equals("order")) - orderInfo = " order by " + searchCondition[0] + " " + valueInfo; - else if(searchCondition[2].equals("gb")) - groupbyInfo = " group by " + searchCondition[0]; - else - hql.append(emptyPrefix + searchCondition[0] + getType(searchCondition[2]) + "'" + valueInfo + "'"); - } - } - } - return hql.append(groupbyInfo).append(orderInfo).toString(); - } - - /** - * 获取指定类型的符号 - * 属性 eq--等于 neq--不等于 like--像 in--包含 gt--大于 gteq--大于等于 lt--小于 lteq--小于等于 order--value desc asc - * @param type - * @return 类型字符串 - */ - private static String getType(String type) - { - String typeStr = ""; - if(type.equals("eq")) - typeStr = " = "; - else if(type.equals("neq")) - typeStr = " != "; - else if(type.equals("like")) - typeStr = " like "; - else if(type.equals("llike")) - typeStr = " like "; - else if(type.equals("rlike")) - typeStr = " like "; - else if(type.equals("in")) - typeStr = " in "; - else if(type.equals("gt")) - typeStr = " > "; - else if(type.equals("gteq")) - typeStr = " >= "; - else if(type.equals("lt")) - typeStr = " < "; - else if(type.equals("lteq")) - typeStr = " <= "; - else if(type.equals("order")) - typeStr = " order "; - else if(type.equals("gy")) - typeStr = " group by "; - else - typeStr = "unknown"; - return typeStr; - } - - public static void main(String[] args) - { - /** - * 拼接搜索条件 - */ - Map condition = new HashMap(); - condition.put("supplier_s_like", "aaa"); - condition.put("contacts_s_llike", "186"); - condition.put("contacts_s_rlike", "186"); - condition.put("phonenum_s_eq", null); - condition.put("email_n_neq", 23); - condition.put("description_s_order", "desc"); - condition.put("description_s_gb", "aaa"); - - //获取搜索条件拼接 - System.out.println(getCondition(condition)); - } -} +package com.jsh.util.common; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +/** + * 根据搜索条件拼装成查询hql语句 + * @author jishenghua + */ +public class SearchConditionUtil +{ + //拼接字符串的前缀空格字符串 + private static final String emptyPrefix = " and "; + + /** + * 根据搜索条件自动拼接成hql搜索语句 + * @param condition 搜索条件 规则: + * 1、类型 n--数字 s--字符串 + * 2、属性 eq--等于 neq--不等于 like--像'%XX%' llike--左像'%XX' rlike--右像'XX%' in--包含 gt--大于 gteq--大于等于 lt--小于 lteq--小于等于 + * order--value desc asc gy-- group by + * 示例: + * Map condition = new HashMap(); + * condition.put("supplier_s_like", "aaa"); + * condition.put("contacts_s_llike", "186"); + * condition.put("contacts_s_rlike", "186"); + * condition.put("phonenum_s_eq", null); + * condition.put("email_n_neq", 23); + * condition.put("description_s_order", "desc"); + * @return 封装后的字符串 + */ + public static String getCondition(Map condition) + { + StringBuffer hql = new StringBuffer(); + Set key = condition.keySet(); + String groupbyInfo = ""; + String orderInfo = ""; + for(String keyInfo:key) + { + /* + * 1、数组为三个 第一个为对象实例的字段 第二个为字段类型 第三个为属性 + * 2、根据分解后的数组拼接搜索条件 + */ + Object valueInfo = condition.get(keyInfo); + if(null != valueInfo &&valueInfo.toString().length()>0) + { + String[] searchCondition = keyInfo.split("_"); + if(searchCondition[1].equals("n")) + hql.append(emptyPrefix + searchCondition[0] + getType(searchCondition[2]) + valueInfo); + else if(searchCondition[1].equals("s")) + { + if(searchCondition[2].equals("like")) + hql.append(emptyPrefix + searchCondition[0] + getType(searchCondition[2]) + "'%" + valueInfo + "%'"); + else if(searchCondition[2].equals("llike")) + hql.append(emptyPrefix + searchCondition[0] + getType(searchCondition[2]) + "'%" + valueInfo + "'"); + else if(searchCondition[2].equals("rlike")) + hql.append(emptyPrefix + searchCondition[0] + getType(searchCondition[2]) + "'" + valueInfo + "%'"); + else if(searchCondition[2].equals("in")) + hql.append(emptyPrefix + searchCondition[0] + getType(searchCondition[2]) + "(" + valueInfo + ")"); + else if(searchCondition[2].equals("order")) + orderInfo = " order by " + searchCondition[0] + " " + valueInfo; + else if(searchCondition[2].equals("gb")) + groupbyInfo = " group by " + searchCondition[0]; + else + hql.append(emptyPrefix + searchCondition[0] + getType(searchCondition[2]) + "'" + valueInfo + "'"); + } + } + } + return hql.append(groupbyInfo).append(orderInfo).toString(); + } + + /** + * 获取指定类型的符号 + * 属性 eq--等于 neq--不等于 like--像 in--包含 gt--大于 gteq--大于等于 lt--小于 lteq--小于等于 order--value desc asc + * @param type + * @return 类型字符串 + */ + private static String getType(String type) + { + String typeStr = ""; + if(type.equals("eq")) + typeStr = " = "; + else if(type.equals("neq")) + typeStr = " != "; + else if(type.equals("like")) + typeStr = " like "; + else if(type.equals("llike")) + typeStr = " like "; + else if(type.equals("rlike")) + typeStr = " like "; + else if(type.equals("in")) + typeStr = " in "; + else if(type.equals("gt")) + typeStr = " > "; + else if(type.equals("gteq")) + typeStr = " >= "; + else if(type.equals("lt")) + typeStr = " < "; + else if(type.equals("lteq")) + typeStr = " <= "; + else if(type.equals("order")) + typeStr = " order "; + else if(type.equals("gy")) + typeStr = " group by "; + else + typeStr = "unknown"; + return typeStr; + } + + public static void main(String[] args) + { + /** + * 拼接搜索条件 + */ + Map condition = new HashMap(); + condition.put("supplier_s_like", "aaa"); + condition.put("contacts_s_llike", "186"); + condition.put("contacts_s_rlike", "186"); + condition.put("phonenum_s_eq", null); + condition.put("email_n_neq", 23); + condition.put("description_s_order", "desc"); + condition.put("description_s_gb", "aaa"); + + //获取搜索条件拼接 + System.out.println(getCondition(condition)); + } +} diff --git a/src/com/jsh/util/common/Tools.java b/src/com/jsh/util/common/Tools.java index 8736f2c3..02d2bd4d 100644 --- a/src/com/jsh/util/common/Tools.java +++ b/src/com/jsh/util/common/Tools.java @@ -1,555 +1,558 @@ -package com.jsh.util.common; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.InetAddress; -import java.net.URLEncoder; -import java.net.UnknownHostException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.Locale; -import java.util.UUID; -import java.util.regex.Pattern; - -import sun.misc.BASE64Encoder; - -public class Tools -{ - /** - * 获得32位唯一序列号 - * @return 32为ID字符串 - */ - public static String getUUID_32() - { - return UUID.randomUUID().toString().replaceAll("-", ""); - } - /** - * 获得当天时间,格式为yyyy-MM-dd - * @return 格式化后的日期格式 - */ - public static String getNow() - { - return new SimpleDateFormat("yyyy-MM-dd").format(new Date()); - } - - /** - * 获取当前月 yyyy-MM - * @return - */ - public static String getCurrentMonth() - { - return new SimpleDateFormat("yyyy-MM").format(new Date()); - } - - /** - * 获取指定日期格式 yyyy-MM - * @return - */ - public static String getCurrentMonth(Date date) - { - return new SimpleDateFormat("yyyy-MM-dd").format(date); - } - - /** - * 获得当天时间,格式为yyyyMMddHHmmss - * @return 格式化后的日期格式 - */ - public static String getNow2(Date date) - { - return new SimpleDateFormat("yyyyMMddHHmmss").format(date); - } - /** - * 获得当天时间,格式为yyyy-MM-dd HH:mm:ss - * @return 格式化后的日期格式 - */ - public static String getNow3() - { - return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); - } - /** - * 获得指定时间,格式为yyyy-MM-dd HH:mm:ss - * @return 格式化后的日期格式 - */ - public static String getCenternTime(Date date) - { - return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date); - } - - /** - * 获得指定时间,格式为mm:ss - * @return 格式化后的日期格式 - */ - public static String getTimeInfo(Date date) - { - return new SimpleDateFormat("mm:ss").format(date); - } - /** - * 获取当前日期是星期几 - * return 星期几 - */ - public static String getWeekDay() - { - Calendar c = Calendar.getInstance(Locale.CHINA); - c.setTime(new Date()); - int day=c.get(Calendar.DAY_OF_WEEK); - String weekDay = ""; - switch (day) - { - case 1: - weekDay = "星期日"; - break; - case 2: - weekDay = "星期一"; - break; - case 3: - weekDay = "星期二"; - break; - case 4: - weekDay = "星期三"; - break; - case 5: - weekDay = "星期四"; - break; - case 6: - weekDay = "星期五"; - break; - case 7: - weekDay = "星期六"; - break; - default: - break; - } - return weekDay; - } - /** - * 判断字符串是否全部为数字 - * @param accountWaste - * @return boolean值 - */ - public static boolean checkStrIsNum(String checkStr) - { - if(checkStr == null || checkStr.length() ==0) - return false; - return Pattern.compile("^[0-9]*.{1}[0-9]*$").matcher(checkStr).matches(); -// return Pattern.compile(":^[0-9]+(.[0-9])*$").matcher(checkStr).matches(); - } - /** - * 获得前一天的时间 - * @return 前一天日期 - */ - public static String getPreviousDate() - { - Calendar cal = Calendar.getInstance(); - cal.add(Calendar.DATE, -1); - return new SimpleDateFormat("yyyy-MM").format(cal.getTime()); - } - - /** - * 截取字符串长度 - * @param beforeStr - * @param cutLeng - * @return 截取后的字符串 - */ - public static String subStr(String beforeStr,int cutLeng){ - if(beforeStr.length()>cutLeng) - return beforeStr.substring(0,cutLeng)+ "..." ; - return beforeStr ; - } - /** - * 生成随机字符串,字母和数字混合 - * @return 组合后的字符串 ^[0-9a-zA-Z] - */ - public static String getRandomChar(){ - //生成一个0、1、2的随机数字 - int rand = (int)Math.round(Math.random() * 1); - long itmp = 0; - char ctmp = '\u0000'; - switch (rand) - { - //生成大写字母 + 1000以内数字 - case 1: - itmp = Math.round(Math.random() * 25 + 65); - ctmp = (char)itmp; - return String.valueOf(ctmp) + (int)Math.random()*1000; - //生成小写字母 - case 2: - itmp = Math.round(Math.random() * 25 + 97); - ctmp = (char)itmp; - return String.valueOf(ctmp)+ (int)Math.random()*1000; - //生成数字 - default : - itmp = Math.round(Math.random() * 1000); - return itmp + ""; - } - } - - /** - * 判断首字母以数字开头,字符串包括数字、字母%以及空格 - * @param str 检查字符串 - * @return 是否以数字开头 - */ - public static boolean CheckIsStartWithNum(String str) - { - return Pattern.compile("^[0-9][a-zA-Z0-9%,\\s]*$").matcher(str).matches(); - } - /** - * 判断首字母以","开头,字符串包括数字、字母%以及空格 - * @param str 检查字符串 - * @return 是否以数字开头 - */ - public static boolean CheckIsStartWithSpec(String str) - { - return Pattern.compile("^[,][a-zA-Z0-9%,\\s]*$").matcher(str).matches(); - } - /** - * 字符转码 - * @param aValue - * @return - * @see 转码后的字符串 - */ - public static String encodeValue(String aValue) - { - if(aValue.trim().length() ==0) - { - return ""; - } - String valueAfterTransCode = null; - try - { - valueAfterTransCode = URLEncoder.encode(aValue, "UTF-8"); - } - catch (UnsupportedEncodingException e) - { - e.getMessage(); - } - return valueAfterTransCode; - } - /** - * 去除str中的' - * @param str - * @return 除去'后的字符串 - * @see [类、类#方法、类#成员] - */ - public static String afterDealStr(String str) - { - return str.replace("'", ""); - } - /** - * 获取用户IP地址 - * @return 用户IP - * @see [类、类#方法、类#成员] - */ - public static String getCurrentUserIP() - { - try - { - return InetAddress.getLocalHost().getHostAddress(); - } - catch (UnknownHostException e) - { - e.printStackTrace(); - return "127.0.0.1"; - } - } - - /** - * 转化前台批量传入的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"); - returnFileName = returnFileName.replace(" ", "%20"); - } - else - { - returnFileName = URLEncoder.encode(fileName, "ISO8859-1"); - returnFileName = returnFileName.replace(" ","%20"); - if (returnFileName.length() > 150) - { - - returnFileName = new String(returnFileName.getBytes("GB2312"), "ISO8859-1"); - returnFileName = returnFileName.replace(" ", "%20"); - } - } - } - catch (UnsupportedEncodingException e) - { - e.printStackTrace(); - } - return returnFileName; - } - - /** - * 写理财日志内容转化特殊字符 - * @param str 需要转化的字符 - * @return 转化后的字符 - */ - public static String htmlspecialchars(String str) - { - str = str.replaceAll("&", "&"); - str = str.replaceAll("<", "<"); - str = str.replaceAll(">", ">"); - str = str.replaceAll("\"", """); - return str; - } - - /** - * 根据消费日期获取消费月 - * @param consumeDate 消费日期 - * @return 返回消费月信息 - */ - public static String getConsumeMonth(String consumeDate) - { - return consumeDate.substring(0,7); - } - - /** - * 获取当前日期的前XX个月 - * @param 之前的第几个月 - * @return 前XX个月字符串 - */ - public static String getBeforeMonth(int beforeMonth) - { - Calendar c = Calendar.getInstance(); - c.add(Calendar.MONTH, -beforeMonth); - return new SimpleDateFormat("yyyy-MM").format(c.getTime()); - } - - - /** - * 获取email用户姓名 - * @param args - */ - public static String getEmailUserName(String emailAddress) - { - return emailAddress.substring(0,emailAddress.lastIndexOf("@")); - } - - /** - * 获取中文编码,邮件附件乱码问题解决 - * @param str - * @return - */ - public static String getChineseString(String emailAttchmentTitle) - { - if(emailAttchmentTitle!=null&&!emailAttchmentTitle.equals("")) - { - try - { - return new String(emailAttchmentTitle.getBytes(),"ISO-8859-1"); - } - catch (UnsupportedEncodingException e) - { - e.printStackTrace(); - } - } - return emailAttchmentTitle; - } - - /** - * 判断userTel是否合法,userTel只能是数字 - * @param userTel - * @return true 合法 false不合法 - */ - public static boolean isTelNumber(String userTel) - { - String reg_phone="^(\\(\\d{3,4}\\)|\\d{3,4}-)?\\d{7,8}$"; - String reg_tel="^(1[0-9][0-9]|1[0-9][0|3|6|8|9])\\d{8}$"; - boolean b_phpne=Pattern.compile(reg_phone).matcher(userTel).matches(); - boolean b_tel=Pattern.compile(reg_tel).matcher(userTel).matches(); - return (b_phpne || b_tel); - } - - /** - * 模糊判断电话号码是否合法,只能是数字 - * @param macAddress - * @return - */ - public static boolean isTelNumberBySlur(String userTel) - { - return Pattern.compile("^([\\s0-9]{0,12}$)").matcher(userTel).matches(); - } - - /** - * 获取当前时间的字符串类型 - * @return 处理后的字符串类型 - */ - public static String getNowTime() - { - return new SimpleDateFormat("yyyyMMddHHmmss").format(Calendar.getInstance().getTime()); - } - - /** - * 开打指定文件 - * @param filePath 文件的绝对路径 - */ - public static void openFile(String filePath) - { - String viewFilePath = filePath.replace("\\", "/"); - // Runtime.getRuntime().exec("cmd /c start "+filePath); - // 解决路径中带空格问题 - Runtime r = Runtime.getRuntime(); - String[] cmdArray = new String[] { "cmd.exe", "/c", viewFilePath }; - try - { - r.exec(cmdArray); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - - /** - * 判断字符串中是否含有中文 - * @author andy - * @param str - * @return - */ - public static boolean isContainsChinese(String str) - { - return Pattern.compile("[\u4e00-\u9fa5]").matcher(str).matches(); - } - - /** - * 过滤html文件中的文本 - * @param content - * @return过滤后的文本 - */ - public static String filterText(String content) - { - return content.replace("/<(?:.|\\s)*?>/g",""); - } - - /** - * 去掉字符串中所有符号,不论是全角,还是半角的,或是货币符号或者空格等 - * @author andy - * @param s - * @return - * - */ - public static String removeSymbolForString(String s) - { - StringBuffer buffer = new StringBuffer(); - char[] chars = s.toCharArray(); - for (int i = 0; i < chars.length; i++) - { - if ((chars[i] >= 19968 && chars[i] <= 40869) || (chars[i] >= 97 && chars[i] <= 122) || (chars[i] >= 65 && chars[i] <= 90)) - { - buffer.append(chars[i]); - } - } - return buffer.toString(); - } - - /** - * 获取一个字符串的MD5 - * @param msg - * @return 加密后的MD5字符串 - * @throws NoSuchAlgorithmException - */ - public static String md5Encryp(String msg) throws NoSuchAlgorithmException - { - return new BASE64Encoder().encode(MessageDigest.getInstance("MD5").digest(msg.getBytes())); - } - - /** - * 处理字符串null值 - * @param beforeStr 处理前字符串 - * @return 处理后的字符串 - */ - public static String dealNullStr(String beforeStr) - { - if(null == beforeStr || beforeStr.length()==0) - return ""; - return beforeStr; - } - - /** - * 使用参数Format将字符串转为Date - * @author andy - * @param strDate - * @param pattern - * @return - * @throws ParseException - * - */ - public static Date parse(String strDate, String pattern) - throws ParseException - { - return new SimpleDateFormat(pattern).parse(strDate); - } - -// /** -// * 过滤html文件中的图片文件 -// * @param content -// * @return -// */ -// public static String filterImg(String content) -// { -// return content.matches("//g"); -// } - - public static void main(String[] args) - { - String aa = "的付的反对法的发的说法"; - char[] bb = aa.toCharArray(); - for(char c : bb) - { - System.out.println(c); - } - System.out.println(getBeforeMonth(1)); - - try - { - System.out.println(md5Encryp("guest")); - System.out.println(md5Encryp("admin")); - } - catch (NoSuchAlgorithmException e) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - String value = "2333"; - System.out.println(checkStrIsNum(value)); - - for(int i = 0 ;i < 100;i ++) - { - System.out.print(getRandomChar() + " || "); - } - } -} \ No newline at end of file +package com.jsh.util.common; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.InetAddress; +import java.net.URLEncoder; +import java.net.UnknownHostException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; +import java.util.UUID; +import java.util.regex.Pattern; +import java.math.BigInteger; + +public class Tools +{ + /** + * 获得32位唯一序列号 + * @return 32为ID字符串 + */ + public static String getUUID_32() + { + return UUID.randomUUID().toString().replaceAll("-", ""); + } + /** + * 获得当天时间,格式为yyyy-MM-dd + * @return 格式化后的日期格式 + */ + public static String getNow() + { + return new SimpleDateFormat("yyyy-MM-dd").format(new Date()); + } + + /** + * 获取当前月 yyyy-MM + * @return + */ + public static String getCurrentMonth() + { + return new SimpleDateFormat("yyyy-MM").format(new Date()); + } + + /** + * 获取指定日期格式 yyyy-MM + * @return + */ + public static String getCurrentMonth(Date date) + { + return new SimpleDateFormat("yyyy-MM-dd").format(date); + } + + /** + * 获得当天时间,格式为yyyyMMddHHmmss + * @return 格式化后的日期格式 + */ + public static String getNow2(Date date) + { + return new SimpleDateFormat("yyyyMMddHHmmss").format(date); + } + /** + * 获得当天时间,格式为yyyy-MM-dd HH:mm:ss + * @return 格式化后的日期格式 + */ + public static String getNow3() + { + return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + } + /** + * 获得指定时间,格式为yyyy-MM-dd HH:mm:ss + * @return 格式化后的日期格式 + */ + public static String getCenternTime(Date date) + { + return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date); + } + + /** + * 获得指定时间,格式为mm:ss + * @return 格式化后的日期格式 + */ + public static String getTimeInfo(Date date) + { + return new SimpleDateFormat("mm:ss").format(date); + } + /** + * 获取当前日期是星期几 + * return 星期几 + */ + public static String getWeekDay() + { + Calendar c = Calendar.getInstance(Locale.CHINA); + c.setTime(new Date()); + int day=c.get(Calendar.DAY_OF_WEEK); + String weekDay = ""; + switch (day) + { + case 1: + weekDay = "星期日"; + break; + case 2: + weekDay = "星期一"; + break; + case 3: + weekDay = "星期二"; + break; + case 4: + weekDay = "星期三"; + break; + case 5: + weekDay = "星期四"; + break; + case 6: + weekDay = "星期五"; + break; + case 7: + weekDay = "星期六"; + break; + default: + break; + } + return weekDay; + } + /** + * 判断字符串是否全部为数字 + * @param accountWaste + * @return boolean值 + */ + public static boolean checkStrIsNum(String checkStr) + { + if(checkStr == null || checkStr.length() ==0) + return false; + return Pattern.compile("^[0-9]*.{1}[0-9]*$").matcher(checkStr).matches(); +// return Pattern.compile(":^[0-9]+(.[0-9])*$").matcher(checkStr).matches(); + } + /** + * 获得前一天的时间 + * @return 前一天日期 + */ + public static String getPreviousDate() + { + Calendar cal = Calendar.getInstance(); + cal.add(Calendar.DATE, -1); + return new SimpleDateFormat("yyyy-MM").format(cal.getTime()); + } + + /** + * 截取字符串长度 + * @param beforeStr + * @param cutLeng + * @return 截取后的字符串 + */ + public static String subStr(String beforeStr,int cutLeng){ + if(beforeStr.length()>cutLeng) + return beforeStr.substring(0,cutLeng)+ "..." ; + return beforeStr ; + } + /** + * 生成随机字符串,字母和数字混合 + * @return 组合后的字符串 ^[0-9a-zA-Z] + */ + public static String getRandomChar(){ + //生成一个0、1、2的随机数字 + int rand = (int)Math.round(Math.random() * 1); + long itmp = 0; + char ctmp = '\u0000'; + switch (rand) + { + //生成大写字母 + 1000以内数字 + case 1: + itmp = Math.round(Math.random() * 25 + 65); + ctmp = (char)itmp; + return String.valueOf(ctmp) + (int)Math.random()*1000; + //生成小写字母 + case 2: + itmp = Math.round(Math.random() * 25 + 97); + ctmp = (char)itmp; + return String.valueOf(ctmp)+ (int)Math.random()*1000; + //生成数字 + default : + itmp = Math.round(Math.random() * 1000); + return itmp + ""; + } + } + + /** + * 判断首字母以数字开头,字符串包括数字、字母%以及空格 + * @param str 检查字符串 + * @return 是否以数字开头 + */ + public static boolean CheckIsStartWithNum(String str) + { + return Pattern.compile("^[0-9][a-zA-Z0-9%,\\s]*$").matcher(str).matches(); + } + /** + * 判断首字母以","开头,字符串包括数字、字母%以及空格 + * @param str 检查字符串 + * @return 是否以数字开头 + */ + public static boolean CheckIsStartWithSpec(String str) + { + return Pattern.compile("^[,][a-zA-Z0-9%,\\s]*$").matcher(str).matches(); + } + /** + * 字符转码 + * @param aValue + * @return + * @see 转码后的字符串 + */ + public static String encodeValue(String aValue) + { + if(aValue.trim().length() ==0) + { + return ""; + } + String valueAfterTransCode = null; + try + { + valueAfterTransCode = URLEncoder.encode(aValue, "UTF-8"); + } + catch (UnsupportedEncodingException e) + { + e.getMessage(); + } + return valueAfterTransCode; + } + /** + * 去除str中的' + * @param str + * @return 除去'后的字符串 + * @see [类、类#方法、类#成员] + */ + public static String afterDealStr(String str) + { + return str.replace("'", ""); + } + /** + * 获取用户IP地址 + * @return 用户IP + * @see [类、类#方法、类#成员] + */ + public static String getCurrentUserIP() + { + try + { + return InetAddress.getLocalHost().getHostAddress(); + } + catch (UnknownHostException e) + { + e.printStackTrace(); + return "127.0.0.1"; + } + } + + /** + * 转化前台批量传入的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"); + returnFileName = returnFileName.replace(" ", "%20"); + } + else + { + returnFileName = URLEncoder.encode(fileName, "ISO8859-1"); + returnFileName = returnFileName.replace(" ","%20"); + if (returnFileName.length() > 150) + { + + returnFileName = new String(returnFileName.getBytes("GB2312"), "ISO8859-1"); + returnFileName = returnFileName.replace(" ", "%20"); + } + } + } + catch (UnsupportedEncodingException e) + { + e.printStackTrace(); + } + return returnFileName; + } + + /** + * 写理财日志内容转化特殊字符 + * @param str 需要转化的字符 + * @return 转化后的字符 + */ + public static String htmlspecialchars(String str) + { + str = str.replaceAll("&", "&"); + str = str.replaceAll("<", "<"); + str = str.replaceAll(">", ">"); + str = str.replaceAll("\"", """); + return str; + } + + /** + * 根据消费日期获取消费月 + * @param consumeDate 消费日期 + * @return 返回消费月信息 + */ + public static String getConsumeMonth(String consumeDate) + { + return consumeDate.substring(0,7); + } + + /** + * 获取当前日期的前XX个月 + * @param 之前的第几个月 + * @return 前XX个月字符串 + */ + public static String getBeforeMonth(int beforeMonth) + { + Calendar c = Calendar.getInstance(); + c.add(Calendar.MONTH, -beforeMonth); + return new SimpleDateFormat("yyyy-MM").format(c.getTime()); + } + + + /** + * 获取email用户姓名 + * @param args + */ + public static String getEmailUserName(String emailAddress) + { + return emailAddress.substring(0,emailAddress.lastIndexOf("@")); + } + + /** + * 获取中文编码,邮件附件乱码问题解决 + * @param str + * @return + */ + public static String getChineseString(String emailAttchmentTitle) + { + if(emailAttchmentTitle!=null&&!emailAttchmentTitle.equals("")) + { + try + { + return new String(emailAttchmentTitle.getBytes(),"ISO-8859-1"); + } + catch (UnsupportedEncodingException e) + { + e.printStackTrace(); + } + } + return emailAttchmentTitle; + } + + /** + * 判断userTel是否合法,userTel只能是数字 + * @param userTel + * @return true 合法 false不合法 + */ + public static boolean isTelNumber(String userTel) + { + String reg_phone="^(\\(\\d{3,4}\\)|\\d{3,4}-)?\\d{7,8}$"; + String reg_tel="^(1[0-9][0-9]|1[0-9][0|3|6|8|9])\\d{8}$"; + boolean b_phpne=Pattern.compile(reg_phone).matcher(userTel).matches(); + boolean b_tel=Pattern.compile(reg_tel).matcher(userTel).matches(); + return (b_phpne || b_tel); + } + + /** + * 模糊判断电话号码是否合法,只能是数字 + * @param macAddress + * @return + */ + public static boolean isTelNumberBySlur(String userTel) + { + return Pattern.compile("^([\\s0-9]{0,12}$)").matcher(userTel).matches(); + } + + /** + * 获取当前时间的字符串类型 + * @return 处理后的字符串类型 + */ + public static String getNowTime() + { + return new SimpleDateFormat("yyyyMMddHHmmss").format(Calendar.getInstance().getTime()); + } + + /** + * 开打指定文件 + * @param filePath 文件的绝对路径 + */ + public static void openFile(String filePath) + { + String viewFilePath = filePath.replace("\\", "/"); + // Runtime.getRuntime().exec("cmd /c start "+filePath); + // 解决路径中带空格问题 + Runtime r = Runtime.getRuntime(); + String[] cmdArray = new String[] { "cmd.exe", "/c", viewFilePath }; + try + { + r.exec(cmdArray); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + + /** + * 判断字符串中是否含有中文 + * @author jishenghua + * @param str + * @return + */ + public static boolean isContainsChinese(String str) + { + return Pattern.compile("[\u4e00-\u9fa5]").matcher(str).matches(); + } + + /** + * 过滤html文件中的文本 + * @param content + * @return过滤后的文本 + */ + public static String filterText(String content) + { + return content.replace("/<(?:.|\\s)*?>/g",""); + } + + /** + * 去掉字符串中所有符号,不论是全角,还是半角的,或是货币符号或者空格等 + * @author jishenghua + * @param s + * @return + * + */ + public static String removeSymbolForString(String s) + { + StringBuffer buffer = new StringBuffer(); + char[] chars = s.toCharArray(); + for (int i = 0; i < chars.length; i++) + { + if ((chars[i] >= 19968 && chars[i] <= 40869) || (chars[i] >= 97 && chars[i] <= 122) || (chars[i] >= 65 && chars[i] <= 90)) + { + buffer.append(chars[i]); + } + } + return buffer.toString(); + } + + /** + * 获取一个字符串的MD5 + * @param msg + * @return 加密后的MD5字符串 + * @throws NoSuchAlgorithmException + */ + public static String md5Encryp(String msg) throws NoSuchAlgorithmException + { + // 生成一个MD5加密计算摘要 + MessageDigest md = MessageDigest.getInstance("MD5"); + // 计算md5函数 + md.update(msg.getBytes()); + return new BigInteger(1, md.digest()).toString(16); + } + + /** + * 处理字符串null值 + * @param beforeStr 处理前字符串 + * @return 处理后的字符串 + */ + public static String dealNullStr(String beforeStr) + { + if(null == beforeStr || beforeStr.length()==0) + return ""; + return beforeStr; + } + + /** + * 使用参数Format将字符串转为Date + * @author jishenghua + * @param strDate + * @param pattern + * @return + * @throws ParseException + * + */ + public static Date parse(String strDate, String pattern) + throws ParseException + { + return new SimpleDateFormat(pattern).parse(strDate); + } + +// /** +// * 过滤html文件中的图片文件 +// * @param content +// * @return +// */ +// public static String filterImg(String content) +// { +// return content.matches("//g"); +// } + + public static void main(String[] args) + { + String aa = "的付的反对法的发的说法"; + char[] bb = aa.toCharArray(); + for(char c : bb) + { + System.out.println(c); + } + System.out.println(getBeforeMonth(1)); + + try + { + System.out.println(md5Encryp("guest")); + System.out.println(md5Encryp("admin")); + } + catch (NoSuchAlgorithmException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + String value = "2333"; + System.out.println(checkStrIsNum(value)); + + for(int i = 0 ;i < 100;i ++) + { + System.out.print(getRandomChar() + " || "); + } + } +}