| | |
| | | package com.consum.base.controller; |
| | | |
| | | 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.core.io.InputStreamResource; |
| | | import org.springframework.core.io.Resource; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | 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 com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.context.AnalysisContext; |
| | | import com.alibaba.excel.event.AnalysisEventListener; |
| | |
| | | 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.core.io.InputStreamResource; |
| | | import org.springframework.core.io.Resource; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | 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; |
| | | |
| | | /** |
| | | * @Description åºå |
| | |
| | | if (param.getFirstZmS() != null && !param.getFirstZmS().equals("")) { |
| | | whStr.append(" and name is not null and("); |
| | | String upperCase = param.getFirstZmS().toUpperCase(); |
| | | whStr.append("instr(:upperFirstZmS,F_PINYIN( SUBSTR(name, 1, 1)))>0 or instr(:upperFirstZmS2,SUBSTR(name, 1, 1))>0"); |
| | | whStr.append( |
| | | "instr(:upperFirstZmS,F_PINYIN( SUBSTR(name, 1, 1)))>0 or instr(:upperFirstZmS2,SUBSTR(name, 1, 1))>0"); |
| | | parameter.put("upperFirstZmS", upperCase); |
| | | parameter.put("upperFirstZmS2", upperCase); |
| | | whStr.append(")"); |
| | |
| | | List<FinSysTenant> select = this.finSysTenantService.select(new FinSysTenant(), whStr.toString(), parameter); |
| | | return ResponseValue.success(select); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * å é¤ |
| | |
| | | } |
| | | |
| | | @GetMapping("getImportTemplate") |
| | | public ResponseEntity<InputStreamResource> getImportTemplate() throws IOException { |
| | | public ResponseEntity<InputStreamResource> getImportTemplate(String type) throws IOException { |
| | | // ä»å½å项ç®èµæºç®å½è·åæä»¶ |
| | | Resource resource = new ClassPathResource("import/æºæå¯¼å
¥æ¨¡æ¿.xls"); |
| | | String fileName = null; |
| | | if ("tenant".equals(type)) { |
| | | fileName = "æºæå¯¼å
¥æ¨¡æ¿.xls"; |
| | | } else if ("goods".equals(type)) { |
| | | fileName = "ç©åä¿¡æ¯.xls"; |
| | | } |
| | | Resource resource = new ClassPathResource("import/" + fileName); |
| | | // è·åæä»¶è¾å
¥æµ |
| | | InputStream inputStream = resource.getInputStream(); |
| | | // 设置HTTPååºå¤´ |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); |
| | | String encodedFilename = URLEncoder.encode("æºæå¯¼å
¥æ¨¡æ¿.xls", "UTF-8"); |
| | | String encodedFilename = URLEncoder.encode(fileName, "UTF-8"); |
| | | headers.setContentDispositionFormData("attachment", encodedFilename); |
| | | // å建InputStreamResource对象ï¼å°æä»¶è¾å
¥æµå
è£
èµ·æ¥ |
| | | InputStreamResource resourceToDownload = new InputStreamResource(inputStream); |
| | | // è¿å带ææä»¶è¾å
¥æµçResponseEntity对象 |
| | | return ResponseEntity |
| | | .status(HttpStatus.OK) |
| | | .headers(headers) |
| | | .body(resourceToDownload); |
| | | return ResponseEntity.status(HttpStatus.OK).headers(headers).body(resourceToDownload); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @return è·å项ç®å¯¼å
¥çæ¨¡æ¿ |
| | | * @throws IOException |
| | | */ |
| | | @GetMapping("getProjectImportTemplate") |
| | | public ResponseEntity<InputStreamResource> getProjectImportTemplate() throws IOException { |
| | | // ä»å½å项ç®èµæºç®å½è·åæä»¶ |
| | | Resource resource = new ClassPathResource("import/项ç®å¯¼å
¥æ¨¡æ¿.xls"); |
| | | // è·åæä»¶è¾å
¥æµ |
| | | InputStream inputStream = resource.getInputStream(); |
| | | // 设置HTTPååºå¤´ |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); |
| | | String encodedFilename = URLEncoder.encode("项ç®å¯¼å
¥æ¨¡æ¿.xls", "UTF-8"); |
| | | headers.setContentDispositionFormData("attachment", encodedFilename); |
| | | // å建InputStreamResource对象ï¼å°æä»¶è¾å
¥æµå
è£
èµ·æ¥ |
| | | InputStreamResource resourceToDownload = new InputStreamResource(inputStream); |
| | | // è¿å带ææä»¶è¾å
¥æµçResponseEntity对象 |
| | | return ResponseEntity |
| | | .status(HttpStatus.OK) |
| | | .headers(headers) |
| | | .body(resourceToDownload); |
| | | } |
| | | |
| | | |
| | | @PostMapping("import") |
| | | public ResponseValue upload(@RequestParam Long pid, MultipartFile file) throws IOException { |
| | |
| | | throw exception; |
| | | } |
| | | if (null != finSysTenantService.queryOneByCode(finSysTenantParam.getCode())) { |
| | | throw new IllegalStateException("第" + analysisContext.readSheetHolder().getRowIndex() + "è¡,æºæç¼å·å·²åå¨"); |
| | | throw new IllegalStateException( |
| | | "第" + analysisContext.readSheetHolder().getRowIndex() + "è¡,æºæç¼å·å·²åå¨"); |
| | | } |
| | | if (StringUtils.isEmpty(finSysTenantParam.getName()) || finSysTenantParam.getName().length() > 100) { |
| | | IllegalStateException exception = new IllegalStateException( |
| | |
| | | if (exception instanceof ExcelDataConvertException) { |
| | | ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException) exception; |
| | | logger.error("第{}è¡ï¼ç¬¬{}åè§£æå¼å¸¸ï¼æ°æ®ä¸º:{}", excelDataConvertException.getRowIndex(), |
| | | excelDataConvertException.getColumnIndex() + 1, excelDataConvertException.getCellData().getStringValue()); |
| | | throw new IllegalStateException( |
| | | "第" + (excelDataConvertException.getRowIndex() + 1) + "è¡ï¼ç¬¬" + (excelDataConvertException.getColumnIndex() + 1) + "åè§£æå¼å¸¸,å¼å¸¸æ°æ®ä¸º:[ " |
| | | excelDataConvertException.getColumnIndex() + 1, |
| | | excelDataConvertException.getCellData().getStringValue()); |
| | | throw new IllegalStateException("第" + (excelDataConvertException.getRowIndex() + 1) + "è¡ï¼ç¬¬" |
| | | + (excelDataConvertException.getColumnIndex() + 1) + "åè§£æå¼å¸¸,å¼å¸¸æ°æ®ä¸º:[ " |
| | | + excelDataConvertException.getCellData().getStringValue() + " ]"); |
| | | } |
| | | if (exception instanceof IllegalStateException) { |
| | |
| | | } |
| | | // ç |
| | | FinSysTenant finSysTenant1 = this.finSysTenantService.get(new FinSysTenant(finSysTenant.getParentId())); |
| | | List<FinSysTenantUser> finSysTenantUserList = this.finSysTenantUserService.getByOrgId(finSysTenant1.getId()); |
| | | List<FinSysTenantUser> finSysTenantUserList = |
| | | this.finSysTenantUserService.getByOrgId(finSysTenant1.getId()); |
| | | if (!StringUtils.isEmptyList(finSysTenantUserList)) { |
| | | FinSysTenantUserResult finSysTenantUserResult = new FinSysTenantUserResult(); |
| | | finSysTenantUserResult.setOrgId(finSysTenant1.getId()); |
| | |
| | | } |
| | | // å¸ |
| | | FinSysTenant finSysTenant2 = this.finSysTenantService.get(new FinSysTenant(finSysTenant.getParentId())); |
| | | List<FinSysTenantUser> finSysTenantUserList2 = this.finSysTenantUserService.getByOrgId(finSysTenant2.getId()); |
| | | List<FinSysTenantUser> finSysTenantUserList2 = |
| | | this.finSysTenantUserService.getByOrgId(finSysTenant2.getId()); |
| | | if (!StringUtils.isEmptyList(finSysTenantUserList2)) { |
| | | FinSysTenantUserResult finSysTenantUserResult = new FinSysTenantUserResult(); |
| | | finSysTenantUserResult.setOrgId(finSysTenant2.getId()); |
| | |
| | | } |
| | | // ç |
| | | FinSysTenant finSysTenant1 = this.finSysTenantService.get(new FinSysTenant(finSysTenant2.getParentId())); |
| | | List<FinSysTenantUser> finSysTenantUserList = this.finSysTenantUserService.getByOrgId(finSysTenant1.getId()); |
| | | List<FinSysTenantUser> finSysTenantUserList = |
| | | this.finSysTenantUserService.getByOrgId(finSysTenant1.getId()); |
| | | if (!StringUtils.isEmptyList(finSysTenantUserList)) { |
| | | FinSysTenantUserResult finSysTenantUserResult = new FinSysTenantUserResult(); |
| | | finSysTenantUserResult.setOrgId(finSysTenant1.getId()); |
| | |
| | | |
| | | @ApiOperation(value = "è·åç¶çº§æºæ", notes = "è·åç¶çº§æºæ") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "token", dataType = "String", paramType = "header"), |
| | | }) |
| | | @ApiImplicitParam(name = "Authorization", value = "token", dataType = "String", paramType = "header"),}) |
| | | @GetMapping("/get/parent/tenant") |
| | | public ResponseValue getParentTenant() { |
| | | FinSysTenantUser sysInfo = getSysInfo(); |