This commit is contained in:
wangliwen 2022-04-25 15:51:59 +08:00
parent f4a756ec19
commit 2756ed523b
11 changed files with 519 additions and 10 deletions

View File

@ -0,0 +1,91 @@
package io.renren.common.controller;
import com.alibaba.fastjson.JSONObject;
import io.renren.common.page.PageData;
import io.renren.common.utils.Result;
import io.renren.common.validator.ValidatorUtils;
import io.renren.common.validator.group.AddGroup;
import io.renren.common.validator.group.DefaultGroup;
import io.renren.modules.activiti.dto.ProcessInstanceDTO;
import io.renren.modules.activiti.dto.ProcessStartDTO;
import io.renren.modules.activiti.service.ActProcessService;
import io.renren.modules.activiti.service.ActRunningService;
import io.renren.modules.demanData.dto.TDemandDataDTO;
import io.renren.modules.demanData.service.TDemandDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.codehaus.jackson.map.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
@Api(tags = "能力需求")
@RestController
@RequestMapping("/demand/center")
public class DemandDataController {
private static Logger logger = LoggerFactory.getLogger(ResourceMountController.class);
@Autowired
private ActProcessService actProcessService;
@Autowired
private ActRunningService actRunningService;
@Autowired
private TDemandDataService tDemandDataService;
private static String key = "abilitydemandapply";
private static Map<String, Object> params = new HashMap<String, Object>() {
{
put("isLatestVersion", true); // 取最新版本
put("key", key); // 限定 能力资源上架
}
};
@PostMapping(value = "/apply")
@ApiOperation("进行能力需求申请")
public Result<ProcessInstanceDTO> apply(@RequestBody TDemandDataDTO tDemandDataDTO) {
// 仿照请求接口 /act/process/lastestPage
PageData<Map<String, Object>> page = actProcessService.page(params);
if (page.getTotal() <= 0) { //
return new Result().error("联系管理员添加流程:" + key);
}
logger.info("---------------------------------------------------");
logger.info(JSONObject.toJSONString(tDemandDataDTO));
logger.info("####################################################");
tDemandDataDTO.setFlag(1);
ValidatorUtils.validateEntity(tDemandDataDTO, AddGroup.class, DefaultGroup.class);
tDemandDataService.save(tDemandDataDTO);
if (tDemandDataDTO.getId() == null) {
return null;
}
logger.info("-------------------1.保存申请表单成功--------------------------");
// 仿照请求接口 /act/running/startOfBusinessKey
ProcessStartDTO processStartDTO = new ProcessStartDTO();
processStartDTO.setBusinessKey(tDemandDataDTO.getId().toString());
processStartDTO.setProcessDefinitionKey(key); // 限定资源上架
ObjectMapper oMapper = new ObjectMapper();
Map<String, Object> variables = oMapper.convertValue(tDemandDataDTO, Map.class);
processStartDTO.setVariables(variables);
ProcessInstanceDTO dto = actRunningService.startOfBusinessKey(processStartDTO);
logger.info("-------------------2.启动流程成功--------------------------");
logger.info("ProcessInstanceDTO.getBusinessKey:" + dto.getBusinessKey());
if (Long.valueOf(dto.getBusinessKey()) != null) {
// 仿照请求接口 /processForm/tabilityapplication/updateInstanceId
tDemandDataService.updateInstanceId(dto.getProcessInstanceId(), Long.valueOf(dto.getBusinessKey()));
logger.info("-------------------更新updateInstanceId.成功--------------------------");
logger.info("ProcessInstanceDTO.getProcessInstanceId:" + dto.getProcessInstanceId());
}
return new Result<ProcessInstanceDTO>().ok(dto);
}
}

View File

@ -0,0 +1,115 @@
package io.renren.modules.demanData.controller;
import io.renren.common.annotation.LogOperation;
import io.renren.common.constant.Constant;
import io.renren.common.page.PageData;
import io.renren.common.utils.ExcelUtils;
import io.renren.common.utils.Result;
import io.renren.common.validator.AssertUtils;
import io.renren.common.validator.ValidatorUtils;
import io.renren.common.validator.group.AddGroup;
import io.renren.common.validator.group.DefaultGroup;
import io.renren.common.validator.group.UpdateGroup;
import io.renren.modules.demanData.dto.TDemandDataDTO;
import io.renren.modules.demanData.excel.TDemandDataExcel;
import io.renren.modules.demanData.service.TDemandDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* 能力需求评审主体
*
* @author wangliwen wangliwen2@hisense.com
* @since 1.0 2022-04-25
*/
@RestController
@RequestMapping("demanData/tdemanddata")
@Api(tags="能力需求评审主体")
public class TDemandDataController {
@Autowired
private TDemandDataService tDemandDataService;
@GetMapping("page")
@ApiOperation("分页")
@ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String")
})
// @RequiresPermissions("demanData:tdemanddata:page")
public Result<PageData<TDemandDataDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
PageData<TDemandDataDTO> page = tDemandDataService.page(params);
return new Result<PageData<TDemandDataDTO>>().ok(page);
}
@GetMapping("{id}")
@ApiOperation("信息")
// @RequiresPermissions("demanData:tdemanddata:info")
public Result<TDemandDataDTO> get(@PathVariable("id") Long id){
TDemandDataDTO data = tDemandDataService.get(id);
return new Result<TDemandDataDTO>().ok(data);
}
@PostMapping
@ApiOperation("保存")
@LogOperation("保存")
// @RequiresPermissions("demanData:tdemanddata:save")
public Result save(@RequestBody TDemandDataDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
tDemandDataService.save(dto);
return new Result();
}
@PutMapping
@ApiOperation("修改")
@LogOperation("修改")
// @RequiresPermissions("demanData:tdemanddata:update")
public Result update(@RequestBody TDemandDataDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
tDemandDataService.update(dto);
return new Result();
}
@DeleteMapping
@ApiOperation("删除")
@LogOperation("删除")
// @RequiresPermissions("demanData:tdemanddata:delete")
public Result delete(@RequestBody Long[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
tDemandDataService.delete(ids);
return new Result();
}
@GetMapping("export")
@ApiOperation("导出")
@LogOperation("导出")
// @RequiresPermissions("demanData:tdemanddata:export")
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<TDemandDataDTO> list = tDemandDataService.list(params);
ExcelUtils.exportExcelToTarget(response, null, "能力需求评审主体", list, TDemandDataExcel.class);
}
}

View File

@ -0,0 +1,17 @@
package io.renren.modules.demanData.dao;
import io.renren.common.dao.BaseDao;
import io.renren.modules.demanData.entity.TDemandDataEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 能力需求评审主体
*
* @author wangliwen wangliwen2@hisense.com
* @since 1.0 2022-04-25
*/
@Mapper
public interface TDemandDataDao extends BaseDao<TDemandDataEntity> {
void updateInstanceId(String instanceId, Long id);
}

View File

@ -0,0 +1,63 @@
package io.renren.modules.demanData.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 能力需求评审主体
*
* @author wangliwen wangliwen2@hisense.com
* @since 1.0 2022-04-25
*/
@Data
@ApiModel(value = "能力需求评审主体")
public class TDemandDataDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id")
private Long id;
@ApiModelProperty(value = "申请人用户id")
private String applyUserId;
@ApiModelProperty(value = "申请人姓名")
private String applyUserName;
@ApiModelProperty(value = "申请人部门id")
private String applyUserDeptId;
@ApiModelProperty(value = "申请人部门名称")
private String applyUserDeptName;
@ApiModelProperty(value = "申请人联系电话")
private String applyUserPhone;
@ApiModelProperty(value = "需求主题")
private String demandSubject;
@ApiModelProperty(value = "需求描述")
private String demandDetails;
@ApiModelProperty(value = "需求类型(基础设施、数据资源、组件服务、应用资源、知识库)")
private String detailsType;
@ApiModelProperty(value = "需求领域")
private String detailsField;
private Long creator;
private Date createDate;
@ApiModelProperty(value = "附件")
private String enclosure;
@ApiModelProperty(value = "业务标志0:初始化 1:审批中 2:审批拒绝 3:审批通过)")
private Integer flag;
@ApiModelProperty(value = "审批意见")
private String approvalOpinions;
@ApiModelProperty(value = "审批人姓名")
private String approvalUserName;
@ApiModelProperty(value = "审批人部门名称")
private String approvalUserDeptName;
@ApiModelProperty(value = "访问量")
private Long visits;
@ApiModelProperty(value = "实例ID")
private String instanceId;
public TDemandDataDTO() {
this.flag = 0;
this.visits = 0l;
}
}

View File

@ -0,0 +1,85 @@
package io.renren.modules.demanData.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.renren.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 能力需求评审主体
*
* @author wangliwen wangliwen2@hisense.com
* @since 1.0 2022-04-25
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("t_demand_data")
public class TDemandDataEntity extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 申请人用户id
*/
private String applyUserId;
/**
* 申请人姓名
*/
private String applyUserName;
/**
* 申请人部门id
*/
private String applyUserDeptId;
/**
* 申请人部门名称
*/
private String applyUserDeptName;
/**
* 申请人联系电话
*/
private String applyUserPhone;
/**
* 需求主题
*/
private String demandSubject;
/**
* 需求描述
*/
private String demandDetails;
/**
* 需求类型基础设施数据资源组件服务应用资源知识库
*/
private String detailsType;
/**
* 需求领域
*/
private String detailsField;
/**
* 附件
*/
private String enclosure;
/**
* 业务标志0:初始化 1:审批中 2:审批拒绝 3:审批通过
*/
private Integer flag;
/**
* 审批意见
*/
private String approvalOpinions;
/**
* 审批人姓名
*/
private String approvalUserName;
/**
* 审批人部门名称
*/
private String approvalUserDeptName;
/**
* 访问量
*/
private Long visits;
/**
* 实例ID
*/
private String instanceId;
}

View File

@ -0,0 +1,57 @@
package io.renren.modules.demanData.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import lombok.Data;
import java.util.Date;
/**
* 能力需求评审主体
*
* @author wangliwen wangliwen2@hisense.com
* @since 1.0 2022-04-25
*/
@Data
@ContentRowHeight(20)
@HeadRowHeight(20)
@ColumnWidth(25)
public class TDemandDataExcel {
@ExcelProperty(value = "id", index = 0)
private Long id;
@ExcelProperty(value = "申请人用户id", index = 1)
private String applyUserId;
@ExcelProperty(value = "申请人姓名", index = 2)
private String applyUserName;
@ExcelProperty(value = "申请人部门id", index = 3)
private String applyUserDeptId;
@ExcelProperty(value = "申请人部门名称", index = 4)
private String applyUserDeptName;
@ExcelProperty(value = "申请人联系电话", index = 5)
private String applyUserPhone;
@ExcelProperty(value = "需求主题", index = 6)
private String demandSubject;
@ExcelProperty(value = "需求描述", index = 7)
private String demandDetails;
@ExcelProperty(value = "需求类型(基础设施、数据资源、组件服务、应用资源、知识库)", index = 8)
private String detailsType;
@ExcelProperty(value = "需求领域", index = 9)
private String detailsField;
@ExcelProperty(value = "Long", index = 10)
private Long creator;
@ExcelProperty(value = "Date", index = 11)
private Date createDate;
@ExcelProperty(value = "附件", index = 12)
private String enclosure;
@ExcelProperty(value = "业务标志0:初始化 1:审批中 2:审批拒绝 3:审批通过)", index = 13)
private Integer flag;
@ExcelProperty(value = "审批意见", index = 14)
private String approvalOpinions;
@ExcelProperty(value = "审批人姓名", index = 15)
private String approvalUserName;
@ExcelProperty(value = "审批人部门名称", index = 16)
private String approvalUserDeptName;
@ExcelProperty(value = "访问量", index = 17)
private Long visits;
}

View File

@ -0,0 +1,15 @@
package io.renren.modules.demanData.service;
import io.renren.common.service.CrudService;
import io.renren.modules.demanData.dto.TDemandDataDTO;
import io.renren.modules.demanData.entity.TDemandDataEntity;
/**
* 能力需求评审主体
*
* @author wangliwen wangliwen2@hisense.com
* @since 1.0 2022-04-25
*/
public interface TDemandDataService extends CrudService<TDemandDataEntity, TDemandDataDTO> {
void updateInstanceId(String instanceId, Long id);
}

View File

@ -0,0 +1,35 @@
package io.renren.modules.demanData.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.modules.demanData.dao.TDemandDataDao;
import io.renren.modules.demanData.dto.TDemandDataDTO;
import io.renren.modules.demanData.entity.TDemandDataEntity;
import io.renren.modules.demanData.service.TDemandDataService;
import org.springframework.stereotype.Service;
import java.util.Map;
/**
* 能力需求评审主体
*
* @author wangliwen wangliwen2@hisense.com
* @since 1.0 2022-04-25
*/
@Service
public class TDemandDataServiceImpl extends CrudServiceImpl<TDemandDataDao, TDemandDataEntity, TDemandDataDTO> implements TDemandDataService {
@Override
public QueryWrapper<TDemandDataEntity> getWrapper(Map<String, Object> params) {
QueryWrapper<TDemandDataEntity> wrapper = new QueryWrapper<>();
return wrapper;
}
@Override
public void updateInstanceId(String instanceId, Long id) {
baseDao.updateInstanceId(instanceId, id);
}
}

View File

@ -9,7 +9,6 @@ import io.renren.common.validator.ValidatorUtils;
import io.renren.common.validator.group.AddGroup; import io.renren.common.validator.group.AddGroup;
import io.renren.common.validator.group.DefaultGroup; import io.renren.common.validator.group.DefaultGroup;
import io.renren.modules.resource.dto.ResourceDTO; import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.entity.ResourceEntity;
import io.renren.modules.resource.service.ResourceService; import io.renren.modules.resource.service.ResourceService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
@ -19,7 +18,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;

View File

@ -62,7 +62,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
private AttrDao attrDao; private AttrDao attrDao;
@Override @Override
public QueryWrapper<ResourceEntity> getWrapper(Map<String, Object> params){ public QueryWrapper<ResourceEntity> getWrapper(Map<String, Object> params) {
QueryWrapper<ResourceEntity> wrapper = new QueryWrapper<>(); QueryWrapper<ResourceEntity> wrapper = new QueryWrapper<>();
wrapper.eq("type", params.get("type").toString()) wrapper.eq("type", params.get("type").toString())
.eq("del_flag", 0) .eq("del_flag", 0)
@ -81,7 +81,9 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
resourceEntity.setDelFlag(0); resourceEntity.setDelFlag(0);
resourceDao.insert(resourceEntity); resourceDao.insert(resourceEntity);
List<AttrEntity> attrEntities= dto.getInfoList(); BeanUtils.copyProperties(resourceEntity, dto);
List<AttrEntity> attrEntities = dto.getInfoList();
attrEntities.forEach(item -> { attrEntities.forEach(item -> {
item.setDelFlag(0); item.setDelFlag(0);
item.setDataResourceId(resourceID); item.setDataResourceId(resourceID);
@ -107,7 +109,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
ArrayList<Long> list = new ArrayList<>(); ArrayList<Long> list = new ArrayList<>();
list.add(resourceEntity.getId()); list.add(resourceEntity.getId());
attrDao.delete4Resource(list); attrDao.delete4Resource(list);
List<AttrEntity> attrEntities= dto.getInfoList(); List<AttrEntity> attrEntities = dto.getInfoList();
attrEntities.forEach(item -> { attrEntities.forEach(item -> {
item.setDelFlag(0); item.setDelFlag(0);
attrDao.insert(item); attrDao.insert(item);
@ -142,8 +144,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("del_flag", 0) queryWrapper.eq("del_flag", 0)
.like(StringUtils.isNotBlank(resourceDTO.getName()), "name", resourceDTO.getName()) .like(StringUtils.isNotBlank(resourceDTO.getName()), "name", resourceDTO.getName())
.eq(ObjectUtil.isNotNull(resourceDTO.getDistrictId()),"district_id", resourceDTO.getDistrictId()) .eq(ObjectUtil.isNotNull(resourceDTO.getDistrictId()), "district_id", resourceDTO.getDistrictId())
.eq(ObjectUtil.isNotNull(resourceDTO.getDeptId()),"dept_id", resourceDTO.getDeptId()) .eq(ObjectUtil.isNotNull(resourceDTO.getDeptId()), "dept_id", resourceDTO.getDeptId())
.eq("type", resourceDTO.getType()); .eq("type", resourceDTO.getType());
Page<ResourceEntity> entityPage = resourceDao.selectPage(page, queryWrapper); Page<ResourceEntity> entityPage = resourceDao.selectPage(page, queryWrapper);
ArrayList<ResourceDTO> list = new ArrayList<>(); ArrayList<ResourceDTO> list = new ArrayList<>();
@ -164,7 +166,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
resultPage.setTotal(0); resultPage.setTotal(0);
} else { } else {
ArrayList<ResourceDTO> recordLists = new ArrayList<>(); ArrayList<ResourceDTO> recordLists = new ArrayList<>();
for (int i = (pageNum - 1 ) * pageSize; i < j; i++) { for (int i = (pageNum - 1) * pageSize; i < j; i++) {
recordLists.add(resourceDTOS.get(i)); recordLists.add(resourceDTOS.get(i));
} }
resultPage.setRecords(recordLists); resultPage.setRecords(recordLists);
@ -239,7 +241,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
IPage<ResourceEntity> page = new Page<>(jsonObject.getIntValue("pageNum"), jsonObject.getIntValue("pageSize")); IPage<ResourceEntity> page = new Page<>(jsonObject.getIntValue("pageNum"), jsonObject.getIntValue("pageSize"));
QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.orderByDesc("create_date") queryWrapper.orderByDesc("create_date")
.eq(StringUtils.isNotBlank(jsonObject.getString("type")),"type", jsonObject.getString("type")) .eq(StringUtils.isNotBlank(jsonObject.getString("type")), "type", jsonObject.getString("type"))
.eq("del_flag", 0); .eq("del_flag", 0);
IPage<ResourceEntity> entityIPage = resourceDao.selectPage(page, queryWrapper); IPage<ResourceEntity> entityIPage = resourceDao.selectPage(page, queryWrapper);
return entityIPage; return entityIPage;

View File

@ -0,0 +1,31 @@
<?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="io.renren.modules.demanData.dao.TDemandDataDao">
<resultMap type="io.renren.modules.demanData.entity.TDemandDataEntity" id="tDemandDataMap">
<result property="id" column="id"/>
<result property="applyUserId" column="apply_user_id"/>
<result property="applyUserName" column="apply_user_name"/>
<result property="applyUserDeptId" column="apply_user_dept_id"/>
<result property="applyUserDeptName" column="apply_user_dept_name"/>
<result property="applyUserPhone" column="apply_user_phone"/>
<result property="demandSubject" column="demand_subject"/>
<result property="demandDetails" column="demand_details"/>
<result property="detailsType" column="details_type"/>
<result property="detailsField" column="details_field"/>
<result property="creator" column="creator"/>
<result property="createDate" column="create_date"/>
<result property="enclosure" column="enclosure"/>
<result property="flag" column="flag"/>
<result property="approvalOpinions" column="approval_opinions"/>
<result property="approvalUserName" column="approval_user_name"/>
<result property="approvalUserDeptName" column="approval_user_dept_name"/>
<result property="visits" column="visits"/>
</resultMap>
<update id="updateInstanceId">
update t_demand_data set instance_id = #{instanceId} where id = #{id};
</update>
</mapper>