package cn.bx.bid.ctrl;
import cn.bx.bid.entity.Page;
import cn.bx.bid.entity.Professor;
import cn.bx.bid.entity.ProfessorEnroll;
import cn.bx.bid.entity.Project;
import cn.bx.bid.service.ProjectService;
import cn.bx.bid.util.AjaxResult;
import com.alibaba.fastjson.JSON;
import org.apache.http.HttpEntity;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import org.apache.http.util.EntityUtils;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.apache.http.ParseException;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @author
* @version 1.0
* @date 2020/1/8
* @description cn.bx.bid.ctrl
*/
@Controller
public class ProjectController {
@Resource
private ProjectService projectService;
/**
* 日期处理
*/
@InitBinder
public void initBinder(WebDataBinder webDataBinder) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
webDataBinder.registerCustomEditor(Date.class, new CustomDateEditor(format, true));
}
/**
* 查询所有项目
*
* @param page
* @param limit
* @return
*/
@GetMapping(value = "projectSearch", produces = "application/json;charset=utf-8")
@ResponseBody
public Page<Project> search(@RequestParam(name = "page", defaultValue = "1") int page, @RequestParam(name = "limit", defaultValue = "10") int limit, @RequestParam(name = "name", required = false) String name, @RequestParam(name = "category", required = false) String category) {
Page<Project> projectPage = projectService.paging(page, limit, name, category);
return projectPage;
}
/**
* 根据id查看项目
*
* @param id
* @return
*/
@ResponseBody
@PostMapping(value = "getProject", produces = "application/json;charset=utf-8")
public AjaxResult getProject(@RequestParam(name = "id") long id) {
Project project = projectService.get(id);
if (project != null) {
return AjaxResult.success(project);
}
return AjaxResult.error("接口请求异常!");
}
/**
* 根据项目id查看所有专家
*
* @param id
* @return
*/
@ResponseBody
@PostMapping(value = "/searchProfessor", produces = "application/json;charset=utf-8")
public Page searchProfessor(@RequestParam(name = "id") long id) {
Page<ProfessorEnroll> page = projectService.searchProfessorInProjs(id);
return page;
}
/**
* 添加项目
*
* @param session
* @param p
* @param file
* @return
*/
@ResponseBody
@PostMapping(value = "addProject",produces ="application/json;charset=utf-8")
public AjaxResult add(HttpSession session, @ModelAttribute("p") Project p, @RequestParam(value = "fujian", required = false) MultipartFile file) {
try{
if(file.isEmpty()==false){
String oldName = file.getOriginalFilename();
System.out.println(oldName);
String prefix = oldName.substring(oldName.lastIndexOf('.'));
String newFilePath = UUID.randomUUID()+prefix;
p.setProjectFilePath(newFilePath);
File path = new File(session.getServletContext().getRealPath("doc"));
if(path.exists() == false){
path.mkdirs();
}
try {
file.transferTo(new File(path,newFilePath));
} catch (IOException e) {
e.printStackTrace();
}
}
}catch(Exception e){
e.printStackTrace();
}
int num=projectService.addProject(p);
System.out.println(num);
System.out.println(">>>>>"+p);
if(num>0){
return AjaxResult.success("添加成功",num);
}
return AjaxResult.error("添加失败");
}
@ResponseBody
@PostMapping(value = "/delProject", produces = "application/json;charset=utf-8")
public AjaxResult delProject(@RequestParam(name = "id") long id) {
int num = projectService.delProject(id);
if(num != 0){
return AjaxResult.success("删除成功!");
}
return AjaxResult.error("删除失败!");
}
/**
* 确定参加
*
* @param projid
* @param pfid
* @return
*/
@ResponseBody
@PostMapping(value = "/profRoleProject", produces = "application/json;charset=utf-8")
public AjaxResult profRoleProject(@RequestParam(name = "projid") long projid, @RequestParam(name = "pfid") long pfid) {
int num = projectService.profRoleProject(pfid, projid);
if (num != 0) {
return AjaxResult.success("选择成功");
}
return AjaxResult.error("更改失败");
}
/**
* 不参加
*
* @param proid
* @param pfid
* @param reason
* @return
*/
@ResponseBody
@PostMapping(value = "/profnotPresentProject", produces = "application/json;charset=utf-8")
public AjaxResult profnotPresentProject(@RequestParam(name = "proid") long proid, @RequestParam(name = "pfid") long pfid, @RequestParam(name = "reason") String reason){
System.out.println(pfid+"-"+proid+"-"+reason);
int num=this.projectService.profnotPresentProject(proid,pfid,reason);
if(num != 0){
return AjaxResult.success("选择成功");
}
return AjaxResult.error("更改失败");
}
/**
* 开始抽选专家
*
* @param pjid
* @param category
* @param distance
* @return
*/
@ResponseBody
@PostMapping(value = "/randomSelect", produces = "application/json;charset=utf-8")
public AjaxResult randomSelect(@RequestParam(name = "pjid") long pjid, @RequestParam(name = "category") String category, @RequestParam(name = "distance") Double distance) {
Project p = projectService.get(pjid);
//考虑了能来的,去掉确定不来的,不确定的也加上了
int hasSelected = projectService.getPrentProfessors(pjid);
String msg = "";
try {
if (p.getStatus() == 1) {
msg = "{\"result\":false,\"msg\":\"此项目已经结束,不能再选\"}";
} else if (hasSelected >= p.getProfessorNum()) {
msg = "{\"result\":false,\"msg\":\"此项目人数已经满足,无需再选\"}";
} else {
List<Professor> list = projectService.getProfessorsForChoose(pjid, category);
//
if (distance != null) {//distance>0
//根据距离过滤
Jw location = getPos(p.getAddress());//项目开标地址的经纬度
System.out.println("开会地点。。。。。。" + location);
if (location != null) {
Iterator<Professor> r = list.iterator();
while (r.hasNext()) {
Professor t = r.next();
Jw l2 = getPos(t.getAddress());//获得专家的经纬度
if (l2 == null)
continue;//地址不确定的先不考虑
System.out.println("专家:" + t.getProfessorName() + " 住址:" + l2 + ">>>距离:" + l2.dis(location) + "公里");
if (l2.dis(loc
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【资源说明】 1、该资源内项目代码都是经过测试运行成功,功能正常的情况下才上传的,请放心下载使用。 2、适用人群:主要针对计算机相关专业(如计科、信息安全、数据科学与大数据技术、人工智能、通信、物联网、数学、电子信息等)的同学或企业员工下载使用,具有较高的学习借鉴价值。 3、不仅适合小白学习实战练习,也可作为大作业、课程设计、毕设项目、初期项目立项演示等,欢迎下载,互相学习,共同进步!
资源推荐
资源详情
资源评论
收起资源包目录
投标管理系统完整源码+说明(框架:ssm+layui)(验证码是网页验证).zip (443个子文件)
ProjectController.class 13KB
ProjectController.class 13KB
Project.class 9KB
Project.class 9KB
Professor.class 8KB
Professor.class 8KB
UserController.class 7KB
UserController.class 7KB
ProfessorController.class 6KB
ProfessorController.class 6KB
ProjectService.class 5KB
ProjectService.class 5KB
Client.class 4KB
Client.class 4KB
Page.class 4KB
Page.class 4KB
User.class 3KB
User.class 3KB
ProfessorService.class 3KB
ProfessorService.class 3KB
RandomName.class 3KB
RandomName.class 3KB
WorkHistory.class 3KB
WorkHistory.class 3KB
VerifyCode.class 3KB
VerifyCode.class 3KB
UserService.class 3KB
UserService.class 3KB
DocUtil.class 3KB
DocUtil.class 3KB
AjaxResult.class 2KB
AjaxResult.class 2KB
RoleInterceptor.class 2KB
RoleInterceptor.class 2KB
Jw.class 2KB
Jw.class 2KB
RoleController.class 2KB
RoleController.class 2KB
ProjectDao.class 2KB
ProjectDao.class 2KB
StringKit.class 2KB
StringKit.class 2KB
MyBatisUtil.class 2KB
MyBatisUtil.class 2KB
ProfessorEnroll.class 1KB
ProfessorEnroll.class 1KB
Userrole.class 1KB
Userrole.class 1KB
ProfessorDao.class 1KB
ProfessorDao.class 1KB
LogUtil.class 1KB
LogUtil.class 1KB
UserDao.class 1KB
UserDao.class 1KB
StringUtil.class 883B
StringUtil.class 883B
RoleService.class 677B
RoleService.class 677B
RoleDao.class 218B
RoleDao.class 218B
layui.css 68KB
layui.css 68KB
layer.css 14KB
layer.css 14KB
xadmin.css 10KB
xadmin.css 10KB
layui.mobile.css 10KB
layui.mobile.css 10KB
laydate.css 7KB
laydate.css 7KB
login.css 2KB
login.css 2KB
code.css 1KB
code.css 1KB
theme5.css 590B
theme5.css 590B
font.css 505B
font.css 505B
theme4.css 309B
theme4.css 309B
theme1.css 304B
theme1.css 304B
theme3.css 297B
theme3.css 297B
theme2.css 288B
theme2.css 288B
iconfont.eot 48KB
iconfont.eot 48KB
iconfont.eot 40KB
iconfont.eot 40KB
professor.ftl 63KB
professor.ftl 63KB
professor.ftl 63KB
59.gif 10KB
59.gif 10KB
22.gif 10KB
22.gif 10KB
24.gif 8KB
24.gif 8KB
13.gif 7KB
共 443 条
- 1
- 2
- 3
- 4
- 5
资源评论
龙年行大运
- 粉丝: 996
- 资源: 3859
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- JavaScript《基于自动分析数据并给出营业建议的餐厅管理系统(接入AI) 》+源代码+项目说明及资料
- 355670834783295707ad04e-427f-4cde-9589-e578224a8459.zip
- 动态sql解析引擎,类似mybatis动态sql的功能
- EDA365-Skill-V2.5安装包,支持Allegro17.x版本
- C# 常用单词汇总,常用单词汇总
- 【ERP标准流程-标准流程-库内业务管理】(DOC 14页).doc
- Python《数据库期末作业-餐厅点单系统 》+源代码+设计资料
- 学生成绩管理系统(C++课程设计
- 双指针法判断链表有环-go语言实现
- MyBatis动态SQL是一种强大的特性,它允许我们在SQL语句中根据条件动态地添加或删除某些部分,从而实现更加灵活和高效的数据
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功