| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454 |
- package com.goafanti.demand.controller;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RestController;
- import com.goafanti.admin.service.AftFileService;
- import com.goafanti.common.bo.Result;
- import com.goafanti.common.constant.ErrorConstants;
- import com.goafanti.common.controller.CertifyApiController;
- import com.goafanti.common.enums.AttachmentType;
- import com.goafanti.common.enums.DeleteStatus;
- import com.goafanti.common.enums.DemandAuditStatus;
- import com.goafanti.common.model.AftFile;
- import com.goafanti.common.model.Demand;
- import com.goafanti.common.model.DemandFollow;
- import com.goafanti.common.model.DemandFollowDetail;
- import com.goafanti.common.model.DemandPublish;
- import com.goafanti.common.utils.StringUtils;
- import com.goafanti.demand.service.DemandFollowService;
- import com.goafanti.demand.service.DemandOrderService;
- import com.goafanti.demand.service.DemandPublishPageService;
- import com.goafanti.demand.service.DemandPublishService;
- import com.goafanti.demand.service.DemandService;
- import com.goafanti.user.service.UserService;
- @RestController
- @RequestMapping(value = "/api/admin/demand")
- public class AdminDemandApiController extends CertifyApiController {
- @Resource
- private DemandService demandService;
- @Resource
- private UserService userService;
- @Resource
- private AftFileService aftFileService;
- @Resource
- private DemandOrderService demandOrderService;
- @Resource
- DemandPublishService demandPublishService;
- @Resource
- DemandFollowService demandFollowService;
- /**
- * 科技需求匹配科技成果
- */
- @RequestMapping(value = "/matchAchievement", method = RequestMethod.POST)
- public Result matchAchievement(String id) {
- Result res = new Result();
- if (StringUtils.isBlank(id)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "成果ID"));
- return res;
- }
- Demand d = demandService.selectByPrimaryKey(id);
- if (null == d|| !DeleteStatus.UNDELETE.getCode().equals(d.getDeletedSign())
- || !DemandAuditStatus.AUDITED.getCode().equals(d.getAuditStatus())) {
- res.getError().add(buildError("", "当前状态无法匹配!"));
- return res;
- }
- res.setData(demandService.updateMatchAchievement(d));
- return res;
- }
-
- /**
- * 成果需求匹配列表
- */
- @RequestMapping(value = "/achievementDemand", method = RequestMethod.GET)
- public Result achievementDemand(String id) {
- Result res = new Result();
- res.setData(demandService.selectAchievementDemandListByDemandId(id));
- return res;
- }
- /**
- * 下载技术需求批量导入Excel模板
- *
- * @param response
- * @return
- */
- @RequestMapping(value = "/downloadTemplate", method = RequestMethod.GET)
- public Result downloadTemplateFile(HttpServletResponse response, String sign) {
- Result res = new Result();
- AttachmentType attachmentType = AttachmentType.getField(sign);
- if (attachmentType == AttachmentType.DEMAND_TEMPLATE) {
- String fileName = "";
- AftFile af = aftFileService.selectAftFileBySign(sign);
- if (null == af) {
- res.getError().add(buildError(ErrorConstants.FILE_NON_EXISTENT, "", "找不到文件!"));
- } else {
- String path = af.getFilePath();
- String suffix = path.substring(path.lastIndexOf("."));
- fileName = AttachmentType.DEMAND_TEMPLATE.getDesc() + suffix;
- downloadFile(response, fileName, path);
- }
- } else {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
- }
- return res;
- }
- /**
- * 个人用户--需求列表
- */
- @RequestMapping(value = "/userList", method = RequestMethod.GET)
- public Result userList(String pageNo, String pageSize) {
- Result res = new Result();
- //res.setData(null); TODO
- return res;
- }
- /**
- * 组织用户--需求列表(个人组织合并)
- */
- @RequestMapping(value = "/orgList", method = RequestMethod.GET)
- public Result orgList(String pageNo, String pageSize) {
- Result res = new Result();
- //res.setData(null); TODO
- return res;
- }
- /**
- * 个人需求详情
- */
- @RequestMapping(value = "/userDemandDetail", method = RequestMethod.GET)
- public Result userDemandDetail(String id) {
- Result res = new Result();
- if (StringUtils.isBlank(id)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
- return res;
- }
- res.setData(demandService.selectUserDemandDetail(id));
- return res;
- }
- /**
- * 组织用户详情(个人组织合并)
- */
- @RequestMapping(value = "/orgDemandDetail", method = RequestMethod.GET)
- public Result orgDemandDetail(String id,Integer dataCategory) {
- Result res = new Result();
- if (StringUtils.isBlank(id)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
- return res;
- }
- if(dataCategory==0){
- res.setData(demandService.selectUserDemandDetail(id));
- return res;
- }else if(dataCategory==1){
- res.setData(demandService.selectOrgDemandDetail(id));
- return res;
- }
- return res;
- }
- /**
- * 需求管理--获取个人用户下拉
- */
- @RequestMapping(value = "/userNames", method = RequestMethod.GET)
- public Result getUserNames() {
- Result res = new Result();
- res.setData(userService.selectDemandUserNames());
- return res;
- }
- /**
- * 需求管理--获取组织用户下拉
- */
- @RequestMapping(value = "/unitNames", method = RequestMethod.GET)
- public Result getUnitNames() {
- Result res = new Result();
- res.setData(userService.selectDemandUnitNames());
- return res;
- }
- /**
- * 需求资料--图片上传
- */
- @RequestMapping(value = "/uploadPicture", method = RequestMethod.POST)
- public Result uploadPicture(HttpServletRequest req, String sign, String uid) {
- Result res = new Result();
- if (StringUtils.isBlank(uid)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户ID", "用户ID"));
- return res;
- }
- AttachmentType attachmentType = AttachmentType.getField(sign);
- if (attachmentType == AttachmentType.DEMAND_PICTURE|| attachmentType == AttachmentType.DEMAND_COVER_PICTURE) {
- res.setData(handleFiles(res, "/demand/", false, req, sign, uid));
- } else {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
- }
- return res;
- }
- /**
- * 需求资料--文本文件上传
- */
- @RequestMapping(value = "/uploadTextFile", method = RequestMethod.POST)
- public Result uploadTextFile(HttpServletRequest req, String sign, String uid) {
- Result res = new Result();
- if (StringUtils.isBlank(uid)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户ID", "用户ID"));
- return res;
- }
- AttachmentType attachmentType = AttachmentType.getField(sign);
- if (attachmentType == AttachmentType.DEMAND_TEXT_FILE) {
- res.setData(handleFiles(res, "/demand/", false, req, sign, uid));
- } else {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "附件标示"));
- }
- return res;
- }
- /**
- * 需求撤消发布(下架)
- */
- @RequestMapping(value = "/offShelf", method = RequestMethod.POST)
- public Result offShelf(String id,Integer releaseStatus) {
- Result res = new Result();
- if (StringUtils.isBlank(id)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求ID", "需求ID"));
- return res;
- }
- Demand d = demandService.selectByPrimaryKey(id);
- if (null == d) {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "需求ID"));
- return res;
- }
- d.setReleaseStatus(releaseStatus);
- res.setData(demandService.updateReleaseStatus(d));
- return res;
- }
- /**
- * 下载需求文件--文本文件
- */
- @RequestMapping(value = "/download", method = RequestMethod.GET)
- public Result download(HttpServletResponse response, String id) {
- Result res = new Result();
- if (StringUtils.isEmpty(id)) {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "需求ID"));
- return res;
- }
- Demand d = demandService.selectByPrimaryKey(id);
- if (null == d) {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "", "需求ID"));
- return res;
- }
- downloadUnPrivateFile(response, d.getTextFileDownloadFileName(), d.getTextFileUrl());
- return res;
- }
- /**
- * 我的需求列表
- */
- @RequestMapping(value = "/myList", method = RequestMethod.GET)
- public Result myList(String pageNo, String pageSize) {
- Result res = new Result();
- // res.setData(null) todo;
- return res;
- }
-
- /**
- * 需求发布
- */
- @RequestMapping(value = "/addDemandPublish", method = RequestMethod.POST)
- private Result addDemandPublish(DemandPublish d) {
- Result res = new Result();
- if (StringUtils.isBlank(d.getDemandId())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求", "需求"));
- return res;
- }
- res.setData(demandPublishService.insertDemandPublish(d));
- return res;
- }
- /**
- * 撤销发布
- */
- @RequestMapping(value = "/deletePublish", method = RequestMethod.GET)
- private Result deletePublish(String id) {
- Result res = new Result();
- res.setData(demandPublishService.deletePublish(id));
- return res;
- }
- /**
- * 修改发布
- */
- @RequestMapping(value = "/updatePublish", method = RequestMethod.GET)
- private Result updatePublish(DemandPublish d) {
- Result res = new Result();
- res.setData(demandPublishService.updatePublish(d));
- return res;
- }
-
- /**
- * 发布列表
- */
- @RequestMapping(value = "/listPublish", method = RequestMethod.GET)
- private Result listPublish(String name,String publishPlatform,Integer publishClient,String publishPage,
- Integer ifTop, Integer pageNo, Integer pageSize,String employerName) {
- Result res = new Result();
- if (null==pageNo) {
- pageNo=1;
- }
- if (null==pageSize) {
- pageSize=10;
- }
- res.setData(demandPublishService.listPublish( name, publishPlatform, publishClient, publishPage,
- ifTop, pageNo, pageSize,employerName));
- return res;
- }
- /**
- * 获取需求页面位置
- */
- @RequestMapping(value="/getPublishPage",method = RequestMethod.GET)
- private Result getPublishPage(){
- Result res=new Result();
- return res.data(DemandPublishPageService.getBranchInformation());
- }
- /**
- * 新增匹配跟进保存
- */
- @RequestMapping(value = "/addDemandFollow", method = RequestMethod.POST)
- private Result addDemandFollow(DemandFollow d) {
- Result res = new Result();
- if (StringUtils.isBlank(d.getDemandId())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求", "需求"));
- return res;
- }
- if (StringUtils.isBlank(d.getContactMobile())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到联系人电话", "联系人电话"));
- return res;
- }
- if (StringUtils.isBlank(d.getContacts())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到联系人", "联系人"));
- return res;
- }
- if (StringUtils.isBlank(d.getOrganization())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到机构", "机构"));
- return res;
- }
- res.data(demandFollowService.insertDemandFollow(d));
- return res;
- }
-
- /**
- * 修改匹配跟进
- */
- @RequestMapping(value = "/updateDemandFollow", method = RequestMethod.POST)
- private Result DemandFollow(DemandFollow d) {
- Result res = new Result();
- if (StringUtils.isBlank(d.getId())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求匹配", "匹配跟进"));
- return res;
- }
- res.setData(demandFollowService.updateDemandFollow(d));
- return res;
- }
-
- /**
- * 新增跟进情况
- */
- @RequestMapping(value = "/addDemandFollowDetail", method = RequestMethod.POST)
- private Result addDemandFollowDetail(DemandFollowDetail d,String createTimeFormattedDate) {
- Result res = new Result();
- if (StringUtils.isBlank(d.getDemandFollowId())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求匹配跟进", "需求匹配跟进"));
- return res;
- }
- if (StringUtils.isBlank(d.getRemarks())) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到跟进情况", "跟进情况"));
- return res;
- }
- if (null==d.getResult()) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到跟进结果", "跟进结果"));
- return res;
- }
- if (StringUtils.isBlank(createTimeFormattedDate)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到跟进时间", "跟进时间"));
- return res;
- }
- res.data(demandFollowService.insertDemandFollowDetail(d,createTimeFormattedDate));
- return res;
- }
-
- /**
- * 跟进列表
- */
- @RequestMapping(value = "/listDemandFollow", method = RequestMethod.GET)
- private Result listDemandFollow(String id,Integer pNo,Integer pSize) {
- Result res = new Result();
- if (StringUtils.isBlank(id)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求匹配跟进", "需求匹配跟进"));
- return res;
- }
- res.data(demandFollowService.selectDemandFollow( id, pNo, pSize));
- return res;
- }
-
- /**
- * 删除跟进
- */
- @RequestMapping(value = "/deleteDemandFollow", method = RequestMethod.GET)
- private Result deleteDemandFollow(String id) {
- Result res = new Result();
- if (StringUtils.isBlank(id)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求匹配跟进", "需求匹配跟进"));
- return res;
- }
- res.data(demandFollowService.deleteDemandFollow( id));
- return res;
- }
-
- /**
- * 跟进情况列表
- */
- @RequestMapping(value = "/listDemandFollowDetail", method = RequestMethod.GET)
- private Result listDemandFollowDetail(String id,Integer pNo, Integer pSize) {
- Result res = new Result();
- if (StringUtils.isBlank(id)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求跟进", "需求跟进"));
- return res;
- }
- res.data(demandFollowService.selectDemandFollowDetail( id,pNo, pSize));
- return res;
- }
- /**
- * 匹配跟进
- */
- @RequestMapping(value = "/DemandFollowDetails", method = RequestMethod.GET)
- private Result DemandFollowDetails(String id) {
- Result res = new Result();
- if (StringUtils.isBlank(id)) {
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到需求跟进", "需求跟进"));
- return res;
- }
- res.data(demandService.DemandFollowDetails(id));
- return res;
- }
- }
|