|
@@ -1,49 +1,45 @@
|
|
|
package org.jeecg.modules.prowork.controller;
|
|
|
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
-import java.net.URLDecoder;
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-
|
|
|
+import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiModelProperty;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.constant.CommonConstant;
|
|
|
+import org.jeecg.common.dto.prowork.ProWorkLogicAddReqDTO;
|
|
|
import org.jeecg.common.dto.prowork.ProWorkLogicListReqDTO;
|
|
|
-import org.jeecg.common.system.query.QueryGenerator;
|
|
|
-import org.jeecg.common.util.oConvertUtils;
|
|
|
+import org.jeecg.common.dto.prowork.ProWorkLogicRespDTO;
|
|
|
+import org.jeecg.common.dto.prowork.ProdWorkLogicReqDTO;
|
|
|
+import org.jeecg.common.exception.JeecgBootException;
|
|
|
import org.jeecg.modules.prowork.entity.ProWorkLogic;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.jeecg.modules.prowork.service.ProWorkLogicService;
|
|
|
-import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
|
-import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
|
-import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
|
-import org.jeecgframework.poi.excel.entity.ImportParams;
|
|
|
-import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
-import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
-import org.springframework.web.servlet.ModelAndView;
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
|
|
|
-
|
|
|
+
|
|
|
* @Title: Controller
|
|
|
* @Description: 日志(实施,开发,服务)
|
|
|
* @author: jeecg-boot
|
|
|
* @date: 2021-03-02
|
|
|
* @version: V1.0
|
|
|
*/
|
|
|
+ @Api("日志(实施,开发,服务)接口")
|
|
|
@RestController
|
|
|
@RequestMapping("/prowork/proWorkLogic")
|
|
|
@Slf4j
|
|
@@ -55,36 +51,68 @@ public class ProWorkLogicController {
|
|
|
@ApiOperation(value = "分页查询接口", notes = "日志分页查询")
|
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name="pkOrg", value="组织",required=false, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="type", value="1.开发 2.实施 3.服务",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="billcode", value="单据编号",required=false, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="proName", value="项目名称",required=false, dataType="String"),
|
|
|
})
|
|
|
@GetMapping(value = "/list")
|
|
|
- public Result<IPage<ProWorkLogic>> queryPageList(ProWorkLogicListReqDTO reqDTO,
|
|
|
+ public Result<IPage<ProWorkLogic>> queryPageList(@Valid ProWorkLogicListReqDTO reqDTO,
|
|
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize
|
|
|
) {
|
|
|
Result<IPage<ProWorkLogic>> result = new Result<IPage<ProWorkLogic>>();
|
|
|
- QueryWrapper<ProWorkLogic> queryWrapper = new QueryWrapper<>();
|
|
|
- Page<ProWorkLogic> page = new Page<ProWorkLogic>(pageNo, pageSize);
|
|
|
|
|
|
- if(StringUtils.isNotBlank(reqDTO.getBillcode())){
|
|
|
- queryWrapper.eq("billcode", reqDTO.getBillcode());
|
|
|
- }
|
|
|
-
|
|
|
+ try {
|
|
|
|
|
|
- queryWrapper.eq("pkOrg", reqDTO.getPkOrg());
|
|
|
- queryWrapper.eq("del_flag", CommonConstant.STATUS_NORMAL.toString());
|
|
|
- IPage<ProWorkLogic> pageList = proWorkLogicService.page(page, queryWrapper);
|
|
|
- result.setSuccess(true);
|
|
|
- result.setResult(pageList);
|
|
|
+ QueryWrapper<ProWorkLogic> queryWrapper = new QueryWrapper<>();
|
|
|
+ Page<ProWorkLogic> page = new Page<ProWorkLogic>(pageNo, pageSize);
|
|
|
+ if(StringUtils.isBlank(reqDTO.getType())){
|
|
|
+ throw new JeecgBootException("参数type不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isNotBlank(reqDTO.getBillcode())) {
|
|
|
+ queryWrapper.eq("billcode", reqDTO.getBillcode());
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(reqDTO.getProName())) {
|
|
|
+ queryWrapper.eq("pro_name", reqDTO.getProName());
|
|
|
+ }
|
|
|
+ queryWrapper.eq("type", reqDTO.getType());
|
|
|
+ if(StringUtils.isNotBlank(reqDTO.getPkOrg())) {
|
|
|
+ queryWrapper.eq("pk_org", reqDTO.getPkOrg());
|
|
|
+ }
|
|
|
+
|
|
|
+ queryWrapper.eq("del_flag", CommonConstant.STATUS_NORMAL.toString());
|
|
|
+ IPage<ProWorkLogic> pageList = proWorkLogicService.page(page, queryWrapper);
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setResult(pageList);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ log.info(e.getMessage());
|
|
|
+ result.error500("操作失败:" + e.getMessage());
|
|
|
+ }
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- * 添加
|
|
|
- * @param proWorkLogic
|
|
|
- * @return
|
|
|
- */
|
|
|
+
|
|
|
+ @ApiOperation(value = "新增接口", notes = "新增日志")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="pkOrg", value="组织",required=false, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="billcode", value="单据编号",required=false, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="proId", value="项目id",required=false, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="proName", value="项目名称",required=false, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="startDate", value="开始日期",required=false, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="endDate", value="结束日期",required=false, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="reporter", value="汇报人",required=false, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="milesId", value="里程碑id",required=false, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="milesName", value="里程碑(计划)",required=false, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="currentUser", value="填写人(当前用户)",required=false, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="logicId", value="日志id",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="proArchivesId", value="项目档案id",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="proArchivesMilestone", value="项目档案里程碑",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="content", value="工作内容",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="duration", value="工作时长",required=true, dataType="String"),
|
|
|
+ })
|
|
|
@PostMapping(value = "/add")
|
|
|
- public Result<ProWorkLogic> add(@RequestBody ProWorkLogic proWorkLogic, BindingResult bindingResult) {
|
|
|
+ public Result<ProWorkLogic> add(@RequestBody ProWorkLogicAddReqDTO reqDTO, BindingResult bindingResult) {
|
|
|
Result<ProWorkLogic> result = new Result<ProWorkLogic>();
|
|
|
try {
|
|
|
StringBuilder sb = new StringBuilder();
|
|
@@ -94,7 +122,7 @@ public class ProWorkLogicController {
|
|
|
result.error500(sb.toString());
|
|
|
return result;
|
|
|
}
|
|
|
- proWorkLogicService.save(proWorkLogic);
|
|
|
+ proWorkLogicService.add(reqDTO);
|
|
|
result.success("添加成功!");
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
@@ -103,21 +131,34 @@ public class ProWorkLogicController {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- * 编辑
|
|
|
- * @param proWorkLogic
|
|
|
- * @return
|
|
|
- */
|
|
|
+
|
|
|
+ @ApiOperation(value = "编辑接口", notes = "编辑日志")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="id", value="id",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="pkOrg", value="组织",required=false, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="billcode", value="单据编号",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="proId", value="项目id",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="proName", value="项目名称",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="startDate", value="开始日期",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="endDate", value="结束日期",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="reporter", value="汇报人",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="milesId", value="里程碑id",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="milesName", value="里程碑(计划)",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="currentUser", value="填写人(当前用户)",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="logicId", value="日志id",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="proArchivesId", value="项目档案id",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="proArchivesMilestone", value="项目档案里程碑",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="content", value="工作内容",required=true, dataType="String"),
|
|
|
+ @ApiImplicitParam(name="duration", value="工作时长",required=true, dataType="String"),
|
|
|
+ })
|
|
|
@PutMapping(value = "/edit")
|
|
|
- public Result<ProWorkLogic> edit(@RequestBody ProWorkLogic proWorkLogic) {
|
|
|
+ public Result<ProWorkLogic> edit(@RequestBody ProWorkLogicAddReqDTO reqDTO) {
|
|
|
Result<ProWorkLogic> result = new Result<ProWorkLogic>();
|
|
|
- ProWorkLogic proWorkLogicEntity = proWorkLogicService.getById(proWorkLogic.getId());
|
|
|
+ ProWorkLogic proWorkLogicEntity = proWorkLogicService.getById(reqDTO.getId());
|
|
|
if(proWorkLogicEntity==null) {
|
|
|
result.error500("未找到对应实体");
|
|
|
}else {
|
|
|
- boolean ok = proWorkLogicService.updateById(proWorkLogic);
|
|
|
-
|
|
|
+ boolean ok = proWorkLogicService.edit(reqDTO);
|
|
|
if(ok) {
|
|
|
result.success("修改成功!");
|
|
|
}
|
|
@@ -125,20 +166,19 @@ public class ProWorkLogicController {
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- * 通过id删除
|
|
|
- * @param id
|
|
|
- * @return
|
|
|
- */
|
|
|
+
|
|
|
+ @ApiOperation(value = "通过id删除接口", notes = "通过id删除日志")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="id", value="id",required=false, dataType="String"),
|
|
|
+ })
|
|
|
@DeleteMapping(value = "/delete")
|
|
|
- public Result<ProWorkLogic> delete(@RequestParam(name="id",required=true) String id) {
|
|
|
+ public Result<ProWorkLogic> delete(@RequestBody ProdWorkLogicReqDTO reqDTO) {
|
|
|
Result<ProWorkLogic> result = new Result<ProWorkLogic>();
|
|
|
- ProWorkLogic proWorkLogic = proWorkLogicService.getById(id);
|
|
|
+ ProWorkLogic proWorkLogic = proWorkLogicService.getById(reqDTO.getId());
|
|
|
if(proWorkLogic==null) {
|
|
|
result.error500("未找到对应实体");
|
|
|
}else {
|
|
|
- boolean ok = proWorkLogicService.removeById(id);
|
|
|
+ boolean ok = proWorkLogicService.dropById(proWorkLogic);
|
|
|
if(ok) {
|
|
|
result.success("删除成功!");
|
|
|
}
|
|
@@ -147,32 +187,19 @@ public class ProWorkLogicController {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- * 批量删除
|
|
|
- * @param ids
|
|
|
- * @return
|
|
|
- */
|
|
|
- @DeleteMapping(value = "/deleteBatch")
|
|
|
- public Result<ProWorkLogic> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
|
|
- Result<ProWorkLogic> result = new Result<ProWorkLogic>();
|
|
|
- if(ids==null || "".equals(ids.trim())) {
|
|
|
- result.error500("参数不识别!");
|
|
|
- }else {
|
|
|
- this.proWorkLogicService.removeByIds(Arrays.asList(ids.split(",")));
|
|
|
- result.success("删除成功!");
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
* 通过id查询
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
|
+ @ApiOperation(value = "通过id查询接口", notes = "通过id查询日志")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="id", value="id",required=false, dataType="String"),
|
|
|
+ })
|
|
|
@GetMapping(value = "/queryById")
|
|
|
- public Result<ProWorkLogic> queryById(@RequestParam(name="id",required=true) String id) {
|
|
|
- Result<ProWorkLogic> result = new Result<ProWorkLogic>();
|
|
|
- ProWorkLogic proWorkLogic = proWorkLogicService.getById(id);
|
|
|
+ public Result<ProWorkLogicRespDTO> queryById(@RequestParam(name="id",required=true) String id) {
|
|
|
+ Result<ProWorkLogicRespDTO> result = new Result<ProWorkLogicRespDTO>();
|
|
|
+ ProWorkLogicRespDTO proWorkLogic = proWorkLogicService.queryById(id);
|
|
|
if(proWorkLogic==null) {
|
|
|
result.error500("未找到对应实体");
|
|
|
}else {
|
|
@@ -181,74 +208,4 @@ public class ProWorkLogicController {
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- * 导出excel
|
|
|
- *
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
- */
|
|
|
- @RequestMapping(value = "/exportXls")
|
|
|
- public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
|
|
|
-
|
|
|
- QueryWrapper<ProWorkLogic> queryWrapper = null;
|
|
|
- try {
|
|
|
- String paramsStr = request.getParameter("paramsStr");
|
|
|
- if (oConvertUtils.isNotEmpty(paramsStr)) {
|
|
|
- String deString = URLDecoder.decode(paramsStr, "UTF-8");
|
|
|
- ProWorkLogic proWorkLogic = JSON.parseObject(deString, ProWorkLogic.class);
|
|
|
- queryWrapper = QueryGenerator.initQueryWrapper(proWorkLogic, request.getParameterMap());
|
|
|
- }
|
|
|
- } catch (UnsupportedEncodingException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
|
|
- List<ProWorkLogic> pageList = proWorkLogicService.list(queryWrapper);
|
|
|
-
|
|
|
- mv.addObject(NormalExcelConstants.FILE_NAME, "日志(实施,开发,服务)列表");
|
|
|
- mv.addObject(NormalExcelConstants.CLASS, ProWorkLogic.class);
|
|
|
- mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("日志(实施,开发,服务)列表数据", "导出人:Jeecg", "导出信息"));
|
|
|
- mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
|
|
- return mv;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- * 通过excel导入数据
|
|
|
- *
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
|
- public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
|
|
- MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
|
|
- Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
|
|
- for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
|
|
- MultipartFile file = entity.getValue();
|
|
|
- ImportParams params = new ImportParams();
|
|
|
- params.setTitleRows(2);
|
|
|
- params.setHeadRows(1);
|
|
|
- params.setNeedSave(true);
|
|
|
- try {
|
|
|
- List<ProWorkLogic> listProWorkLogics = ExcelImportUtil.importExcel(file.getInputStream(), ProWorkLogic.class, params);
|
|
|
- for (ProWorkLogic proWorkLogicExcel : listProWorkLogics) {
|
|
|
- proWorkLogicService.save(proWorkLogicExcel);
|
|
|
- }
|
|
|
- return Result.ok("文件导入成功!数据行数:" + listProWorkLogics.size());
|
|
|
- } catch (Exception e) {
|
|
|
- log.error(e.getMessage());
|
|
|
- return Result.error("文件导入失败!");
|
|
|
- } finally {
|
|
|
- try {
|
|
|
- file.getInputStream().close();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return Result.ok("文件导入失败!");
|
|
|
- }
|
|
|
-
|
|
|
}
|