Просмотр исходного кода

发货请求返回发货单id

git-svn-id: svn+ssh://10.10.101.21/source/platform/platform-b2b@1373 f3bf4e98-0cf0-11e4-a00c-a99a8b9d557d
suntg 10 лет назад
Родитель
Сommit
06197cff97

+ 20 - 9
src/main/java/com/uas/platform/b2b/controller/SaleNoticeController.java

@@ -7,9 +7,8 @@ import java.util.List;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Sort.Direction;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -26,6 +25,7 @@ import com.uas.platform.b2b.service.PurchaseNoticeService;
 import com.uas.platform.b2b.support.JxlsExcelView;
 import com.uas.platform.b2b.support.SystemSession;
 import com.uas.platform.b2b.support.UsageBufferedLogger;
+import com.uas.platform.core.exception.IllegalOperatorException;
 import com.uas.platform.core.logging.BufferedLoggerManager;
 import com.uas.platform.core.model.Constant;
 import com.uas.platform.core.model.PageInfo;
@@ -178,11 +178,17 @@ public class SaleNoticeController {
 	 * @return
 	 */
 	@RequestMapping(value = "/{noticeId}", method = RequestMethod.POST)
-	public ResponseEntity<String> send(@PathVariable("noticeId") Long noticeId, @RequestBody String json) {
+	@ResponseBody
+	public ModelMap send(@PathVariable("noticeId") Long noticeId, @RequestBody String json) {
+		ModelMap map = new ModelMap();
 		SaleSend send = FlexJsonUtils.fromJson(json, SaleSend.class);
-		purchaseNoticeService.send(noticeId, send);
-		logger.log("客户送货提醒", "给单个客户送货提醒填写数量并确认发货", send.sendDescription(), null, noticeId);
-		return new ResponseEntity<String>(HttpStatus.OK);
+		send = purchaseNoticeService.send(noticeId, send);
+		if (send != null) {
+			logger.log("客户送货提醒", "给单个客户送货提醒填写数量并确认发货", send.sendDescription(), null, noticeId);
+			map.put("id", send.getId());
+			return map;
+		} else 
+			throw new IllegalOperatorException("程序错误");
 	}
 
 	/**
@@ -193,12 +199,17 @@ public class SaleNoticeController {
 	 * @return
 	 */
 	@RequestMapping(value = "/sendByBatch", method = RequestMethod.POST)
-	public ResponseEntity<String> sendByBatch(@RequestBody String json) {
+	@ResponseBody
+	public ModelMap sendByBatch(@RequestBody String json) {
+		ModelMap map = new ModelMap();
 		SaleSend send = FlexJsonUtils.fromJson(json, SaleSend.class);
 		send = purchaseNoticeService.send(send);
-		if (send != null)
+		if (send != null) {
 			logger.log("客户送货提醒", "给同一客户多个送货提醒填写数量并确认发货", send.sendDescription(), null, send.getId());
-		return new ResponseEntity<String>(HttpStatus.OK);
+			map.put("id", send.getId());
+			return map;
+		} else 
+			throw new IllegalOperatorException("程序错误");
 	}
 
 	/**

+ 1 - 1
src/main/java/com/uas/platform/b2b/service/PurchaseNoticeService.java

@@ -101,7 +101,7 @@ public interface PurchaseNoticeService {
 	 * @param send
 	 *            本次发货
 	 */
-	public void send(Long noticeId, SaleSend send);
+	public SaleSend send(Long noticeId, SaleSend send);
 
 	/**
 	 * 批量发货

+ 5 - 2
src/main/java/com/uas/platform/b2b/service/impl/PurchaseNoticeServiceImpl.java

@@ -220,7 +220,7 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
 	}
 
 	@Override
-	public void send(Long noticeId, SaleSend send) {
+	public SaleSend send(Long noticeId, SaleSend send) {
 		PurchaseNotice notice = purchaseNoticeDao.findOne(noticeId);
 		// //限制同一个供应商发货单号不可以重复,(限制被去掉 -- 2015年6月5日15:23:52)
 		// List<SaleSend> saleSend = saleSendDao.findByEnUUAndCode(SystemSession.getUser().getEnterprise().getUu(), send.getCode());
@@ -266,6 +266,7 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
 				saleSends.add(sendItems.get(0).getSend());
 				ContextUtils.publishEvent(new SaleSendSaveEvent(saleSends));
 			}
+			return sendItems.get(0).getSend();
 		} else {
 			throw new IllegalOperatorException("请对有效的送货提醒发货!");
 		}
@@ -324,8 +325,10 @@ public class PurchaseNoticeServiceImpl implements PurchaseNoticeService {
 				saleSends.add(sendItems.get(0).getSend());
 				ContextUtils.publishEvent(new SaleSendSaveEvent(saleSends));
 			}
+			return sendItems.get(0).getSend();
+		} else {
+			throw new IllegalArgumentException();
 		}
-		return null;
 	}
 
 	@Override