songhuangfeng123
2022-09-01 b854d8d7604329dcf99584d15f83ff02076d9e07
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
package com.gkhy.safePlatform.targetDuty.controller;
 
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.gkhy.safePlatform.commons.enums.ResultCodes;
import com.gkhy.safePlatform.commons.query.PageQuery;
import com.gkhy.safePlatform.commons.utils.PageUtils;
import com.gkhy.safePlatform.commons.vo.ResultVO;
import com.gkhy.safePlatform.targetDuty.entity.TargetExamine;
import com.gkhy.safePlatform.targetDuty.model.dto.req.TargetExamineQueryCriteria;
import com.gkhy.safePlatform.targetDuty.service.CommonService;
import com.gkhy.safePlatform.targetDuty.service.TargetExamineService;
import com.gkhy.safePlatform.targetDuty.service.TargetMngService;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
 
/**
 * (TargetExamine)表控制层
 *
 * @author xurui
 * @since 2022-07-22 09:30:01
 */
@RestController
@RequestMapping("targetExamine")
public class TargetExamineController {
    /**
     * 服务对象
     */
    @Resource
    private TargetExamineService targetExamineService;
    @Resource
    private TargetMngService targetMngService;
 
    @Resource
    private CommonService commonService;
 
//    /**
//     * 通过主键查询单条数据
//     *
//     * @param targetId 主键
//     * @return 单条数据
//     */
//    @GetMapping(value = "/selectOne/{targetId}")
//    public ResultVO selectOne(@PathVariable Long targetId) {
//        TargetExamineDto dto = new TargetExamineDto();
//        TargetMng targetMng = targetMngService.getById(targetId);
//        if(targetMng == null) {
//            return new ResultVO<>(ResultCodes.CLIENT_PROJECT_NOT_EXIST);
//        }
//
//        TargetExamineQueryCriteria criteria = new TargetExamineQueryCriteria();
//        criteria.setTargetId(targetId);
//
//        List<TargetExamineDivideDto> respList = BeanCopyUtils.copyBeanList(this.targetExamineService.queryAll(criteria), TargetExamineDivideDto.class);
//
//
//        // --------------------------- 获取部门信息-----------------------
//        //收集所用到的部门ID
//        Set<Long> collectDepIdSet = new HashSet();
//        respList.forEach(f->{
//            collectDepIdSet.add(f.getDutyDepartmentId());
//            collectDepIdSet.add(f.getMakerDepartmentId());
//        });
//        //获取部门名集合
//        Map<Long,String> depNameMap = commonService.getDepName(collectDepIdSet);
//
//        respList.forEach(f->{
//            f.setDutyDepartmentName(depNameMap.get(f.getDutyDepartmentId()));
//            f.setMakerDepartmentName(depNameMap.get(f.getMakerDepartmentId()));
//        });
//
//        dto.setExamineList(respList);
//        dto.setId(targetMng.getId());
//        dto.setIndexNum(targetMng.getIndexNum());
//        dto.setqName(targetMng.getqName());
//        dto.setValue(targetMng.getValue());
//        dto.setYear(targetMng.getYear());
//        return new ResultVO<>(ResultCodes.OK,dto);
//    }
 
 
 
    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping(value = "/selectOne/{id}")
    public ResultVO selectOne(@PathVariable Serializable id) {
        return new ResultVO<>(ResultCodes.OK,this.targetExamineService.getById(id));
    }
 
 
    /**
     * 新增或者修改数据
     *
     * @param infoDto 实体对象
     * @return 修改结果
     */
    @PostMapping(value = "/addOrUpdate")
    public ResultVO update(@RequestBody TargetExamine infoDto) {
        infoDto.setExamineDate(new Timestamp(new Date().getTime()));
        if (infoDto.getId() == null) {
            return new ResultVO<>(ResultCodes.OK,targetExamineService.save(infoDto));
        } else {
            targetExamineService.update(infoDto,new UpdateWrapper<TargetExamine>().eq("id",infoDto.getId()));
            return new ResultVO<>(ResultCodes.OK);
        }
    }
 
    /**
     * 删除数据
     *
     * @param ids 主键结合
     * @return 删除结果
     */
    @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);
 
        List<TargetExamine> delList = new ArrayList<>();
        idList.forEach(f->{
            TargetExamine info = new TargetExamine();
            info.setDelFlag(1);
            info.setId(f);
            delList.add(info);
        });
        this.targetExamineService.updateBatchById(delList);
        return new ResultVO<>(ResultCodes.OK);
    }
 
 
    public static void main(String[] args) {
//        TargetExamineSaveOrUpdate saveOrUpdate = new TargetExamineSaveOrUpdate();
//        saveOrUpdate.setDelIds("1,2");
//
//
//        List<TargetExamine> examineList = Lists.newArrayList();
//        TargetExamine item = new TargetExamine();
//        item.setTargetDivideDetailId(1L);
//        item.setUploadValue("2");
//        item.setUploadDate(new Timestamp(new java.util.Date().getTime()));
//        item.setExamineResult(1);
//        item.setExaminePersonId(0L);
//        item.setExamineDate(new Timestamp(new java.util.Date().getTime()));
//        examineList.add(item);
//        saveOrUpdate.setExamineList(examineList);
//        System.out.println(JSONObject.toJSONString(saveOrUpdate));
    }
}