| | |
| | | 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 åºå |
| | |
| | | |
| | | while (var3.hasNext()) { |
| | | Object obj = var3.next(); |
| | | node = this.toTreeNode((FinSysTenant) obj); |
| | | node = this.toTreeNode((FinSysTenant)obj); |
| | | |
| | | if (node.getId() == this.defaultParentId) { |
| | | this.rootMap.put(node.getId(), node); |
| | |
| | | var3 = this.rootMap.values().iterator(); |
| | | |
| | | while (var3.hasNext()) { |
| | | TreeNode n = (TreeNode) var3.next(); |
| | | TreeNode n = (TreeNode)var3.next(); |
| | | n.setParentId(this.defaultParentId); |
| | | this.dummyRoot.addChild(n); |
| | | } |
| | |
| | | Iterator i = childMap.values().iterator(); |
| | | |
| | | while (i.hasNext()) { |
| | | _node = (TreeNode) i.next(); |
| | | _node = (TreeNode)i.next(); |
| | | this.mountMiddleNode(_node, childMap); |
| | | } |
| | | |
| | | } |
| | | |
| | | private void mountMiddleNode(TreeNode currentNode, Map<Long, TreeNode> childMap) { |
| | | TreeNode _parentNode = (TreeNode) this.rootMap.get(currentNode.getParentId()); |
| | | TreeNode _parentNode = (TreeNode)this.rootMap.get(currentNode.getParentId()); |
| | | if (_parentNode == null) { |
| | | _parentNode = (TreeNode) childMap.get(currentNode.getId()); |
| | | _parentNode = (TreeNode)childMap.get(currentNode.getId()); |
| | | if (_parentNode == null) { |
| | | throw new NullPointerException("parent node not found, current: " + currentNode); |
| | | } |
| | |
| | | |
| | | protected TreeNode toTreeNode(FinSysTenant entity) { |
| | | TreeNode treeNode = |
| | | new TreeNode(entity.getId(), entity.getName(), (List) null, entity.getParentId(), entity.getCode()); |
| | | new TreeNode(entity.getId(), entity.getName(), (List)null, entity.getParentId(), entity.getCode()); |
| | | return treeNode; |
| | | } |
| | | |
| | |
| | | Iterator var2 = this.rootMap.values().iterator(); |
| | | |
| | | while (var2.hasNext()) { |
| | | TreeNode node = (TreeNode) var2.next(); |
| | | TreeNode node = (TreeNode)var2.next(); |
| | | list.add(node); |
| | | } |
| | | return list; |
| | |
| | | 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( |
| | |
| | | public void onException(Exception exception, AnalysisContext context) { |
| | | // å¦ææ¯æä¸ä¸ªåå
æ ¼ç转æ¢å¼å¸¸ è½è·åå°å
·ä½è¡å· |
| | | if (exception instanceof ExcelDataConvertException) { |
| | | ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException) exception; |
| | | 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() + " ]"); |
| | | 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; |
| | | throw (IllegalStateException)exception; |
| | | } |
| | | |
| | | } |
| | |
| | | if (sysInfo == null) { |
| | | return ResponseValue.error("ç»å½ç¨æ·ä¿¡æ¯ä¸åå¨"); |
| | | } |
| | | // FinSysTenant finSysTenant1 = this.finSysTenantService.selectByTenantId(sysInfo.getTenantCode()); |
| | | // if (finSysTenant1.getLv() != 1) { |
| | | // return ResponseValue.error("ææ ä¿®æ¹æé"); |
| | | // } |
| | | // FinSysTenant finSysTenant1 = this.finSysTenantService.selectByTenantId(sysInfo.getTenantCode()); |
| | | // if (finSysTenant1.getLv() != 1) { |
| | | // return ResponseValue.error("ææ ä¿®æ¹æé"); |
| | | // } |
| | | int num = this.finSysTenantService.updateFinSysTenant(param, this.getSysInfo()); |
| | | return num > 0 ? ResponseValue.success(1) : ResponseValue.error("ç¼è¾å¤±è´¥ï¼"); |
| | | } |
| | |
| | | } |
| | | // ç |
| | | 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(); |
| | |
| | | finSysTenant.setTempId(Long.valueOf(tenantId)); |
| | | FinSysTenant userTenant = this.finSysTenantService.get(finSysTenant); |
| | | Long parentId = userTenant.getParentId(); |
| | | //第ä¸çº§ |
| | | // 第ä¸çº§ |
| | | if (parentId == 0) { |
| | | return ResponseValue.success(userTenant); |
| | | } else { |