From b854d8d7604329dcf99584d15f83ff02076d9e07 Mon Sep 17 00:00:00 2001 From: songhuangfeng123 <shf18767906695@163.com> Date: 星期四, 01 九月 2022 10:52:04 +0800 Subject: [PATCH] 假删除fix --- goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/controller/TargetMngController.java | 65 +++++++++++++++++++++++++++----- 1 files changed, 54 insertions(+), 11 deletions(-) diff --git a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/controller/TargetMngController.java b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/controller/TargetMngController.java index ce65094..023a55e 100644 --- a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/controller/TargetMngController.java +++ b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/controller/TargetMngController.java @@ -3,6 +3,7 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.gkhy.safePlatform.commons.co.ContextCacheUser; import com.gkhy.safePlatform.commons.enums.ResultCodes; import com.gkhy.safePlatform.commons.query.PageQuery; import com.gkhy.safePlatform.commons.utils.BeanCopyUtils; @@ -10,6 +11,7 @@ import com.gkhy.safePlatform.commons.vo.ResultVO; import com.gkhy.safePlatform.targetDuty.entity.TargetDivideDetail; import com.gkhy.safePlatform.targetDuty.entity.TargetMng; +import com.gkhy.safePlatform.targetDuty.model.dto.req.TargetCheckAndSubmitQueryCriteria; import com.gkhy.safePlatform.targetDuty.model.dto.req.TargetMngImportExcel; import com.gkhy.safePlatform.targetDuty.model.dto.req.TargetMngQueryCriteria; import com.gkhy.safePlatform.targetDuty.model.dto.resp.TargetMngExcel; @@ -20,6 +22,7 @@ import com.gkhy.safePlatform.targetDuty.utils.poihelper.ExcelUtil; import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.Authentication; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -32,7 +35,6 @@ import java.net.URLEncoder; import java.sql.Timestamp; import java.util.*; -import java.util.stream.Collectors; /** * 目标指标(TargetMng)表控制层 @@ -69,9 +71,9 @@ return new ResultVO<>(ResultCodes.CLIENT_PARAM_ILLEGAL,"缺少targetType"); } PageUtils.checkCheck(pageQuery); - return this.targetMngService.queryAll(pageQuery); + return this.targetMngService.queryAll(pageQuery); } - + /** * 通过主键查询单条数据 @@ -112,14 +114,27 @@ * @param ids 主键结合 * @return 删除结果 */ - @GetMapping(value = "/delete") - public ResultVO delete(String ids) { - List<String> idList = Arrays.stream(ids.split(",")) - .collect(Collectors.toList()); + @RequestMapping(value = "/delete",method = RequestMethod.POST) + public ResultVO delete(@RequestBody Long[] ids) { + if(ids == null){ + return new ResultVO<>(ResultCodes.CLIENT_PARAM_ILLEGAL); + } + List<Long> idList = Arrays.asList(ids); //删除关联表数据 - this.targetDivideDetailService.remove(new QueryWrapper<TargetDivideDetail>().in("target_id",idList)); + UpdateWrapper<TargetDivideDetail> updateWrapper = new UpdateWrapper<>(); + updateWrapper.in("target_id",idList); + TargetDivideDetail detail = new TargetDivideDetail(); + detail.setDelFlag(1); + this.targetDivideDetailService.update(detail,updateWrapper); - this.targetMngService.removeByIds(idList); + List<TargetMng> delList = new ArrayList<>(); + idList.forEach(f->{ + TargetMng info = new TargetMng(); + info.setDelFlag(1); + info.setId(f); + delList.add(info); + }); + this.targetMngService.updateBatchById(delList); return new ResultVO<>(ResultCodes.OK); } @@ -132,7 +147,7 @@ Map<String,String> map = new LinkedHashMap<>(); map.put("1","安全目标指标"); map.put("2","目标指标编号"); - map.put("3","指标类型 1:年指标 2:月指标"); + map.put("3","指标类型 1:年指标 2:月指标 3:半年 4:季度"); map.put("4","年度"); map.put("5","指标值"); map.put("6","指标级别 1:公司级 2:部门分厂级 3:工段班组级"); @@ -203,6 +218,34 @@ } + + /** + * 分页查询所有数据 -- 【目标检查上报页面】使用 + * + * @param pageQuery 查询实体 + * @return 所有数据 + */ + @PostMapping(value = "/checkAndSubimt/list") + public ResultVO list(Authentication authentication, @RequestBody PageQuery<TargetCheckAndSubmitQueryCriteria> pageQuery){ + if(pageQuery.getSearchParams().getRelateType() == null){ + return new ResultVO<>(ResultCodes.CLIENT_PARAM_ILLEGAL,"缺少targetType"); + } + PageUtils.checkCheck(pageQuery); + ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal(); + return this.targetMngService.queryAll(currentUser.getUid(),pageQuery); + } + + /** + * 统计 + * + * @return 删除结果 + */ + @GetMapping(value = "/statistics") + public ResultVO statistics(TargetMngQueryCriteria criteria) { + return new ResultVO<>(ResultCodes.OK,this.targetMngService.statistics(criteria)); + } + + public static void main(String[] args) { TargetMng mng = new TargetMng(); mng.setqName("12"); @@ -217,4 +260,4 @@ System.out.println(JSONObject.toJSONString(mng)); } -} +} \ No newline at end of file -- Gitblit v1.9.2