Browse Source

【打印权限】修改打印方法,修复打印窗口会被浏览器拦截的问题;
【询价单消息】取消使用线程,修复会出现部分单据数据丢失,不产生消息问题。

dongbw 8 years ago
parent
commit
7b76ec8231

+ 5 - 6
src/main/java/com/uas/platform/b2b/controller/BaseInfoController.java

@@ -9,10 +9,7 @@ import com.uas.platform.b2b.model.Vendor;
 import com.uas.platform.b2b.search.SearchService;
 import com.uas.platform.b2b.service.BaseInfoService;
 import com.uas.platform.b2b.service.ProductService;
-import com.uas.platform.b2b.support.JxlsExcelView;
-import com.uas.platform.b2b.support.SystemSession;
-import com.uas.platform.b2b.support.TokenService;
-import com.uas.platform.b2b.support.UsageBufferedLogger;
+import com.uas.platform.b2b.support.*;
 import com.uas.platform.b2b.temporary.model.BasePartnersInfo;
 import com.uas.platform.b2b.temporary.model.NewPurcOrder;
 import com.uas.platform.b2b.temporary.model.ProdInfo;
@@ -45,8 +42,6 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
-import static org.springframework.data.jpa.domain.AbstractPersistable_.id;
-
 /**
  * 基础资料设置<br>
  * 物料查看、物料资料上传
@@ -71,6 +66,9 @@ public class BaseInfoController {
 	@Autowired
 	private TokenService tokenService;
 
+	@Autowired
+	private SysConf sysConf;
+
 	/**
 	 * 查看自己的物料资料
 	 */
@@ -289,6 +287,7 @@ public class BaseInfoController {
 	 */
 	@RequestMapping(value = "/xls/permission", method = RequestMethod.GET)
 	public ModelMap exportPermission() {
+		sysConf.getB2b();
 		return new ModelMap("success", true);
 	}
 

+ 25 - 3
src/main/java/com/uas/platform/b2b/service/impl/PurchaseInquiryServiceImpl.java

@@ -1,5 +1,6 @@
 package com.uas.platform.b2b.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.uas.message.mail.service.MailService;
 import com.uas.platform.b2b.core.util.ContextUtils;
 import com.uas.platform.b2b.core.util.DateFormatUtils;
@@ -101,6 +102,9 @@ public class PurchaseInquiryServiceImpl implements PurchaseInquiryService {
 	@Autowired
 	private MailService mailService;
 
+	@Autowired
+	private EnterpriseDao enterpriseDao;
+
 	@Autowired
 	private MessageConf messageConf;
 
@@ -112,7 +116,19 @@ public class PurchaseInquiryServiceImpl implements PurchaseInquiryService {
 		saveUserOrders(inquiryItems);
 		sendRemind(PurchaseInquiryItem.distinct(inquiryItems));
 //		ContextUtils.publishEvent(new PurchaseInquiryItemSaveEvent(inquiryItems));  // 之前的索引分词,已弃用
-		sendMessage(inquiryItems);
+		// 产生消息
+		List<PurchaseInquiry> inquiries = PurchaseInquiryItem.distinct(inquiryItems);
+		List<PurchaseInquiryItem> items = new ArrayList<>();
+		for (PurchaseInquiry inquiry : inquiries) {
+			Set<Long> enUUs = new HashSet<>();
+			for (PurchaseInquiryItem inquiryItem : inquiry.getInquiryItems()) {
+				if (!enUUs.contains(inquiryItem.getVendUU())) {
+					items.add(inquiryItem);
+					enUUs.add(inquiryItem.getVendUU());
+				}
+			}
+		}
+		ContextUtils.publishEvent(new PurchaseInquiryItemSaveReleaseEvent(items));
 	}
 
 	/**
@@ -216,7 +232,7 @@ public class PurchaseInquiryServiceImpl implements PurchaseInquiryService {
 					obj.add(inquiry.getEnterprise().getEnName());
 					sms.setParams(obj);
 					for (PurchaseInquiryItem inquiryItem : inquiry.getInquiryItems()) {
-						if (!enUUs.contains(inquiryItem.getVendUU())) {
+						if (null != inquiryItem.getVendUU() && !enUUs.contains(inquiryItem.getVendUU())) {
 							// 查找业务员邮箱
 							String userEmailSql = "select distinct us.user_email useremail from sec$users us " +
 									" left join sec$userrole ur on us.user_uu = ur.user_uu left join sec$roles sr " +
@@ -230,7 +246,13 @@ public class PurchaseInquiryServiceImpl implements PurchaseInquiryService {
 							List<String> userTels = commonDao.query(userTelSql, String.class);
 							// 发邮件
 							Map<String, Object> model = new HashMap<String, Object>();
-							model.put("vendorname", inquiryItem.getEnterprise().getEnName());
+							System.out.println(JSON.toJSON(inquiryItem));
+							Enterprise vendor = enterpriseDao.findOne(inquiryItem.getVendUU());
+							if (null != vendor) {
+								model.put("vendorname", vendor.getEnName());
+							} else {
+								model.put("vendorname", "供应商");
+							}
 							model.put("custname", inquiry.getEnterprise().getEnName());
 							model.put("date", DateFormatUtils.DATE_FORMAT.format(new Date()));
 							for (String userEmail : userEmails) {

+ 11 - 4
src/main/webapp/resources/js/common/services.js

@@ -225,7 +225,7 @@ define(['angular', 'toaster', 'big'], function(angular, big) {
                 return query.length ? query.substr(0, query.length - 1) : query;
             }
         };
-    }).factory('ReportService', ['$http', 'BaseService', 'toaster', function($http, BaseService, toaster) {
+    }).factory('ReportService', ['$http', 'BaseService', 'toaster', '$rootScope', function($http, BaseService, toaster, $rootScope) {
         var rootPath = BaseService.getRootPath();
         return {
             /**
@@ -233,9 +233,16 @@ define(['angular', 'toaster', 'big'], function(angular, big) {
 			 * 单据的条件(格式:where tableName.propertyName = value)
 			 * 
 			 */
-            print: function(enuu, reportName, whereCondition) {
-            	window.open(rootPath + "/report/print?enuu=" + enuu + "&reportName=" + reportName + "&whereCondition=" + whereCondition);
-                /*$http.get(rootPath + '/report/print', {
+            print: function(enuu, reportName, whereCondition, newPage) {
+                var printUrl = rootPath + "/report/print?enuu=" + enuu + "&reportName=" + reportName + "&whereCondition=" + whereCondition;
+            	// window.open(rootPath + "/report/print?enuu=" + enuu + "&reportName=" + reportName + "&whereCondition=" + whereCondition);
+                // 不为空的为需要验证权限的,否则是不用验证权限的
+                if (null != newPage) {
+                    newPage.location.href=printUrl;
+                } else {
+                    window.open(rootPath + "/report/print?enuu=" + enuu + "&reportName=" + reportName + "&whereCondition=" + whereCondition);
+                }
+            	/*$http.get(rootPath + '/report/print', {
                     params: {
                         enuu: enuu,
                         reportName: reportName,

+ 21 - 9
src/main/webapp/resources/js/index/app.js

@@ -883,7 +883,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
     }]);
 
     app.controller('PagingReleaseCtrl', ['$scope', 'PagingRelease', 'BaseService', 'ngTableParams', 'toaster', '$modalInstance', 'PagingReleaseInfo', function ($scope, PagingRelease, BaseService, ngTableParams, toaster, $modalInstance, PagingReleaseInfo) {
-        BaseService.scrollBackToTop();
+        // BaseService.scrollBackToTop();
         $scope.active = "todo";
         $scope.searchStatus = false; // 默认从数据库直接获取
         $scope.setActive = function (state) {
@@ -2757,12 +2757,15 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 
             // 需方  打印    采购单
             $scope.custPrint = function (order) {
+                var newPage = window.open("about:blank");
                 PurcOrder.printPermission({}, function () {
                     PurcOrder.custPrintCount({id: order.id}, {});//增加打印此次
-                    ReportService.print(order.enUU, 'PURCLIST_CUST', "where purc$orders.pu_id=" + order.id);
+                    ReportService.print(order.enUU, 'PURCLIST_CUST', "where purc$orders.pu_id=" + order.id, newPage);
                 }, function (response) {
+                    newPage.close();
                     toaster.pop('error', '打印失败', response.data);
                 });
+
             };
 
             $scope.openDatePicker = function ($event, item, openParam) {
@@ -2942,7 +2945,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
         };
     }]);
 
-    app.controller('SaleOrderCtrl', ['$scope', '$filter', 'PurcOrderItem', 'PurcOrder', 'ngTableParams', 'toaster', 'ReportService', 'BaseService', 'PurcOrderItemHis', 'PagingRelease', 'SnapshotService', 'PurcOrderItemInfo', 'token', 'CurrentRole', function ($scope, $filter, PurcOrderItem, PurcOrder, ngTableParams, toaster, ReportService, BaseService, PurcOrderItemHis, PagingRelease, SnapshotService, PurcOrderItemInfo, token, CurrentRole) {
+    app.controller('SaleOrderCtrl', ['$scope', '$filter', 'PurcOrderItem', 'PurcOrder', 'ngTableParams', 'toaster', 'ReportService', 'BaseService', 'PurcOrderItemHis', 'PagingRelease', 'SnapshotService', 'PurcOrderItemInfo', 'token', 'CurrentRole', '$timeout', function ($scope, $filter, PurcOrderItem, PurcOrder, ngTableParams, toaster, ReportService, BaseService, PurcOrderItemHis, PagingRelease, SnapshotService, PurcOrderItemInfo, token, CurrentRole, $timeout) {
         BaseService.scrollBackToTop();
 
         // 判断是否为普通用户
@@ -3156,15 +3159,16 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 
         //打印    采购单
         $scope.print = function (order) {
+            var newPage = window.open("about:blank");
             PurcOrder.printPermission({}, function () {
                 PurcOrder.printCount({id: order.id}, {});//增加打印此次 // 在此方法内添加记录日志
                 if (order.display == 1) $scope.setDisplay('setRead', order.id);//设置为已查看状态
-                ReportService.print(order.enUU, 'PURCLIST', "where purc$orders.pu_id=" + order.id);
+                ReportService.print(order.enUU, 'PURCLIST', "where purc$orders.pu_id=" + order.id , newPage);
                 $scope.tableParams.reload();
             },function (response) {
+                newPage.close();
                 toaster.pop('error', '打印失败', response.data);
             });
-            
         };
 
         $scope.getReply = function (item) {
@@ -3356,10 +3360,12 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 
         // 采购单
         $scope.print = function (order) {
+            var newPage = window.open("about:blank");
             PurcOrder.printPermission({}, function () {
                 PurcOrder.printCount({id: order.id}, {});//增加打印此次
-                ReportService.print(order.enUU, 'PURCLIST', "where purc$orders.pu_id=" + order.id);
+                ReportService.print(order.enUU, 'PURCLIST', "where purc$orders.pu_id=" + order.id, newPage);
             },function (response) {
+                newPage.close();
                 toaster.pop('error', '打印失败', response.data);
             });
         };
@@ -7004,11 +7010,13 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 
         //打印    发货单
         $scope.print = function (send) {
+            var newPage = window.open("about:blank");
             SaleSend.printPermission({}, function () {
                 SaleSend.printCount({id: send.id}, {});   //增加打印此次
+                ReportService.print(send.custUU, 'SALESEND', "where sale$send.ss_id=" + send.id, newPage);
                 $scope.tableParams.reload();
-                ReportService.print(send.custUU, 'SALESEND', "where sale$send.ss_id=" + send.id);
             }, function (response) {
+                newPage.close();
                 toaster.pop('error', '打印失败', response.data);
             });
         };
@@ -7740,10 +7748,12 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
         };
         //打印  样品采购单
         $scope.print = function (sample) {
+            var newPage = window.open("about:blank");
             PurcSample.printPermission({}, function () {
                 PurcSample.printCount({id: sample.id}, {});//增加打印此次
-                ReportService.print(sample.proofing.enUU, 'PURCPROOFING', "where purc$proofingitems.ppi_id =" + sample.id);
+                ReportService.print(sample.proofing.enUU, 'PURCPROOFING', "where purc$proofingitems.ppi_id =" + sample.id, newPage);
             }, function (response) {
+                newPage.close();
                 toaster.pop('error', '打印失败', response.data);
             });
             };
@@ -9547,10 +9557,12 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
 
         //打印  对账单
         $scope.print = function (check) {
+            var newPage = window.open("about:blank");
             FaApCheck.printPermission({}, function () {
                 FaApCheck.printCount({id: check.id}, {});//增加打印此次
-                ReportService.print(check.custUu, 'PURCCHECK', 'where purc$apcheck.pa_id =' + check.id);
+                ReportService.print(check.custUu, 'PURCCHECK', 'where purc$apcheck.pa_id =' + check.id, newPage);
             }, function (response) {
+                newPage.close();
                 toaster.pop('error', '打印失败', response.data);
             });
         };

+ 9 - 0
src/main/webapp/resources/tpl/index/make/order.html

@@ -117,6 +117,13 @@
 	top: -2px;
 }
 
+.order-table>tbody:hover .operates {
+	display: block;
+}
+.order-table>tbody:hover .operates-status {
+	display: none;
+}
+
 </style>
 <link rel="stylesheet" href="static/css/public.css">
 <div class="block" id="public">
@@ -265,6 +272,8 @@
 				ng-bind="::(isUser?'-':(order.qty * order.price| number : 2))"
 				class="text-num text-bold"></span>
 			<td colspan="1" class="text-center">
+				<span ng-if="order.print" class="label ng-scope operates-status" style="margin-right: 5px;background-color: #5D6C79">已打印</span>
+				<span ng-if="!order.print" class="label ng-scope operates-status" style="margin-right: 5px;background-color: #CA3955">未打印</span>
 				<div class="operates">
 					<a ng-click="print(order)" title="打印{{order.print? '(已打印)':'(未打印)'}}" ng-class="{'unPrinted' : !order.print, 'text-muted': order.print}"><i
 						class="fa fa-print fa-lg"></i></a><a 

+ 1 - 1
src/main/webapp/resources/tpl/index/sale/order.html

@@ -414,7 +414,7 @@
 				<span ng-if="order.print" class="label ng-scope operates-status" style="margin-right: 5px;background-color: #5D6C79">已打印</span>
 				<span ng-if="!order.print" class="label ng-scope operates-status" style="margin-right: 5px;background-color: #CA3955">未打印</span>
 				<div class="operates">
-					<a ng-click="print(order)" title="打印{{order.print? '(已打印)':'(未打印)'}}" ng-class="{'unPrinted' : !order.print, 'text-muted': order.print}"><i
+					<a ng-click="print(order);" title="打印{{order.print? '(已打印)':'(未打印)'}}" ng-class="{'unPrinted' : !order.print, 'text-muted': order.print}"><i
 						class="fa fa-print fa-lg"></i></a> <a
 						ng-click="order.$collapsed=!order.$collapsed" class="text-muted"
 						title="收拢"><i class="fa fa-toggle-down fa-lg"></i></a>