|  | @@ -0,0 +1,233 @@
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * Copyright © 2021-2025 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +package com.jeeplus.gwflow.controller;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +import javax.servlet.http.HttpServletResponse;
 | 
	
		
			
				|  |  | +import javax.validation.Valid;
 | 
	
		
			
				|  |  | +import com.google.common.collect.Lists;
 | 
	
		
			
				|  |  | +import com.jeeplus.aop.logging.annotation.ApiLog;
 | 
	
		
			
				|  |  | +import com.jeeplus.circulation2.service.GwCirculationCard2Service;
 | 
	
		
			
				|  |  | +import com.jeeplus.circulation2.service.dto.GwCirculationCard2DTO;
 | 
	
		
			
				|  |  | +import com.jeeplus.circulation2.service.mapstruct.GwCirculationCard2Wrapper;
 | 
	
		
			
				|  |  | +import com.jeeplus.core.excel.EasyExcelUtils;
 | 
	
		
			
				|  |  | +import com.jeeplus.core.excel.ExcelOptions;
 | 
	
		
			
				|  |  | +import com.jeeplus.core.excel.annotation.ExportMode;
 | 
	
		
			
				|  |  | +import com.jeeplus.core.query.QueryWrapperGenerator;
 | 
	
		
			
				|  |  | +import com.jeeplus.sys.service.UserService;
 | 
	
		
			
				|  |  | +import com.jeeplus.sys.service.dto.UserDTO;
 | 
	
		
			
				|  |  | +import com.jeeplus.sys.utils.UserUtils;
 | 
	
		
			
				|  |  | +import io.swagger.annotations.Api;
 | 
	
		
			
				|  |  | +import io.swagger.annotations.ApiOperation;
 | 
	
		
			
				|  |  | +import org.springframework.http.ResponseEntity;
 | 
	
		
			
				|  |  | +import org.springframework.security.access.prepost.PreAuthorize;
 | 
	
		
			
				|  |  | +import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | +import org.springframework.web.bind.annotation.*;
 | 
	
		
			
				|  |  | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 | 
	
		
			
				|  |  | +import com.baomidou.mybatisplus.core.metadata.IPage;
 | 
	
		
			
				|  |  | +import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
	
		
			
				|  |  | +import com.jeeplus.gwflow.domain.GwFlow;
 | 
	
		
			
				|  |  | +import com.jeeplus.gwflow.service.dto.GwFlowDTO;
 | 
	
		
			
				|  |  | +import com.jeeplus.gwflow.service.mapstruct.GwFlowWrapper;
 | 
	
		
			
				|  |  | +import com.jeeplus.gwflow.service.GwFlowService;
 | 
	
		
			
				|  |  | +import org.springframework.web.multipart.MultipartFile;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +import java.io.IOException;
 | 
	
		
			
				|  |  | +import java.util.List;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * 公文流程Controller
 | 
	
		
			
				|  |  | + * @author 尹宇
 | 
	
		
			
				|  |  | + * @version 2024-03-21
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +@Api(tags ="公文流程")
 | 
	
		
			
				|  |  | +@RestController
 | 
	
		
			
				|  |  | +@RequestMapping(value = "/gwflow/gwFlow")
 | 
	
		
			
				|  |  | +public class GwFlowController {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	@Autowired
 | 
	
		
			
				|  |  | +	private GwFlowService gwFlowService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	@Autowired
 | 
	
		
			
				|  |  | +	private GwFlowWrapper gwFlowWrapper;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	@Autowired
 | 
	
		
			
				|  |  | +	private UserService userService;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	@Autowired
 | 
	
		
			
				|  |  | +	private GwCirculationCard2Service gwCirculationCard2Service;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	@Autowired
 | 
	
		
			
				|  |  | +	private GwCirculationCard2Wrapper gwCirculationCard2Wrapper;
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 公文流程列表数据
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	@ApiLog("查询公文流程列表数据")
 | 
	
		
			
				|  |  | +	@ApiOperation(value = "查询公文流程列表数据")
 | 
	
		
			
				|  |  | +	@PreAuthorize("hasAuthority('gwflow:gwFlow:list')")
 | 
	
		
			
				|  |  | +	@GetMapping("list")
 | 
	
		
			
				|  |  | +	public ResponseEntity<IPage<GwFlowDTO>> list(GwFlowDTO gwFlowDTO, Page<GwFlow> page) throws Exception {
 | 
	
		
			
				|  |  | +		QueryWrapper queryWrapper = QueryWrapperGenerator.buildQueryCondition (gwFlowDTO, GwFlowDTO.class);
 | 
	
		
			
				|  |  | +		IPage<GwFlowDTO> result = gwFlowWrapper.toDTO ( gwFlowService.page (page, queryWrapper) );
 | 
	
		
			
				|  |  | +		return ResponseEntity.ok (result);
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 根据Id获取公文流程数据
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	@ApiLog("根据Id获取公文流程数据")
 | 
	
		
			
				|  |  | +	@ApiOperation(value = "根据Id获取公文流程数据")
 | 
	
		
			
				|  |  | +	@PreAuthorize("hasAnyAuthority('gwflow:gwFlow:view','gwflow:gwFlow:add','gwflow:gwFlow:edit')")
 | 
	
		
			
				|  |  | +	@GetMapping("queryById")
 | 
	
		
			
				|  |  | +	public ResponseEntity<GwFlowDTO> queryById(String id) {
 | 
	
		
			
				|  |  | +		return ResponseEntity.ok ( gwFlowWrapper.toDTO ( gwFlowService.getById ( id ) ) );
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 根据GWId获取公文流程数据
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	@ApiLog("根据GWId获取公文流程数据")
 | 
	
		
			
				|  |  | +	@ApiOperation(value = "根据GWId获取公文流程数据")
 | 
	
		
			
				|  |  | +	@GetMapping("queryByGwId")
 | 
	
		
			
				|  |  | +	public ResponseEntity<List<GwFlowDTO>> queryByGwId(String Gwid) {
 | 
	
		
			
				|  |  | +		return ResponseEntity.ok (  gwFlowService.getByGwId ( Gwid )  );
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 保存公文流程
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	@ApiLog("保存公文流程")
 | 
	
		
			
				|  |  | +	@ApiOperation(value = "保存公文流程")
 | 
	
		
			
				|  |  | +	@PreAuthorize("hasAnyAuthority('gwflow:gwFlow:add','gwflow:gwFlow:edit')")
 | 
	
		
			
				|  |  | +	@PostMapping("save")
 | 
	
		
			
				|  |  | +	public  ResponseEntity <String> save(@Valid @RequestBody GwFlowDTO gwFlowDTO) {
 | 
	
		
			
				|  |  | +		//新增或编辑表单保存
 | 
	
		
			
				|  |  | +		gwFlowService.saveOrUpdate (gwFlowWrapper.toEntity (gwFlowDTO));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		//此时是办公室主任选人后的操作
 | 
	
		
			
				|  |  | +		if(gwFlowDTO.getNext()!=null&&gwFlowDTO.getNext().equals("1")){
 | 
	
		
			
				|  |  | +			UserDTO userDTO= UserUtils.getCurrentUserDTO();
 | 
	
		
			
				|  |  | +			//有选择领导的时候新增
 | 
	
		
			
				|  |  | +			if(gwFlowDTO.getNextLeadUser()!=null&&gwFlowDTO.getNextLeadUser().contains(",")) {
 | 
	
		
			
				|  |  | +			   String [] NextLeadUsers=gwFlowDTO.getNextLeadUser().split(",");
 | 
	
		
			
				|  |  | +				for (String user:NextLeadUsers) {//每个领导都生成一条流程数据
 | 
	
		
			
				|  |  | +					if(!user.equals("")){
 | 
	
		
			
				|  |  | +						GwFlowDTO a1=new GwFlowDTO();
 | 
	
		
			
				|  |  | +						a1.setGwId(gwFlowDTO.getGwId());
 | 
	
		
			
				|  |  | +						a1.setState("1");
 | 
	
		
			
				|  |  | +						UserDTO userDTO2=userService.getUserByLoginName(user,"10000");
 | 
	
		
			
				|  |  | +						a1.setCreateBy(userDTO);
 | 
	
		
			
				|  |  | +						a1.setUpdateBy(userDTO2);
 | 
	
		
			
				|  |  | +						a1.setCreateTruename(userDTO.getName());
 | 
	
		
			
				|  |  | +						a1.setNextTruename(userDTO2.getName());
 | 
	
		
			
				|  |  | +						a1.setNextUser(userDTO2.getId());
 | 
	
		
			
				|  |  | +						a1.setWhich("1");
 | 
	
		
			
				|  |  | +						gwFlowService.saveOrUpdate (gwFlowWrapper.toEntity (a1));
 | 
	
		
			
				|  |  | +					}
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			//有选择科室承办的时候新增
 | 
	
		
			
				|  |  | +			if(gwFlowDTO.getNextDepUser()!=null&&gwFlowDTO.getNextDepUser().contains(",")) {
 | 
	
		
			
				|  |  | +				String [] NextDepUsers=gwFlowDTO.getNextDepUser().split(",");
 | 
	
		
			
				|  |  | +				for (String user:NextDepUsers) {//每个领导都生成一条流程数据
 | 
	
		
			
				|  |  | +					if(!user.equals("")){
 | 
	
		
			
				|  |  | +						GwFlowDTO a1=new GwFlowDTO();
 | 
	
		
			
				|  |  | +						a1.setGwId(gwFlowDTO.getGwId());
 | 
	
		
			
				|  |  | +						a1.setState("1");
 | 
	
		
			
				|  |  | +						UserDTO userDTO2=userService.getUserByLoginName(user,"10000");
 | 
	
		
			
				|  |  | +						a1.setCreateBy(userDTO);
 | 
	
		
			
				|  |  | +						a1.setUpdateBy(userDTO2);
 | 
	
		
			
				|  |  | +						a1.setCreateTruename(userDTO.getName());
 | 
	
		
			
				|  |  | +						a1.setNextTruename(userDTO2.getName());
 | 
	
		
			
				|  |  | +						a1.setNextUser(userDTO2.getId());
 | 
	
		
			
				|  |  | +						a1.setWhich("2");
 | 
	
		
			
				|  |  | +						gwFlowService.saveOrUpdate (gwFlowWrapper.toEntity (a1));
 | 
	
		
			
				|  |  | +					}
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			//remark不为空时,备注更新
 | 
	
		
			
				|  |  | +			if(gwFlowDTO.getRemark()!=null&&!gwFlowDTO.getRemark().equals("")){
 | 
	
		
			
				|  |  | +				GwCirculationCard2DTO gwCirculationCard2DTO =gwCirculationCard2Wrapper.toDTO (gwCirculationCard2Service.getById ( gwFlowDTO.getGwId() ));
 | 
	
		
			
				|  |  | +				gwCirculationCard2DTO.setRemark(gwFlowDTO.getRemark());
 | 
	
		
			
				|  |  | +				gwCirculationCard2Service.saveOrUpdate (gwCirculationCard2Wrapper.toEntity (gwCirculationCard2DTO));
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        return ResponseEntity.ok ( "保存公文流程成功" );
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 删除公文流程
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	@ApiLog("删除公文流程")
 | 
	
		
			
				|  |  | +	@ApiOperation(value = "删除公文流程")
 | 
	
		
			
				|  |  | +	@PreAuthorize("hasAuthority('gwflow:gwFlow:del')")
 | 
	
		
			
				|  |  | +	@DeleteMapping("delete")
 | 
	
		
			
				|  |  | +	public ResponseEntity <String> delete(String ids) {
 | 
	
		
			
				|  |  | +		String idArray[] = ids.split(",");
 | 
	
		
			
				|  |  | +        gwFlowService.removeByIds ( Lists.newArrayList ( idArray ) );
 | 
	
		
			
				|  |  | +		return ResponseEntity.ok( "删除公文流程成功" );
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 导出公文流程数据
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param gwFlowDTO
 | 
	
		
			
				|  |  | +     * @param page
 | 
	
		
			
				|  |  | +     * @param response
 | 
	
		
			
				|  |  | +     * @throws Exception
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    @ApiLog("导出公文流程数据")
 | 
	
		
			
				|  |  | +    @PreAuthorize("hasAnyAuthority('gwflow:gwFlow:export')")
 | 
	
		
			
				|  |  | +    @GetMapping("export")
 | 
	
		
			
				|  |  | +    public void exportFile(GwFlowDTO gwFlowDTO, Page <GwFlow> page, ExcelOptions options, HttpServletResponse response) throws Exception {
 | 
	
		
			
				|  |  | +        String fileName = options.getFilename ( );
 | 
	
		
			
				|  |  | +		QueryWrapper queryWrapper = QueryWrapperGenerator.buildQueryCondition (gwFlowDTO, GwFlowDTO.class);
 | 
	
		
			
				|  |  | +        if ( ExportMode.current.equals ( options.getMode ( ) ) ) { // 导出当前页数据
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        } else if ( ExportMode.selected.equals ( options.getMode ( ) ) ) { // 导出选中数据
 | 
	
		
			
				|  |  | +            queryWrapper.in ( "id", options.getSelectIds () );
 | 
	
		
			
				|  |  | +        } else { // 导出全部数据
 | 
	
		
			
				|  |  | +            page.setSize ( -1 );
 | 
	
		
			
				|  |  | +            page.setCurrent ( 0 );
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        List < GwFlow> result = gwFlowService.page ( page, queryWrapper ).getRecords ( );
 | 
	
		
			
				|  |  | +        EasyExcelUtils.newInstance ( gwFlowService, gwFlowWrapper ).exportExcel ( result,  options.getSheetName ( ), GwFlowDTO.class, fileName,options.getExportFields (), response );
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 导入公文流程数据
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    @PreAuthorize("hasAnyAuthority('gwflow:gwFlow:import')")
 | 
	
		
			
				|  |  | +    @PostMapping("import")
 | 
	
		
			
				|  |  | +    public ResponseEntity importFile(MultipartFile file) throws IOException {
 | 
	
		
			
				|  |  | +        String result = EasyExcelUtils.newInstance ( gwFlowService, gwFlowWrapper ).importExcel ( file, GwFlowDTO.class );
 | 
	
		
			
				|  |  | +        return ResponseEntity.ok ( result );
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 下载导入公文流程数据模板
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param response
 | 
	
		
			
				|  |  | +     * @return
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    @PreAuthorize ("hasAnyAuthority('gwflow:gwFlow:import')")
 | 
	
		
			
				|  |  | +    @GetMapping("import/template")
 | 
	
		
			
				|  |  | +    public void importFileTemplate(HttpServletResponse response) throws IOException {
 | 
	
		
			
				|  |  | +        String fileName = "公文流程数据导入模板.xlsx";
 | 
	
		
			
				|  |  | +        List<GwFlowDTO> list = Lists.newArrayList();
 | 
	
		
			
				|  |  | +        EasyExcelUtils.newInstance ( gwFlowService, gwFlowWrapper ).exportExcel ( list,  "公文流程数据", GwFlowDTO.class, fileName, null, response );
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +}
 |