Browse Source

git-svn-id: svn+ssh://10.10.101.21/source/platform/platform-b2b@206 f3bf4e98-0cf0-11e4-a00c-a99a8b9d557d

administrator 11 years ago
parent
commit
744e1d94d5

+ 6 - 8
src/main/java/com/uas/platform/b2b/controller/SaleOrderController.java

@@ -44,9 +44,9 @@ public class SaleOrderController {
 	}
 	
 	/**
-	 * 作为卖家,根据单据号查询收到一条采购订单
+	 * 作为卖家,根据采购单据ID查找采购订单(含明细)
 	 * 
-	 * @param json
+	 * @param id
 	 * @return
 	 */
 	@RequestMapping(value = "/orders/{id}", method = RequestMethod.GET)
@@ -58,7 +58,7 @@ public class SaleOrderController {
 	/**
 	 * 作为卖家,收到的采购订单(含明细)
 	 * 
-	 * @param json
+	 * @param params
 	 * @return
 	 */
 	@RequestMapping(value = "/orders/items", method = RequestMethod.GET)
@@ -87,16 +87,14 @@ public class SaleOrderController {
 	}
 	
 	/**
-	 * 作为卖家,回复收到的采购订单
+	 * 作为卖家,批量回复采购订单
 	 * 
 	 * @param json
 	 * @return
 	 */
 	@RequestMapping(value = "/orders/items/reply", method = RequestMethod.POST)
-	public ResponseEntity<String> replyOrderItemByBatch(@RequestBody String str) {
-		System.out.println(str);
-		String[] idsStr = str.split(",");
-		purchaseOrderService.replyByBatch(idsStr);
+	public ResponseEntity<String> replyOrderItemByBatch(@RequestBody String idString) {
+		purchaseOrderService.replyByBatch(idString.split(","));
 		return new ResponseEntity<String>(HttpStatus.OK);
 	}
 }

+ 3 - 1
src/main/java/com/uas/platform/b2b/dao/PurchaseOrderAllDao.java

@@ -12,5 +12,7 @@ import com.uas.platform.b2b.model.PurchaseOrderAll;
 public interface PurchaseOrderAllDao extends JpaSpecificationExecutor<PurchaseOrderAll>, JpaRepository<PurchaseOrderAll, Long> {
 
 	public List<PurchaseOrderAll> findPurchaseOrderAllByCode(String code);
-	public List<PurchaseOrderAll> findPurchaseOrderAllById(Long code);
+
+	public List<PurchaseOrderAll> findPurchaseOrderAllById(Long id);
+
 }

+ 13 - 2
src/main/java/com/uas/platform/b2b/dao/PurchaseOrderItemDao.java

@@ -1,13 +1,24 @@
 package com.uas.platform.b2b.dao;
 
+import java.util.List;
+
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
 
 import com.uas.platform.b2b.model.PurchaseOrderItem;
 
 @Repository
 public interface PurchaseOrderItemDao extends JpaSpecificationExecutor<PurchaseOrderItem>, JpaRepository<PurchaseOrderItem, Long> {
-	
-	public PurchaseOrderItem findPurcOrderItemById(Long id);
+
+	/**
+	 * 按订单明细状态查找订单明细
+	 * 
+	 * @param statusCode
+	 * @return
+	 */
+	@Query("from PurchaseOrderItem d where d.order.id = :orderId and d.status = :status")
+	public List<PurchaseOrderItem> findByOrderIdAndStatus(@Param("orderId") long orderId, @Param("status") short status);
 }

+ 3 - 3
src/main/java/com/uas/platform/b2b/model/PurchaseOrderAll.java

@@ -106,7 +106,7 @@ public class PurchaseOrderAll {
 	 * 采购单状态
 	 */
 	@Column(name = "pu_status")
-	private Integer status;
+	private Short status;
 
 	/**
 	 * 采购单明细
@@ -219,11 +219,11 @@ public class PurchaseOrderAll {
 		this.payments = payments;
 	}
 
-	public Integer getStatus() {
+	public Short getStatus() {
 		return status;
 	}
 
-	public void setStatus(Integer status) {
+	public void setStatus(Short status) {
 		this.status = status;
 	}
 

+ 1 - 27
src/main/java/com/uas/platform/b2b/model/PurchaseOrderItem.java

@@ -63,12 +63,6 @@ public class PurchaseOrderItem {
 	@Column(name = "pd_remark")
 	private String remark;
 	
-	/**
-	 * 回复状态
-	 */
-	@Column(name = "pd_reply")
-	private String reply;
-
 	/**
 	 * 含税单价
 	 */
@@ -106,11 +100,8 @@ public class PurchaseOrderItem {
 	private Date delivery;
 	
 	/**
-	 * 回复日期
+	 * 回复状态
 	 */
-	@Column(name = "pd_deliveryreply")
-	private Date deliveryreply;
-	
 	@Column(name="pd_status")
 	private Short status;
 
@@ -234,21 +225,4 @@ public class PurchaseOrderItem {
 		this.status = status;
 	}
 
-	public String getReply() {
-		return reply;
-	}
-
-	public void setReply(String reply) {
-		this.reply = reply;
-	}
-
-	public Date getDeliveryreply() {
-		return deliveryreply;
-	}
-
-	public void setDeliveryreply(Date deliveryreply) {
-		this.deliveryreply = deliveryreply;
-	}
-	
-	
 }

+ 14 - 0
src/main/java/com/uas/platform/b2b/model/PurchaseReply.java

@@ -67,6 +67,12 @@ public class PurchaseReply implements Serializable {
 	@Column(name = "pr_delivery")
 	private Date delivery;
 
+	/**
+	 * 状态{待上传、已下载}
+	 */
+	@Column(name = "pr_status")
+	private Short status;
+
 	public Long getId() {
 		return id;
 	}
@@ -115,4 +121,12 @@ public class PurchaseReply implements Serializable {
 		this.delivery = delivery;
 	}
 
+	public Short getStatus() {
+		return status;
+	}
+
+	public void setStatus(Short status) {
+		this.status = status;
+	}
+
 }

+ 25 - 14
src/main/java/com/uas/platform/b2b/service/impl/PurchaseOrderServiceImpl.java

@@ -13,6 +13,7 @@ import org.springframework.data.domain.Page;
 import org.springframework.data.jpa.domain.Specification;
 import org.springframework.security.core.userdetails.UsernameNotFoundException;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import com.uas.platform.b2b.dao.PurchaseOrderAllDao;
 import com.uas.platform.b2b.dao.PurchaseOrderDao;
@@ -23,7 +24,9 @@ import com.uas.platform.b2b.model.PurchaseOrderAll;
 import com.uas.platform.b2b.model.PurchaseOrderItem;
 import com.uas.platform.b2b.model.PurchaseReply;
 import com.uas.platform.b2b.service.PurchaseOrderService;
+import com.uas.platform.core.exception.IllegalOperatorException;
 import com.uas.platform.core.model.PageInfo;
+import com.uas.platform.core.model.Status;
 
 @Service
 public class PurchaseOrderServiceImpl implements PurchaseOrderService {
@@ -36,7 +39,7 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
 
 	@Autowired
 	private PurchaseReplyDao purchaseReplyDao;
-	
+
 	@Autowired
 	private PurchaseOrderItemDao purchaseOrderItemDao;
 
@@ -62,34 +65,41 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
 	}
 
 	@Override
+	@Transactional
 	public void reply(PurchaseReply reply) {
 		reply.setDate(new Date());
-		purchaseReplyDao.save(reply);
+		// 作为B2B->ERP数据是否已传输的标志
+		reply.setStatus((short) Status.NOT_UPLOAD.value());
 		PurchaseOrderItem item = purchaseOrderItemDao.findOne(reply.getOrderItem().getId());
-		item.setReply("待回复");
-		item.setDeliveryreply(reply.getDelivery());
-		PurchaseOrder order = purchaseOrderDao.findOne(item.getOrder().getId());
-		order.setReply("待回复");
 		Double replyQty = item.getReplyQty();
 		replyQty = replyQty == null ? 0 : replyQty;
 		item.setReplyQty(replyQty + reply.getQty());
+		if (item.getReplyQty() > item.getQty())
+			throw new IllegalOperatorException("回复的数量合计超过了订单数量");
+		// 该行回复状态
+		item.setStatus((short) (Double.compare(item.getReplyQty(), item.getQty()) == 0 ? Status.REPLIED.value() : Status.NOT_REPLY.value()));
+		purchaseReplyDao.save(reply);
 		purchaseOrderItemDao.save(item);
-		purchaseOrderDao.save(order);
+		// 订单主记录状态
+		List<PurchaseOrderItem> notReply = purchaseOrderItemDao.findByOrderIdAndStatus(item.getOrder().getId(), (short)Status.NOT_REPLY.value());
+//		PurchaseOrder order = purchaseOrderDao.findOne(item.getOrder().getId());
+//		order.setStatus((short) (notReply.size() > 0 ? Status.NOT_REPLY.value() : Status.REPLIED.value()));
+//		purchaseOrderAllDao.save(order);
 	}
 
 	@Override
 	public PurchaseOrderAll findByCode(String code) {
 		List<PurchaseOrderAll> purchaseOrderAlls = purchaseOrderAllDao.findPurchaseOrderAllByCode(code);
-		if(purchaseOrderAlls.size() == 0) {
+		if (purchaseOrderAlls.size() == 0) {
 			throw new UsernameNotFoundException("没有找到对应单据号的PO-" + code);
 		}
 		return purchaseOrderAlls.get(0);
 	}
-	
+
 	@Override
 	public PurchaseOrderAll findById(Long id) {
 		List<PurchaseOrderAll> purchaseOrderAlls = purchaseOrderAllDao.findPurchaseOrderAllById(id);
-		if(purchaseOrderAlls.size() == 0) {
+		if (purchaseOrderAlls.size() == 0) {
 			throw new UsernameNotFoundException("没有找到对应单据Id的PO-" + id);
 		}
 		return purchaseOrderAlls.get(0);
@@ -97,20 +107,21 @@ public class PurchaseOrderServiceImpl implements PurchaseOrderService {
 
 	@Override
 	public void replyByBatch(String[] str) {
-		PurchaseOrderItem orderItem ;
-		for(String s : str) {
+		PurchaseOrderItem orderItem;
+		for (String s : str) {
 			System.out.println(s);
 			orderItem = purchaseOrderItemDao.findOne(Long.parseLong(s));
 			PurchaseReply purchaseReply = new PurchaseReply();
 			purchaseReply.setOrderItem(orderItem);
 			purchaseReply.setDelivery(orderItem.getDelivery());
 			purchaseReply.setRemark("批量回复");
-			if(orderItem.getReplyQty() == null ) orderItem.setReplyQty((double) 0);
+			if (orderItem.getReplyQty() == null)
+				orderItem.setReplyQty((double) 0);
 			System.out.println("orderItem.getReplyQty():" + orderItem.getReplyQty());
 			purchaseReply.setQty(orderItem.getQty() - orderItem.getReplyQty());
 			reply(purchaseReply);
 		}
-		
+
 	}
 
 }

+ 19 - 26
src/main/webapp/resources/js/index/app.js

@@ -262,7 +262,7 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/PurcOrder',
 			}
 		};
 	});
-	app.controller('SaleOrderCtrl', function($scope, $filter, PurcOrderItem, ngTableParams, $modal){
+	app.controller('SaleOrderCtrl', function($scope, $filter, PurcOrderItem, ngTableParams, toaster){
 		var isNumber = function(n) {
             return !isNaN(parseFloat(n)) && isFinite(n);
         };
@@ -316,39 +316,32 @@ define([ 'toaster', 'charts', 'ngTable', 'common/services', 'service/PurcOrder',
 			return sum;
 		};
 		
-		$scope.onReplyClick = function(order, orderItem) {
-			$modal.open({
-				templateUrl : 'sale/orders/items/reply.html',
-				controller : 'ReplyCtrl',
-				backdrop : "static",
-				resolve : {
-					order : function() {
-						return order;
-					},
-					orderItem: function() {
-						return orderItem;
-					}
-				}
-			});
+		$scope.openDatePicker = function($event, item) {
+			$event.preventDefault();
+		    $event.stopPropagation();
+		    item.$opened = !item.$opened;
 		};
 		
-		$scope.reply = function(item) {
+		$scope.parseDate = function(dateStr) {
+			if(dateStr)
+				return Date.parse(dateStr, 'yyyy-MM-dd');
+			return new Date();
+		};
+		
+		$scope.onReplyClick = function(item) {
 			if(item.reply) {
-				var reply = angular.copy(item.reply), 
-					dateFilter = $filter('date');
-				if(reply.delivery) {
+				var reply = angular.copy(item.reply); 
+				if(reply.delivery && typeof reply.delivery == 'object') {
 					reply.delivery = reply.delivery.getTime();
 				}
-				reply.orderItem = {id: item.id};
-				PurcOrderItem.reply(reply, function(){
-					$scope.tableParams.reload();
+				PurcOrderItem.reply({orderItemId: item.id}, reply, function(){
+					toaster.pop('info', '提示', '回复成功');
+//					$scope.tableParams.reload();
+				}, function(responseText){
+					toaster.pop('error', '回复失败', responseText);
 				});
 			}
 		};
 	});
-	app.controller('ReplyCtrl', function($scope, $modalInstance, order, orderItem){
-		$scope.order = order;
-		$scope.orderItem = orderItem;
-	});
 	return app;
 });

+ 5 - 4
src/main/webapp/resources/lib/angular/ui-bootstrap-tpls.js

@@ -1225,9 +1225,10 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
         }
 
         scope.labels = new Array(7);
+        var day_ch = ['日', '一', '二', '三', '四', '五', '六'];
         for (var j = 0; j < 7; j++) {
           scope.labels[j] = {
-            abbr: dateFilter(days[j].date, ctrl.formatDayHeader),
+            abbr: day_ch[days[j].date.getDay()],//ctrl.formatDayHeader
             full: dateFilter(days[j].date, 'EEEE')
           };
         }
@@ -3855,7 +3856,7 @@ angular.module("template/carousel/slide.html", []).run(["$templateCache", functi
 
 angular.module("template/datepicker/datepicker.html", []).run(["$templateCache", function($templateCache) {
   $templateCache.put("template/datepicker/datepicker.html",
-    "<div ng-switch=\"datepickerMode\" role=\"application\" ng-keydown=\"keydown($event)\">\n" +
+    "<div ng-switch=\"datepickerMode\" style=\"padding: 0 5px\" role=\"application\" ng-keydown=\"keydown($event)\">\n" +
     "  <daypicker ng-switch-when=\"day\" tabindex=\"0\"></daypicker>\n" +
     "  <monthpicker ng-switch-when=\"month\" tabindex=\"0\"></monthpicker>\n" +
     "  <yearpicker ng-switch-when=\"year\" tabindex=\"0\"></yearpicker>\n" +
@@ -3915,8 +3916,8 @@ angular.module("template/datepicker/popup.html", []).run(["$templateCache", func
     "	<li ng-transclude></li>\n" +
     "	<li ng-if=\"showButtonBar\" style=\"padding:10px 9px 2px\">\n" +
     "		<span class=\"btn-group\">\n" +
-    "			<button type=\"button\" class=\"btn btn-sm btn-info\" ng-click=\"select('today')\">{{ getText('current') }}</button>\n" +
-    "			<button type=\"button\" class=\"btn btn-sm btn-danger\" ng-click=\"select(null)\">{{ getText('clear') }}</button>\n" +
+    "			<button type=\"button\" class=\"btn btn-sm btn-default\" ng-click=\"select('today')\">{{ getText('current') }}</button>\n" +
+    "			<button type=\"button\" class=\"btn btn-sm btn-default\" ng-click=\"select(null)\">{{ getText('clear') }}</button>\n" +
     "		</span>\n" +
     "		<button type=\"button\" class=\"btn btn-sm btn-success pull-right\" ng-click=\"close()\">{{ getText('close') }}</button>\n" +
     "	</li>\n" +

File diff suppressed because it is too large
+ 0 - 0
src/main/webapp/resources/lib/angular/ui-bootstrap-tpls.min.js


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

@@ -77,27 +77,34 @@
 	border-bottom: 1px solid #e6e6e6;
 }
 
-.order-table .order-bd td {
+.order-table .order-bd>td {
 	padding: 10px 5px;
 	vertical-align: top;
+	position: relative;
 }
 
 .order-table .order-bd .product {
 	padding-left: 20px;
 }
 
-.dropdown.item-reply:hover>.dropdown-toggle {
-	border: none;
+.input-xs,.input-group-xs>.form-control, .input-group-xs>.input-group-addon, .input-group-xs>.input-group-btn>.btn {
+	height: 26px;
+	padding: 0 5px;
+	font-size: 12px;
+	line-height: 1.5;
+	border-radius: 3px;
 }
 
-.dropdown.item-reply:hover>.dropdown-menu {
-	top: 0;
-	right: 100%;
+.input-group-xs .form-control:last-child, .input-group-addon:last-child, .input-group-btn:first-child>.btn:not(:first-child), .input-group-btn:last-child>.btn {
+	border-top-left-radius: 0;
+	border-bottom-left-radius: 0;
 }
 
-.order-reply .modal-header span {
-	margin-right: 5px;
+.input-trigger .dropdown-menu tr>td>.btn {
+	border-radius: 0;
+	border: none;
 }
+
 </style>
 <div ng-controller="SaleOrderCtrl" class="block">
 	<div class="loading in">
@@ -119,10 +126,10 @@
 			<tr class="header">
 				<th>商品</th>
 				<th>单价</th>
-				<th>数量</th>
-				<th>交货日期</th>
-				<th>回复状态</th>
-				<th>操作</th>
+				<th width="100">数量</th>
+				<th width="120">交货日期</th>
+				<th width="180">回复状态</th>
+				<th width="60">操作</th>
 			</tr>
 			<tr class="sep-row">
 				<td colspan="6"></td>
@@ -177,33 +184,42 @@
 				<td class="text-center">
 					<div class="text-num" title="{{item.qty}}" ng-bind="item.qty"></div>
 					<div class="text-muted" ng-bind="item.product.unit"></div>
+					<div style="margin: 0 auto" ng-show="item.$editing">
+						<input type="text" ng-model="item.reply.qty" ng-init="item.reply.qty=item.qty-item.replyQty" class="form-control input-xs" placeholder="回复数量">
+					</div>
+				</td>
+				<td class="text-center br-l">
+					<div class="text-num" ng-bind="item.delivery"></div>
+					<br>
+					<div style="margin: 0 auto" class="input-group input-group-xs input-trigger" ng-show="item.$editing">
+						<input type="text" ng-model="item.reply.delivery" ng-init="item.reply.delivery=parseDate(item.delivery)" class="form-control" 
+						placeholder="回复交期" datepicker-popup="yyyy-MM-dd" is-open="item.$opened" min-date="order.date" 
+						ng-required="true" current-text="今天" clear-text="清除" close-text="关闭"
+						datepicker-options="{formatDayTitle: 'yyyy年M月', formatMonth: 'M月', showWeeks: false}"
+						ng-focus="openDatePicker($event, item)">
+						<span class="input-group-btn">
+                			<button type="button" class="btn btn-default" ng-click="openDatePicker($event, item)"><i class="fa fa-calendar"></i></button>
+              			</span>
+					</div>
+				</td>
+				<td class="text-center br-l">
+					<div>数量完成48%</div>
+					<div>交期未达标</div>
+					<div style="margin: 0 auto" ng-show="item.$editing">
+						<input type="text" ng-model="item.reply.remark" class="form-control input-xs" placeholder="回复备注">
+					</div>
+				</td>
+				<td class="text-center br-l">
+					<div ng-show="!item.$editing">
+						<a ng-click="item.$editing=!item.$editing">回复</a>
+					</div>
+					<div ng-show="item.$editing">
+						<div><a ng-click="item.$editing=!item.$editing">取消</a></div>
+						<br>
+						<div><a ng-click="onReplyClick(item)" class="text-inverse">确认回复</a></div>
+					</div>
 				</td>
-				<td class="text-center text-num br-l" ng-bind="item.delivery"></td>
-				<td class="text-center br-l"><div>数量完成48%</div>
-					<div>交期未达标</div></td>
-				<td class="text-center br-l"><a
-					ng-click="onReplyClick(order, orderItem)">回复</a></td>
 			</tr>
 		</tbody>
 	</table>
-</div>
-<!-- modal window template -->
-<script type="text/ng-template" id="sale/orders/items/reply.html">
-<div class="order-reply">
-	<div class="modal-header">
-		<span class="text-num text-bold" title="{{order.date}}" ng-bind="order.date"></span> 
-		<span>订单号:<a class="text-num" ng-bind="order.code" href="#"></a></span>
-		<span class="pull-right" ng-bind="order.enterprise.enName"></span>
-	</div>
-	<div class="modal-body">
-		
-	</div>
-	<div class="modal-footer">
-		<div class="btn-group pull-right">
-			<a class="btn btn-default">取&nbsp;&nbsp;消</a>
-			<a class="btn btn-info" tooltip-placement="bottom" tooltip="回复成功后自动跳转下一条">回&nbsp;&nbsp;复</a>
-			<a class="btn btn-default">下一条</a>
-		</div>
-	</div>
-</div>
-</script>
+</div>

Some files were not shown because too many files changed in this diff