SpmkController.java 39.3 KB
Newer Older
yuquan.zhu committed
1 2
package cn.timer.api.controller.spmk;

3
import java.util.ArrayList;
tangzhaoqian committed
4
import java.util.Date;
lal committed
5
import java.util.HashMap;
tangzhaoqian committed
6
import java.util.HashSet;
yuquan.zhu committed
7
import java.util.List;
tangzhaoqian committed
8
import java.util.Set;
yuquan.zhu committed
9 10 11

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
12 13
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.MethodArgumentNotValidException;
yuquan.zhu committed
14 15 16 17 18 19 20
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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;
21
import org.springframework.web.bind.annotation.RequestParam;
yuquan.zhu committed
22 23 24 25
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
26
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
yuquan.zhu committed
27
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
28
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
yuquan.zhu committed
29 30

import cn.hutool.core.bean.BeanUtil;
tangzhaoqian committed
31
import cn.hutool.core.collection.CollUtil;
32
import cn.hutool.core.collection.CollectionUtil;
33
import cn.hutool.core.lang.Console;
yuquan.zhu committed
34
import cn.hutool.core.util.ObjectUtil;
35
import cn.hutool.json.JSONObject;
tangzhaoqian committed
36 37
import cn.timer.api.aspect.lang.annotation.Log;
import cn.timer.api.aspect.lang.enums.BusinessType;
lal committed
38 39
import cn.timer.api.bean.kqgl.PunchRecord;
import cn.timer.api.bean.kqmk.KqglAssoLeaveRules;
40
import cn.timer.api.bean.qyzx.QyzxEmpEntAsso;
41 42 43 44
import cn.timer.api.bean.spmk.SpmkApprovalG;
import cn.timer.api.bean.spmk.SpmkApprovalTemplate;
import cn.timer.api.bean.spmk.SpmkApprovalTemplateG;
import cn.timer.api.bean.spmk.SpmkApproveDetail;
45
import cn.timer.api.bean.spmk.SpmkApproveExecuteRecord;
46 47
import cn.timer.api.bean.spmk.SpmkApproveSummary;
import cn.timer.api.bean.spmk.SpmkCustomApproval;
tangzhaoqian committed
48
import cn.timer.api.bean.spmk.SpmkExecutor;
yuquan.zhu committed
49
import cn.timer.api.bean.spmk.SpmkIcon;
50
import cn.timer.api.bean.spmk.SpmkInitiatorConfig;
51
import cn.timer.api.bean.yggl.YgglMainEmp;
tangzhaoqian committed
52
import cn.timer.api.bean.zzgl.ZzglBmgwM;
yuquan.zhu committed
53 54
import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
55
import cn.timer.api.config.enuminterface.SpmkEnumInterface;
56
import cn.timer.api.config.enuminterface.SpmkEnumInterface.ApproveSummarySts;
tangzhaoqian committed
57
import cn.timer.api.config.enuminterface.SpmkEnumInterface.ExecutorSts;
58
import cn.timer.api.config.enums.CommonEnum;
59
import cn.timer.api.config.enums.SysRoleType;
60
import cn.timer.api.config.exception.CustomException;
61
import cn.timer.api.config.validation.Insert;
62
import cn.timer.api.config.validation.Ranks;
63
import cn.timer.api.config.validation.Update;
64
import cn.timer.api.config.validation.ValidList;
65
import cn.timer.api.controller.spmk.service.SpmkService;
66
import cn.timer.api.controller.yggl.service.YgglService;
67
import cn.timer.api.controller.zzgl.service.ZzglBmgwMService;
lal committed
68
import cn.timer.api.dao.kqgl.PunchRecordMapper;
69
import cn.timer.api.dao.qyzx.QyzxEmpEntAssoMapper;
70 71 72 73 74 75 76 77 78
import cn.timer.api.dao.spmk.SpmkApprovalGMapper;
import cn.timer.api.dao.spmk.SpmkApprovalTemplateGMapper;
import cn.timer.api.dao.spmk.SpmkApprovalTemplateMapper;
import cn.timer.api.dao.spmk.SpmkApproveDetailMapper;
import cn.timer.api.dao.spmk.SpmkApproveExecuteRecordMapper;
import cn.timer.api.dao.spmk.SpmkApproveSummaryMapper;
import cn.timer.api.dao.spmk.SpmkCustomApprovalMapper;
import cn.timer.api.dao.spmk.SpmkExecutorMapper;
import cn.timer.api.dao.spmk.SpmkInitiatorConfigMapper;
lal committed
79
import cn.timer.api.dto.spmk.ApprovedQuantityDto;
80
import cn.timer.api.dto.spmk.ApprovingDto;
81
import cn.timer.api.dto.spmk.FlowChildren;
82
import cn.timer.api.dto.spmk.FromData;
83
import cn.timer.api.dto.spmk.MySummaryQueryDto;
84
import cn.timer.api.dto.spmk.Router;
85 86 87 88
import cn.timer.api.dto.spmk.SpmkApprovalTemplateDto;
import cn.timer.api.dto.spmk.SpmkApproveDetailDto;
import cn.timer.api.dto.spmk.SpmkApproveSummaryDto;
import cn.timer.api.dto.spmk.SpmkCustomApprovalDto;
89
import cn.timer.api.dto.spmk.SummaryQueryDto;
yuquan.zhu committed
90 91
import cn.timer.api.utils.Result;
import cn.timer.api.utils.ResultUtil;
92
import cn.timer.api.utils.router.RouterUtils;
93 94 95
import cn.timer.api.utils.router.business.SpmkAssoBusiness;
import cn.timer.api.utils.router.business.SpmkAssoBusinessFactory;
import cn.timer.api.utils.router.enums.ApproveEnum;
yuquan.zhu committed
96 97 98 99 100 101 102 103
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(tags = "3.0审批模块")
@RestController
@Transactional
@RequestMapping(value = "/spmk",  
produces = { "application/json","multipart/form-data" })
104
public class SpmkController {
yuquan.zhu committed
105 106

	@Autowired
107 108 109
	private SpmkService spmkService;
	@Autowired
	private ZzglBmgwMService zzglBmgwMService;
110
	
111
	@Autowired
112 113
	private QyzxEmpEntAssoMapper qyzxEmpEntAssoMapper;
	@Autowired
114 115 116 117 118 119 120
    private SpmkApprovalTemplateGMapper spmkApprovalTemplateGMapper;
	@Autowired
    private SpmkApprovalTemplateMapper spmkApprovalTemplateMapper;
	@Autowired
    private SpmkApprovalGMapper spmkApprovalGMapper;
	@Autowired
    private SpmkCustomApprovalMapper spmkCustomApprovalMapper;
121
	@Autowired
122 123 124 125 126 127 128 129 130 131
	private SpmkApproveSummaryMapper spmkApproveSummaryMapper;
	@Autowired
	private SpmkApproveDetailMapper spmkApproveDetailMapper;
	@Autowired
	private SpmkApproveExecuteRecordMapper spmkApproveExecuteRecordMapper;
	@Autowired
	private SpmkExecutorMapper spmkExecutorMapper;
	@Autowired
	private SpmkInitiatorConfigMapper spmkInitiatorConfigMapper;
	
tangzhaoqian committed
132 133 134
	@Autowired
	private SpmkAssoBusinessFactory spmkAssoBusinessFactory;
	
135
	private boolean ISFIRST = true; // 第一次启动审批流程
136
	
137
	//TODO 审批模板组
138
	/**
139
	 * 新增或编辑-审批模板组
140
	 */
141
	@PostMapping(value = "/save_approval_template_g")
142
	@ApiOperation(value = "1.新增或编辑-审批模板组", httpMethod = "POST", notes = "新增或编辑-审批模板组")
143
	@ApiOperationSupport(order = 1)
144
	public Result<Object> saveAtg(@Validated({Insert.class,Update.class}) @RequestBody SpmkApprovalTemplateG spmkApprovalTemplateG){
145
		
146
		if (spmkApprovalTemplateG.selectCount(new QueryWrapper<SpmkApprovalTemplateG>().lambda()
147
				.ne(spmkApprovalTemplateG.getId() != null,SpmkApprovalTemplateG::getId, spmkApprovalTemplateG.getId())
148 149 150 151
				.eq(SpmkApprovalTemplateG::getName, spmkApprovalTemplateG.getName())) > 0) {
			return ResultUtil.error("审批模板组名重复!");
		}
		
152
        return spmkApprovalTemplateG.insertOrUpdate() ? 
153
        		ResultUtil.data(spmkApprovalTemplateG) : ResultUtil.error();
154 155 156
	}
	
	/**
157
	 * 删除-审批模板组
158
	 */
159
	@DeleteMapping(value = "/delete_approval_template_g/{id}")
160 161
	@ApiOperation(value = "2.删除-审批模板组", httpMethod = "DELETE", notes = "删除-审批模板组")
	@ApiOperationSupport(order = 2)
162
	public Result<Object> deleteAtgById(@PathVariable int id){
163
		
164 165 166
		if (spmkApprovalTemplateMapper.selectCount(new QueryWrapper<SpmkApprovalTemplate>().lambda().eq(SpmkApprovalTemplate::getApprovalTemplateGId, id)) > 0 ) 
			return ResultUtil.error("审批模板组存在 模板,不可直接删除!");
		
167
        return SpmkApprovalTemplateG.builder().id(id).build().deleteById() ? 
168
        		ResultUtil.success() : ResultUtil.error("没有找到该对象");
169 170 171
	}
	
	/**
172
	 * 查询列表-审批模板组
173
	 */
174
	@GetMapping(value = "/list_approval_template_g")
175 176
	@ApiOperation(value = "3.查询列表-审批模板组", httpMethod = "GET", notes = "查询列表-审批模板组")
	@ApiOperationSupport(order = 3)
177 178
	public Result<Object> selectListAtg(){
        
179
        return ResultUtil.data(spmkApprovalTemplateGMapper.selectListAtInAtg());
180 181
	}
	
182 183 184
	/**
	 * 排序-审批模板组
	 */
tangzhaoqian committed
185
	@PutMapping(value = "/update_approval_template_g")
186 187
	@ApiOperation(value = "4.排序-审批模板组", httpMethod = "PUT", notes = "排序-审批模板组")
	@ApiOperationSupport(order = 4)
188
	public Result<Object> ranksAtg(@Validated(Ranks.class) @RequestBody ValidList<SpmkApprovalTemplateG> list){
189 190 191 192 193
		
		if (list == null || (list != null && list.size() <= 0)) {
			return ResultUtil.success();
		}
        return spmkApprovalTemplateGMapper.updateListRandsById(list) ? ResultUtil.success() : ResultUtil.error();
194
	}
195
	
196 197 198 199 200
	//TODO 审批模板
	/**
	 * 新增或编辑-审批模板
	 */
	@PostMapping(value = "/save_approval_template")
201 202
	@ApiOperation(value = "5.新增或编辑-审批模板", httpMethod = "POST", notes = "新增或编辑-审批模板")
	@ApiOperationSupport(order = 5)
203
	public Result<Object> saveAt(@Validated @RequestBody SpmkApprovalTemplateDto spmkApprovalTemplateDto){
204
		
205 206
		Integer approvalTemplateGId = spmkApprovalTemplateDto.getApprovalTemplateGId();
		if (ObjectUtil.isNull(approvalTemplateGId)) 
207
			return ResultUtil.error("审批模板ID不为空");
208 209 210

		SpmkApprovalTemplate at = SpmkApprovalTemplate.builder().build();

211
		// 克隆 SpmkApprovalTemplateDto对象 到 SpmkApprovalTemplate对象,排除属性froms,router
212
		BeanUtil.copyProperties(spmkApprovalTemplateDto, at , "froms","router");
213
		// 序列化 后 写入 SpmkApprovalTemplate对象
214
		at.setFroms(ObjectUtil.serialize((List<JSONObject>)spmkApprovalTemplateDto.getFroms()));
215 216
		at.setRouter(ObjectUtil.serialize(spmkApprovalTemplateDto.getRouter()));
		
217
		if (at.selectCount(new QueryWrapper<SpmkApprovalTemplate>().lambda()
218
				.ne(at.getId() != null, SpmkApprovalTemplate::getId, at.getId())
219 220 221 222
				.eq(SpmkApprovalTemplate::getName, at.getName())) > 0) {
			return ResultUtil.error("审批模板名重复!");
		}
		
223
		if (!at.insertOrUpdate()) 
224
			return ResultUtil.error("数据库操作失败");
225 226 227 228
		
		// 清空前端不需要的字段再返回,节省流量
		at.setFroms(null);
		at.setRouter(null);
229
		return  ResultUtil.data(at);
230 231
		
	}
232
	
233 234 235 236
	/**
	 * 删除-审批模板
	 */
	@DeleteMapping(value = "/delete_approval_template/{id}")
237 238
	@ApiOperation(value = "6.删除-审批模板", httpMethod = "DELETE", notes = "删除-审批模板")
	@ApiOperationSupport(order = 6)
239 240
	public Result<Object> deleteAtById(@PathVariable int id){
		
241
        return SpmkApprovalTemplate.builder().id(id).build().deleteById() ? ResultUtil.success() : ResultUtil.error("没有找到该对象");
242 243 244 245 246 247
		
	}

	/**
	 * id查询-审批模板
	 */
248
	@GetMapping(value = "/select_approval_template/{id}")
249 250
	@ApiOperation(value = "7.id查询-审批模板", httpMethod = "GET", notes = "id查询-审批模板")
	@ApiOperationSupport(order = 7)
251
	public Result<Object> selectAtById(@PathVariable int id){
252 253 254 255 256 257
		SpmkApprovalTemplate at = SpmkApprovalTemplate.builder().id(id).build().selectById();
		
		SpmkApprovalTemplateDto atd = SpmkApprovalTemplateDto.builder().build();
		BeanUtil.copyProperties(at, atd,"froms","router");
		atd.setFroms(ObjectUtil.deserialize(at.getFroms()));
		atd.setRouter(ObjectUtil.deserialize(at.getRouter()));
258
        return ResultUtil.data(atd);
259 260 261 262 263 264
        
	}
	
	/**
	 * 排序-审批模板
	 */
tangzhaoqian committed
265
	@PutMapping(value = "/update_approval_template")
266
	@ApiOperation(value = "8.排序-审批模板", httpMethod = "PUT", notes = "查询列表-审批模板组")
267
	@ApiOperationSupport(order = 8)
268
	public Result<Object> ranksAt(@Validated({Ranks.class})@RequestBody ValidList<SpmkApprovalTemplate> list){
269

270 271 272 273 274
		if (list == null || (list != null && list.size() <= 0)) {
			return ResultUtil.success();
		}
		
        return spmkApprovalTemplateMapper.updateListRandsById(list) ? ResultUtil.success() : ResultUtil.error();
275 276
	
	}
277 278
	
	
279 280
	
	//TODO 审批组
281
	/**
282
	 * 新增或编辑-审批组
283
	 */
284
	@PostMapping(value = "/save_approval_g")
285 286
	@ApiOperation(value = "9.新增或编辑-审批组", httpMethod = "POST", notes = "新增或编辑-审批组")
	@ApiOperationSupport(order = 9)
287
	public Result<Object> saveAg(@CurrentUser UserBean userBean, @Validated({Insert.class,Update.class}) @RequestBody SpmkApprovalG spmkApprovalG){
288
		
289
		if (spmkApprovalG.selectCount(new QueryWrapper<SpmkApprovalG>().lambda()
290
				.ne(spmkApprovalG.getId() != null, SpmkApprovalG::getId, spmkApprovalG.getId())
291 292
				.eq(SpmkApprovalG::getName, spmkApprovalG.getName())
				.eq(SpmkApprovalG::getOrgCode, userBean.getOrgCode())) > 0) {
293 294 295
			return ResultUtil.error("审批组名重复!");
		}
		
296
		spmkApprovalG.setOrgCode(userBean.getOrgCode());
297
		return spmkApprovalG.insertOrUpdate() ? ResultUtil.data(spmkApprovalG) : ResultUtil.error();
298
		
299 300 301 302 303 304
	}
	
	/**
	 * 删除-审批组
	 */
	@DeleteMapping(value = "/delete_approval_g/{id}")
305 306
	@ApiOperation(value = "10.删除-审批组", httpMethod = "DELETE", notes = "删除-审批组")
	@ApiOperationSupport(order = 10)
307 308
	public Result<Object> deleteAgById(@PathVariable int id){
		
lal committed
309 310
//		if (spmkCustomApprovalMapper.selectCount(new QueryWrapper<SpmkCustomApproval>().lambda().eq(SpmkCustomApproval::getApprovalGId, id)) > 0 ) 
//			return ResultUtil.error("审批组存在 自定义审批,不可直接删除!");
311
		
lal committed
312
		SpmkCustomApproval.builder().build().delete(new QueryWrapper<SpmkCustomApproval>().lambda().eq(SpmkCustomApproval::getApprovalGId, id));
313
        return SpmkApprovalG.builder().id(id).build().deleteById() ? ResultUtil.success() : ResultUtil.error("没有找到该对象");
314 315 316
		
	}
	
317
	/**
318 319 320 321 322 323 324 325 326
	 * 查询列表-审批组-审批管理
	 */
	@GetMapping(value = "/all_approval_g")
	@ApiOperation(value = "11.查询列表-审批组-审批管理", httpMethod = "GET", notes = "查询列表-审批组-审批管理")
	@ApiOperationSupport(order = 11)
	public Result<Object> selectListAgByAdmin(@CurrentUser UserBean userBean){
		
		List<Integer> depts = zzglBmgwMService.empNumupGetDepts(userBean.getOrgCode(), userBean.getEmpNum());
		System.out.println(depts);
327
        return ResultUtil.data(spmkApprovalGMapper.selectListAgInCaByAdmin(userBean.getOrgCode(), userBean.getEmpNum(), depts));
328 329 330 331 332
	
	}
	
	/**
	 * 查询列表-审批组-个人审批
333 334
	 */
	@GetMapping(value = "/list_approval_g")
335
	@ApiOperation(value = "11.查询列表-审批组-个人审批", httpMethod = "GET", notes = "查询列表-审批组-个人审批")
336
	@ApiOperationSupport(order = 11)
337 338
	public Result<Object> selectListAg(@CurrentUser UserBean userBean){
		
339
		return ResultUtil.data(spmkService.selectListAg(userBean));
340
	}
341
	
342 343 344
	/**
	 * 排序-审批组
	 */
tangzhaoqian committed
345
	@PutMapping(value = "/update_approval_g")
346 347
	@ApiOperation(value = "12.排序-审批组", httpMethod = "PUT", notes = "排序-审批组")
	@ApiOperationSupport(order = 12)
348
	public Result<Object> ranksAg(@Validated({Ranks.class}) @RequestBody ValidList<SpmkApprovalG> list){
349
		
350
		if (list == null || list.size() <= 0) {
351 352 353 354
			return ResultUtil.success();
		}
		
        return spmkApprovalGMapper.updateListRandsById(list) ? ResultUtil.success() : ResultUtil.error();
355
	}
356
	
357
	//TODO 自定义审批
358
	
359 360 361 362
	/**
	 * 新增或编辑-自定义审批
	 */
	@PostMapping(value = "/save_custom_approval")
363 364
	@ApiOperation(value = "13.新增或编辑-自定义审批", httpMethod = "POST", notes = "新增或编辑-自定义审批")
	@ApiOperationSupport(order = 13)
365
	@Transactional(rollbackFor = Exception.class)
366
	public Result<Object> saveCa(@CurrentUser UserBean userBean,@Validated @RequestBody SpmkCustomApprovalDto spmkCustomApprovalDto) throws Exception{
367 368 369 370

		SpmkCustomApproval ca = SpmkCustomApproval.builder().build();

		BeanUtil.copyProperties(spmkCustomApprovalDto, ca , "froms","router","initiatorConfigs");
371
		
372
		if (ca.selectCount(new QueryWrapper<SpmkCustomApproval>().lambda()
373
				.ne(ca.getId() != null, SpmkCustomApproval::getId, ca.getId())
374 375
				.eq(SpmkCustomApproval::getName, ca.getName())
				.eq(SpmkCustomApproval::getOrgCode, userBean.getOrgCode())) > 0) {
376 377
			return ResultUtil.error("自定义审批名重复!");
		}
378
		ca.setOrgCode(userBean.getOrgCode());
379 380 381
		ca.setFroms(ObjectUtil.serialize(spmkCustomApprovalDto.getFroms()));
		ca.setRouter(ObjectUtil.serialize(spmkCustomApprovalDto.getRouter()));
		
382
		//1.新增 SpmkCustomApproval-自定义审批
383
		if (!ca.insertOrUpdate())
384
			return ResultUtil.error("新增自定义审批 失败!");
385
		
386
		
387
		Integer id = ca.getId();
388 389
		// 2.删除	历史的  SpmkInitiatorConfig-审批发起人配置,
		SpmkInitiatorConfig.builder().build().delete(new QueryWrapper<SpmkInitiatorConfig>().lambda().eq(SpmkInitiatorConfig::getCustomApprovalId, id));
390 391 392
		Console.log("自定义审批id: " + id);
		List<SpmkInitiatorConfig> listIc = spmkCustomApprovalDto.getInitiatorConfigs();

393 394 395 396
		if (listIc != null && listIc.size() > 0) {
			for (int i = 0, n = listIc.size(); i < n; i++) {
				listIc.get(i).setCustomApprovalId(id);
			}
397
			// 3.新增	最新的 SpmkInitiatorConfig-审批发起人配置,
398 399 400 401 402
			if (!spmkInitiatorConfigMapper.insertList(listIc)) {
				// 手动抛出异常,事务回滚
				throw new Exception();
			}
			
403
		}
404
		
405 406 407
		//  
		/**
		 * 注意: 为保证该api的原子性 要加 事务处理 回滚(方法注解-@Transactional(rollbackFor = Exception.class))
408 409 410
		 * 1.新增 SpmkCustomApproval-自定义审批
		 * 2.删除	历史的  SpmkInitiatorConfig-审批发起人配置,
		 * 3.新增	最新的 SpmkInitiatorConfig-审批发起人配置,
411
		 */
412 413 414 415

		// 清空前端不需要的字段再返回,节省流量
		ca.setFroms(null);
		ca.setRouter(null);
416
		return ResultUtil.data(ca);
417 418
		
	}
419
	
420 421
	/**
	 * 删除-自定义审批
422
	 * @throws Exception 
423 424
	 */
	@DeleteMapping(value = "/delete_custom_approval/{id}")
425
	@ApiOperation(value = "14.删除-自定义审批", httpMethod = "DELETE", notes = "删除-自定义审批")
426
	@Transactional(rollbackFor = Exception.class)
427
	@ApiOperationSupport(order = 14)
428 429 430 431 432 433 434
	public Result<Object> deleteCaById(@PathVariable int id) throws Exception{
		SpmkInitiatorConfig.builder().build().delete(new QueryWrapper<SpmkInitiatorConfig>().lambda().eq(SpmkInitiatorConfig::getCustomApprovalId, id));
        
		if (!SpmkCustomApproval.builder().id(id).build().deleteById()) {
			throw new Exception();
		}
		
435
		return  ResultUtil.success();
436 437 438 439 440
	}

	/**
	 * id查询-自定义审批
	 */
441 442 443
	@GetMapping(value = "/select_custom_approval/{id}")
	@ApiOperation(value = "15.id查询-自定义审批", httpMethod = "GET", notes = "id查询-自定义审批")
	@ApiOperationSupport(order = 15)
444
	public Result<Object> selectCaById(@PathVariable int id){
445
		SpmkCustomApproval ca = SpmkCustomApproval.builder().id(id).build().selectById();
446
		List<SpmkInitiatorConfig> listIc = SpmkInitiatorConfig.builder().build().selectList(new QueryWrapper<SpmkInitiatorConfig>().lambda().eq(SpmkInitiatorConfig::getCustomApprovalId, id));
447
		SpmkCustomApprovalDto caD = SpmkCustomApprovalDto.builder()
448 449
				.froms(ObjectUtil.deserialize(ca.getFroms()))
				.router(ObjectUtil.deserialize(ca.getRouter()))
450 451
				.build();
		BeanUtil.copyProperties(ca, caD,"froms","router");
452
		caD.setInitiatorConfigs(listIc);
453
        return ResultUtil.data(caD);
454
	}
455
	
456 457 458
	/**
	 * 排序-自定义审批
	 */
tangzhaoqian committed
459
	@PutMapping(value = "/update_custom_approval")
460 461
	@ApiOperation(value = "16.排序-自定义审批", httpMethod = "PUT", notes = "排序-自定义审批")
	@ApiOperationSupport(order = 16)
462
	public Result<Object> ranksCa(@Validated({Ranks.class}) @RequestBody ValidList<SpmkCustomApproval> list){
463 464 465 466 467 468
		
		if (list == null || (list != null && list.size() <= 0)) {
			return ResultUtil.success();
		}
		
        return spmkCustomApprovalMapper.updateListRandsById(list) ? ResultUtil.success() : ResultUtil.error();
469
	}
470
	
471 472 473
	@Autowired
	YgglService ygglService;
	
tangzhaoqian committed
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514
	/**
	 * 排序-自定义审批
	 */
	@PutMapping(value = "/test_spmk")
	@ApiOperation(value = "16.测试", httpMethod = "PUT", notes = "排序-自定义审批")
	@ApiOperationSupport(order = 16)
	public Result<Object> test222(@Validated({Ranks.class}) @RequestBody ValidList<SpmkCustomApproval> list){
		
		Set<Integer> lanzi = new HashSet<Integer>();
		//所有部门岗位
		List<ZzglBmgwM> bmgws = ZzglBmgwM.builder().build().selectList(new QueryWrapper<ZzglBmgwM>().lambda().eq(ZzglBmgwM::getOrgCode, 311));
		//个人岗位
		YgglMainEmp one = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda()
							.select(YgglMainEmp::getBmgwId)
							.eq(YgglMainEmp::getOrgCode, 311).eq(YgglMainEmp::getEmpNum, 12512));
		
		Integer getId = one != null ? one.getBmgwId() : null;
		System.out.println(getId);
		Set<Integer> all = getId != null ? empNumupdept2(lanzi, bmgws, getId) : new HashSet<Integer>();
		all.add(getId);
		
		System.out.println(all);
		
		return spmkCustomApprovalMapper.updateListRandsById(list) ? ResultUtil.success() : ResultUtil.error();
	}
	
	//遍历
	public static Set<Integer> empNumupdept2(Set<Integer> lanzi,List<ZzglBmgwM> bmgws,Integer getId) {
		for (ZzglBmgwM z : bmgws) {
			if (getId.equals(z.getId())) {
				lanzi.add(getId);
				if (z.getUpId()==null || z.getUpId() == 0) {
					return lanzi;
				}
				getId = z.getUpId();
				empNumupdept2(lanzi, bmgws, getId);
			}
		}
		return lanzi;
	}
	
515 516 517
	// TODO 审批汇总(发起审批)
	/**
	 * 发起审批
518
	 * @throws Exception 
519 520
	 */
	@PostMapping(value = "/start_approval")
521 522 523
	@ApiOperation(value = "17.发起审批", httpMethod = "POST", notes = "发起审批")
	@ApiOperationSupport(order = 17)
	@Transactional(rollbackFor = Exception.class)
tangzhaoqian committed
524
	@Log(title = "审批-发起审批", businessType = BusinessType.INSERT)
tangzhaoqian committed
525
	public Result<Object> saveA(@CurrentUser UserBean userBean,@Validated @RequestBody SpmkApproveSummaryDto spmkApproveSummaryDto) throws Exception{
526 527 528
			YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>()
					.lambda()
					.select(YgglMainEmp::getHeadUrl,YgglMainEmp::getName)
529 530 531
					.eq(YgglMainEmp::getEmpNum, userBean.getEmpNum())
					.eq(YgglMainEmp::getOrgCode, userBean.getOrgCode())
					);
532 533
			
			if (ygglMainEmp == null) 
534 535 536
				return ResultUtil.error("发起人不存在!");
			
//			List<SpmkApprovalG> saG = spmkService.selectListAg(userBean);
537
			
538 539
			Router router = spmkApproveSummaryDto.getRouter();
			List<Router> routers = router.getChildren();
540
			if (CollectionUtil.isNotEmpty(routers)) {
yuquan.zhu committed
541 542 543 544 545 546 547 548
//				List<Relation> relations = routers.get(0).getRelation();
//				if (relations == null || relations.size() < 1) {
//					return ResultUtil.error("无法发起,请完善审批流程");
//				}
//				List<User> users = relations.get(0).getUsers();
//				if (CollectionUtil.isEmpty(users)) {
//					return ResultUtil.error("无法发起,请完善审批流程");
//				}
549 550 551 552 553
				
			}else {
				return ResultUtil.error("无法发起,请完善审批流程");
			}
			
554
			List<Router> listRouter = new ArrayList<Router>();
555 556
			listRouter.add(router);
			
557
			JSONObject jSONObject = spmkApproveSummaryDto.getRequestData()
tangzhaoqian committed
558 559 560 561
					.set("orgCode", userBean.getOrgCode())
					.set("initiator", ygglMainEmp.getName())
					.set("headUrl", ygglMainEmp.getHeadUrl())
					.set("id", userBean.getEmpNum());
562
			RouterUtils.NextNode(listRouter, jSONObject, ISFIRST);
563
			System.out.println(listRouter);
564 565
			List<FlowChildren> listFlowChildren = new ArrayList<FlowChildren>();
			RouterUtils.getIsFlowChildren(listRouter,listFlowChildren);
yuquan.zhu committed
566
			System.out.println("listFlowChildren");
567
			System.out.println(listFlowChildren);
568
			
569 570 571 572 573 574 575 576 577 578
			// 当前审批人
			String currentApprover = jSONObject.getStr("current_approver");
			// 封装 审批汇总
			SpmkApproveSummary as = SpmkApproveSummary
					.builder()
					.orgCode(userBean.getOrgCode())
					.empNum(userBean.getEmpNum())
					.title(spmkApproveSummaryDto.getTitle())
					.initiator(spmkApproveSummaryDto.getInitiator())
					.approveName(spmkApproveSummaryDto.getApproveName())
579
					.assoType(spmkApproveSummaryDto.getAssoType())
580
					.sts(ApproveSummarySts.IN.ordinal())
581
					.currentApprover(currentApprover).build();
582
			
583
			if (!as.insert()) {
584
				throw new CustomException("审批汇总-新增异常");
585
			}
586
			
tangzhaoqian committed
587
			// 插入记录- 审批执行记录 - 执行人记录
588 589
			RouterUtils.insertogExecuteRecord(listFlowChildren, as.getId());
			
590 591 592 593 594
			// 封装 审批详情
			SpmkApproveDetail ad = SpmkApproveDetail.builder().build();
			ad.setApproveSummaryId(as.getId());
			ad.setName(spmkApproveSummaryDto.getTitle());
			ad.setRequestData(ObjectUtil.serialize(spmkApproveSummaryDto.getRequestData()));
595
			ad.setFroms(ObjectUtil.serialize((List<JSONObject>)spmkApproveSummaryDto.getFroms()));
596 597
			ad.setRouter(ObjectUtil.serialize(listRouter.get(0)));
			ad.setFlowChildren(ObjectUtil.serialize(listFlowChildren));
598
			
599
			if (!ad.insert()) 
600
				throw new CustomException("审批详情-新增异常");
601
			
602
			return ResultUtil.success();
603 604
	}
	
605
	//TODO 审批汇总
606 607 608 609
	/**
	 * 审批汇总
	 * @param summaryQueryDto
	 * @return
610
	 * @throws  
611
	 */
612 613 614
	@PostMapping(value = "/select_approve_summary")
	@ApiOperation(value = "18.审批汇总", httpMethod = "POST", notes = "审批汇总")
	@ApiOperationSupport(order = 18)
tangzhaoqian committed
615
	@Log(title = "审批-审批汇总", businessType = BusinessType.OTHER)
616 617 618 619 620 621
	public Result<Object> selectAs(@CurrentUser UserBean userBean, @RequestBody SummaryQueryDto summaryQueryDto) {

			IPage<SpmkApproveSummary> page = new Page<SpmkApproveSummary>(
				summaryQueryDto.getCurrentPage() == null ? 1 : summaryQueryDto.getCurrentPage(),
				summaryQueryDto.getTotalPage() == null ? 10 : summaryQueryDto.getTotalPage());
			summaryQueryDto.setOrgCode(userBean.getOrgCode());
622 623
			
			Integer deptId = summaryQueryDto.getDeptId();
tangzhaoqian committed
624
			List<YgglMainEmp> listYgglMainEmp = zzglBmgwMService.selectOtherlistent(userBean.getOrgCode(), deptId);
tangzhaoqian committed
625

626
			if (deptId != null && (listYgglMainEmp == null || listYgglMainEmp.size() == 0)) {
627
				return ResultUtil.data(new ArrayList<SpmkApproveSummary>());
628 629 630 631 632 633 634
			}
			
			List<Integer> empNums = new ArrayList<Integer>();
			for (YgglMainEmp ygglMainEmp : listYgglMainEmp) {
				empNums.add(ygglMainEmp.getEmpNum());
			}
			summaryQueryDto.setEmpNums(empNums);
635

636
			// 缺-部门id 搜索
637 638 639
			IPage<SpmkApproveSummary> pageAs = spmkApproveSummaryMapper.selectPageByQuery(page, summaryQueryDto);
			
			List<SpmkApproveSummary> listAs = pageAs.getRecords();
640
			
641
			return ResultUtil.data(pageAs, listAs);
642
	}
643
	
644 645 646 647 648 649 650
	//TODO 审批详情
	/**
	 * 审批详情
	 */
	@GetMapping(value = "/select_approve_detail/{id}")
	@ApiOperation(value = "19.审批详情", httpMethod = "GET", notes = "审批详情")
	@ApiOperationSupport(order = 19)
tangzhaoqian committed
651
	@Log(title = "审批-审批详情", businessType = BusinessType.OTHER)
tangzhaoqian committed
652
	public Result<Object> selectAd(@PathVariable(required = true) Integer id) {
653
		
654
		SpmkApproveDetailDto adD = spmkService.selectApproveDetailByAsId(id);
655
		
656
		return ResultUtil.data(adD);
657
	}
658
	
659 660 661 662 663 664
	//TODO 审批人审批
	/**
	 * 审批人审批
	 */
	@PostMapping(value = "/approving")
	@ApiOperation(value = "20.审批人审批", httpMethod = "POST", notes = "审批人审批")
tangzhaoqian committed
665 666
	@Transactional(rollbackFor = Exception.class)
	@ApiOperationSupport(order = 20)
tangzhaoqian committed
667
	@Log(title = "审批-审批流程", businessType = BusinessType.UPDATE)
668
//	@BindingResultCtrol(title = "审批人审批")
669 670
	public Result<Object> approving(@CurrentUser UserBean userBean,@Validated @RequestBody ApprovingDto approvingDto) throws Exception {
		
671
		Integer asId = approvingDto.getAsId();
672
		SpmkApproveDetail ad = SpmkApproveDetail.builder().build().selectOne(new QueryWrapper<SpmkApproveDetail>()
673
				.lambda()
674 675 676
				.select(SpmkApproveDetail::getId,
						SpmkApproveDetail::getRequestData,
						SpmkApproveDetail::getFlowChildren)
677
				.eq(SpmkApproveDetail::getApproveSummaryId, asId));
678
		
679 680 681
		// 查询 SpmkApproveSummary 状态
		SpmkApproveSummary aSummary = spmkApproveSummaryMapper.selectOne(new QueryWrapper<SpmkApproveSummary>().lambda()
				.select(SpmkApproveSummary::getSts)
682
				.eq(SpmkApproveSummary::getId, asId));
683
		
684
		if (aSummary.getSts() > SpmkEnumInterface.ApproveSummarySts.IN.ordinal()) {
685 686 687 688
			return ResultUtil.error("该审批已结束!");
		}
		
		// 查询该 审批的状态 是否为 1 审批中 
tangzhaoqian committed
689 690
		Integer count = SpmkExecutor.builder().build().selectCount(new QueryWrapper<SpmkExecutor>().lambda()
				.eq(SpmkExecutor::getId, approvingDto.getExecutorId())
tangzhaoqian committed
691
				.eq(SpmkExecutor::getSts, ExecutorSts.IN_EXECUTION.ordinal()));
tangzhaoqian committed
692 693 694 695 696
		
		if (count == 0) {
			return ResultUtil.error("您已审批过!");
		}
		
697 698 699 700
		if ( spmkExecutorMapper.selectCount(new QueryWrapper<SpmkExecutor>().lambda()
				.eq(SpmkExecutor::getId, approvingDto.getExecutorId())
				.eq(SpmkExecutor::getEmpNum, userBean.getEmpNum())
				.eq(SpmkExecutor::getSts, SpmkEnumInterface.ExecutorSts.IN_EXECUTION.ordinal())) == 0) {
701 702 703 704 705 706 707 708 709 710 711
			
			Integer adminNum = new LambdaQueryChainWrapper<QyzxEmpEntAsso>(qyzxEmpEntAssoMapper)
					.eq(QyzxEmpEntAsso::getEmpNum, userBean.getEmpNum())
					.eq(QyzxEmpEntAsso::getOrgCode, userBean.getOrgCode())
					.in(QyzxEmpEntAsso::getUserType, SysRoleType.U_TYPE_ADMIN,SysRoleType.U_TYPE_C_ADMIN)
					.count();
			
			if (adminNum <= 0) {
				return ResultUtil.error("非当前审批人 或 管理员,无法操作!");
			}
			
712 713
		}
		
714
		if (aSummary.getSts() == 0) {
715
			List<FlowChildren> listFlowChildren = ObjectUtil.deserialize(ad.getFlowChildren());
716
			// 审批逻辑
717 718
			RouterUtils.approving(
					listFlowChildren, 
719
					asId, 
720 721 722
					approvingDto.getExecuteRecordId(), 
					approvingDto.getExecutorId(), 
					approvingDto.getOpinion(),
723 724 725
					approvingDto.getSts(),
					approvingDto.getUser()
					);
726 727 728
			
			System.out.println(listFlowChildren);
			// 更新 flowChildren
tangzhaoqian committed
729
			SpmkApproveDetail.builder().id(ad.getId()).flowChildren(ObjectUtil.serialize(listFlowChildren)).build().updateById();
730 731 732 733
			FlowChildren fc = CollUtil.getLast(listFlowChildren);
			if (fc.getExecute() == "2") {
				// 查询 SpmkApproveSummary 状态
				aSummary = spmkApproveSummaryMapper.selectOne(new QueryWrapper<SpmkApproveSummary>().lambda()
734
						.select(SpmkApproveSummary::getSts,SpmkApproveSummary::getAssoType)
735
						.eq(SpmkApproveSummary::getId, asId));
736
				
737
				if (aSummary.getSts() != SpmkEnumInterface.ApproveSummarySts.REFUSE.ordinal()) {
738
					SpmkApproveSummary.builder().id(asId).currentApprover(CommonEnum.NULL_STR.getDesc()).endTime(new Date()).sts(ApproveSummarySts.FINISH.ordinal()).build().updateById();
739
						
740
					JSONObject jSONObject = ObjectUtil.deserialize(ad.getRequestData());
tangzhaoqian committed
741
					jSONObject.set("approveId", FromData.builder().value(String.valueOf(asId)).build());
tangzhaoqian committed
742
					jSONObject.set("orgCode", userBean.getOrgCode());
743
					
744
					//审批完成后 业务
tangzhaoqian committed
745
					SpmkAssoBusiness sab = spmkAssoBusinessFactory.createSpmkService(ApproveEnum.getEnums(aSummary.getAssoType()));
746
					if (sab != null)
747 748
						System.out.println("1----------"+ sab);
						System.out.println("2----------"+ jSONObject);
749
						sab.handleApprove(jSONObject);
750
				}
tangzhaoqian committed
751
			}
752 753 754 755
			
		}else {
			return ResultUtil.error("该审批已结束!");
		}
756
		return ResultUtil.success();
757
	}
758
	
lal committed
759 760
	@Autowired
	private PunchRecordMapper punchrecordmapper;
tangzhaoqian committed
761
	//TODO 我发起的/我审批的/抄送我的
762
	/**
tangzhaoqian committed
763
	 * 查询列表-我发起的/我审批的/抄送我的-分页
764 765
	 */
	@PostMapping(value = "/select_my_approve")
tangzhaoqian committed
766
	@ApiOperation(value = "21.查询列表-我发起的/我审批的/抄送我的-分页", httpMethod = "POST", notes = "查询列表-我审批的-关键字、审批状态、发起时间-分页")
tangzhaoqian committed
767
	@ApiOperationSupport(order = 21)
tangzhaoqian committed
768
	@Log(title = "审批-我发起的/我审批的/抄送我的", businessType = BusinessType.OTHER)
769
	public Result<Object> selectMyAs(@CurrentUser UserBean userBean, @Validated @RequestBody MySummaryQueryDto mySummaryQueryDto) throws MethodArgumentNotValidException{
770 771 772 773 774
			IPage<SpmkApproveSummary> page = new Page<SpmkApproveSummary>(
				mySummaryQueryDto.getCurrentPage() == null ? 1 : mySummaryQueryDto.getCurrentPage(),
				mySummaryQueryDto.getTotalPage() == null ? 10 : mySummaryQueryDto.getTotalPage());
			mySummaryQueryDto.setOrgCode(userBean.getOrgCode());
			mySummaryQueryDto.setEmpNum(userBean.getEmpNum());
lal committed
775 776 777
			if(mySummaryQueryDto.getSts() == null) {
				mySummaryQueryDto.setSts(0);
			}
778 779 780 781
			// 缺-部门id 搜索
			IPage<SpmkApproveSummary> pageAs = spmkApproveSummaryMapper.selectPageByQueryForEmpNum(page, mySummaryQueryDto);
			
			List<SpmkApproveSummary> listAs = pageAs.getRecords();
lal committed
782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826
			
			for(SpmkApproveSummary sp : listAs) {
				
				String requerstr = "";
				try {
					SpmkApproveDetail ad = spmkApproveDetailMapper.selectOne(new QueryWrapper<SpmkApproveDetail>().lambda().eq(SpmkApproveDetail::getApproveSummaryId, sp.getId()));
					
					JSONObject as = ObjectUtil.deserialize(ad.getRequestData());
//					System.out.println(as);
//					System.out.println(sp.getId()+"==========================================="+sp.getAssoType());
					requerstr = "";
					//assoType : 1转正 2离职 3调薪 4调岗 5加班 6请假 7出差 8外出 9补卡
					switch (sp.getAssoType()) {
					case 1:requerstr = "转正时间:"+as.getJSONObject("__newConfirmationTime").getStr("value");break;
					case 2:requerstr = "离职时间:"+as.getJSONObject("__terminationDate").getStr("value");break;
					case 3:
						String namepos = "";
						PunchRecord pu = punchrecordmapper.organizationalStructure(Integer.valueOf(as.getJSONObject("__TransferInDepartment").getStr("value")));
						if(pu != null) {
							namepos = pu.getPost();
						}
						requerstr = "调入岗位:"+namepos;
						break;
					case 5:requerstr = "加班时长:"+as.getJSONObject("__timeLong").getStr("value")+"(小时)";break;
					case 6:
						String name = "";
						KqglAssoLeaveRules rul = KqglAssoLeaveRules.builder().build().selectById(as.getJSONObject("__LeaveType").getStr("value"));
						if(rul != null) {
							name = rul.getName();
						}
						requerstr = "请假类型:"+name;
						break;
					case 7:requerstr = "出差时长:"+as.getJSONObject("__longTime").getStr("value")+"(小时)";break;
					case 8:requerstr = "外出时长:"+as.getJSONObject("__longTime").getStr("value")+"(小时)";break;
					case 9:requerstr = "补卡时间:"+as.getJSONObject("__PatchCardTime").getStr("value");break;
					default:
						break;
					}
				} catch (Exception e) {
					e.printStackTrace();
				}
//				System.out.println(requerstr);
				sp.setDigest(requerstr);
			}
			
827
			return ResultUtil.data(pageAs, listAs);
828
	}
829
	
830 831 832 833 834 835 836 837
	//TODO 撤销审批
	/**
	 * 撤销审批
	 */
	@PutMapping(value = "/revoke_approval/{id}")
	@ApiOperation(value = "22.撤销审批", httpMethod = "PUT", notes = "撤销审批")
	@Transactional(rollbackFor = Exception.class)
	@ApiOperationSupport(order = 22)
tangzhaoqian committed
838
	@Log(title = "审批-撤销审批", businessType = BusinessType.UPDATE)
839 840 841 842 843 844 845
	public Result<Object> revokeApproval(@PathVariable Integer id) throws Exception {
		
		SpmkApproveSummary as = spmkApproveSummaryMapper.selectOne(new QueryWrapper<SpmkApproveSummary>()
				.lambda()
				.select(SpmkApproveSummary::getSts)
				.eq(SpmkApproveSummary::getId, id));
		
846
		return as != null && as.getSts() != ApproveSummarySts.FINISH.ordinal() ? (SpmkApproveSummary.builder().id(id).endTime(new Date()).sts(ApproveSummarySts.UNDONE.ordinal()).build().updateById() ? 
847
				ResultUtil.success() : ResultUtil.error("撤销异常")) : ResultUtil.error("审批已结束,无法撤销!");
848 849 850 851 852 853 854 855
	}
	
	/**
	 * 删除-审批(发起的审批)-根据审批汇总id
	 */
	@DeleteMapping(value = "/delete_approval/{id}")
	@ApiOperation(value = "23.删除-审批(发起的审批)-根据审批汇总id", httpMethod = "DELETE", notes = "删除-审批(发起的审批)-根据审批汇总id")
	@ApiOperationSupport(order = 23)
tangzhaoqian committed
856
	@Log(title = "审批-删除审批", businessType = BusinessType.DELETE)
857 858 859 860 861
	public Result<Object> deleteApprovalData(@PathVariable Integer id){
		List<SpmkApproveExecuteRecord> listAer = spmkApproveExecuteRecordMapper.selectList(new QueryWrapper<SpmkApproveExecuteRecord>()
				.lambda()
				.select(SpmkApproveExecuteRecord::getId)
				.eq(SpmkApproveExecuteRecord::getApproveSummaryId, id));
862
		if (listAer != null && listAer.size() > 0) {
863 864 865 866 867 868 869 870 871 872 873
			for (SpmkApproveExecuteRecord aer : listAer) {
				spmkExecutorMapper.delete(new QueryWrapper<SpmkExecutor>().lambda().eq(SpmkExecutor::getApproveExecuteRecordId, aer.getId()));
			}
		}
		
		spmkApproveExecuteRecordMapper.delete(new QueryWrapper<SpmkApproveExecuteRecord>().lambda().eq(SpmkApproveExecuteRecord::getApproveSummaryId, id));
		
		spmkApproveDetailMapper.delete(new QueryWrapper<SpmkApproveDetail>().lambda().eq(SpmkApproveDetail::getApproveSummaryId, id));
		
		spmkApproveSummaryMapper.delete(new QueryWrapper<SpmkApproveSummary>().lambda().eq(SpmkApproveSummary::getId, id));
		
874
		return ResultUtil.success();
875 876
	}
	
877
	/**
878
	 * 删除-审批组、自定义审批、审批汇总、审批详情、审批执行记录、审批执行人记录 所有数据
879 880
	 */
	@DeleteMapping(value = "/delete_approval_data")
881
	@ApiOperation(value = "90.(开发使用)删除-审批数据", httpMethod = "DELETE", notes = "审批组、自定义审批、审批汇总、审批详情、审批执行记录、审批执行人记录 所有数据")
tangzhaoqian committed
882
	@ApiOperationSupport(order = 90)
883
	public Result<Object> deleteApprovalData(@CurrentUser UserBean userBean){
884 885
		spmkApprovalGMapper.delete(null);
		spmkCustomApprovalMapper.delete(null);
886 887 888 889
		spmkApproveSummaryMapper.delete(null);
		spmkApproveDetailMapper.delete(null);
		spmkApproveExecuteRecordMapper.delete(null);
		spmkExecutorMapper.delete(null);
890
		System.out.println("删除-审批组、自定义审批、审批汇总、审批详情、审批执行记录、审批执行人记录 所有数据 完成!");
891
		return ResultUtil.success();
892
	}
893
	
tangzhaoqian committed
894 895 896 897 898 899 900 901 902 903 904
	//TODO 审批图标列表
	@GetMapping(value = "/icon")
	@ApiOperation(value = "99.图标列表", httpMethod = "GET", notes = "接口发布说明")
	@ApiOperationSupport(order = 99)
	public Result<List<SpmkIcon>> selectListIcon(@CurrentUser UserBean userBean){
		
		List<SpmkIcon> spmkIcons = SpmkIcon.builder().build().selectAll();
		
		return ResultUtil.data(spmkIcons,"获取图标列表成功");
	}
	
905 906 907 908 909 910
	//TODO 测试-生成 审批组 和 自定义审批
	@GetMapping(value = "/test")
	@ApiOperation(value = "98.测试-生成 审批组 和 自定义审批", httpMethod = "GET", notes = "测试-生成 审批组 和 自定义审批")
	@ApiOperationSupport(order = 98)
	public Result<List<SpmkIcon>> createCustomApproval(@RequestParam Integer orgCode){
		
911
		spmkService.createCustomApproval(orgCode);
912 913 914
		
		List<SpmkIcon> spmkIcons = SpmkIcon.builder().build().selectAll();
		
915
		return ResultUtil.data(spmkIcons,"生成 审批组 和 自定义审批成功");
916
	}
lal committed
917 918 919 920 921 922 923 924 925 926 927 928 929
	
	@GetMapping(value = "/verification_staff")
	@ApiOperation(value = "校验员工是否是正式员工", httpMethod = "GET", notes = " 查询列表-假期规则")
	public Result<Object> verification_staff(@CurrentUser UserBean userBean) {
		String msg = "";
		YgglMainEmp ygem = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getOrgCode, userBean.getOrgCode())
				.eq(YgglMainEmp::getEmpNum, userBean.getEmpNum()));
		if(ygem.getJobStatus() == 1) {
			msg = "正式员工不能发起转正审批";
		}
		
		return ResultUtil.data(msg);
	}
lal committed
930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969
	
	@PostMapping(value = "/approved_quantity")
	@ApiOperation(value = "APP-我发起的/我审批的/抄送我的-数量", httpMethod = "POST", notes = "")
	public Result<Object> ApprovedQuantity(@CurrentUser UserBean userBean, @Validated @RequestBody MySummaryQueryDto mysummaryquerydto){
		
			ApprovedQuantityDto qna = ApprovedQuantityDto.builder().build();
			
			mysummaryquerydto.setEndTime(null);
			mysummaryquerydto.setStartTime(null);
			
			mysummaryquerydto.setOrgCode(userBean.getOrgCode());
			mysummaryquerydto.setEmpNum(userBean.getEmpNum());
			mysummaryquerydto.setSts(5);//状态 0审批中 1审批撤销 2审批通过/审批完成 3审批拒绝 4:(2/3)	5:全部
	
			int istartedit=0,ccme=0,iapprovedit=0;
			mysummaryquerydto.setType(0);//我发起的
			List<SpmkApproveSummary> istartedit_ = spmkApproveSummaryMapper.selectPageByQueryForEmpNum(mysummaryquerydto);
			if(istartedit_.size() > 0) {
				istartedit = istartedit_.size();
			}
			
			mysummaryquerydto.setType(1);//抄送我的
			List<SpmkApproveSummary> ccme_ = spmkApproveSummaryMapper.selectPageByQueryForEmpNum(mysummaryquerydto);
			if(ccme_.size() > 0) {
				ccme = ccme_.size();
			}
			
			mysummaryquerydto.setType(2);//我审批的
			List<SpmkApproveSummary> iapprovedit_ = spmkApproveSummaryMapper.selectPageByQueryForEmpNum(mysummaryquerydto);
			if(iapprovedit_.size() > 0) {
				iapprovedit = iapprovedit_.size();
			}
			
			qna.setIstartedit(istartedit);
			qna.setCcme(ccme);
			qna.setIapprovedit(iapprovedit);
	
			
			return ResultUtil.data(qna);
	}
yuquan.zhu committed
970
}