src/main/java/com/product/contract/controller/ProjectInfoController.java
@@ -1,5 +1,7 @@ package com.product.contract.controller; import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSONObject; import com.product.common.lang.StringUtils; import com.product.contract.config.CmnConst; import com.product.contract.config.SystemCode; @@ -7,12 +9,14 @@ import com.product.contract.service.ide.IProjectInfoService; import com.product.core.config.CoreConst; import com.product.core.controller.support.AbstractBaseController; import com.product.core.dao.BaseDao; import com.product.core.entity.DataTableEntity; import com.product.core.entity.FieldSetEntity; import com.product.core.entity.RequestParameterEntity; import com.product.core.exception.BaseException; import com.product.core.spring.context.SpringMVCContextHolder; import com.product.module.sys.version.ApiVersion; import com.product.util.BaseUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -35,6 +39,7 @@ @Autowired public ProjectInfoService projectInfoService; /** * 根据uuid获取项目详情 * @param request @@ -221,7 +226,33 @@ @RequestMapping(value = "/add-update-data-list/{version}", method = RequestMethod.POST) @ApiVersion(1) public String addUpdateDataList(HttpServletRequest request){ FieldSetEntity fse = BaseUtil.getFieldSetEntity(request); if(ObjectUtil.isNotEmpty(fse)){ projectInfoService.saveOrUpdate(fse); } return OK(); } @RequestMapping(value = "/get-data-list/{version}", method = RequestMethod.POST) @ApiVersion(1) public String getDataList(HttpServletRequest request){ FieldSetEntity fse = BaseUtil.getFieldSetEntity(request); if(StringUtils.isNotEmpty(fse.getValues().get("dict_name").toString())){ String dic_name = fse.getValues().get("dict_name").toString(); JSONObject dataList = projectInfoService.getDataList(dic_name); return OK(dataList); }else { return null; } } src/main/java/com/product/contract/service/ProjectInfoService.java
@@ -1,4 +1,7 @@ package com.product.contract.service; import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.product.contract.config.CmnConst; import com.product.contract.service.ide.IProjectInfoService; import com.product.core.dao.BaseDao; @@ -15,9 +18,7 @@ import org.springframework.stereotype.Component; import com.product.common.lang.StringUtils; import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.*; /** * Copyright LX @@ -82,6 +83,66 @@ } /** * 设置资料清单 * @param fse * @throws BaseException */ @Override @Transactional public void saveOrUpdate(FieldSetEntity fse) throws BaseException { String dic_name = fse.getValues().get("dict_name").toString(); StringBuilder filterSb = new StringBuilder(64);; filterSb.append( " project_type = "+dic_name); DataTableEntity dataListNew = fse.getSubData().get("product_project_manager_data_list"); for (int i = 0; i < dataListNew.getRows(); i++) { FieldSetEntity fs = dataListNew.getData().get(i); //此时为新增数据 if(ObjectUtil.isNotEmpty(fs.getValues().get("~uuid~"))){ fs.setValue("project_type",dic_name); fs.setValue("org_level_uuid", SpringMVCContextHolder.getCurrentUser().getOrg_level_uuid()); fs.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id()); fs.setValue("created_utc_datetime",new Date()); baseDao.add(fs); }else if(ObjectUtil.isNotEmpty(fs.getValues().get("~type~"))&&fs.getValues().get("~type~").toString().equals("del")){ StringBuilder filter = new StringBuilder(64); filter.append( "uuid = '"+fs.getValues().get("uuid")+"'"); filter.append(" and id = "+fs.getValues().get("id")); baseDao.delete("product_project_manager_data_list",filter.toString(),new Object[]{}); }else { fs.setValue("updated_by",SpringMVCContextHolder.getCurrentUser().getUser_id()); fs.setValue("updated_utc_datetime",new Date()); baseDao.update(fs); } } } /** * 获取资料清单列表(分项目类型) * @param dict_value * @return * @throws BaseException */ @Override public JSONObject getDataList(String dict_value) throws BaseException { JSONObject jsonObject=new JSONObject(); if(!StringUtils.isEmpty(dict_value)){ StringBuilder filterSb = new StringBuilder(64);; filterSb.append( " project_type = "+dict_value); DataTableEntity product_project_manager_data_list = baseDao.listTable("product_project_manager_data_list", filterSb.toString(), new Object[]{}); JSONArray objects = BaseUtil.dataTableEntityToJson(product_project_manager_data_list); jsonObject.put("data",objects); } return jsonObject; } /** * 获取合同列表 * @param fs * @return src/main/java/com/product/contract/service/ide/IProjectInfoService.java
@@ -1,5 +1,6 @@ package com.product.contract.service.ide; import com.alibaba.fastjson.JSONObject; import com.product.core.entity.FieldSetEntity; import com.product.core.exception.BaseException; @@ -14,4 +15,10 @@ boolean deleteProjectInfo(FieldSetEntity fs) throws BaseException; void saveOrUpdate(FieldSetEntity fse) throws BaseException; JSONObject getDataList(String dic_value) throws BaseException; }