68 lines
3.5 KiB
Java
68 lines
3.5 KiB
Java
|
|
package cn.palmte.work.service;
|
|||
|
|
|
|||
|
|
import cn.palmte.work.model.Project;
|
|||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|||
|
|
import org.springframework.stereotype.Service;
|
|||
|
|
import top.jfunc.common.db.QueryHelper;
|
|||
|
|
import top.jfunc.common.db.bean.Page;
|
|||
|
|
import top.jfunc.common.db.utils.Pagination;
|
|||
|
|
import top.jfunc.common.utils.StrUtil;
|
|||
|
|
|
|||
|
|
import java.util.Map;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @author xiongshiyan at 2021/10/29 , contact me with email yanshixiong@126.com or phone 15208384257
|
|||
|
|
*/
|
|||
|
|
@Service
|
|||
|
|
public class ProjectService {
|
|||
|
|
@Autowired
|
|||
|
|
private Pagination pagination;
|
|||
|
|
|
|||
|
|
|
|||
|
|
private QueryHelper getQueryHelper(Map<String, String> searchInfo, int pageNumber, int pageSize) {
|
|||
|
|
/*"CASE p.type WHEN 1 THEN '工程集成类' WHEN 2 THEN '设备集成类' WHEN 3 THEN '战略合作类' ELSE '未知' AS typeDesc," +
|
|||
|
|
"CASE p.status WHEN 0 THEN '草稿' WHEN 1 THEN '项目创建' WHEN 5 THEN '概算完成' WHEN 10 THEN '预算完成' WHEN 15 THEN '结算中' WHEN 20 THEN '决算完成' ELSE '未知' AS statusDesc," +
|
|||
|
|
"CASE p.approve_status WHEN 0 THEN '待审核' WHEN 1 THEN '审核通过' WHEN 2 THEN '审核不通过' ELSE '未知' AS approveStatusDesc," +
|
|||
|
|
*/
|
|||
|
|
QueryHelper queryHelper = new QueryHelper("SELECT p.*","project","p");
|
|||
|
|
if(StrUtil.isNotEmpty(searchInfo.get("status")) && "-1".equals(searchInfo.get("status"))){
|
|||
|
|
queryHelper.addCondition("p.status=?", searchInfo.get("status"));
|
|||
|
|
}
|
|||
|
|
if(StrUtil.isNotEmpty(searchInfo.get("approveStatus")) && "-1".equals(searchInfo.get("approveStatus"))){
|
|||
|
|
queryHelper.addCondition("p.approve_status=?", searchInfo.get("approveStatus"));
|
|||
|
|
}
|
|||
|
|
if(StrUtil.isNotEmpty(searchInfo.get("deptId")) && "-1".equals(searchInfo.get("deptId"))){
|
|||
|
|
queryHelper.addCondition("p.dept_id=?", searchInfo.get("deptId"));
|
|||
|
|
}
|
|||
|
|
if(StrUtil.isNotEmpty(searchInfo.get("type")) && "-1".equals(searchInfo.get("type"))){
|
|||
|
|
queryHelper.addCondition("p.type=?", searchInfo.get("type"));
|
|||
|
|
}
|
|||
|
|
queryHelper.addCondition(StrUtil.isNotEmpty(searchInfo.get("name")),"p.name LIKE ?", "%"+searchInfo.get("name")+"%");
|
|||
|
|
queryHelper.addCondition(StrUtil.isNotEmpty(searchInfo.get("creatorName")),"p.creator_name LIKE ?", "%"+searchInfo.get("creatorName")+"%");
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 只选择了一个时间的情况,就项目时间包括这个时间的
|
|||
|
|
*/
|
|||
|
|
if(StrUtil.isNotEmpty(searchInfo.get("startTime")) && StrUtil.isEmpty(searchInfo.get("endTime"))){
|
|||
|
|
queryHelper.addCondition("p.start_date<=? AND p.end_date>?",searchInfo.get("startTime"), searchInfo.get("startTime"));
|
|||
|
|
}
|
|||
|
|
if(StrUtil.isNotEmpty(searchInfo.get("endTime")) && StrUtil.isEmpty(searchInfo.get("startTime"))){
|
|||
|
|
queryHelper.addCondition("p.start_date<=? AND p.end_date>?",searchInfo.get("endTime"), searchInfo.get("endTime"));
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* 两个时间都选了,则包含项目时间
|
|||
|
|
*/
|
|||
|
|
if(StrUtil.isNotEmpty(searchInfo.get("startTime")) && StrUtil.isNotEmpty(searchInfo.get("endTime"))){
|
|||
|
|
queryHelper.addCondition("p.start_date>=? AND p.end_date<?",searchInfo.get("endTime"), searchInfo.get("endTime"));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return queryHelper;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public Page<Project> list(Map<String, String> searchInfo, int pageNumber, int pageSize){
|
|||
|
|
QueryHelper queryHelper = getQueryHelper(searchInfo, pageNumber, pageSize);
|
|||
|
|
return pagination.paginate(queryHelper.getSql(), Project.class,pageNumber,pageSize);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|