|
|
@@ -0,0 +1,379 @@
|
|
|
+package com.uas.platform.b2b.mall2.controller;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.uas.platform.b2b.dao.PurchaseOrderAllDao;
|
|
|
+import com.uas.platform.b2b.dao.PurchaseOrderWaitingDao;
|
|
|
+import com.uas.platform.b2b.model.*;
|
|
|
+import com.uas.platform.b2b.search.SearchService;
|
|
|
+import com.uas.platform.b2b.service.OrderRedDotService;
|
|
|
+import com.uas.platform.b2b.service.PurchaseOrderService;
|
|
|
+import com.uas.platform.b2b.service.UserService;
|
|
|
+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.core.logging.BufferedLoggerManager;
|
|
|
+import com.uas.platform.core.model.Constant;
|
|
|
+import com.uas.platform.core.model.PageInfo;
|
|
|
+import com.uas.platform.core.model.PageParams;
|
|
|
+import com.uas.platform.core.model.Status;
|
|
|
+import com.uas.platform.core.util.serializer.FlexJsonUtils;
|
|
|
+import com.uas.platform.core.web.bind.RequestState;
|
|
|
+import com.uas.search.b2b.model.MultiValue;
|
|
|
+import com.uas.search.b2b.model.SPage;
|
|
|
+import com.uas.search.b2b.model.Sort;
|
|
|
+import com.uas.search.b2b.model.Sort.Type;
|
|
|
+import com.uas.search.b2b.util.SearchConstants;
|
|
|
+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.util.CollectionUtils;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.servlet.ModelAndView;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 提供给新商城的销售订单接口
|
|
|
+ *
|
|
|
+ * @author suntg
|
|
|
+ * @date 2019-3-26 17:08:29
|
|
|
+ */
|
|
|
+@SuppressWarnings("deprecation")
|
|
|
+@Controller("mall2.SaleOrderController")
|
|
|
+@RequestMapping("/mall2/sale/orders")
|
|
|
+public class SaleOrderController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PurchaseOrderService purchaseOrderService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SearchService searchService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
+
|
|
|
+ private final static UsageBufferedLogger logger = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 作为卖家,收到的采购订单(含明细) - 搜索
|
|
|
+ *
|
|
|
+ * @param params
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/info/search", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public SPage<PurchaseOrderAll> getPurchaseOrderItems(PageParams params, String searchFilter) {
|
|
|
+ logger.log("客户采购单", "查看收到的客户采购订单列表(包括采购明细)(全部)");
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(searchFilter);
|
|
|
+ String keyword = jsonObject.getString("keyword");
|
|
|
+ com.uas.search.b2b.model.PageParams pageParams = searchService.convertPageParams(params, searchFilter);
|
|
|
+ // 当前登录企业作为供应商
|
|
|
+ pageParams.getFilters().put("pu_venduu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ SearchFilter filter = userService.distribute();
|
|
|
+ if (filter != null && filter.getDistribute() == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (filter != null && !CollectionUtils.isEmpty(filter.getDistribute())) {
|
|
|
+ List<Object> list = new ArrayList<>();
|
|
|
+ list.addAll(filter.getDistribute());
|
|
|
+ pageParams.getFilters().put("pu_enuu", new MultiValue(list, true));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageParams.getPage() > 1) {
|
|
|
+ pageParams.setSize(pageParams.getPage() * pageParams.getSize());
|
|
|
+ pageParams.setPage(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("pu_id", false, Type.INT, 1L));
|
|
|
+ pageParams.getFilters().put(SearchConstants.SORT_KEY, sortList);
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>(1);
|
|
|
+ map.put("pu_status", (short) Status.UNAUDIT.value());
|
|
|
+ pageParams.setNotEqualFilters(map);
|
|
|
+ return searchService.searchPurchaseOrderIds(keyword, pageParams);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 作为卖家,收到的采购订单(含明细)(已结案) - 搜索
|
|
|
+ *
|
|
|
+ * @param params
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/info/search", params = RequestState.END, method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public SPage<PurchaseOrderEnd> getEndPurchaseOrderItems(PageParams params, String searchFilter) {
|
|
|
+ logger.log("客户采购单", "查看收到的客户采购订单列表(包括采购明细)(已结案)");
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(searchFilter);
|
|
|
+ String keyword = jsonObject.getString("keyword");
|
|
|
+ com.uas.search.b2b.model.PageParams pageParams = searchService.convertPageParams(params, searchFilter);
|
|
|
+ SearchFilter filter = userService.distribute();
|
|
|
+ if (filter != null && filter.getDistribute() == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (filter != null && !CollectionUtils.isEmpty(filter.getDistribute())) {
|
|
|
+ List<Object> list = new ArrayList<>();
|
|
|
+ for (Object object : filter.getDistribute()) {
|
|
|
+ list.add(object);
|
|
|
+ }
|
|
|
+ pageParams.getFilters().put("pu_enuu", new MultiValue(list, true));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageParams.getPage() > 1) {
|
|
|
+ pageParams.setSize(pageParams.getPage() * pageParams.getSize());
|
|
|
+ pageParams.setPage(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 当前登录企业作为供应商
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("pu_id", false, Type.INT, new Long(1)));
|
|
|
+ pageParams.getFilters().put(SearchConstants.SORT_KEY, sortList);
|
|
|
+ pageParams.getFilters().put("pu_venduu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ pageParams.getFilters().put("pu_end", Constant.YES);
|
|
|
+ return searchService.searchaPurchaseEndOrderIds(keyword, pageParams);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param params
|
|
|
+ * @param searchFilter
|
|
|
+ * @author wangmh 获取已收货的订单 - 搜索
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/info/search", params = RequestState.RECEIVED, method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public SPage<PurchaseOrderReceived> getReceivedPurchaseOrderItems(PageParams params, String searchFilter) {
|
|
|
+ logger.log("客户采购单", "查看收到的客户采购订单列表(包括采购明细)(已收货)");
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(searchFilter);
|
|
|
+ String keyword = jsonObject.getString("keyword");
|
|
|
+ com.uas.search.b2b.model.PageParams pageParams = searchService.convertPageParams(params, searchFilter);
|
|
|
+ SearchFilter filter = userService.distribute();
|
|
|
+ if (filter != null && filter.getDistribute() == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (filter != null && !CollectionUtils.isEmpty(filter.getDistribute())) {
|
|
|
+ List<Object> list = new ArrayList<>();
|
|
|
+ for (Object object : filter.getDistribute()) {
|
|
|
+ list.add(object);
|
|
|
+ }
|
|
|
+ pageParams.getFilters().put("pu_enuu", new MultiValue(list, true));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageParams.getPage() > 1) {
|
|
|
+ pageParams.setSize(pageParams.getPage() * pageParams.getSize());
|
|
|
+ pageParams.setPage(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 当前登录企业作为供应商
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("pu_id", false, Type.INT, new Long(1)));
|
|
|
+ pageParams.getFilters().put(SearchConstants.SORT_KEY, sortList);
|
|
|
+ pageParams.getFilters().put("pu_venduu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ pageParams.getFilters().put("pu_end", Constant.NO);
|
|
|
+ return searchService.searchPurchaseReceivedOrderIds(keyword, pageParams);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param params
|
|
|
+ * @param searchFilter
|
|
|
+ * @author yujia 获取待发货的订单 - 搜索
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/info/search", params = RequestState.WAITING, method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public SPage<PurchaseOrderWaiting> getWaitingPurchaseOrderItems(PageParams params, String searchFilter) {
|
|
|
+ logger.log("客户采购单", "查看收到的客户采购订单列表(包括采购明细)(待交货)");
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(searchFilter);
|
|
|
+ String keyword = jsonObject.getString("keyword");
|
|
|
+ com.uas.search.b2b.model.PageParams pageParams = searchService.convertPageParams(params, searchFilter);
|
|
|
+ SearchFilter filter = userService.distribute();
|
|
|
+ if (filter != null && filter.getDistribute() == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (filter != null && !CollectionUtils.isEmpty(filter.getDistribute())) {
|
|
|
+ List<Object> list = new ArrayList<>();
|
|
|
+ for (Object object : filter.getDistribute()) {
|
|
|
+ list.add(object);
|
|
|
+ }
|
|
|
+ pageParams.getFilters().put("pu_enuu", new MultiValue(list, true));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pageParams.getPage() > 1) {
|
|
|
+ pageParams.setSize(pageParams.getPage() * pageParams.getSize());
|
|
|
+ pageParams.setPage(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 当前登录企业作为供应商
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("pu_id", false, Type.INT, new Long(1)));
|
|
|
+ pageParams.getFilters().put(SearchConstants.SORT_KEY, sortList);
|
|
|
+ pageParams.getFilters().put("pu_venduu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ List<Object> list = new ArrayList<>();
|
|
|
+ list.add(Constant.YES);
|
|
|
+ // 建索引时,将不处于已结案状态,但是货物全部交接完毕的单,end值设为了2
|
|
|
+ list.add((short) 2);
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ map.put("pu_end", new MultiValue(list, true));
|
|
|
+ map.put("pu_status", (short) Status.UNAUDIT.value());
|
|
|
+ pageParams.setNotEqualFilters(map);
|
|
|
+ return searchService.searchPurchaseWaitingOrderIds(keyword, pageParams);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 作为卖家,收到的采购订单(含明细)
|
|
|
+ *
|
|
|
+ * @param params
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/info/nosearch", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public SPage<PurchaseOrderAll> getSaleOrders(PageParams params, String searchFilter) {
|
|
|
+ logger.log("客户采购单", "查看收到的客户采购订单列表(包括采购明细)(全部)");
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(searchFilter);
|
|
|
+ String keyword = jsonObject.getString("keyword");
|
|
|
+ if (!StringUtils.isEmpty(keyword)) {
|
|
|
+ return getPurchaseOrderItems(params, searchFilter);
|
|
|
+ }
|
|
|
+ PageInfo pageInfo = new PageInfo(params);
|
|
|
+
|
|
|
+ if (pageInfo.getPageNumber() > 1) {
|
|
|
+ pageInfo.setPageSize(pageInfo.getPageSize() * pageInfo.getPageNumber());
|
|
|
+ pageInfo.setPageNumber(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ pageInfo.filter("vendUU", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ SearchFilter filter = JSONObject.parseObject(searchFilter, SearchFilter.class);
|
|
|
+ SearchFilter distribute = userService.distribute();
|
|
|
+ if (distribute != null && distribute.getDistribute() == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (distribute != null && !CollectionUtils.isEmpty(distribute.getDistribute())) {
|
|
|
+ filter.setDistribute(distribute.getDistribute());
|
|
|
+ }
|
|
|
+ return purchaseOrderService.findOrdersByPageInfo(pageInfo, filter);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 作为卖家,收到的采购订单(含明细)(已结案)
|
|
|
+ *
|
|
|
+ * @param params
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/info/nosearch", params = RequestState.END, method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public SPage<PurchaseOrderEnd> getEndSaleOrders(PageParams params, String searchFilter) {
|
|
|
+ logger.log("客户采购单", "查看收到的客户采购单列表(已结案)");
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(searchFilter);
|
|
|
+ String keyword = jsonObject.getString("keyword");
|
|
|
+ if (!StringUtils.isEmpty(keyword)) {
|
|
|
+ return getEndPurchaseOrderItems(params, searchFilter);
|
|
|
+ }
|
|
|
+ PageInfo pageInfo = new PageInfo(params);
|
|
|
+
|
|
|
+ if (pageInfo.getPageNumber() > 1) {
|
|
|
+ pageInfo.setPageSize(pageInfo.getPageSize() * pageInfo.getPageNumber());
|
|
|
+ pageInfo.setPageNumber(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ pageInfo.filter("vendUU", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ SearchFilter filter = JSONObject.parseObject(searchFilter, SearchFilter.class);
|
|
|
+ SearchFilter distribute = userService.distribute();
|
|
|
+ if (distribute != null && distribute.getDistribute() == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (distribute != null && !CollectionUtils.isEmpty(distribute.getDistribute())) {
|
|
|
+ filter.setDistribute(distribute.getDistribute());
|
|
|
+ }
|
|
|
+ return purchaseOrderService.findEndOrders(pageInfo, filter);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param params
|
|
|
+ * @param searchFilter
|
|
|
+ * @author wangmh 获取已发货的订单
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/info/nosearch", params = RequestState.RECEIVED, method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public SPage<PurchaseOrderReceived> getReceivedOrders(PageParams params, String searchFilter) {
|
|
|
+ logger.log("客户采购单", "查看收到的客户采购订单列表(包括采购明细)(待交货)");
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(searchFilter);
|
|
|
+ String keyword = jsonObject.getString("keyword");
|
|
|
+ if (!StringUtils.isEmpty(keyword)) {
|
|
|
+ return getReceivedPurchaseOrderItems(params, searchFilter);
|
|
|
+ }
|
|
|
+ PageInfo pageInfo = new PageInfo(params);
|
|
|
+
|
|
|
+ if (pageInfo.getPageNumber() > 1) {
|
|
|
+ pageInfo.setPageSize(pageInfo.getPageSize() * pageInfo.getPageNumber());
|
|
|
+ pageInfo.setPageNumber(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ pageInfo.filter("vendUU", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ SearchFilter filter = JSONObject.parseObject(searchFilter, SearchFilter.class);
|
|
|
+ SearchFilter distribute = userService.distribute();
|
|
|
+ if (distribute != null && distribute.getDistribute() == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (distribute != null && !CollectionUtils.isEmpty(distribute.getDistribute())) {
|
|
|
+ filter.setDistribute(distribute.getDistribute());
|
|
|
+ }
|
|
|
+ return purchaseOrderService.findReceivedOrders(pageInfo, filter);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param params
|
|
|
+ * @param searchFilter
|
|
|
+ * @author yujia 获取待发货的订单
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/info/nosearch", params = RequestState.WAITING, method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public SPage<PurchaseOrderWaiting> getWaitingOrders(PageParams params, String searchFilter) {
|
|
|
+ logger.log("客户采购单", "查看收到的客户采购订单列表(包括采购明细)(待交货)");
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(searchFilter);
|
|
|
+ String keyword = jsonObject.getString("keyword");
|
|
|
+ if (!StringUtils.isEmpty(keyword)) {
|
|
|
+ return getWaitingPurchaseOrderItems(params, searchFilter);
|
|
|
+ }
|
|
|
+ PageInfo pageInfo = new PageInfo(params);
|
|
|
+
|
|
|
+ if (pageInfo.getPageNumber() > 1) {
|
|
|
+ pageInfo.setPageSize(pageInfo.getPageSize() * pageInfo.getPageNumber());
|
|
|
+ pageInfo.setPageNumber(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ pageInfo.filter("vendUU", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ SearchFilter filter = JSONObject.parseObject(searchFilter, SearchFilter.class);
|
|
|
+ SearchFilter distribute = userService.distribute();
|
|
|
+ if (distribute != null && distribute.getDistribute() == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (distribute != null && !CollectionUtils.isEmpty(distribute.getDistribute())) {
|
|
|
+ filter.setDistribute(distribute.getDistribute());
|
|
|
+ }
|
|
|
+ return purchaseOrderService.findWaitingOrders(pageInfo, filter);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取单据数据统计
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/counts", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public ModelMap getCounts() {
|
|
|
+ ModelMap modelMap = new ModelMap();
|
|
|
+ Long vendUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
+ SearchFilter distribute = userService.distribute();
|
|
|
+ Collection enUUs = null;
|
|
|
+ if (distribute != null && distribute.getDistribute() != null) {
|
|
|
+ enUUs = distribute.getDistribute();
|
|
|
+ }
|
|
|
+ modelMap.put("all", purchaseOrderService.countSaleAllOrders(vendUU, enUUs));
|
|
|
+ modelMap.put("received", purchaseOrderService.countSaleReceivedOrders(vendUU, enUUs));
|
|
|
+ modelMap.put("waiting", purchaseOrderService.countSaleWaitingOrders(vendUU, enUUs));
|
|
|
+ return modelMap;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|