|
|
@@ -0,0 +1,583 @@
|
|
|
+package com.uas.platform.b2b.erp.controller;
|
|
|
+
|
|
|
+import com.alibaba.dubbo.common.utils.CollectionUtils;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.uas.platform.b2b.erp.service.TenderService;
|
|
|
+import com.uas.platform.b2b.model.*;
|
|
|
+import com.uas.platform.b2b.search.SearchService;
|
|
|
+import com.uas.platform.b2b.service.AttachService;
|
|
|
+import com.uas.platform.b2b.service.UserService;
|
|
|
+import com.uas.platform.b2b.support.SystemSession;
|
|
|
+import com.uas.platform.core.model.Constant;
|
|
|
+import com.uas.platform.core.model.PageParams;
|
|
|
+import com.uas.platform.core.util.serializer.FlexJsonUtils;
|
|
|
+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.util.SearchConstants;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.ui.ModelMap;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by dongbw
|
|
|
+ * 17/05/03 9:54.
|
|
|
+ */
|
|
|
+@Controller
|
|
|
+@RequestMapping(value = "/erp/tender")
|
|
|
+public class TenderController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TenderService tenderService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SearchService searchService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserService userService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AttachService attachService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 作为采购方,发布招标单
|
|
|
+ *
|
|
|
+ * @param tender 招标单
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/publish", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ @Transactional
|
|
|
+ public ResponseEntity<String> publishTender(String tender, String vendorUUs) {
|
|
|
+ PurchaseTender purchaseTender = FlexJsonUtils.fromJson(tender, PurchaseTender.class);
|
|
|
+ if (purchaseTender.getIfOpen() == Constant.YES) {
|
|
|
+ tenderService.publishOpen(purchaseTender);
|
|
|
+ } else {
|
|
|
+ if (null != vendorUUs) {
|
|
|
+ vendorUUs = "[".concat(vendorUUs);
|
|
|
+ vendorUUs = vendorUUs.concat("]");
|
|
|
+ List<Long> vendUUs = FlexJsonUtils.fromJsonArray(vendorUUs, Long.class);
|
|
|
+ tenderService.publish(purchaseTender, vendUUs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new ResponseEntity<String>(HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 作为采购方,保存招标单
|
|
|
+ *
|
|
|
+ * @param tender 招标单
|
|
|
+ * @param vendorUUs 所选供应商uu
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/save", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ @Transactional
|
|
|
+ public ModelMap saveTender(String tender, String vendorUUs) {
|
|
|
+ PurchaseTender purchaseTender = FlexJsonUtils.fromJson(tender, PurchaseTender.class);
|
|
|
+ if (purchaseTender.getIfOpen() == Constant.YES) {
|
|
|
+ return tenderService.saveOpen(purchaseTender);
|
|
|
+ } else {
|
|
|
+ if (null != vendorUUs) {
|
|
|
+ vendorUUs = "[".concat(vendorUUs);
|
|
|
+ vendorUUs = vendorUUs.concat("]");
|
|
|
+ List<Long> vendUUs = FlexJsonUtils.fromJsonArray(vendorUUs, Long.class);
|
|
|
+ return tenderService.save(purchaseTender, vendUUs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ map.put("success", false);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 供应商投标
|
|
|
+ *
|
|
|
+ * @param enBaseInfo 投标企业信息
|
|
|
+ * @param tenderItems 投标明细
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/reply", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public ResponseEntity<String> replyTender(String tenderItems, String enBaseInfo, String attaches) {
|
|
|
+ tenderItems = "[".concat(tenderItems);
|
|
|
+ tenderItems = tenderItems.concat("]");
|
|
|
+ List<SaleTenderItem> saleTenderItems = FlexJsonUtils.fromJsonArray(tenderItems, SaleTenderItem.class);
|
|
|
+ EnterpriseBaseInfo vendor = FlexJsonUtils.fromJson(enBaseInfo, EnterpriseBaseInfo.class);
|
|
|
+ List<Attach> saleTenderAttaches = new ArrayList<>();
|
|
|
+ if (attaches != null && !Objects.equals(attaches, "")) {
|
|
|
+ attaches = "[".concat(attaches);
|
|
|
+ attaches = attaches.concat("]");
|
|
|
+ saleTenderAttaches = FlexJsonUtils.fromJsonArray(attaches, Attach.class);
|
|
|
+ }
|
|
|
+ tenderService.reply(saleTenderItems, vendor, saleTenderAttaches);
|
|
|
+ return new ResponseEntity<String>(HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看招标单详情
|
|
|
+ *
|
|
|
+ * @param id 招标单id
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/detail", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public PurchaseTender getTenderById(Long id) {
|
|
|
+ return tenderService.findById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 公开招标转投标单
|
|
|
+ *
|
|
|
+ * @param id 招标单id
|
|
|
+ * @return 投标单id 和code
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/addItems", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public ModelMap addTenderItemById(Long id) {
|
|
|
+ return tenderService.addTenderItemById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 招标方定标
|
|
|
+ *
|
|
|
+ * @param json 招标单json
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/decide", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public ResponseEntity<String> decideTender(@RequestBody String json) {
|
|
|
+ PurchaseTender purchaseTender = FlexJsonUtils.fromJson(json, PurchaseTender.class);
|
|
|
+ tenderService.decide(purchaseTender);
|
|
|
+ return new ResponseEntity<String>(HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 作为供应商,查看收到的招标单(全部)
|
|
|
+ *
|
|
|
+ * @param params 分页参数
|
|
|
+ * @return Spage
|
|
|
+ */
|
|
|
+ @RequestMapping(method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public SPage<PurchaseTender> getAllTenders(PageParams params, String searchFilter) {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("pt_id", false, Sort.Type.LONG, 1L));
|
|
|
+ pageParams.getFilters().put(SearchConstants.SORT_KEY, sortList);
|
|
|
+ pageParams.getFilters().put("pt_ispublish", Constant.YES);
|
|
|
+// pageParams.getFilters().put("pt_ifopen", Constant.NO); // 现在公开的也在这个列表
|
|
|
+ pageParams.getFilters().put("tp_ptid", SystemSession.getUser().getEnterprise().getEnName());
|
|
|
+ return searchService.searchPurcTenderIds(keyword, pageParams);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 作为供应商,查看收到的招标单(已结标)
|
|
|
+ *
|
|
|
+ * @param params 分页参数
|
|
|
+ * @return Sapge
|
|
|
+ */
|
|
|
+ @RequestMapping(value="/done", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public SPage<PurchaseTender> getDoneTenders(PageParams params, String searchFilter) {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("pt_id", false, Sort.Type.LONG, 1L));
|
|
|
+ pageParams.getFilters().put(SearchConstants.SORT_KEY, sortList);
|
|
|
+ pageParams.getFilters().put("tp_ptid", SystemSession.getUser().getEnterprise().getEnName());
|
|
|
+ pageParams.getFilters().put("pt_ispublish", Constant.YES);
|
|
|
+ pageParams.getFilters().put("pt_result", Constant.YES);
|
|
|
+// pageParams.getFilters().put("pt_ifopen", Constant.NO);
|
|
|
+ return searchService.searchPurcTenderIds(keyword, pageParams);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 作为供应商,查看收到的招标单(待评标)
|
|
|
+ *
|
|
|
+ * @param params 分页参数
|
|
|
+ * @return 招标单Spage
|
|
|
+ */
|
|
|
+ @RequestMapping(value="/waiting", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public SPage<PurchaseTender> getWaitingTenders(PageParams params, String searchFilter) {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("pt_id", false, Sort.Type.LONG, 1L));
|
|
|
+ pageParams.getFilters().put(SearchConstants.SORT_KEY, sortList);
|
|
|
+ pageParams.getFilters().put("tp_ptid", SystemSession.getUser().getEnterprise().getEnName());
|
|
|
+ pageParams.getFilters().put("pt_ispublish", Constant.YES);
|
|
|
+// pageParams.getFilters().put("pt_ifopen", Constant.NO);
|
|
|
+ pageParams.getFilters().put("pt_overdue", Constant.YES);
|
|
|
+ pageParams.getFilters().put("pt_result", Constant.NO);
|
|
|
+ pageParams.getFilters().put("pt_status", "待评标");
|
|
|
+ return searchService.searchPurcTenderIds(keyword, pageParams);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 作为供应商,查看收到的招标单(待投标)
|
|
|
+ *
|
|
|
+ * @param params 分页参数
|
|
|
+ * @return 招标单Spage
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/todo", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public SPage<PurchaseTender> getTodoTenders(PageParams params, String searchFilter) {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("pt_id", false, Sort.Type.LONG, 1L));
|
|
|
+ pageParams.getFilters().put(SearchConstants.SORT_KEY, sortList);
|
|
|
+ pageParams.getFilters().put("tp_ptid", SystemSession.getUser().getEnterprise().getEnName());
|
|
|
+ pageParams.getFilters().put("pt_ispublish", Constant.YES);
|
|
|
+// pageParams.getFilters().put("pt_ifopen", Constant.NO);
|
|
|
+ pageParams.getFilters().put("pt_overdue", Constant.NO);
|
|
|
+ return searchService.searchPurcTenderIds(keyword, pageParams);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 作为供应商,查看收到的招标单(过期)
|
|
|
+ *
|
|
|
+ * @param params 分页参数
|
|
|
+ * @return 招标单Spage
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/end", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public SPage<PurchaseTender> getEndTenders(PageParams params, String searchFilter) {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("pt_id", false, Sort.Type.LONG, 1L));
|
|
|
+ pageParams.getFilters().put(SearchConstants.SORT_KEY, sortList);
|
|
|
+ pageParams.getFilters().put("tp_ptid", SystemSession.getUser().getEnterprise().getEnName());
|
|
|
+ pageParams.getFilters().put("pt_ispublish", Constant.YES);
|
|
|
+// pageParams.getFilters().put("pt_ifopen", Constant.NO);
|
|
|
+ pageParams.getFilters().put("pt_status", "待投标");
|
|
|
+ pageParams.getFilters().put("pt_overdue", Constant.YES);
|
|
|
+ return searchService.searchPurcTenderIds(keyword, pageParams);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 作为供应商,查看平台开放招标单(全部)
|
|
|
+ *
|
|
|
+ * @param params 分页参数
|
|
|
+ * @return 招标单Spage
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/open", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public SPage<PurchaseTender> getAllOpenTenders(PageParams params, String searchFilter) {
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(searchFilter);
|
|
|
+ String keyword = jsonObject.getString("keyword");
|
|
|
+ com.uas.search.b2b.model.PageParams pageParams = searchService.convertPageParams(params, searchFilter);
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("pt_id", false, Sort.Type.LONG, 1L));
|
|
|
+ pageParams.getFilters().put(SearchConstants.SORT_KEY, sortList);
|
|
|
+ pageParams.getFilters().put("pt_ispublish", Constant.YES);
|
|
|
+ pageParams.getFilters().put("pt_ifopen", Constant.YES);
|
|
|
+ return searchService.searchOpenPurcTenderIds(keyword, pageParams);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 作为采购方,查看发出的招标单
|
|
|
+ *
|
|
|
+ * @param params
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/purc", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public SPage<PurchaseTender> getMyAllTenders(PageParams params, String searchFilter) {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ buildFilter(filter, pageParams);
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("pt_id", false, Sort.Type.LONG, 1L));
|
|
|
+ pageParams.getFilters().put(SearchConstants.SORT_KEY, sortList);
|
|
|
+ pageParams.getFilters().put("pt_enuu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ return searchService.searchPurcTenderIds(keyword, pageParams);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * filter处理
|
|
|
+ *
|
|
|
+ * @param filter 拦截器
|
|
|
+ * @param pageParams 分页参数
|
|
|
+ */
|
|
|
+ private void buildFilter(SearchFilter filter, com.uas.search.b2b.model.PageParams pageParams) {
|
|
|
+ if (filter != null && !CollectionUtils.isEmpty(filter.getDistribute())) {
|
|
|
+ List<Object> list = new ArrayList<>();
|
|
|
+ list.addAll(filter.getDistribute());
|
|
|
+ pageParams.getFilters().put("pti_venduu", new MultiValue(list, true));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 作为采购方,查看发出的招标单(待评标)
|
|
|
+ *
|
|
|
+ * @param params
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/purc/done", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public SPage<PurchaseTender> getMyDoneTenders(PageParams params, String searchFilter) {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ buildFilter(filter, pageParams);
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("pt_id", false, Sort.Type.LONG, 1L));
|
|
|
+ pageParams.getFilters().put(SearchConstants.SORT_KEY, sortList);
|
|
|
+ pageParams.getFilters().put("pt_enuu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ pageParams.getFilters().put("pt_ispublish", Constant.YES);
|
|
|
+ pageParams.getFilters().put("pt_status", "待评标");
|
|
|
+ pageParams.getFilters().put("pt_overdue", Constant.YES);
|
|
|
+ pageParams.getFilters().put("pt_result", Constant.NO);
|
|
|
+ return searchService.searchPurcTenderIds(keyword, pageParams);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 作为采购方,查看发出的招标单(待投标)
|
|
|
+ *
|
|
|
+ * @param params 参数
|
|
|
+ * @return 单据
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/purc/todo", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public SPage<PurchaseTender> getMyTodoTenders(PageParams params, String searchFilter) {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ buildFilter(filter, pageParams);
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("pt_id", false, Sort.Type.LONG, 1L));
|
|
|
+ pageParams.getFilters().put(SearchConstants.SORT_KEY, sortList);
|
|
|
+ pageParams.getFilters().put("pt_enuu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ pageParams.getFilters().put("pt_ispublish", Constant.YES);
|
|
|
+ pageParams.getFilters().put("pt_overdue", Constant.NO);
|
|
|
+ return searchService.searchPurcTenderIds(keyword, pageParams);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 作为客户,查看发出的招标单(待发布)
|
|
|
+ *
|
|
|
+ * @param params 参数
|
|
|
+ * @param searchFilter 搜索参数
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/purc/waiting", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public SPage<PurchaseTender> getWaitingPTenders(PageParams params, String searchFilter) {
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(searchFilter);
|
|
|
+ String keyword = jsonObject.getString("keyword");
|
|
|
+ com.uas.search.b2b.model.PageParams pageParams = searchService.convertPageParams(params, searchFilter);
|
|
|
+ // 当前登录企业作为客户
|
|
|
+
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("pt_id", false, Sort.Type.LONG, 1L));
|
|
|
+ pageParams.getFilters().put(SearchConstants.SORT_KEY, sortList);
|
|
|
+ pageParams.getFilters().put("pt_enuu", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ SearchFilter filter = userService.distribute();
|
|
|
+ if (filter != null && filter.getDistribute() == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ buildFilter(filter, pageParams);
|
|
|
+ pageParams.getFilters().put("pt_ispublish", Constant.NO);
|
|
|
+ pageParams.getFilters().put("pt_status", "待发布");
|
|
|
+ return searchService.searchPurcTenderIds(keyword, pageParams);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 招标附件上传
|
|
|
+ *
|
|
|
+ * @return attach
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/addTenderAttach", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public Attach addTenderAttaches(FileUpload uploadItem) throws Exception {
|
|
|
+ return tenderService.addTenderAttaches(uploadItem);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 投标附件上传
|
|
|
+ *
|
|
|
+ * @return attach
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/addTenderItemAttach", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public Attach addTenderItemAttaches(FileUpload uploadItem) throws Exception {
|
|
|
+ return tenderService.addTenderItemAttaches(uploadItem);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看最近公开招标
|
|
|
+ *
|
|
|
+ * @return 招标单List
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/latestOpenTender", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public List<PurchaseTender> getLatestOpenTender() {
|
|
|
+// PageInfo info = new PageInfo(params);
|
|
|
+// info.sorting("date", Direction.DESC); // 按发布日期倒序
|
|
|
+ return tenderService.findOpen();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除在录入的单据
|
|
|
+ *
|
|
|
+ * @param id 招标单id
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
|
|
+ @ResponseBody
|
|
|
+ public ModelMap deleteTender(Long id) {
|
|
|
+ return tenderService.delete(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发布在录入单据
|
|
|
+ *
|
|
|
+ * @param tender 招标单json
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/publishSaved", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ @Transactional
|
|
|
+ public ModelMap publishSavedTender(String tender, String vendorUUs) {
|
|
|
+ PurchaseTender purchaseTender = FlexJsonUtils.fromJson(tender, PurchaseTender.class);
|
|
|
+ if (purchaseTender.getIfOpen() == Constant.YES) {
|
|
|
+ return tenderService.publishSavedOpen(purchaseTender);
|
|
|
+ } else {
|
|
|
+ if (null != vendorUUs) {
|
|
|
+ vendorUUs = "[".concat(vendorUUs);
|
|
|
+ vendorUUs = vendorUUs.concat("]");
|
|
|
+ List<Long> vendUUs = FlexJsonUtils.fromJsonArray(vendorUUs, Long.class);
|
|
|
+ return tenderService.publishSaved(purchaseTender, vendUUs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ map.put("success", false);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新在录入单据
|
|
|
+ *
|
|
|
+ * @param tender 招标单
|
|
|
+ * @param vendorUUs 供应商uu
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/updateSaved", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ @Transactional
|
|
|
+ public ModelMap updateSavedTender(String tender, String vendorUUs) {
|
|
|
+ PurchaseTender purchaseTender = FlexJsonUtils.fromJson(tender, PurchaseTender.class);
|
|
|
+ if (purchaseTender.getIfOpen() == Constant.YES) { // 开放时进另外的方法
|
|
|
+ return tenderService.updateSavedOpen(purchaseTender);
|
|
|
+ } else {
|
|
|
+ if (null != vendorUUs) {
|
|
|
+ vendorUUs = "[".concat(vendorUUs);
|
|
|
+ vendorUUs = vendorUUs.concat("]");
|
|
|
+ List<Long> vendUUs = FlexJsonUtils.fromJsonArray(vendorUUs, Long.class);
|
|
|
+ return tenderService.updateSaved(purchaseTender, vendUUs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ map.put("success", false);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除对应产品明细
|
|
|
+ *
|
|
|
+ * @param tenderProdId 招标产品明细id
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/deleteProd", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public ResponseEntity<String> deleteProd(Long tenderProdId) {
|
|
|
+ tenderService.deleteProd(tenderProdId);
|
|
|
+ return new ResponseEntity<String>(HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除对应供应商投标单
|
|
|
+ *
|
|
|
+ * @param id 招标单id
|
|
|
+ * @param vendUU 删除的投标单的供应商UU
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/removeSaleTender", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public ResponseEntity<String> removeSaleTender(Long id, Long vendUU) {
|
|
|
+ tenderService.removeSaleTender(id, vendUU);
|
|
|
+ return new ResponseEntity<String>(HttpStatus.OK);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除单个附件
|
|
|
+ *
|
|
|
+ * @param attachId 附件id
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/removeAttach", method = RequestMethod.POST)
|
|
|
+ public void deleteAttach(Long attachId) {
|
|
|
+ tenderService.deleteAttach(attachId);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|