From 3df3aea533134db0318431b13d7adcf1fa72860b Mon Sep 17 00:00:00 2001 From: ni ziyi <310925901@qq.com> Date: Sat, 13 Dec 2025 21:55:55 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=B4=A6=E6=88=B7=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E6=96=B0=E5=A2=9E)=201=E3=80=81=E5=AE=9E=E7=8E=B0=E5=8D=95?= =?UTF-8?q?=E4=B8=AA=E8=B4=A6=E6=88=B7=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E8=B4=A6=E6=88=B7=E4=BD=99=E9=A2=9D=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=EF=BC=88=E5=88=9D=E5=A7=8B=E4=BD=99=E9=A2=9D?= =?UTF-8?q?=20+=20=E6=94=B6=E5=85=A5=20-=20=E6=94=AF=E5=87=BA=EF=BC=89?= =?UTF-8?q?=EF=BC=8C=E5=88=9B=E5=BB=BA=E5=8D=95=E7=8B=AC=E7=9A=84=E8=B4=A6?= =?UTF-8?q?=E6=88=B7=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2=EF=BC=8C=E8=B4=A6?= =?UTF-8?q?=E5=8D=95=E8=87=AA=E5=8A=A8=E5=85=B3=E8=81=94=E5=88=B0=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E8=B4=A6=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AccountController.java | 55 +++++++ .../com/accounting/dto/AccountRequest.java | 13 ++ .../com/accounting/dto/AccountResponse.java | 26 +++ .../java/com/accounting/entity/Account.java | 27 ++++ src/main/java/com/accounting/entity/Bill.java | 2 + .../com/accounting/mapper/AccountMapper.java | 10 ++ .../accounting/service/AccountService.java | 150 ++++++++++++++++++ .../com/accounting/service/BillService.java | 14 ++ .../com/accounting/service/OcrService.java | 6 +- src/main/resources/db/schema.sql | 17 ++ 10 files changed, 317 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/accounting/controller/AccountController.java create mode 100644 src/main/java/com/accounting/dto/AccountRequest.java create mode 100644 src/main/java/com/accounting/dto/AccountResponse.java create mode 100644 src/main/java/com/accounting/entity/Account.java create mode 100644 src/main/java/com/accounting/mapper/AccountMapper.java create mode 100644 src/main/java/com/accounting/service/AccountService.java diff --git a/src/main/java/com/accounting/controller/AccountController.java b/src/main/java/com/accounting/controller/AccountController.java new file mode 100644 index 0000000..f2001f9 --- /dev/null +++ b/src/main/java/com/accounting/controller/AccountController.java @@ -0,0 +1,55 @@ +package com.accounting.controller; + +import com.accounting.dto.AccountRequest; +import com.accounting.dto.AccountResponse; +import com.accounting.entity.User; +import com.accounting.mapper.UserMapper; +import com.accounting.service.AccountService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.web.bind.annotation.*; + +@Tag(name = "账户管理", description = "账户管理接口") +@RestController +@RequestMapping("/api/accounts") +public class AccountController { + + @Autowired + private AccountService accountService; + + @Autowired + private UserMapper userMapper; + + @Operation(summary = "获取账户信息") + @GetMapping + public ResponseEntity getAccount(Authentication authentication) { + Long userId = getUserId(authentication); + AccountResponse response = accountService.getAccountBalance(userId); + return ResponseEntity.ok(response); + } + + @Operation(summary = "更新账户信息") + @PutMapping + public ResponseEntity updateAccount( + @RequestBody AccountRequest request, + Authentication authentication) { + Long userId = getUserId(authentication); + AccountResponse response = accountService.updateAccount(userId, request); + return ResponseEntity.ok(response); + } + + private Long getUserId(Authentication authentication) { + UserDetails userDetails = (UserDetails) authentication.getPrincipal(); + String username = userDetails.getUsername(); + User user = userMapper.selectOne( + new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper() + .eq(User::getUsername, username) + ); + return user != null ? user.getId() : null; + } +} + diff --git a/src/main/java/com/accounting/dto/AccountRequest.java b/src/main/java/com/accounting/dto/AccountRequest.java new file mode 100644 index 0000000..9c25cf3 --- /dev/null +++ b/src/main/java/com/accounting/dto/AccountRequest.java @@ -0,0 +1,13 @@ +package com.accounting.dto; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class AccountRequest { + private String name; + + private BigDecimal initialBalance; +} + diff --git a/src/main/java/com/accounting/dto/AccountResponse.java b/src/main/java/com/accounting/dto/AccountResponse.java new file mode 100644 index 0000000..855daeb --- /dev/null +++ b/src/main/java/com/accounting/dto/AccountResponse.java @@ -0,0 +1,26 @@ +package com.accounting.dto; + +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +@Data +public class AccountResponse { + private Long id; + + private String name; + + private BigDecimal initialBalance; + + private BigDecimal balance; // 计算后的余额(初始余额 + 收入 - 支出) + + private BigDecimal totalIncome; // 总收入 + + private BigDecimal totalExpense; // 总支出 + + private LocalDateTime createTime; + + private LocalDateTime updateTime; +} + diff --git a/src/main/java/com/accounting/entity/Account.java b/src/main/java/com/accounting/entity/Account.java new file mode 100644 index 0000000..e638f4e --- /dev/null +++ b/src/main/java/com/accounting/entity/Account.java @@ -0,0 +1,27 @@ +package com.accounting.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +@Data +@TableName("account") +public class Account { + @TableId(type = IdType.AUTO) + private Long id; + + private Long userId; + + private String name; + + private BigDecimal initialBalance; + + private LocalDateTime createTime; + + private LocalDateTime updateTime; +} + diff --git a/src/main/java/com/accounting/entity/Bill.java b/src/main/java/com/accounting/entity/Bill.java index 775d763..d1b02c2 100644 --- a/src/main/java/com/accounting/entity/Bill.java +++ b/src/main/java/com/accounting/entity/Bill.java @@ -17,6 +17,8 @@ public class Bill { private Long userId; + private Long accountId; + private Long categoryId; private BigDecimal amount; diff --git a/src/main/java/com/accounting/mapper/AccountMapper.java b/src/main/java/com/accounting/mapper/AccountMapper.java new file mode 100644 index 0000000..fe568a8 --- /dev/null +++ b/src/main/java/com/accounting/mapper/AccountMapper.java @@ -0,0 +1,10 @@ +package com.accounting.mapper; + +import com.accounting.entity.Account; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface AccountMapper extends BaseMapper { +} + diff --git a/src/main/java/com/accounting/service/AccountService.java b/src/main/java/com/accounting/service/AccountService.java new file mode 100644 index 0000000..f0a601b --- /dev/null +++ b/src/main/java/com/accounting/service/AccountService.java @@ -0,0 +1,150 @@ +package com.accounting.service; + +import com.accounting.dto.AccountRequest; +import com.accounting.dto.AccountResponse; +import com.accounting.entity.Account; +import com.accounting.entity.Bill; +import com.accounting.mapper.AccountMapper; +import com.accounting.mapper.BillMapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.util.List; + +@Service +public class AccountService { + + @Autowired + private AccountMapper accountMapper; + + @Autowired + private BillMapper billMapper; + + /** + * 获取或创建用户账户(如果不存在则创建默认账户) + */ + @Transactional + public Account getOrCreateAccount(Long userId) { + Account account = accountMapper.selectOne( + new LambdaQueryWrapper() + .eq(Account::getUserId, userId) + ); + + if (account == null) { + account = new Account(); + account.setUserId(userId); + account.setName("默认账户"); + account.setInitialBalance(BigDecimal.ZERO); + accountMapper.insert(account); + } + + return account; + } + + /** + * 获取用户账户 + */ + public Account getAccount(Long userId) { + return accountMapper.selectOne( + new LambdaQueryWrapper() + .eq(Account::getUserId, userId) + ); + } + + /** + * 更新账户信息(主要是初始余额) + */ + @Transactional + public AccountResponse updateAccount(Long userId, AccountRequest request) { + Account account = getOrCreateAccount(userId); + + if (request.getName() != null) { + account.setName(request.getName()); + } + if (request.getInitialBalance() != null) { + account.setInitialBalance(request.getInitialBalance()); + } + + accountMapper.updateById(account); + + return getAccountBalance(userId); + } + + /** + * 计算账户余额(初始余额 + 收入总额 - 支出总额) + */ + public BigDecimal calculateBalance(Long accountId) { + Account account = accountMapper.selectById(accountId); + if (account == null) { + return BigDecimal.ZERO; + } + + BigDecimal initialBalance = account.getInitialBalance() != null ? account.getInitialBalance() : BigDecimal.ZERO; + + // 查询该账户的所有账单 + List bills = billMapper.selectList( + new LambdaQueryWrapper() + .eq(Bill::getAccountId, accountId) + ); + + BigDecimal totalIncome = BigDecimal.ZERO; + BigDecimal totalExpense = BigDecimal.ZERO; + + for (Bill bill : bills) { + if (bill.getType() != null && bill.getAmount() != null) { + if (bill.getType() == 2) { // 收入 + totalIncome = totalIncome.add(bill.getAmount()); + } else if (bill.getType() == 1) { // 支出 + totalExpense = totalExpense.add(bill.getAmount().abs()); + } + } + } + + return initialBalance.add(totalIncome).subtract(totalExpense); + } + + /** + * 获取账户余额信息(包含余额、总收入、总支出) + */ + public AccountResponse getAccountBalance(Long userId) { + Account account = getOrCreateAccount(userId); + + AccountResponse response = new AccountResponse(); + BeanUtils.copyProperties(account, response); + + BigDecimal balance = calculateBalance(account.getId()); + response.setBalance(balance); + + // 计算总收入 + List incomeBills = billMapper.selectList( + new LambdaQueryWrapper() + .eq(Bill::getAccountId, account.getId()) + .eq(Bill::getType, 2) // 收入 + ); + BigDecimal totalIncome = incomeBills.stream() + .map(Bill::getAmount) + .filter(amount -> amount != null) + .reduce(BigDecimal.ZERO, BigDecimal::add); + response.setTotalIncome(totalIncome); + + // 计算总支出 + List expenseBills = billMapper.selectList( + new LambdaQueryWrapper() + .eq(Bill::getAccountId, account.getId()) + .eq(Bill::getType, 1) // 支出 + ); + BigDecimal totalExpense = expenseBills.stream() + .map(Bill::getAmount) + .map(BigDecimal::abs) + .filter(amount -> amount != null) + .reduce(BigDecimal.ZERO, BigDecimal::add); + response.setTotalExpense(totalExpense); + + return response; + } +} + diff --git a/src/main/java/com/accounting/service/BillService.java b/src/main/java/com/accounting/service/BillService.java index 44d6e9b..4229b36 100644 --- a/src/main/java/com/accounting/service/BillService.java +++ b/src/main/java/com/accounting/service/BillService.java @@ -2,6 +2,7 @@ package com.accounting.service; import com.accounting.dto.BillRequest; import com.accounting.dto.BillResponse; +import com.accounting.entity.Account; import com.accounting.entity.Bill; import com.accounting.entity.Category; import com.accounting.mapper.BillMapper; @@ -25,6 +26,9 @@ public class BillService { @Autowired private CategoryMapper categoryMapper; + @Autowired + private AccountService accountService; + @Transactional public BillResponse createBill(BillRequest request, Long userId) { // 验证分类是否存在 @@ -33,9 +37,13 @@ public class BillService { throw new RuntimeException("分类不存在"); } + // 获取或创建账户 + Account account = accountService.getOrCreateAccount(userId); + // 创建账单 Bill bill = new Bill(); bill.setUserId(userId); + bill.setAccountId(account.getId()); // 自动关联账户 bill.setCategoryId(request.getCategoryId()); bill.setAmount(request.getAmount()); bill.setDescription(request.getDescription()); @@ -67,6 +75,12 @@ public class BillService { throw new RuntimeException("分类不存在"); } + // 如果账单没有关联账户,则自动关联 + if (bill.getAccountId() == null) { + Account account = accountService.getOrCreateAccount(userId); + bill.setAccountId(account.getId()); + } + // 更新账单 bill.setCategoryId(request.getCategoryId()); bill.setAmount(request.getAmount()); diff --git a/src/main/java/com/accounting/service/OcrService.java b/src/main/java/com/accounting/service/OcrService.java index 30173fa..c943dba 100644 --- a/src/main/java/com/accounting/service/OcrService.java +++ b/src/main/java/com/accounting/service/OcrService.java @@ -48,11 +48,11 @@ public class OcrService { RecognizeGeneralRequest request = new RecognizeGeneralRequest() .setBody(inputStream); -// RecognizeGeneralResponse response = ocrClient.recognizeGeneral(request); + RecognizeGeneralResponse response = ocrClient.recognizeGeneral(request); - String body = "{\"data\":\"{\\\"algo_version\\\":\\\"\\\",\\\"content\\\":\\\"中 拼多多平台商户 -9.39 拼 12月2日13:14 拼 拼多多平台商户 -46.90 1o 进。 12月2日13:14 1 拼多多平台商户 -35.12 拼 12月2日13:13 拼多多平台商户 -4.01 拼 12月2日13:13 中 拼多多平台商户 -33.47 拼 12月1日09:48 拼 拼多多平台商户 -22.10 Re 12月1日09:48 中 拼多多平台商户 -42.00 拼 12月1日09:47 拼多多平台商户 -12.40 拼 12月1日09:16 \\\",\\\"height\\\":1761,\\\"orgHeight\\\":1761,\\\"orgWidth\\\":1080,\\\"prism_version\\\":\\\"1.0.9\\\",\\\"prism_wnum\\\":39,\\\"prism_wordsInfo\\\":[{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":35,\\\"pos\\\":[{\\\"x\\\":117,\\\"y\\\":86},{\\\"x\\\":153,\\\"y\\\":86},{\\\"x\\\":153,\\\"y\\\":117},{\\\"x\\\":117,\\\"y\\\":117}],\\\"prob\\\":94,\\\"width\\\":30,\\\"word\\\":\\\"中\\\",\\\"x\\\":120,\\\"y\\\":83},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":330,\\\"pos\\\":[{\\\"x\\\":208,\\\"y\\\":71},{\\\"x\\\":539,\\\"y\\\":71},{\\\"x\\\":539,\\\"y\\\":123},{\\\"x\\\":208,\\\"y\\\":123}],\\\"prob\\\":99,\\\"width\\\":52,\\\"word\\\":\\\"拼多多平台商户\\\",\\\"x\\\":347,\\\"y\\\":-67},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":113,\\\"pos\\\":[{\\\"x\\\":925,\\\"y\\\":78},{\\\"x\\\":1039,\\\"y\\\":79},{\\\"x\\\":1038,\\\"y\\\":119},{\\\"x\\\":925,\\\"y\\\":118}],\\\"prob\\\":99,\\\"width\\\":40,\\\"word\\\":\\\"-9.39\\\",\\\"x\\\":962,\\\"y\\\":42},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":40,\\\"pos\\\":[{\\\"x\\\":98,\\\"y\\\":104},{\\\"x\\\":138,\\\"y\\\":104},{\\\"x\\\":138,\\\"y\\\":135},{\\\"x\\\":98,\\\"y\\\":135}],\\\"prob\\\":99,\\\"width\\\":30,\\\"word\\\":\\\"拼\\\",\\\"x\\\":103,\\\"y\\\":99},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":236,\\\"pos\\\":[{\\\"x\\\":212,\\\"y\\\":147},{\\\"x\\\":448,\\\"y\\\":147},{\\\"x\\\":448,\\\"y\\\":187},{\\\"x\\\":212,\\\"y\\\":187}],\\\"prob\\\":99,\\\"width\\\":39,\\\"word\\\":\\\"12月2日13:14\\\",\\\"x\\\":310,\\\"y\\\":49},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":23,\\\"pos\\\":[{\\\"x\\\":93,\\\"y\\\":318},{\\\"x\\\":117,\\\"y\\\":318},{\\\"x\\\":117,\\\"y\\\":348},{\\\"x\\\":93,\\\"y\\\":348}],\\\"prob\\\":99,\\\"width\\\":30,\\\"word\\\":\\\"拼\\\",\\\"x\\\":90,\\\"y\\\":321},{\\\"angle\\\":0,\\\"direction\\\":0,\\\"height\\\":52,\\\"pos\\\":[{\\\"x\\\":208,\\\"y\\\":287},{\\\"x\\\":538,\\\"y\\\":287},{\\\"x\\\":538,\\\"y\\\":339},{\\\"x\\\":208,\\\"y\\\":340}],\\\"prob\\\":99,\\\"width\\\":330,\\\"word\\\":\\\"拼多多平台商户\\\",\\\"x\\\":208,\\\"y\\\":287},{\\\"angle\\\":-88,\\\"direction\\\":0,\\\"height\\\":145,\\\"pos\\\":[{\\\"x\\\":891,\\\"y\\\":294},{\\\"x\\\":1036,\\\"y\\\":298},{\\\"x\\\":1035,\\\"y\\\":334},{\\\"x\\\":890,\\\"y\\\":330}],\\\"prob\\\":99,\\\"width\\\":35,\\\"word\\\":\\\"-46.90\\\",\\\"x\\\":945,\\\"y\\\":241},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":23,\\\"pos\\\":[{\\\"x\\\":75,\\\"y\\\":340},{\\\"x\\\":99,\\\"y\\\":340},{\\\"x\\\":99,\\\"y\\\":369},{\\\"x\\\":75,\\\"y\\\":369}],\\\"prob\\\":69,\\\"width\\\":28,\\\"word\\\":\\\"1o\\\",\\\"x\\\":73,\\\"y\\\":343},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":40,\\\"pos\\\":[{\\\"x\\\":98,\\\"y\\\":329},{\\\"x\\\":139,\\\"y\\\":329},{\\\"x\\\":139,\\\"y\\\":361},{\\\"x\\\":98,\\\"y\\\":361}],\\\"prob\\\":91,\\\"width\\\":31,\\\"word\\\":\\\"进。\\\",\\\"x\\\":103,\\\"y\\\":325},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":236,\\\"pos\\\":[{\\\"x\\\":212,\\\"y\\\":362},{\\\"x\\\":449,\\\"y\\\":363},{\\\"x\\\":449,\\\"y\\\":404},{\\\"x\\\":212,\\\"y\\\":403}],\\\"prob\\\":99,\\\"width\\\":40,\\\"word\\\":\\\"12月2日13:14\\\",\\\"x\\\":310,\\\"y\\\":265},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":42,\\\"pos\\\":[{\\\"x\\\":105,\\\"y\\\":522},{\\\"x\\\":148,\\\"y\\\":522},{\\\"x\\\":148,\\\"y\\\":556},{\\\"x\\\":105,\\\"y\\\":556}],\\\"prob\\\":75,\\\"width\\\":33,\\\"word\\\":\\\"1\\\",\\\"x\\\":109,\\\"y\\\":517},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":329,\\\"pos\\\":[{\\\"x\\\":208,\\\"y\\\":503},{\\\"x\\\":538,\\\"y\\\":504},{\\\"x\\\":538,\\\"y\\\":556},{\\\"x\\\":208,\\\"y\\\":555}],\\\"prob\\\":99,\\\"width\\\":51,\\\"word\\\":\\\"拼多多平台商户\\\",\\\"x\\\":347,\\\"y\\\":365},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":141,\\\"pos\\\":[{\\\"x\\\":898,\\\"y\\\":510},{\\\"x\\\":1040,\\\"y\\\":511},{\\\"x\\\":1039,\\\"y\\\":551},{\\\"x\\\":898,\\\"y\\\":550}],\\\"prob\\\":99,\\\"width\\\":40,\\\"word\\\":\\\"-35.12\\\",\\\"x\\\":949,\\\"y\\\":459},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":36,\\\"pos\\\":[{\\\"x\\\":82,\\\"y\\\":544},{\\\"x\\\":118,\\\"y\\\":544},{\\\"x\\\":118,\\\"y\\\":574},{\\\"x\\\":82,\\\"y\\\":574}],\\\"prob\\\":99,\\\"width\\\":30,\\\"word\\\":\\\"拼\\\",\\\"x\\\":85,\\\"y\\\":540},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":235,\\\"pos\\\":[{\\\"x\\\":212,\\\"y\\\":579},{\\\"x\\\":447,\\\"y\\\":580},{\\\"x\\\":447,\\\"y\\\":620},{\\\"x\\\":212,\\\"y\\\":619}],\\\"prob\\\":99,\\\"width\\\":39,\\\"word\\\":\\\"12月2日13:13\\\",\\\"x\\\":310,\\\"y\\\":482},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":329,\\\"pos\\\":[{\\\"x\\\":209,\\\"y\\\":717},{\\\"x\\\":538,\\\"y\\\":721},{\\\"x\\\":538,\\\"y\\\":773},{\\\"x\\\":208,\\\"y\\\":769}],\\\"prob\\\":99,\\\"width\\\":52,\\\"word\\\":\\\"拼多多平台商户\\\",\\\"x\\\":347,\\\"y\\\":580},{\\\"angle\\\":-88,\\\"direction\\\":0,\\\"height\\\":113,\\\"pos\\\":[{\\\"x\\\":921,\\\"y\\\":727},{\\\"x\\\":1035,\\\"y\\\":730},{\\\"x\\\":1034,\\\"y\\\":765},{\\\"x\\\":920,\\\"y\\\":762}],\\\"prob\\\":99,\\\"width\\\":35,\\\"word\\\":\\\"-4.01\\\",\\\"x\\\":960,\\\"y\\\":689},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":50,\\\"pos\\\":[{\\\"x\\\":78,\\\"y\\\":757},{\\\"x\\\":128,\\\"y\\\":757},{\\\"x\\\":128,\\\"y\\\":787},{\\\"x\\\":78,\\\"y\\\":787}],\\\"prob\\\":99,\\\"width\\\":29,\\\"word\\\":\\\"拼\\\",\\\"x\\\":88,\\\"y\\\":747},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":234,\\\"pos\\\":[{\\\"x\\\":213,\\\"y\\\":795},{\\\"x\\\":447,\\\"y\\\":796},{\\\"x\\\":447,\\\"y\\\":835},{\\\"x\\\":212,\\\"y\\\":835}],\\\"prob\\\":99,\\\"width\\\":39,\\\"word\\\":\\\"12月2日13:13\\\",\\\"x\\\":310,\\\"y\\\":698},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":35,\\\"pos\\\":[{\\\"x\\\":118,\\\"y\\\":951},{\\\"x\\\":154,\\\"y\\\":951},{\\\"x\\\":154,\\\"y\\\":982},{\\\"x\\\":118,\\\"y\\\":982}],\\\"prob\\\":85,\\\"width\\\":31,\\\"word\\\":\\\"中\\\",\\\"x\\\":120,\\\"y\\\":948},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":329,\\\"pos\\\":[{\\\"x\\\":208,\\\"y\\\":933},{\\\"x\\\":537,\\\"y\\\":937},{\\\"x\\\":537,\\\"y\\\":989},{\\\"x\\\":207,\\\"y\\\":986}],\\\"prob\\\":99,\\\"width\\\":52,\\\"word\\\":\\\"拼多多平台商户\\\",\\\"x\\\":346,\\\"y\\\":796},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":141,\\\"pos\\\":[{\\\"x\\\":898,\\\"y\\\":941},{\\\"x\\\":1040,\\\"y\\\":943},{\\\"x\\\":1039,\\\"y\\\":983},{\\\"x\\\":897,\\\"y\\\":982}],\\\"prob\\\":99,\\\"width\\\":40,\\\"word\\\":\\\"-33.47\\\",\\\"x\\\":948,\\\"y\\\":891},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":55,\\\"pos\\\":[{\\\"x\\\":74,\\\"y\\\":975},{\\\"x\\\":130,\\\"y\\\":975},{\\\"x\\\":130,\\\"y\\\":1007},{\\\"x\\\":74,\\\"y\\\":1007}],\\\"prob\\\":93,\\\"width\\\":31,\\\"word\\\":\\\"拼\\\",\\\"x\\\":86,\\\"y\\\":963},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":238,\\\"pos\\\":[{\\\"x\\\":212,\\\"y\\\":1011},{\\\"x\\\":450,\\\"y\\\":1012},{\\\"x\\\":450,\\\"y\\\":1051},{\\\"x\\\":212,\\\"y\\\":1050}],\\\"prob\\\":99,\\\"width\\\":39,\\\"word\\\":\\\"12月1日09:48\\\",\\\"x\\\":311,\\\"y\\\":912},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":34,\\\"pos\\\":[{\\\"x\\\":84,\\\"y\\\":1183},{\\\"x\\\":119,\\\"y\\\":1183},{\\\"x\\\":119,\\\"y\\\":1214},{\\\"x\\\":84,\\\"y\\\":1214}],\\\"prob\\\":99,\\\"width\\\":30,\\\"word\\\":\\\"拼\\\",\\\"x\\\":86,\\\"y\\\":1181},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":330,\\\"pos\\\":[{\\\"x\\\":208,\\\"y\\\":1151},{\\\"x\\\":538,\\\"y\\\":1152},{\\\"x\\\":538,\\\"y\\\":1203},{\\\"x\\\":207,\\\"y\\\":1202}],\\\"prob\\\":99,\\\"width\\\":51,\\\"word\\\":\\\"拼多多平台商户\\\",\\\"x\\\":347,\\\"y\\\":1012},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":140,\\\"pos\\\":[{\\\"x\\\":898,\\\"y\\\":1157},{\\\"x\\\":1039,\\\"y\\\":1157},{\\\"x\\\":1039,\\\"y\\\":1200},{\\\"x\\\":898,\\\"y\\\":1200}],\\\"prob\\\":99,\\\"width\\\":42,\\\"word\\\":\\\"-22.10\\\",\\\"x\\\":947,\\\"y\\\":1108},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":24,\\\"pos\\\":[{\\\"x\\\":106,\\\"y\\\":1199},{\\\"x\\\":131,\\\"y\\\":1199},{\\\"x\\\":131,\\\"y\\\":1230},{\\\"x\\\":106,\\\"y\\\":1230}],\\\"prob\\\":82,\\\"width\\\":30,\\\"word\\\":\\\"Re\\\",\\\"x\\\":103,\\\"y\\\":1202},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":247,\\\"pos\\\":[{\\\"x\\\":212,\\\"y\\\":1227},{\\\"x\\\":460,\\\"y\\\":1228},{\\\"x\\\":460,\\\"y\\\":1266},{\\\"x\\\":212,\\\"y\\\":1266}],\\\"prob\\\":99,\\\"width\\\":38,\\\"word\\\":\\\"12月1日09:48\\\",\\\"x\\\":317,\\\"y\\\":1123},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":34,\\\"pos\\\":[{\\\"x\\\":119,\\\"y\\\":1383},{\\\"x\\\":153,\\\"y\\\":1383},{\\\"x\\\":153,\\\"y\\\":1413},{\\\"x\\\":119,\\\"y\\\":1413}],\\\"prob\\\":92,\\\"width\\\":30,\\\"word\\\":\\\"中\\\",\\\"x\\\":121,\\\"y\\\":1381},{\\\"angle\\\":0,\\\"direction\\\":0,\\\"height\\\":51,\\\"pos\\\":[{\\\"x\\\":208,\\\"y\\\":1368},{\\\"x\\\":539,\\\"y\\\":1366},{\\\"x\\\":539,\\\"y\\\":1418},{\\\"x\\\":208,\\\"y\\\":1419}],\\\"prob\\\":99,\\\"width\\\":331,\\\"word\\\":\\\"拼多多平台商户\\\",\\\"x\\\":208,\\\"y\\\":1367},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":145,\\\"pos\\\":[{\\\"x\\\":890,\\\"y\\\":1375},{\\\"x\\\":1035,\\\"y\\\":1377},{\\\"x\\\":1035,\\\"y\\\":1413},{\\\"x\\\":889,\\\"y\\\":1411}],\\\"prob\\\":99,\\\"width\\\":35,\\\"word\\\":\\\"-42.00\\\",\\\"x\\\":944,\\\"y\\\":1321},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":48,\\\"pos\\\":[{\\\"x\\\":78,\\\"y\\\":1405},{\\\"x\\\":127,\\\"y\\\":1405},{\\\"x\\\":127,\\\"y\\\":1435},{\\\"x\\\":78,\\\"y\\\":1435}],\\\"prob\\\":99,\\\"width\\\":30,\\\"word\\\":\\\"拼\\\",\\\"x\\\":87,\\\"y\\\":1396},{\\\"angle\\\":0,\\\"direction\\\":0,\\\"height\\\":44,\\\"pos\\\":[{\\\"x\\\":211,\\\"y\\\":1441},{\\\"x\\\":450,\\\"y\\\":1441},{\\\"x\\\":450,\\\"y\\\":1485},{\\\"x\\\":212,\\\"y\\\":1486}],\\\"prob\\\":99,\\\"width\\\":238,\\\"word\\\":\\\"12月1日09:47\\\",\\\"x\\\":212,\\\"y\\\":1441},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":329,\\\"pos\\\":[{\\\"x\\\":208,\\\"y\\\":1582},{\\\"x\\\":538,\\\"y\\\":1583},{\\\"x\\\":538,\\\"y\\\":1635},{\\\"x\\\":208,\\\"y\\\":1634}],\\\"prob\\\":99,\\\"width\\\":51,\\\"word\\\":\\\"拼多多平台商户\\\",\\\"x\\\":347,\\\"y\\\":1443},{\\\"angle\\\":0,\\\"direction\\\":0,\\\"height\\\":40,\\\"pos\\\":[{\\\"x\\\":898,\\\"y\\\":1591},{\\\"x\\\":1038,\\\"y\\\":1591},{\\\"x\\\":1038,\\\"y\\\":1631},{\\\"x\\\":898,\\\"y\\\":1631}],\\\"prob\\\":99,\\\"width\\\":140,\\\"word\\\":\\\"-12.40\\\",\\\"x\\\":898,\\\"y\\\":1591},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":40,\\\"pos\\\":[{\\\"x\\\":97,\\\"y\\\":1619},{\\\"x\\\":138,\\\"y\\\":1619},{\\\"x\\\":138,\\\"y\\\":1649},{\\\"x\\\":97,\\\"y\\\":1649}],\\\"prob\\\":99,\\\"width\\\":29,\\\"word\\\":\\\"拼\\\",\\\"x\\\":103,\\\"y\\\":1613},{\\\"angle\\\":0,\\\"direction\\\":0,\\\"height\\\":39,\\\"pos\\\":[{\\\"x\\\":212,\\\"y\\\":1660},{\\\"x\\\":449,\\\"y\\\":1659},{\\\"x\\\":449,\\\"y\\\":1699},{\\\"x\\\":212,\\\"y\\\":1699}],\\\"prob\\\":99,\\\"width\\\":237,\\\"word\\\":\\\"12月1日09:16\\\",\\\"x\\\":212,\\\"y\\\":1659}],\\\"width\\\":1080}\",\"requestId\":\"077630B9-150F-54D5-8FFE-DDC9D5A9E172\"}"; +// String body = "{\"data\":\"{\\\"algo_version\\\":\\\"\\\",\\\"content\\\":\\\"中 拼多多平台商户 -9.39 拼 12月2日13:14 拼 拼多多平台商户 -46.90 1o 进。 12月2日13:14 1 拼多多平台商户 -35.12 拼 12月2日13:13 拼多多平台商户 -4.01 拼 12月2日13:13 中 拼多多平台商户 -33.47 拼 12月1日09:48 拼 拼多多平台商户 -22.10 Re 12月1日09:48 中 拼多多平台商户 -42.00 拼 12月1日09:47 拼多多平台商户 -12.40 拼 12月1日09:16 \\\",\\\"height\\\":1761,\\\"orgHeight\\\":1761,\\\"orgWidth\\\":1080,\\\"prism_version\\\":\\\"1.0.9\\\",\\\"prism_wnum\\\":39,\\\"prism_wordsInfo\\\":[{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":35,\\\"pos\\\":[{\\\"x\\\":117,\\\"y\\\":86},{\\\"x\\\":153,\\\"y\\\":86},{\\\"x\\\":153,\\\"y\\\":117},{\\\"x\\\":117,\\\"y\\\":117}],\\\"prob\\\":94,\\\"width\\\":30,\\\"word\\\":\\\"中\\\",\\\"x\\\":120,\\\"y\\\":83},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":330,\\\"pos\\\":[{\\\"x\\\":208,\\\"y\\\":71},{\\\"x\\\":539,\\\"y\\\":71},{\\\"x\\\":539,\\\"y\\\":123},{\\\"x\\\":208,\\\"y\\\":123}],\\\"prob\\\":99,\\\"width\\\":52,\\\"word\\\":\\\"拼多多平台商户\\\",\\\"x\\\":347,\\\"y\\\":-67},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":113,\\\"pos\\\":[{\\\"x\\\":925,\\\"y\\\":78},{\\\"x\\\":1039,\\\"y\\\":79},{\\\"x\\\":1038,\\\"y\\\":119},{\\\"x\\\":925,\\\"y\\\":118}],\\\"prob\\\":99,\\\"width\\\":40,\\\"word\\\":\\\"-9.39\\\",\\\"x\\\":962,\\\"y\\\":42},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":40,\\\"pos\\\":[{\\\"x\\\":98,\\\"y\\\":104},{\\\"x\\\":138,\\\"y\\\":104},{\\\"x\\\":138,\\\"y\\\":135},{\\\"x\\\":98,\\\"y\\\":135}],\\\"prob\\\":99,\\\"width\\\":30,\\\"word\\\":\\\"拼\\\",\\\"x\\\":103,\\\"y\\\":99},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":236,\\\"pos\\\":[{\\\"x\\\":212,\\\"y\\\":147},{\\\"x\\\":448,\\\"y\\\":147},{\\\"x\\\":448,\\\"y\\\":187},{\\\"x\\\":212,\\\"y\\\":187}],\\\"prob\\\":99,\\\"width\\\":39,\\\"word\\\":\\\"12月2日13:14\\\",\\\"x\\\":310,\\\"y\\\":49},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":23,\\\"pos\\\":[{\\\"x\\\":93,\\\"y\\\":318},{\\\"x\\\":117,\\\"y\\\":318},{\\\"x\\\":117,\\\"y\\\":348},{\\\"x\\\":93,\\\"y\\\":348}],\\\"prob\\\":99,\\\"width\\\":30,\\\"word\\\":\\\"拼\\\",\\\"x\\\":90,\\\"y\\\":321},{\\\"angle\\\":0,\\\"direction\\\":0,\\\"height\\\":52,\\\"pos\\\":[{\\\"x\\\":208,\\\"y\\\":287},{\\\"x\\\":538,\\\"y\\\":287},{\\\"x\\\":538,\\\"y\\\":339},{\\\"x\\\":208,\\\"y\\\":340}],\\\"prob\\\":99,\\\"width\\\":330,\\\"word\\\":\\\"拼多多平台商户\\\",\\\"x\\\":208,\\\"y\\\":287},{\\\"angle\\\":-88,\\\"direction\\\":0,\\\"height\\\":145,\\\"pos\\\":[{\\\"x\\\":891,\\\"y\\\":294},{\\\"x\\\":1036,\\\"y\\\":298},{\\\"x\\\":1035,\\\"y\\\":334},{\\\"x\\\":890,\\\"y\\\":330}],\\\"prob\\\":99,\\\"width\\\":35,\\\"word\\\":\\\"-46.90\\\",\\\"x\\\":945,\\\"y\\\":241},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":23,\\\"pos\\\":[{\\\"x\\\":75,\\\"y\\\":340},{\\\"x\\\":99,\\\"y\\\":340},{\\\"x\\\":99,\\\"y\\\":369},{\\\"x\\\":75,\\\"y\\\":369}],\\\"prob\\\":69,\\\"width\\\":28,\\\"word\\\":\\\"1o\\\",\\\"x\\\":73,\\\"y\\\":343},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":40,\\\"pos\\\":[{\\\"x\\\":98,\\\"y\\\":329},{\\\"x\\\":139,\\\"y\\\":329},{\\\"x\\\":139,\\\"y\\\":361},{\\\"x\\\":98,\\\"y\\\":361}],\\\"prob\\\":91,\\\"width\\\":31,\\\"word\\\":\\\"进。\\\",\\\"x\\\":103,\\\"y\\\":325},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":236,\\\"pos\\\":[{\\\"x\\\":212,\\\"y\\\":362},{\\\"x\\\":449,\\\"y\\\":363},{\\\"x\\\":449,\\\"y\\\":404},{\\\"x\\\":212,\\\"y\\\":403}],\\\"prob\\\":99,\\\"width\\\":40,\\\"word\\\":\\\"12月2日13:14\\\",\\\"x\\\":310,\\\"y\\\":265},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":42,\\\"pos\\\":[{\\\"x\\\":105,\\\"y\\\":522},{\\\"x\\\":148,\\\"y\\\":522},{\\\"x\\\":148,\\\"y\\\":556},{\\\"x\\\":105,\\\"y\\\":556}],\\\"prob\\\":75,\\\"width\\\":33,\\\"word\\\":\\\"1\\\",\\\"x\\\":109,\\\"y\\\":517},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":329,\\\"pos\\\":[{\\\"x\\\":208,\\\"y\\\":503},{\\\"x\\\":538,\\\"y\\\":504},{\\\"x\\\":538,\\\"y\\\":556},{\\\"x\\\":208,\\\"y\\\":555}],\\\"prob\\\":99,\\\"width\\\":51,\\\"word\\\":\\\"拼多多平台商户\\\",\\\"x\\\":347,\\\"y\\\":365},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":141,\\\"pos\\\":[{\\\"x\\\":898,\\\"y\\\":510},{\\\"x\\\":1040,\\\"y\\\":511},{\\\"x\\\":1039,\\\"y\\\":551},{\\\"x\\\":898,\\\"y\\\":550}],\\\"prob\\\":99,\\\"width\\\":40,\\\"word\\\":\\\"-35.12\\\",\\\"x\\\":949,\\\"y\\\":459},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":36,\\\"pos\\\":[{\\\"x\\\":82,\\\"y\\\":544},{\\\"x\\\":118,\\\"y\\\":544},{\\\"x\\\":118,\\\"y\\\":574},{\\\"x\\\":82,\\\"y\\\":574}],\\\"prob\\\":99,\\\"width\\\":30,\\\"word\\\":\\\"拼\\\",\\\"x\\\":85,\\\"y\\\":540},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":235,\\\"pos\\\":[{\\\"x\\\":212,\\\"y\\\":579},{\\\"x\\\":447,\\\"y\\\":580},{\\\"x\\\":447,\\\"y\\\":620},{\\\"x\\\":212,\\\"y\\\":619}],\\\"prob\\\":99,\\\"width\\\":39,\\\"word\\\":\\\"12月2日13:13\\\",\\\"x\\\":310,\\\"y\\\":482},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":329,\\\"pos\\\":[{\\\"x\\\":209,\\\"y\\\":717},{\\\"x\\\":538,\\\"y\\\":721},{\\\"x\\\":538,\\\"y\\\":773},{\\\"x\\\":208,\\\"y\\\":769}],\\\"prob\\\":99,\\\"width\\\":52,\\\"word\\\":\\\"拼多多平台商户\\\",\\\"x\\\":347,\\\"y\\\":580},{\\\"angle\\\":-88,\\\"direction\\\":0,\\\"height\\\":113,\\\"pos\\\":[{\\\"x\\\":921,\\\"y\\\":727},{\\\"x\\\":1035,\\\"y\\\":730},{\\\"x\\\":1034,\\\"y\\\":765},{\\\"x\\\":920,\\\"y\\\":762}],\\\"prob\\\":99,\\\"width\\\":35,\\\"word\\\":\\\"-4.01\\\",\\\"x\\\":960,\\\"y\\\":689},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":50,\\\"pos\\\":[{\\\"x\\\":78,\\\"y\\\":757},{\\\"x\\\":128,\\\"y\\\":757},{\\\"x\\\":128,\\\"y\\\":787},{\\\"x\\\":78,\\\"y\\\":787}],\\\"prob\\\":99,\\\"width\\\":29,\\\"word\\\":\\\"拼\\\",\\\"x\\\":88,\\\"y\\\":747},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":234,\\\"pos\\\":[{\\\"x\\\":213,\\\"y\\\":795},{\\\"x\\\":447,\\\"y\\\":796},{\\\"x\\\":447,\\\"y\\\":835},{\\\"x\\\":212,\\\"y\\\":835}],\\\"prob\\\":99,\\\"width\\\":39,\\\"word\\\":\\\"12月2日13:13\\\",\\\"x\\\":310,\\\"y\\\":698},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":35,\\\"pos\\\":[{\\\"x\\\":118,\\\"y\\\":951},{\\\"x\\\":154,\\\"y\\\":951},{\\\"x\\\":154,\\\"y\\\":982},{\\\"x\\\":118,\\\"y\\\":982}],\\\"prob\\\":85,\\\"width\\\":31,\\\"word\\\":\\\"中\\\",\\\"x\\\":120,\\\"y\\\":948},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":329,\\\"pos\\\":[{\\\"x\\\":208,\\\"y\\\":933},{\\\"x\\\":537,\\\"y\\\":937},{\\\"x\\\":537,\\\"y\\\":989},{\\\"x\\\":207,\\\"y\\\":986}],\\\"prob\\\":99,\\\"width\\\":52,\\\"word\\\":\\\"拼多多平台商户\\\",\\\"x\\\":346,\\\"y\\\":796},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":141,\\\"pos\\\":[{\\\"x\\\":898,\\\"y\\\":941},{\\\"x\\\":1040,\\\"y\\\":943},{\\\"x\\\":1039,\\\"y\\\":983},{\\\"x\\\":897,\\\"y\\\":982}],\\\"prob\\\":99,\\\"width\\\":40,\\\"word\\\":\\\"-33.47\\\",\\\"x\\\":948,\\\"y\\\":891},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":55,\\\"pos\\\":[{\\\"x\\\":74,\\\"y\\\":975},{\\\"x\\\":130,\\\"y\\\":975},{\\\"x\\\":130,\\\"y\\\":1007},{\\\"x\\\":74,\\\"y\\\":1007}],\\\"prob\\\":93,\\\"width\\\":31,\\\"word\\\":\\\"拼\\\",\\\"x\\\":86,\\\"y\\\":963},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":238,\\\"pos\\\":[{\\\"x\\\":212,\\\"y\\\":1011},{\\\"x\\\":450,\\\"y\\\":1012},{\\\"x\\\":450,\\\"y\\\":1051},{\\\"x\\\":212,\\\"y\\\":1050}],\\\"prob\\\":99,\\\"width\\\":39,\\\"word\\\":\\\"12月1日09:48\\\",\\\"x\\\":311,\\\"y\\\":912},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":34,\\\"pos\\\":[{\\\"x\\\":84,\\\"y\\\":1183},{\\\"x\\\":119,\\\"y\\\":1183},{\\\"x\\\":119,\\\"y\\\":1214},{\\\"x\\\":84,\\\"y\\\":1214}],\\\"prob\\\":99,\\\"width\\\":30,\\\"word\\\":\\\"拼\\\",\\\"x\\\":86,\\\"y\\\":1181},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":330,\\\"pos\\\":[{\\\"x\\\":208,\\\"y\\\":1151},{\\\"x\\\":538,\\\"y\\\":1152},{\\\"x\\\":538,\\\"y\\\":1203},{\\\"x\\\":207,\\\"y\\\":1202}],\\\"prob\\\":99,\\\"width\\\":51,\\\"word\\\":\\\"拼多多平台商户\\\",\\\"x\\\":347,\\\"y\\\":1012},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":140,\\\"pos\\\":[{\\\"x\\\":898,\\\"y\\\":1157},{\\\"x\\\":1039,\\\"y\\\":1157},{\\\"x\\\":1039,\\\"y\\\":1200},{\\\"x\\\":898,\\\"y\\\":1200}],\\\"prob\\\":99,\\\"width\\\":42,\\\"word\\\":\\\"-22.10\\\",\\\"x\\\":947,\\\"y\\\":1108},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":24,\\\"pos\\\":[{\\\"x\\\":106,\\\"y\\\":1199},{\\\"x\\\":131,\\\"y\\\":1199},{\\\"x\\\":131,\\\"y\\\":1230},{\\\"x\\\":106,\\\"y\\\":1230}],\\\"prob\\\":82,\\\"width\\\":30,\\\"word\\\":\\\"Re\\\",\\\"x\\\":103,\\\"y\\\":1202},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":247,\\\"pos\\\":[{\\\"x\\\":212,\\\"y\\\":1227},{\\\"x\\\":460,\\\"y\\\":1228},{\\\"x\\\":460,\\\"y\\\":1266},{\\\"x\\\":212,\\\"y\\\":1266}],\\\"prob\\\":99,\\\"width\\\":38,\\\"word\\\":\\\"12月1日09:48\\\",\\\"x\\\":317,\\\"y\\\":1123},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":34,\\\"pos\\\":[{\\\"x\\\":119,\\\"y\\\":1383},{\\\"x\\\":153,\\\"y\\\":1383},{\\\"x\\\":153,\\\"y\\\":1413},{\\\"x\\\":119,\\\"y\\\":1413}],\\\"prob\\\":92,\\\"width\\\":30,\\\"word\\\":\\\"中\\\",\\\"x\\\":121,\\\"y\\\":1381},{\\\"angle\\\":0,\\\"direction\\\":0,\\\"height\\\":51,\\\"pos\\\":[{\\\"x\\\":208,\\\"y\\\":1368},{\\\"x\\\":539,\\\"y\\\":1366},{\\\"x\\\":539,\\\"y\\\":1418},{\\\"x\\\":208,\\\"y\\\":1419}],\\\"prob\\\":99,\\\"width\\\":331,\\\"word\\\":\\\"拼多多平台商户\\\",\\\"x\\\":208,\\\"y\\\":1367},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":145,\\\"pos\\\":[{\\\"x\\\":890,\\\"y\\\":1375},{\\\"x\\\":1035,\\\"y\\\":1377},{\\\"x\\\":1035,\\\"y\\\":1413},{\\\"x\\\":889,\\\"y\\\":1411}],\\\"prob\\\":99,\\\"width\\\":35,\\\"word\\\":\\\"-42.00\\\",\\\"x\\\":944,\\\"y\\\":1321},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":48,\\\"pos\\\":[{\\\"x\\\":78,\\\"y\\\":1405},{\\\"x\\\":127,\\\"y\\\":1405},{\\\"x\\\":127,\\\"y\\\":1435},{\\\"x\\\":78,\\\"y\\\":1435}],\\\"prob\\\":99,\\\"width\\\":30,\\\"word\\\":\\\"拼\\\",\\\"x\\\":87,\\\"y\\\":1396},{\\\"angle\\\":0,\\\"direction\\\":0,\\\"height\\\":44,\\\"pos\\\":[{\\\"x\\\":211,\\\"y\\\":1441},{\\\"x\\\":450,\\\"y\\\":1441},{\\\"x\\\":450,\\\"y\\\":1485},{\\\"x\\\":212,\\\"y\\\":1486}],\\\"prob\\\":99,\\\"width\\\":238,\\\"word\\\":\\\"12月1日09:47\\\",\\\"x\\\":212,\\\"y\\\":1441},{\\\"angle\\\":-89,\\\"direction\\\":0,\\\"height\\\":329,\\\"pos\\\":[{\\\"x\\\":208,\\\"y\\\":1582},{\\\"x\\\":538,\\\"y\\\":1583},{\\\"x\\\":538,\\\"y\\\":1635},{\\\"x\\\":208,\\\"y\\\":1634}],\\\"prob\\\":99,\\\"width\\\":51,\\\"word\\\":\\\"拼多多平台商户\\\",\\\"x\\\":347,\\\"y\\\":1443},{\\\"angle\\\":0,\\\"direction\\\":0,\\\"height\\\":40,\\\"pos\\\":[{\\\"x\\\":898,\\\"y\\\":1591},{\\\"x\\\":1038,\\\"y\\\":1591},{\\\"x\\\":1038,\\\"y\\\":1631},{\\\"x\\\":898,\\\"y\\\":1631}],\\\"prob\\\":99,\\\"width\\\":140,\\\"word\\\":\\\"-12.40\\\",\\\"x\\\":898,\\\"y\\\":1591},{\\\"angle\\\":-90,\\\"direction\\\":0,\\\"height\\\":40,\\\"pos\\\":[{\\\"x\\\":97,\\\"y\\\":1619},{\\\"x\\\":138,\\\"y\\\":1619},{\\\"x\\\":138,\\\"y\\\":1649},{\\\"x\\\":97,\\\"y\\\":1649}],\\\"prob\\\":99,\\\"width\\\":29,\\\"word\\\":\\\"拼\\\",\\\"x\\\":103,\\\"y\\\":1613},{\\\"angle\\\":0,\\\"direction\\\":0,\\\"height\\\":39,\\\"pos\\\":[{\\\"x\\\":212,\\\"y\\\":1660},{\\\"x\\\":449,\\\"y\\\":1659},{\\\"x\\\":449,\\\"y\\\":1699},{\\\"x\\\":212,\\\"y\\\":1699}],\\\"prob\\\":99,\\\"width\\\":237,\\\"word\\\":\\\"12月1日09:16\\\",\\\"x\\\":212,\\\"y\\\":1659}],\\\"width\\\":1080}\",\"requestId\":\"077630B9-150F-54D5-8FFE-DDC9D5A9E172\"}"; // 获取OCR结果 - String ocrResultJson = com.aliyun.teautil.Common.toJSONString(body); + String ocrResultJson = com.aliyun.teautil.Common.toJSONString(response.body); // 解析金额等信息 List resultList = OcrAmountParser.parse(ocrResultJson); diff --git a/src/main/resources/db/schema.sql b/src/main/resources/db/schema.sql index 03c96a7..2ab340f 100644 --- a/src/main/resources/db/schema.sql +++ b/src/main/resources/db/schema.sql @@ -34,6 +34,7 @@ CREATE TABLE IF NOT EXISTS `category` ( CREATE TABLE IF NOT EXISTS `bill` ( `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '账单ID', `user_id` BIGINT NOT NULL COMMENT '用户ID', + `account_id` BIGINT COMMENT '账户ID', `category_id` BIGINT NOT NULL COMMENT '分类ID', `amount` DECIMAL(10,2) NOT NULL COMMENT '金额', `description` VARCHAR(255) COMMENT '描述', @@ -44,12 +45,28 @@ CREATE TABLE IF NOT EXISTS `bill` ( `update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', PRIMARY KEY (`id`), INDEX `idx_user_id` (`user_id`), + INDEX `idx_account_id` (`account_id`), INDEX `idx_category_id` (`category_id`), INDEX `idx_bill_date` (`bill_date`), FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE, + FOREIGN KEY (`account_id`) REFERENCES `account` (`id`) ON DELETE RESTRICT, FOREIGN KEY (`category_id`) REFERENCES `category` (`id`) ON DELETE RESTRICT ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='账单表'; +-- 账户表 +CREATE TABLE IF NOT EXISTS `account` ( + `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '账户ID', + `user_id` BIGINT NOT NULL COMMENT '用户ID', + `name` VARCHAR(50) NOT NULL DEFAULT '默认账户' COMMENT '账户名称', + `initial_balance` DECIMAL(10,2) NOT NULL DEFAULT 0.00 COMMENT '初始余额', + `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + INDEX `idx_user_id` (`user_id`), + FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE, + UNIQUE KEY `uk_user_account` (`user_id`) COMMENT '每个用户只有一个账户' +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='账户表'; + -- OCR记录表 CREATE TABLE IF NOT EXISTS `ocr_record` ( `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT 'OCR记录ID',