1.项目立项控制器根据编号/名称获取项目id,增加逻辑删除条件

查询方法修改
2.新增项目项目预算执行率监控周报三层结构
This commit is contained in:
zty 2024-07-08 16:31:11 +08:00
parent f7839f0dab
commit 01ba956270
12 changed files with 375 additions and 2 deletions

View File

@ -372,8 +372,9 @@ public class Api {
*/
public static final String PROJECT_WEEKLY = PROJECT_PREFIX + "/weekly";
public static final String PROJECT_WEEKLY_ADD = PROJECT_WEEKLY + "/add";
public static final String PROJECT_WEEKLY_BUDGET = PROJECT_PREFIX + "/weekly/budget";
public static final String PROJECT_WEEKLY_BUDGET_ADD = PROJECT_WEEKLY_BUDGET + "/add";
public static final String PROJECT_WEEKLY_BUDGET_DEL = PROJECT_WEEKLY_BUDGET + "/del";
public static final String PROJECT_INFO_GETPROJECTS = PROJECT_INFO;

View File

@ -0,0 +1,23 @@
package com.xqopen.kehui.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.xqopen.kehui.project.dto.ProjectBudgetImplementAddDto;
import com.xqopen.kehui.project.dto.ProjectBudgetImplementFindReq;
import com.xqopen.kehui.project.entity.ProjectBudgetImplement;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author admin
* @description 针对表project_budget_implement的数据库操作Mapper
* @createDate 2024-07-08 10:20:02
* @Entity .domain.ProjectBudgetImplement
*/
@Repository
public interface ProjectBudgetImplementDao extends BaseMapper<ProjectBudgetImplement> {
List<ProjectBudgetImplementAddDto> getList(Page<ProjectBudgetImplementAddDto> page, @Param("projectBudgetImplementFindReq") ProjectBudgetImplementFindReq projectBudgetImplementFindReq);
}

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xqopen.kehui.mapper.ProjectBudgetImplementDao">
<resultMap id="BaseResultMap" type="com.xqopen.kehui.project.entity.ProjectBudgetImplement">
<id property="id" column="id_" jdbcType="VARCHAR"/>
<result property="projectId" column="project_id" jdbcType="VARCHAR"/>
<result property="budget" column="budget" jdbcType="VARCHAR"/>
<result property="execute" column="execute" jdbcType="VARCHAR"/>
<result property="implementationRate" column="implementation_rate" jdbcType="VARCHAR"/>
<result property="isDeleted" column="is_deleted" jdbcType="VARCHAR"></result>
<result property="createdBy" column="created_by" jdbcType="VARCHAR"/>
<result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
<result property="updatedBy" column="updated_by" jdbcType="VARCHAR"/>
<result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id_,project_id,budget,
execute,implementationrate,created_by,
created_at,updated_by,updated_at
</sql>
<select id="getList" resultType="com.xqopen.kehui.project.dto.ProjectBudgetImplementAddDto">
select pbi.*,pi.project_no,pi.project_name from project_budget_implement pbi left join project_info pi on pi.id_=cast(pbi.project_id as BIGINT)
where 1=1 and pbi.is_deleted='0' and pi.is_deleted=false
<if test="projectBudgetImplementFindReq.id!=null">
and pbi.id_=#{projectBudgetImplementFindReq.id}
</if>
</select>
</mapper>

View File

@ -0,0 +1,127 @@
package com.xqopen.kehui.project.action;
import com.alibaba.fastjson.support.spring.FastJsonJsonView;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.xqopen.kehui.Api;
import com.xqopen.kehui.exception.ErrorCode;
import com.xqopen.kehui.exception.XQException;
import com.xqopen.kehui.project.api.ProjectBudgetImplementApi;
import com.xqopen.kehui.project.dto.ProjectBudgetImplementAddDto;
import com.xqopen.kehui.project.dto.ProjectBudgetImplementFindReq;
import com.xqopen.kehui.project.entity.ProjectBudgetImplement;
import com.xqopen.kehui.project.entity.ProjectInfo;
import com.xqopen.kehui.project.service.IProjectBudgetImplementService;
import com.xqopen.kehui.project.service.IProjectInfoService;
import com.xqopen.kehui.util.ApiResponse;
import com.xqopen.kehui.util.ResultListReqUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.sql.Timestamp;
import java.util.List;
@Slf4j
@RestController
@RequestMapping(produces = FastJsonJsonView.DEFAULT_CONTENT_TYPE)
public class ProjectBudgetImplementController implements ProjectBudgetImplementApi {
@Autowired
private IProjectBudgetImplementService projectBudgetImplementService;
@Autowired
private IProjectInfoService projectInfoService;
@PostMapping(Api.PROJECT_WEEKLY_BUDGET)
@Override
public String list(@RequestHeader Long userId,@RequestBody ProjectBudgetImplementFindReq projectBudgetImplementFindReq) throws XQException {
try {
Page<ProjectBudgetImplementAddDto> page = new Page<>(projectBudgetImplementFindReq.getPageNo(), projectBudgetImplementFindReq.getPageSize());
List<ProjectBudgetImplementAddDto> list = projectBudgetImplementService.getList(page, projectBudgetImplementFindReq);
ResultListReqUtil listReq = new ResultListReqUtil();
listReq.setLs(list);
listReq.setTotal(page.getTotal());
listReq.setPages(page.getPages());
return ApiResponse.fillSuccess(listReq);
} catch (Exception e) {
log.error("ProjectBudgetImplementController.list", e);
throw new XQException(ErrorCode.PROJECTINFO_EXCEPTION_ERROR, null);
}
}
@PostMapping(Api.PROJECT_WEEKLY_BUDGET_ADD)
@Override
public String add(@RequestHeader Long userId,@RequestBody ProjectBudgetImplementAddDto projectBudgetImplement) throws XQException {
try {
if (!ObjectUtils.isEmpty(projectBudgetImplement)) {
String projectNo = projectBudgetImplement.getProjectNo();
String projectName = projectBudgetImplement.getProjectName();
if (!StringUtils.isEmpty(projectNo)) {
if (!StringUtils.isEmpty(projectName)) {
ProjectInfo project = getProject(projectNo, projectName);
if (!ObjectUtils.isEmpty(project)) {
projectBudgetImplement.setProjectId(String.valueOf(project.getId()));
verification(projectBudgetImplement);
if (!StringUtils.isEmpty(projectBudgetImplement.getId())) {
projectBudgetImplement.setUpdatedBy(String.valueOf(userId));
projectBudgetImplement.setUpdatedAt(new Timestamp(System.currentTimeMillis()));
projectBudgetImplementService.updateById(projectBudgetImplement);
} else {
projectBudgetImplement.setCreatedBy(String.valueOf(userId));
projectBudgetImplement.setCreatedAt(new Timestamp(System.currentTimeMillis()));
projectBudgetImplementService.insert(projectBudgetImplement);
}
return ApiResponse.fillSuccess("操作成功!");
}else ApiResponse.fillFail("你输入的项目编号/名称不存在!");
}
}
}
} catch (Exception e) {
log.error("ProjectBudgetImplementController.add", e);
throw new XQException(ErrorCode.PROJECTINFO_EXCEPTION_ERROR, null);
}
return ApiResponse.fillFail("操作失败!");
}
@Override
@DeleteMapping(Api.PROJECT_WEEKLY_BUDGET_DEL)
public String delete(@RequestHeader Long user,@RequestParam Long id) throws XQException {
try {
EntityWrapper<ProjectBudgetImplement> wrapper = new EntityWrapper<>();
wrapper.eq("is_deleted", "1");
ProjectBudgetImplement projectBudgetImplement = new ProjectBudgetImplement();
projectBudgetImplement.setId(String.valueOf(id));
projectBudgetImplementService.update(projectBudgetImplement, wrapper);
return ApiResponse.fillSuccess("操作成功!");
} catch (Exception e) {
log.error("ProjectBudgetImplementController.delete", e);
throw new XQException(ErrorCode.PROJECTINFO_EXCEPTION_ERROR, null);
}
}
// 校验
private void verification(ProjectBudgetImplement projectBudgetImplement) throws XQException {
if (StringUtils.isEmpty(projectBudgetImplement.getBudget())) {
throw new XQException(ErrorCode.PROJECTINFO_PROJECTNAME_EMPTY_ERROR, null);
}
if (StringUtils.isEmpty(projectBudgetImplement.getExecute())) {
throw new XQException(ErrorCode.PROJECTINFO_PROJECTCATEGORY_EMPTY_ERROR, null);
}
if (StringUtils.isEmpty(projectBudgetImplement.getImplementationRate())) {
throw new XQException(ErrorCode.PROJECTINFO_PROJECTSTEP_EMPTY_ERROR, null);
}
if (StringUtils.isEmpty(projectBudgetImplement.getProjectId())) {
throw new XQException(ErrorCode.PROJECTINFO_PROJECTSTEP_EMPTY_ERROR, null);
}
}
private ProjectInfo getProject(String projectNo, String projectName) {
EntityWrapper<ProjectInfo> wrapper = new EntityWrapper<>();
wrapper.eq("project_name", projectName);
wrapper.eq("project_no", projectNo);
wrapper.eq("is_deleted", false);
return projectInfoService.selectOne(wrapper);
}
}

View File

@ -99,6 +99,7 @@ public class ProjectWeeklyController implements ProjectWeeklyApi {
String projectName = ext.get("projectName").toString();
if (!StringUtils.isEmpty(projectNo)) wrapper.eq("project_no", projectNo);
if (!StringUtils.isEmpty(projectName)) wrapper.eq("project_name", projectName);
wrapper.eq("is_deleted",false);
wrapper.eq("project_category", "init");
return projectInfoService.selectOne(wrapper);
}
@ -122,6 +123,7 @@ public class ProjectWeeklyController implements ProjectWeeklyApi {
projectWeekly.setIsDeleted("0");
projectWeekly.setUserId(String.valueOf(userId));
projectWeekly.setWeeklyType("0");
if(!StringUtils.isEmpty(projectWeeklyFindReq.getId()!=null))projectWeekly.setId(projectWeeklyFindReq.getId());
List<ProjectWeeklyDto> list = projectWeeklyService.getList(page, projectWeekly);
//判断当前账号是否是项目专员/负责人
@ -140,6 +142,7 @@ public class ProjectWeeklyController implements ProjectWeeklyApi {
projectWeekly1.setIsDeleted("0");
projectWeekly1.setWeeklyType("0");
projectWeekly1.setProjectId(weekly.getProjectId());
if(!StringUtils.isEmpty(projectWeeklyFindReq.getId()!=null))projectWeekly1.setId(projectWeeklyFindReq.getId());
list.addAll(projectWeeklyService.getList(page, projectWeekly1));
}

View File

@ -0,0 +1,34 @@
package com.xqopen.kehui.project.api;
import com.xqopen.kehui.exception.XQException;
import com.xqopen.kehui.project.dto.ProjectAchievementResp;
import com.xqopen.kehui.project.dto.ProjectBudgetImplementAddDto;
import com.xqopen.kehui.project.dto.ProjectBudgetImplementFindReq;
import com.xqopen.kehui.util.ApiResponse;
import com.xqopen.kehui.util.Constants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
@Api(value = "项目预算执行率管理", tags = Constants.MODULE_PROJECT, description = "项目模块")
public interface ProjectBudgetImplementApi {
@ApiOperation(value = "获取项目预算执行率列表", notes = "获取项目预算执行率列表", response = ProjectAchievementResp.class)
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "登录标识符", required = true, paramType = "header", dataType = "String"),
@ApiImplicitParam(name = "userId", value = "用户id", required = true, paramType = "header", dataType = "Long"),
})
String list(Long userId, ProjectBudgetImplementFindReq projectBudgetImplementFindReq) throws XQException;
@ApiOperation(value = "新增项目预算执行率监控周报", notes = "新增项目预算执行率监控周报", response = ApiResponse.class)
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "登录标识符", required = true, paramType = "header", dataType = "String"),
@ApiImplicitParam(name = "userId", value = "用户id", required = true, paramType = "header", dataType = "Long"),
})
String add(Long userId, ProjectBudgetImplementAddDto projectBudgetImplement) throws XQException;
@ApiOperation(value = "删除项目预算执行率监控周报", notes = "删除项目预算执行率监控周报", response = ApiResponse.class)
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "登录标识符", required = true, paramType = "header", dataType = "String"),
@ApiImplicitParam(name = "userId", value = "用户id", required = true, paramType = "header", dataType = "Long"),
})
String delete(Long user,Long id) throws XQException;
}

View File

@ -0,0 +1,10 @@
package com.xqopen.kehui.project.dto;
import com.xqopen.kehui.project.entity.ProjectBudgetImplement;
import lombok.Data;
@Data
public class ProjectBudgetImplementAddDto extends ProjectBudgetImplement {
private String projectNo;
private String projectName;
}

View File

@ -0,0 +1,10 @@
package com.xqopen.kehui.project.dto;
import com.xqopen.kehui.project.entity.ProjectBudgetImplement;
import lombok.Data;
@Data
public class ProjectBudgetImplementFindReq extends ProjectBudgetImplement {
private Integer pageNo;
private Integer pageSize;
}

View File

@ -0,0 +1,69 @@
package com.xqopen.kehui.project.entity;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import lombok.Data;
import java.io.Serializable;
/**
*
* @TableName project_budget_implement
*/
@TableName("project_budget_implement")
@Data
public class ProjectBudgetImplement implements Serializable {
/**
*
*/
@TableId(value = "id_", type = IdType.AUTO)
private String id;
/**
*
*/
private String projectId;
/**
*
*/
private String budget;
/**
*
*/
private String execute;
/**
*
*/
private String implementationRate;
/**
*
*/
private String isDeleted;
private String createdBy;
/**
*
*/
private java.sql.Timestamp createdAt;
/**
*
*/
private String updatedBy;
/**
*
*/
private java.sql.Timestamp updatedAt;
private static final long serialVersionUID = 1L;
}

View File

@ -0,0 +1,18 @@
package com.xqopen.kehui.project.service;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.xqopen.kehui.project.dto.ProjectBudgetImplementAddDto;
import com.xqopen.kehui.project.dto.ProjectBudgetImplementFindReq;
import com.xqopen.kehui.project.entity.ProjectBudgetImplement;
import java.util.List;
/**
* @author admin
* @description 针对表project_budget_implement的数据库操作Service
* @createDate 2024-07-08 10:20:02
*/
public interface IProjectBudgetImplementService extends IService<ProjectBudgetImplement> {
List<ProjectBudgetImplementAddDto> getList(Page<ProjectBudgetImplementAddDto> page, ProjectBudgetImplementFindReq projectBudgetImplementFindReq);
}

View File

@ -0,0 +1,29 @@
package com.xqopen.kehui.project.service.impl;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.xqopen.kehui.mapper.ProjectBudgetImplementDao;
import com.xqopen.kehui.project.dto.ProjectBudgetImplementAddDto;
import com.xqopen.kehui.project.dto.ProjectBudgetImplementFindReq;
import com.xqopen.kehui.project.entity.ProjectBudgetImplement;
import com.xqopen.kehui.project.service.IProjectBudgetImplementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author admin
* @description 针对表project_budget_implement的数据库操作Service实现
* @createDate 2024-07-08 10:20:02
*/
@Service
public class IProjectBudgetImplementServiceImpl extends ServiceImpl<ProjectBudgetImplementDao, ProjectBudgetImplement>
implements IProjectBudgetImplementService {
@Autowired
private ProjectBudgetImplementDao budgetImplementDao;
@Override
public List<ProjectBudgetImplementAddDto> getList(Page<ProjectBudgetImplementAddDto> page, ProjectBudgetImplementFindReq projectBudgetImplementFindReq) {
return budgetImplementDao.getList(page,projectBudgetImplementFindReq);
}
}

View File

@ -0,0 +1,17 @@
package com.xqopen.kehui.util;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class ResultListReqUtil<T>{
@ApiModelProperty(value = "项目列表", required = true, position = 3)
private List<T> ls;
@ApiModelProperty(value = "总记录数", required = true, position = 3)
private long total;
@ApiModelProperty(value = "总页数", required = true, position = 3)
private int pages;
}