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

ilal committed
3 4
import java.text.DateFormat;
import java.text.SimpleDateFormat;
5
import java.util.ArrayList;
tangzhaoqian committed
6
import java.util.Date;
tangzhaoqian committed
7
import java.util.HashSet;
yuquan.zhu committed
8
import java.util.List;
tangzhaoqian committed
9
import java.util.Set;
yuquan.zhu committed
10

yuquan.zhu committed
11
import cn.timer.api.dto.spmk.*;
yuquan.zhu committed
12
import org.springframework.beans.factory.annotation.Autowired;
ilal committed
13
import org.springframework.beans.factory.annotation.Value;
yuquan.zhu committed
14
import org.springframework.transaction.annotation.Transactional;
15 16
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.MethodArgumentNotValidException;
yuquan.zhu committed
17 18 19 20 21 22 23
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;
24
import org.springframework.web.bind.annotation.RequestParam;
yuquan.zhu committed
25 26 27 28
import org.springframework.web.bind.annotation.RestController;

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

import cn.hutool.core.bean.BeanUtil;
tangzhaoqian committed
34
import cn.hutool.core.collection.CollUtil;
35
import cn.hutool.core.collection.CollectionUtil;
36
import cn.hutool.core.lang.Console;
yuquan.zhu committed
37
import cn.hutool.core.util.ObjectUtil;
38
import cn.hutool.json.JSONObject;
tangzhaoqian committed
39 40
import cn.timer.api.aspect.lang.annotation.Log;
import cn.timer.api.aspect.lang.enums.BusinessType;
lal committed
41 42
import cn.timer.api.bean.kqgl.PunchRecord;
import cn.timer.api.bean.kqmk.KqglAssoLeaveRules;
43
import cn.timer.api.bean.qyzx.QyzxEmpEntAsso;
44 45 46 47
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;
48
import cn.timer.api.bean.spmk.SpmkApproveExecuteRecord;
49 50
import cn.timer.api.bean.spmk.SpmkApproveSummary;
import cn.timer.api.bean.spmk.SpmkCustomApproval;
tangzhaoqian committed
51
import cn.timer.api.bean.spmk.SpmkExecutor;
yuquan.zhu committed
52
import cn.timer.api.bean.spmk.SpmkIcon;
53
import cn.timer.api.bean.spmk.SpmkInitiatorConfig;
54
import cn.timer.api.bean.yggl.YgglMainEmp;
tangzhaoqian committed
55
import cn.timer.api.bean.zzgl.ZzglBmgwM;
yuquan.zhu committed
56 57
import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
58
import cn.timer.api.config.enuminterface.SpmkEnumInterface;
59
import cn.timer.api.config.enuminterface.SpmkEnumInterface.ApproveSummarySts;
tangzhaoqian committed
60
import cn.timer.api.config.enuminterface.SpmkEnumInterface.ExecutorSts;
61
import cn.timer.api.config.enums.CommonEnum;
62
import cn.timer.api.config.enums.SysRoleType;
63
import cn.timer.api.config.exception.CustomException;
64
import cn.timer.api.config.validation.Insert;
65
import cn.timer.api.config.validation.Ranks;
66
import cn.timer.api.config.validation.Update;
67
import cn.timer.api.config.validation.ValidList;
68
import cn.timer.api.controller.spmk.service.SpmkService;
69
import cn.timer.api.controller.yggl.service.YgglService;
70
import cn.timer.api.controller.zzgl.service.ZzglBmgwMService;
lal committed
71
import cn.timer.api.dao.kqgl.PunchRecordMapper;
72
import cn.timer.api.dao.qyzx.QyzxEmpEntAssoMapper;
73 74 75 76 77 78 79 80 81
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;
yuquan.zhu committed
82 83
import cn.timer.api.utils.Result;
import cn.timer.api.utils.ResultUtil;
84
import cn.timer.api.utils.router.RouterUtils;
85 86 87
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
88 89 90 91 92 93 94 95
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" })
96
public class SpmkController {
yuquan.zhu committed
97 98

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

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

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

	/**
	 * id查询-审批模板
	 */
240
	@GetMapping(value = "/select_approval_template/{id}")
241 242
	@ApiOperation(value = "7.id查询-审批模板", httpMethod = "GET", notes = "id查询-审批模板")
	@ApiOperationSupport(order = 7)
243
	public Result<Object> selectAtById(@PathVariable int id){
244 245 246 247 248 249
		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()));
250
        return ResultUtil.data(atd);
251 252 253 254 255 256
        
	}
	
	/**
	 * 排序-审批模板
	 */
tangzhaoqian committed
257
	@PutMapping(value = "/update_approval_template")
258
	@ApiOperation(value = "8.排序-审批模板", httpMethod = "PUT", notes = "查询列表-审批模板组")
259
	@ApiOperationSupport(order = 8)
260
	public Result<Object> ranksAt(@Validated({Ranks.class})@RequestBody ValidList<SpmkApprovalTemplate> list){
261

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

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

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

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

		// 清空前端不需要的字段再返回,节省流量
		ca.setFroms(null);
		ca.setRouter(null);
408
		return ResultUtil.data(ca);
409 410
		
	}
411
	
412 413
	/**
	 * 删除-自定义审批
414
	 * @throws Exception 
415 416
	 */
	@DeleteMapping(value = "/delete_custom_approval/{id}")
417
	@ApiOperation(value = "14.删除-自定义审批", httpMethod = "DELETE", notes = "删除-自定义审批")
418
	@Transactional(rollbackFor = Exception.class)
419
	@ApiOperationSupport(order = 14)
420 421 422 423 424 425 426
	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();
		}
		
427
		return  ResultUtil.success();
428 429 430 431 432
	}

	/**
	 * id查询-自定义审批
	 */
433 434 435
	@GetMapping(value = "/select_custom_approval/{id}")
	@ApiOperation(value = "15.id查询-自定义审批", httpMethod = "GET", notes = "id查询-自定义审批")
	@ApiOperationSupport(order = 15)
436
	public Result<Object> selectCaById(@PathVariable int id){
437
		SpmkCustomApproval ca = SpmkCustomApproval.builder().id(id).build().selectById();
438
		List<SpmkInitiatorConfig> listIc = SpmkInitiatorConfig.builder().build().selectList(new QueryWrapper<SpmkInitiatorConfig>().lambda().eq(SpmkInitiatorConfig::getCustomApprovalId, id));
439
		SpmkCustomApprovalDto caD = SpmkCustomApprovalDto.builder()
440 441
				.froms(ObjectUtil.deserialize(ca.getFroms()))
				.router(ObjectUtil.deserialize(ca.getRouter()))
442 443
				.build();
		BeanUtil.copyProperties(ca, caD,"froms","router");
444
		caD.setInitiatorConfigs(listIc);
445
        return ResultUtil.data(caD);
446
	}
447
	
448 449 450
	/**
	 * 排序-自定义审批
	 */
tangzhaoqian committed
451
	@PutMapping(value = "/update_custom_approval")
452 453
	@ApiOperation(value = "16.排序-自定义审批", httpMethod = "PUT", notes = "排序-自定义审批")
	@ApiOperationSupport(order = 16)
454
	public Result<Object> ranksCa(@Validated({Ranks.class}) @RequestBody ValidList<SpmkCustomApproval> list){
455 456 457 458 459 460
		
		if (list == null || (list != null && list.size() <= 0)) {
			return ResultUtil.success();
		}
		
        return spmkCustomApprovalMapper.updateListRandsById(list) ? ResultUtil.success() : ResultUtil.error();
461
	}
462
	
463 464 465
	@Autowired
	YgglService ygglService;
	
tangzhaoqian committed
466 467 468 469 470 471 472 473 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
	/**
	 * 排序-自定义审批
	 */
	@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;
		Set<Integer> all = getId != null ? empNumupdept2(lanzi, bmgws, getId) : new HashSet<Integer>();
		all.add(getId);
		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;
	}
	
503 504 505
	// TODO 审批汇总(发起审批)
	/**
	 * 发起审批
506
	 * @throws Exception 
507 508
	 */
	@PostMapping(value = "/start_approval")
509 510 511
	@ApiOperation(value = "17.发起审批", httpMethod = "POST", notes = "发起审批")
	@ApiOperationSupport(order = 17)
	@Transactional(rollbackFor = Exception.class)
tangzhaoqian committed
512
	@Log(title = "审批-发起审批", businessType = BusinessType.INSERT)
tangzhaoqian committed
513
	public Result<Object> saveA(@CurrentUser UserBean userBean,@Validated @RequestBody SpmkApproveSummaryDto spmkApproveSummaryDto) throws Exception{
514 515 516
			YgglMainEmp ygglMainEmp = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>()
					.lambda()
					.select(YgglMainEmp::getHeadUrl,YgglMainEmp::getName)
517 518 519
					.eq(YgglMainEmp::getEmpNum, userBean.getEmpNum())
					.eq(YgglMainEmp::getOrgCode, userBean.getOrgCode())
					);
520 521
			
			if (ygglMainEmp == null) 
522 523 524
				return ResultUtil.error("发起人不存在!");
			
//			List<SpmkApprovalG> saG = spmkService.selectListAg(userBean);
525
			
526 527
			Router router = spmkApproveSummaryDto.getRouter();
			List<Router> routers = router.getChildren();
yuquan.zhu committed
528 529 530 531
//			routers = RouterUtils.clearRouters(routers);
			if(routers==null){
				return ResultUtil.error("无法发起,请完善审批流程");
			}
532
			if (CollectionUtil.isNotEmpty(routers)) {
yuquan.zhu committed
533 534 535 536 537 538 539
//				boolean hasAudit=false;
//				if(routers.size()>0){
//					for (Relation relation:routers.get(0).getRelation()) {
//						if(relation.getUsers().size()>0){
//							hasAudit=true;
//						}
//					}
yuquan.zhu committed
540
//				}
yuquan.zhu committed
541 542 543 544 545 546 547 548 549 550
////				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("无法发起,请完善审批流程");
////				}
//				if(!hasAudit){
//					return ResultUtil.error("请选择审批人!");
yuquan.zhu committed
551
//				}
552 553 554 555
			}else {
				return ResultUtil.error("无法发起,请完善审批流程");
			}
			
556
			List<Router> listRouter = new ArrayList<Router>();
557 558
			listRouter.add(router);
			
559
			JSONObject jSONObject = spmkApproveSummaryDto.getRequestData()
tangzhaoqian committed
560 561 562 563
					.set("orgCode", userBean.getOrgCode())
					.set("initiator", ygglMainEmp.getName())
					.set("headUrl", ygglMainEmp.getHeadUrl())
					.set("id", userBean.getEmpNum());
564 565 566
			RouterUtils.NextNode(listRouter, jSONObject, ISFIRST);
			List<FlowChildren> listFlowChildren = new ArrayList<FlowChildren>();
			RouterUtils.getIsFlowChildren(listRouter,listFlowChildren);
yuquan.zhu committed
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585

			if(listFlowChildren.isEmpty()){
				return ResultUtil.error("无法发起,请完善审批流程");
			}

		for (FlowChildren flowChildrenItem: listFlowChildren) {
			if("audit".equals(flowChildrenItem.getClassName())){
				boolean hasAudit=false;
				for (Relation relation:flowChildrenItem.getRelation()) {
					if(relation.getUsers().size()>0){
						hasAudit=true;
					}
				}
				if(!hasAudit){
					return ResultUtil.error("审批流程设置审批人为空无法发起!");
				}
			}
		}

ilal committed
586
			Logoutput("listFlowChildren");
587
			
588 589 590 591 592 593 594 595 596 597
			// 当前审批人
			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())
598
					.assoType(spmkApproveSummaryDto.getAssoType())
599
					.sts(ApproveSummarySts.IN.ordinal())
600
					.currentApprover(currentApprover).build();
601
			
602
			if (!as.insert()) {
603
				throw new CustomException("审批汇总-新增异常");
604
			}
605
			
tangzhaoqian committed
606
			// 插入记录- 审批执行记录 - 执行人记录
607 608
			RouterUtils.insertogExecuteRecord(listFlowChildren, as.getId());
			
609 610 611 612 613
			// 封装 审批详情
			SpmkApproveDetail ad = SpmkApproveDetail.builder().build();
			ad.setApproveSummaryId(as.getId());
			ad.setName(spmkApproveSummaryDto.getTitle());
			ad.setRequestData(ObjectUtil.serialize(spmkApproveSummaryDto.getRequestData()));
614
			ad.setFroms(ObjectUtil.serialize((List<JSONObject>)spmkApproveSummaryDto.getFroms()));
615 616
			ad.setRouter(ObjectUtil.serialize(listRouter.get(0)));
			ad.setFlowChildren(ObjectUtil.serialize(listFlowChildren));
617
			
618
			if (!ad.insert()) 
619
				throw new CustomException("审批详情-新增异常");
620
			
621
			return ResultUtil.success();
622 623
	}
	
624
	//TODO 审批汇总
625 626 627 628
	/**
	 * 审批汇总
	 * @param summaryQueryDto
	 * @return
629
	 * @throws  
630
	 */
631 632 633
	@PostMapping(value = "/select_approve_summary")
	@ApiOperation(value = "18.审批汇总", httpMethod = "POST", notes = "审批汇总")
	@ApiOperationSupport(order = 18)
tangzhaoqian committed
634
	@Log(title = "审批-审批汇总", businessType = BusinessType.OTHER)
635 636 637 638 639 640
	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());
641 642
			
			Integer deptId = summaryQueryDto.getDeptId();
tangzhaoqian committed
643
			List<YgglMainEmp> listYgglMainEmp = zzglBmgwMService.selectOtherlistent(userBean.getOrgCode(), deptId);
tangzhaoqian committed
644

645
			if (deptId != null && (listYgglMainEmp == null || listYgglMainEmp.size() == 0)) {
646
				return ResultUtil.data(new ArrayList<SpmkApproveSummary>());
647 648 649 650 651 652 653
			}
			
			List<Integer> empNums = new ArrayList<Integer>();
			for (YgglMainEmp ygglMainEmp : listYgglMainEmp) {
				empNums.add(ygglMainEmp.getEmpNum());
			}
			summaryQueryDto.setEmpNums(empNums);
654

655
			// 缺-部门id 搜索
656 657 658
			IPage<SpmkApproveSummary> pageAs = spmkApproveSummaryMapper.selectPageByQuery(page, summaryQueryDto);
			
			List<SpmkApproveSummary> listAs = pageAs.getRecords();
659
			
660
			return ResultUtil.data(pageAs, listAs);
661
	}
662
	
663 664 665 666 667 668 669
	//TODO 审批详情
	/**
	 * 审批详情
	 */
	@GetMapping(value = "/select_approve_detail/{id}")
	@ApiOperation(value = "19.审批详情", httpMethod = "GET", notes = "审批详情")
	@ApiOperationSupport(order = 19)
tangzhaoqian committed
670
	@Log(title = "审批-审批详情", businessType = BusinessType.OTHER)
tangzhaoqian committed
671
	public Result<Object> selectAd(@PathVariable(required = true) Integer id) {
672
		
673
		SpmkApproveDetailDto adD = spmkService.selectApproveDetailByAsId(id);
674
		
675
		return ResultUtil.data(adD);
676
	}
677
	
678 679 680 681 682 683
	//TODO 审批人审批
	/**
	 * 审批人审批
	 */
	@PostMapping(value = "/approving")
	@ApiOperation(value = "20.审批人审批", httpMethod = "POST", notes = "审批人审批")
tangzhaoqian committed
684 685
	@Transactional(rollbackFor = Exception.class)
	@ApiOperationSupport(order = 20)
tangzhaoqian committed
686
	@Log(title = "审批-审批流程", businessType = BusinessType.UPDATE)
687
//	@BindingResultCtrol(title = "审批人审批")
688 689
	public Result<Object> approving(@CurrentUser UserBean userBean,@Validated @RequestBody ApprovingDto approvingDto) throws Exception {
		
690
		Integer asId = approvingDto.getAsId();
691
		SpmkApproveDetail ad = SpmkApproveDetail.builder().build().selectOne(new QueryWrapper<SpmkApproveDetail>()
692
				.lambda()
693 694 695
				.select(SpmkApproveDetail::getId,
						SpmkApproveDetail::getRequestData,
						SpmkApproveDetail::getFlowChildren)
696
				.eq(SpmkApproveDetail::getApproveSummaryId, asId));
697
		
698 699 700
		// 查询 SpmkApproveSummary 状态
		SpmkApproveSummary aSummary = spmkApproveSummaryMapper.selectOne(new QueryWrapper<SpmkApproveSummary>().lambda()
				.select(SpmkApproveSummary::getSts)
701
				.eq(SpmkApproveSummary::getId, asId));
702
		
703
		if (aSummary.getSts() > SpmkEnumInterface.ApproveSummarySts.IN.ordinal()) {
704 705 706 707
			return ResultUtil.error("该审批已结束!");
		}
		
		// 查询该 审批的状态 是否为 1 审批中 
tangzhaoqian committed
708 709
		Integer count = SpmkExecutor.builder().build().selectCount(new QueryWrapper<SpmkExecutor>().lambda()
				.eq(SpmkExecutor::getId, approvingDto.getExecutorId())
tangzhaoqian committed
710
				.eq(SpmkExecutor::getSts, ExecutorSts.IN_EXECUTION.ordinal()));
tangzhaoqian committed
711 712 713 714 715
		
		if (count == 0) {
			return ResultUtil.error("您已审批过!");
		}
		
716 717 718 719
		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) {
720 721 722 723 724 725 726 727 728 729 730
			
			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("非当前审批人 或 管理员,无法操作!");
			}
			
731 732
		}
		
733
		if (aSummary.getSts() == 0) {
734
			List<FlowChildren> listFlowChildren = ObjectUtil.deserialize(ad.getFlowChildren());
735
			// 审批逻辑
736 737
			RouterUtils.approving(
					listFlowChildren, 
738
					asId, 
739 740 741
					approvingDto.getExecuteRecordId(), 
					approvingDto.getExecutorId(), 
					approvingDto.getOpinion(),
742 743 744
					approvingDto.getSts(),
					approvingDto.getUser()
					);
745 746
			
			// 更新 flowChildren
tangzhaoqian committed
747
			SpmkApproveDetail.builder().id(ad.getId()).flowChildren(ObjectUtil.serialize(listFlowChildren)).build().updateById();
748 749 750 751
			FlowChildren fc = CollUtil.getLast(listFlowChildren);
			if (fc.getExecute() == "2") {
				// 查询 SpmkApproveSummary 状态
				aSummary = spmkApproveSummaryMapper.selectOne(new QueryWrapper<SpmkApproveSummary>().lambda()
752
						.select(SpmkApproveSummary::getSts,SpmkApproveSummary::getAssoType)
753
						.eq(SpmkApproveSummary::getId, asId));
754
				
755
				if (aSummary.getSts() != SpmkEnumInterface.ApproveSummarySts.REFUSE.ordinal()) {
756
					SpmkApproveSummary.builder().id(asId).currentApprover(CommonEnum.NULL_STR.getDesc()).endTime(new Date()).sts(ApproveSummarySts.FINISH.ordinal()).build().updateById();
757
						
758
					JSONObject jSONObject = ObjectUtil.deserialize(ad.getRequestData());
tangzhaoqian committed
759
					jSONObject.set("approveId", FromData.builder().value(String.valueOf(asId)).build());
tangzhaoqian committed
760
					jSONObject.set("orgCode", userBean.getOrgCode());
761
					
762
					//审批完成后 业务
tangzhaoqian committed
763
					SpmkAssoBusiness sab = spmkAssoBusinessFactory.createSpmkService(ApproveEnum.getEnums(aSummary.getAssoType()));
764
					if (sab != null)
ilal committed
765 766
						Logoutput("1----------"+ sab);
						Logoutput("2----------"+ jSONObject);
767
						sab.handleApprove(jSONObject);
768
				}
tangzhaoqian committed
769
			}
770 771 772 773
			
		}else {
			return ResultUtil.error("该审批已结束!");
		}
774
		return ResultUtil.success();
775
	}
776
	
lal committed
777 778
	@Autowired
	private PunchRecordMapper punchrecordmapper;
tangzhaoqian committed
779
	//TODO 我发起的/我审批的/抄送我的
780
	/**
tangzhaoqian committed
781
	 * 查询列表-我发起的/我审批的/抄送我的-分页
782 783
	 */
	@PostMapping(value = "/select_my_approve")
tangzhaoqian committed
784
	@ApiOperation(value = "21.查询列表-我发起的/我审批的/抄送我的-分页", httpMethod = "POST", notes = "查询列表-我审批的-关键字、审批状态、发起时间-分页")
tangzhaoqian committed
785
	@ApiOperationSupport(order = 21)
tangzhaoqian committed
786
	@Log(title = "审批-我发起的/我审批的/抄送我的", businessType = BusinessType.OTHER)
787
	public Result<Object> selectMyAs(@CurrentUser UserBean userBean, @Validated @RequestBody MySummaryQueryDto mySummaryQueryDto) throws MethodArgumentNotValidException{
788 789 790 791 792
			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
793 794 795
			if(mySummaryQueryDto.getSts() == null) {
				mySummaryQueryDto.setSts(0);
			}
ilal committed
796 797
			//我发起的
			if(mySummaryQueryDto.getType() ==  0) {
ilal committed
798
//				mySummaryQueryDto.setSts(null);
ilal committed
799
			}
800 801 802 803
			// 缺-部门id 搜索
			IPage<SpmkApproveSummary> pageAs = spmkApproveSummaryMapper.selectPageByQueryForEmpNum(page, mySummaryQueryDto);
			
			List<SpmkApproveSummary> listAs = pageAs.getRecords();
lal committed
804 805 806 807 808 809 810 811
			
			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());
ilal committed
812 813
//					Logoutput(as);
//					Logoutput(sp.getId()+"==========================================="+sp.getAssoType());
lal committed
814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844
					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();
				}
ilal committed
845
//				Logoutput(requerstr);
lal committed
846 847 848
				sp.setDigest(requerstr);
			}
			
849
			return ResultUtil.data(pageAs, listAs);
850
	}
851
	
852 853 854 855 856 857 858 859
	//TODO 撤销审批
	/**
	 * 撤销审批
	 */
	@PutMapping(value = "/revoke_approval/{id}")
	@ApiOperation(value = "22.撤销审批", httpMethod = "PUT", notes = "撤销审批")
	@Transactional(rollbackFor = Exception.class)
	@ApiOperationSupport(order = 22)
tangzhaoqian committed
860
	@Log(title = "审批-撤销审批", businessType = BusinessType.UPDATE)
861 862 863 864 865 866 867
	public Result<Object> revokeApproval(@PathVariable Integer id) throws Exception {
		
		SpmkApproveSummary as = spmkApproveSummaryMapper.selectOne(new QueryWrapper<SpmkApproveSummary>()
				.lambda()
				.select(SpmkApproveSummary::getSts)
				.eq(SpmkApproveSummary::getId, id));
		
868
		return as != null && as.getSts() != ApproveSummarySts.FINISH.ordinal() ? (SpmkApproveSummary.builder().id(id).endTime(new Date()).sts(ApproveSummarySts.UNDONE.ordinal()).build().updateById() ? 
869
				ResultUtil.success() : ResultUtil.error("撤销异常")) : ResultUtil.error("审批已结束,无法撤销!");
870 871 872 873 874 875 876 877
	}
	
	/**
	 * 删除-审批(发起的审批)-根据审批汇总id
	 */
	@DeleteMapping(value = "/delete_approval/{id}")
	@ApiOperation(value = "23.删除-审批(发起的审批)-根据审批汇总id", httpMethod = "DELETE", notes = "删除-审批(发起的审批)-根据审批汇总id")
	@ApiOperationSupport(order = 23)
tangzhaoqian committed
878
	@Log(title = "审批-删除审批", businessType = BusinessType.DELETE)
879 880 881 882 883
	public Result<Object> deleteApprovalData(@PathVariable Integer id){
		List<SpmkApproveExecuteRecord> listAer = spmkApproveExecuteRecordMapper.selectList(new QueryWrapper<SpmkApproveExecuteRecord>()
				.lambda()
				.select(SpmkApproveExecuteRecord::getId)
				.eq(SpmkApproveExecuteRecord::getApproveSummaryId, id));
884
		if (listAer != null && listAer.size() > 0) {
885 886 887 888 889 890 891 892 893 894 895
			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));
		
896
		return ResultUtil.success();
897 898
	}
	
899
	/**
900
	 * 删除-审批组、自定义审批、审批汇总、审批详情、审批执行记录、审批执行人记录 所有数据
901 902
	 */
	@DeleteMapping(value = "/delete_approval_data")
903
	@ApiOperation(value = "90.(开发使用)删除-审批数据", httpMethod = "DELETE", notes = "审批组、自定义审批、审批汇总、审批详情、审批执行记录、审批执行人记录 所有数据")
tangzhaoqian committed
904
	@ApiOperationSupport(order = 90)
905
	public Result<Object> deleteApprovalData(@CurrentUser UserBean userBean){
906 907
		spmkApprovalGMapper.delete(null);
		spmkCustomApprovalMapper.delete(null);
908 909 910 911
		spmkApproveSummaryMapper.delete(null);
		spmkApproveDetailMapper.delete(null);
		spmkApproveExecuteRecordMapper.delete(null);
		spmkExecutorMapper.delete(null);
ilal committed
912
		Logoutput("删除-审批组、自定义审批、审批汇总、审批详情、审批执行记录、审批执行人记录 所有数据 完成!");
913
		return ResultUtil.success();
914
	}
915
	
tangzhaoqian committed
916 917 918 919 920 921 922 923 924 925 926
	//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,"获取图标列表成功");
	}
	
927 928 929 930 931 932
	//TODO 测试-生成 审批组 和 自定义审批
	@GetMapping(value = "/test")
	@ApiOperation(value = "98.测试-生成 审批组 和 自定义审批", httpMethod = "GET", notes = "测试-生成 审批组 和 自定义审批")
	@ApiOperationSupport(order = 98)
	public Result<List<SpmkIcon>> createCustomApproval(@RequestParam Integer orgCode){
		
933
		spmkService.createCustomApproval(orgCode);
934 935 936
		
		List<SpmkIcon> spmkIcons = SpmkIcon.builder().build().selectAll();
		
937
		return ResultUtil.data(spmkIcons,"生成 审批组 和 自定义审批成功");
938
	}
lal committed
939 940 941 942 943 944 945 946 947 948 949 950 951
	
	@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
952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991
	
	@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);
	}
ilal committed
992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005
	
	@Value("${config-8timer.environmental-science}")
	public String environmental_science;
	
	public void Logoutput(String science) {
		
		if(!("pro").equals(environmental_science)) {
			
			System.out.println(science);
		}else {
			System.out.println("");
		}
		
	}
yuquan.zhu committed
1006
}