| | |
| | | import com.alibaba.excel.event.AnalysisEventListener; |
| | | import com.alibaba.excel.exception.ExcelDataConvertException; |
| | | import com.consum.base.BaseController; |
| | | import com.consum.base.core.utils.FinSysTenantUtils; |
| | | import com.consum.base.pojo.FinSysTenantParam; |
| | | import com.consum.base.pojo.FinSysTenantSearchParam; |
| | | import com.consum.base.service.FinSysTenantServiceImpl; |
| | | import com.consum.base.service.FinSysTenantUserServiceImpl; |
| | | import com.consum.base.core.utils.FinSysTenantUtils; |
| | | import com.consum.model.po.FinSysTenant; |
| | | import com.consum.model.po.FinSysTenantUser; |
| | | import com.consum.model.vo.FinSysTenantUserResult; |
| | |
| | | import com.walker.infrastructure.tree.TreeNode; |
| | | import com.walker.infrastructure.utils.StringUtils; |
| | | import com.walker.web.ResponseValue; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.TreeMap; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.core.io.ClassPathResource; |
| | |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.net.URLEncoder; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @Description 区划 |
| | |
| | | |
| | | /** |
| | | * 删除 |
| | | * |
| | | * @author 卢庆阳 |
| | | * @date 2023/10/4 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 添加机构 |
| | | * |
| | | * @author 卢庆阳 |
| | | * @date 2023/10/4 |
| | | */ |
| | |
| | | return ResponseValue.error("不能创建支局以下机构"); |
| | | } |
| | | int num = this.finSysTenantService.addFinSysTenant(param,this.getSysInfo(),lv); |
| | | if(num>0) return ResponseValue.success(1); |
| | | if (num > 0) { |
| | | return ResponseValue.success(1); |
| | | } |
| | | return ResponseValue.error("插入失败!"); |
| | | } |
| | | |
| | |
| | | |
| | | EasyExcel.read(file.getInputStream(), FinSysTenantParam.class, new AnalysisEventListener<FinSysTenantParam>() { |
| | | LinkedList<FinSysTenantParam> finSysTenantParams = new LinkedList<>(); |
| | | |
| | | @Override |
| | | public void invoke(FinSysTenantParam finSysTenantParam, AnalysisContext analysisContext) { |
| | | if (StringUtils.isEmpty(finSysTenantParam.getCode())||finSysTenantParam.getCode().length()>20){ |
| | | IllegalStateException exception = new IllegalStateException("第" + analysisContext.readSheetHolder().getRowIndex() + "行,机构编号不能为空或长度大于20"); |
| | | IllegalStateException exception = new IllegalStateException( |
| | | "第" + analysisContext.readSheetHolder().getRowIndex() + "行,机构编号不能为空或长度大于20"); |
| | | throw exception; |
| | | } |
| | | if (null!=finSysTenantService.selectByTenantId(finSysTenantParam.getCode())){ |
| | | throw new IllegalStateException("第" + analysisContext.readSheetHolder().getRowIndex() + "行,机构编号已存在"); |
| | | } |
| | | if (StringUtils.isEmpty(finSysTenantParam.getName())||finSysTenantParam.getName().length()>100){ |
| | | IllegalStateException exception = new IllegalStateException("第" + analysisContext.readSheetHolder().getRowIndex() + "行,机构名称不能为空或长度大于100"); |
| | | IllegalStateException exception = new IllegalStateException( |
| | | "第" + analysisContext.readSheetHolder().getRowIndex() + "行,机构名称不能为空或长度大于100"); |
| | | throw exception; |
| | | } |
| | | finSysTenantParam.setParentId(pid); |
| | |
| | | finSysTenantParam.setSummary("系统导入"); |
| | | finSysTenantParams.add(finSysTenantParam); |
| | | } |
| | | |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext analysisContext) { |
| | | finSysTenantService.insertFinSysTenantBatch(finSysTenantParams,sysInfo,lv); |
| | |
| | | ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException)exception; |
| | | logger.error("第{}行,第{}列解析异常,数据为:{}",excelDataConvertException.getRowIndex(), |
| | | excelDataConvertException.getColumnIndex()+1, excelDataConvertException.getCellData().getStringValue()); |
| | | throw new IllegalStateException("第"+(excelDataConvertException.getRowIndex()+1)+"行,第"+(excelDataConvertException.getColumnIndex()+1)+"列解析异常,异常数据为:[ "+excelDataConvertException.getCellData().getStringValue()+" ]"); |
| | | throw new IllegalStateException( |
| | | "第" + (excelDataConvertException.getRowIndex() + 1) + "行,第" + (excelDataConvertException.getColumnIndex() + 1) + "列解析异常,异常数据为:[ " |
| | | + excelDataConvertException.getCellData().getStringValue() + " ]"); |
| | | } |
| | | if (exception instanceof IllegalStateException){ |
| | | throw (IllegalStateException)exception; |
| | |
| | | |
| | | /** |
| | | * 编辑 |
| | | * |
| | | * @author 卢庆阳 |
| | | * @date 2023/10/6 |
| | | */ |
| | |
| | | } |
| | | return ResponseValue.success(finSysTenantUserResults); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取父级机构", notes = "获取父级机构") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "token", dataType = "String", paramType = "header"), |
| | | }) |
| | | @GetMapping("/get/parent/tenant") |
| | | public ResponseValue getParentTenant() { |
| | | FinSysTenantUser sysInfo = getSysInfo(); |
| | | if (sysInfo == null) { |
| | | return ResponseValue.error("登录用户信息不存在"); |
| | | } |
| | | String tenantId = sysInfo.getTenantId(); |
| | | FinSysTenant finSysTenant = new FinSysTenant(); |
| | | finSysTenant.setTempId(Long.valueOf(tenantId)); |
| | | FinSysTenant userTenant = this.finSysTenantService.get(finSysTenant); |
| | | Long parentId = userTenant.getParentId(); |
| | | //第一级 |
| | | if (parentId == 0) { |
| | | return ResponseValue.success(userTenant); |
| | | } else { |
| | | FinSysTenant param = new FinSysTenant(); |
| | | param.setTempId(Long.valueOf(parentId)); |
| | | FinSysTenant result = this.finSysTenantService.get(param); |
| | | return ResponseValue.success(result); |
| | | } |
| | | } |
| | | } |