小程序端login demo
This commit is contained in:
parent
8ac6000605
commit
ed643abfe5
|
|
@ -0,0 +1,74 @@
|
|||
package com.cwhelp.admin.business.controller;
|
||||
|
||||
import com.cwhelp.common.api.baidu.BaiduAipOCR;
|
||||
import com.cwhelp.common.api.baidu.entity.vatinvoice.*;
|
||||
import com.cwhelp.common.constant.ApiConst;
|
||||
import com.cwhelp.common.enums.InvoiceTypeEnum;
|
||||
import com.cwhelp.common.utils.ResultVoUtil;
|
||||
import com.cwhelp.common.vo.ResultVo;
|
||||
import com.cwhelp.component.fileUpload.FileUpload;
|
||||
import com.cwhelp.component.fileUpload.enums.UploadResultEnum;
|
||||
import com.cwhelp.devtools.generate.utils.jAngel.utils.StringUtil;
|
||||
import com.cwhelp.modules.business.domain.BssVatInvoice;
|
||||
import com.cwhelp.modules.system.domain.Upload;
|
||||
import com.cwhelp.modules.system.service.ApiBizService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Created by huangjc on 2019/12/1 0001.
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api_biz")
|
||||
public class BssApiBizController {
|
||||
|
||||
@Autowired
|
||||
private ApiBizService apiBizService;
|
||||
|
||||
@PostMapping("/invoiceOCR")
|
||||
@ResponseBody
|
||||
public ResultVo invoiceOCR(@RequestParam("image") MultipartFile multipartFile,
|
||||
@RequestParam("invoiceType") int invoiceType,
|
||||
@RequestParam("operator") String operator){
|
||||
|
||||
if (multipartFile.getSize() == 0){
|
||||
return new ResultVo(ApiConst.API_PARAM_BLANK_CODE, UploadResultEnum.NO_FILE_NULL.getMessage());
|
||||
}
|
||||
|
||||
if(invoiceType == 0 || StringUtil.isBlank(operator)){
|
||||
return new ResultVo(ApiConst.API_PARAM_BLANK_CODE, ApiConst.API_PARAM_BLANK_MSG);
|
||||
}
|
||||
|
||||
// 创建Upload实体对象
|
||||
Upload upload = FileUpload.getFile(multipartFile, "/images");
|
||||
try {
|
||||
FileUpload.transferTo(multipartFile, upload);
|
||||
File destFile = FileUpload.getDestFile(upload);
|
||||
|
||||
BssVatInvoice vatInvoice = new BssVatInvoice();
|
||||
if(invoiceType == InvoiceTypeEnum.TRAIN_INVOICE.getCode()){
|
||||
TrainResult trainResult = (TrainResult)BaiduAipOCR.queryBaiduVatInvoiceApi(destFile, invoiceType);
|
||||
TrainWordsResult trainWordsResult = trainResult.getWords_result();
|
||||
vatInvoice = apiBizService.getResultByTrain(trainWordsResult, destFile.getPath());
|
||||
}else if(invoiceType == InvoiceTypeEnum.ADD_VALUE_TAX_INVOICE.getCode()){
|
||||
VatInvoiceResult vatInvoiceResult = (VatInvoiceResult)BaiduAipOCR.queryBaiduVatInvoiceApi(destFile, invoiceType);
|
||||
WordsResult wordsResult = vatInvoiceResult.getWords_result();
|
||||
vatInvoice = apiBizService.getResultByAddValue(wordsResult, destFile.getPath());
|
||||
}
|
||||
|
||||
|
||||
return ResultVoUtil.success(ApiConst.API_OPT_SUCCESS_MSG, vatInvoice);
|
||||
|
||||
} catch (Exception e) {
|
||||
return new ResultVo(ApiConst.API_UPLOAD_PICTURE_FAILED_CODE, ApiConst.API_UPLOAD_PICTURE_FAILED_MSG);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
package com.cwhelp.admin.business.controller;
|
||||
|
||||
import com.cwhelp.common.constant.ApiConst;
|
||||
import com.cwhelp.common.utils.ResultVoUtil;
|
||||
import com.cwhelp.common.vo.ResultVo;
|
||||
import com.cwhelp.component.actionLog.action.UserAction;
|
||||
import com.cwhelp.component.actionLog.annotation.ActionLog;
|
||||
import com.cwhelp.devtools.generate.utils.jAngel.utils.StringUtil;
|
||||
import com.cwhelp.modules.system.domain.Role;
|
||||
import com.cwhelp.modules.system.domain.User;
|
||||
import com.cwhelp.modules.system.service.ApiUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by huangjc on 2019/12/1 0001.
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
public class BssApiLoginController {
|
||||
|
||||
@Autowired
|
||||
private ApiUserService apiUserService;
|
||||
|
||||
@PostMapping("/me/login")
|
||||
@ResponseBody
|
||||
@ActionLog(key = UserAction.API_USER_LOGIN, action = UserAction.class)
|
||||
public ResultVo apiUserlogin(HttpServletRequest request, @RequestParam("telephone") String telephone, @RequestParam("password") String password){
|
||||
|
||||
if(StringUtil.isBlank(telephone) || StringUtil.isBlank(password)){
|
||||
return new ResultVo(ApiConst.API_PARAM_BLANK_CODE, ApiConst.API_PARAM_BLANK_MSG);
|
||||
}
|
||||
|
||||
User user = apiUserService.checkLoginPremission(telephone);
|
||||
if(user == null){
|
||||
return new ResultVo(ApiConst.API_LOGIN_PWD_ERR_CODE, ApiConst.API_LOGIN_PWD_ERR_MSG);
|
||||
}else {
|
||||
Iterator<Role> iterator = user.getRoles().iterator();
|
||||
boolean hasPremission = false;
|
||||
while(iterator.hasNext()){
|
||||
if (iterator.next().getName().contains(ApiConst.API_PREMISSION_USER_STR)) {
|
||||
hasPremission = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hasPremission) {
|
||||
//暂定密码为 telephone后六位
|
||||
if(password.equals(telephone.substring(5, telephone.length()))){
|
||||
HttpSession session = request.getSession();
|
||||
String token = UUID.randomUUID().toString();
|
||||
session.setAttribute(token,user);
|
||||
return ResultVoUtil.success(ApiConst.API_LOGIN_SUCCESS_MSG, token);
|
||||
}else{
|
||||
return new ResultVo(ApiConst.API_LOGIN_PWD_ERR_CODE, ApiConst.API_LOGIN_PWD_ERR_MSG);
|
||||
}
|
||||
} else {
|
||||
return new ResultVo(ApiConst.API_NOT_PREMISSION_CODE, ApiConst.API_NOT_PREMISSION_MSG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String tel = "16621001775";
|
||||
|
||||
System.out.println(tel.substring(5, tel.length()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,10 +2,10 @@ package com.cwhelp.admin.business.controller;
|
|||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cwhelp.admin.business.validator.BssVatInvoiceCheckValid;
|
||||
import com.cwhelp.admin.business.validator.BssVatInvoiceValid;
|
||||
import com.cwhelp.common.api.baidu.BaiduAipOCR;
|
||||
import com.cwhelp.common.api.baidu.entity.vatinvoice.*;
|
||||
import com.cwhelp.common.api.baidu.entity.vatinvoice.enums.VatInvoiceTypeEnum;
|
||||
import com.cwhelp.common.enums.InvoiceTypeEnum;
|
||||
import com.cwhelp.common.enums.StatusEnum;
|
||||
import com.cwhelp.common.utils.*;
|
||||
import com.cwhelp.common.vo.ResultVo;
|
||||
|
|
@ -186,7 +186,7 @@ public class BssVatInvoiceController {
|
|||
try {
|
||||
FileUpload.transferTo(multipartFile, upload);
|
||||
File destFile = FileUpload.getDestFile(upload);
|
||||
VatInvoiceResult vatInvoiceResult = BaiduAipOCR.queryBaiduVatInvoiceApi(destFile);
|
||||
VatInvoiceResult vatInvoiceResult = (VatInvoiceResult)BaiduAipOCR.queryBaiduVatInvoiceApi(destFile, InvoiceTypeEnum.ADD_VALUE_TAX_INVOICE.getCode());
|
||||
WordsResult wordsResult = vatInvoiceResult.getWords_result();
|
||||
BssVatInvoice vatInvoice = new BssVatInvoice();
|
||||
Long bssplatformId = ShiroUtil.getSubject().getBssPlatform().getId();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,267 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
|
||||
<link rel="stylesheet" th:href="@{/css/generate.code.css}">
|
||||
</head>
|
||||
<body>
|
||||
生产凭证
|
||||
<div class="layui-form timo-compile" style="padding-top: 0px;">
|
||||
<!-- <div class="layui-tab layui-tab-card">
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this">手工录入</li>
|
||||
<!– <li>查验录入</li>–>
|
||||
</ul>
|
||||
<div class="layui-tab-content" style="height: 100%;">
|
||||
<div class="layui-tab-item layui-show">
|
||||
<form th:action="@{/bss/vatInvoice/add}">
|
||||
<fieldset id="basic" class="layui-elem-field layui-form">
|
||||
<legend class="code-legend">基本信息</legend>
|
||||
<div class="layui-field-box">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label required">发票类型</label>
|
||||
<div class="layui-input-inline">
|
||||
<select id="invoiceType" name="invoiceType" lay-filter="invoiceType">
|
||||
<option value="0">增值税普通发票</option>
|
||||
<option value="1">增值税专用发票</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label required">发票代码</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="invoiceCode" name="invoiceCode" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label required">发票号码</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="invoiceNo" name="invoiceNo" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label required">校验码</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="checkCode" name="checkCode" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label required">发票日期</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="invoiceDate" class="layui-input test-item" id="laydate" placeholder="yyyy-MM-dd" lay-key="1">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">备注</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="remark" name="remark" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label required">不含税金额</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="invoiceMoney" name="invoiceMoney" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label required">税额</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="taxAmount" name="taxAmount" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label required">价税合计</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="totalAmount" name="totalAmount" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label required">价税合计(大写)</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="totalAmountCn" name="totalAmountCn" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
<input type="hidden" id="salerTaxInfoId" name="salerTaxInfoId" />
|
||||
<input type="hidden" id="buyTaxInfoId" name="buyTaxInfoId" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">发票图片</label>
|
||||
<div class="layui-input-inline">
|
||||
<button type="button" class="layui-btn" id="vatInvoiceImg" name="invoiceImg" up-field="path" up-url="/bss/vatInvoice/upload/image">
|
||||
<i class="layui-icon"></i>上传图片
|
||||
</button>
|
||||
</div>
|
||||
<div class="upload-show"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="panel">
|
||||
<div class="panel-header">
|
||||
<div class="title">货物信息</div>
|
||||
<div class="control">
|
||||
<button class="col-add field-add layui-btn layui-btn-primary layui-btn-xs">
|
||||
<i class="fa fa-plus-circle"></i>添加
|
||||
</button>
|
||||
<button class="col-del field-del layui-btn layui-btn-primary layui-btn-xs">
|
||||
<i class="fa fa-minus-circle"></i>删除
|
||||
</button>
|
||||
</div>
|
||||
<div class="entity"><span class="bindTableEntity"></span>(<span class="bindTablePrefix"></span><span class="bindTableName"></span>)</div>
|
||||
</div>
|
||||
<div class="panel-body panel-body-entity">
|
||||
<table class="layui-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="20">#</th>
|
||||
<th width="100">货物名称</th>
|
||||
<th width="100">规格型号</th>
|
||||
<th width="100">单位</th>
|
||||
<th width="100">数量</th>
|
||||
<th width="100">单价</th>
|
||||
<th width="100">金额</th>
|
||||
<th width="100">税率</th>
|
||||
<th width="100">税额</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="entity">
|
||||
<tr>
|
||||
<td class="entity-number" th:text="1"></td>
|
||||
<td class="entity-name"><input type="text" name="name"/></td>
|
||||
<td class="entity-specification"><input type="text" name="specification"/></td>
|
||||
<td class="entity-unit"><input type="text" name="unit"/></td>
|
||||
<td class="entity-num"><input type="text" name="num"/></td>
|
||||
<td class="entity-unitPrice"><input type="text" name="unitPrice"/></td>
|
||||
<td class="entity-detailAmount"><input type="text" name="detailAmount"/></td>
|
||||
<td class="entity-taxRate"><input type="text" name="taxRate"/></td>
|
||||
<td class="entity-taxAmount"><input type="text" name="goodTaxAmount"/></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="layui-form-item timo-finally">
|
||||
<button class="layui-btn ajax-submit" ><i class="fa fa-check-circle"></i> 保存</button>
|
||||
<button class="layui-btn btn-secondary close-popup"><i class="fa fa-times-circle"></i> 关闭</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<!–<div class="layui-tab-item">
|
||||
<form th:action="@{/bss/vatInvoice/check}">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">发票代码</label>
|
||||
<div class="layui-input-inline">
|
||||
<input class="layui-input" type="text" name="invoiceCode" placeholder="请输入发票代码" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">发票号码</label>
|
||||
<div class="layui-input-inline">
|
||||
<input class="layui-input" type="text" name="invoiceNo" placeholder="请输入发票号码" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">开票时间</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="invoiceDate" placeholder="yyyy-MM-dd">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">开具金额(不含税)</label>
|
||||
<div class="layui-input-inline">
|
||||
<input class="layui-input" type="text" name="invoiceMoney" placeholder="请输入开具金额(不含税)" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">校验码</label>
|
||||
<div class="layui-input-inline">
|
||||
<input class="layui-input" type="text" name="checkCode" placeholder="请输入校验码" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item timo-finally">
|
||||
<button class="layui-btn ajax-submit"><i class="fa fa-check-circle"></i> 保存</button>
|
||||
<button class="layui-btn btn-secondary close-popup"><i class="fa fa-times-circle"></i> 关闭</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>–>
|
||||
</div>
|
||||
</div>-->
|
||||
</div>
|
||||
|
||||
<script th:replace="/common/template :: script"></script>
|
||||
<script type="text/javascript" th:src="@{/js/plugins/jquery-3.3.1.min.js}"></script>
|
||||
<!--<script type="text/javascript" th:src="@{/lib/zTree_v3/js/jquery.ztree.core.min.js}"></script>-->
|
||||
<!--<script type="text/javascript" th:src="@{/js/timoTree.js}"></script>-->
|
||||
<script type="text/javascript">
|
||||
// 树形菜单
|
||||
// $.fn.selectTree({
|
||||
// rootTree: '顶级菜单'
|
||||
// });
|
||||
|
||||
// 验证下拉选择器
|
||||
// layui.config({
|
||||
// base: '[[@{/lib/formSelects-v4/}]]'
|
||||
// }).extend({
|
||||
// formSelects: 'formSelects-v4.min'
|
||||
// });
|
||||
|
||||
var entity = $("#entity");
|
||||
var field = null;
|
||||
// 选中字段
|
||||
entity.on("click", ".entity-number", function () {
|
||||
if(field !== null){
|
||||
$(field).css("background-color", "#FFFFFF");
|
||||
$(field).css("color", "#666666");
|
||||
}
|
||||
if(field !== this){
|
||||
$(this).css("background-color", "#5FB878");
|
||||
$(this).css("color", "#FFFFFF");
|
||||
field = this;
|
||||
}else{
|
||||
field = null;
|
||||
}
|
||||
});
|
||||
|
||||
// 添加行
|
||||
$(".col-add").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
var element = entity.children("tr:last-child").clone();
|
||||
element.find("input").val("");
|
||||
if(field == null){
|
||||
entity.append(element);
|
||||
}else {
|
||||
$(field).parent().after(element);
|
||||
}
|
||||
element.children(".entity-number").click();
|
||||
resetNumber();
|
||||
});
|
||||
|
||||
// 删除行
|
||||
$(".col-del").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
if(field != null){
|
||||
if (entity.children("tr").length == 1) {
|
||||
return;
|
||||
}
|
||||
$(field).parent().remove();
|
||||
entity.children("tr:last-child").children(".entity-number").click();
|
||||
resetNumber();
|
||||
}
|
||||
});
|
||||
|
||||
// 重置字段编号
|
||||
var resetNumber = function(){
|
||||
entity.children().each(function (key, val) {
|
||||
$(val).children(".entity-number").text(key + 1);
|
||||
});
|
||||
};
|
||||
</script>
|
||||
<!--<script type="text/javascript" th:src="@{/js/generate.code.js}"></script>-->
|
||||
<!--<script type="text/javascript" th:src="@{/js/build.js}"></script>-->
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -2,7 +2,9 @@ package com.cwhelp.common.api.baidu;
|
|||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baidu.aip.ocr.AipOcr;
|
||||
import com.cwhelp.common.api.baidu.entity.vatinvoice.TrainResult;
|
||||
import com.cwhelp.common.api.baidu.entity.vatinvoice.VatInvoiceResult;
|
||||
import com.cwhelp.common.enums.InvoiceTypeEnum;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -41,9 +43,34 @@ public class BaiduAipOCR {
|
|||
* @param file
|
||||
* @return
|
||||
*/
|
||||
public static VatInvoiceResult queryBaiduVatInvoiceApi(File file){
|
||||
public static Object queryBaiduVatInvoiceApi(File file, int invoiceType){
|
||||
byte[] data = null;
|
||||
try {
|
||||
data = getDataByFile(file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
JSONObject result = null;
|
||||
if(invoiceType == InvoiceTypeEnum.TRAIN_INVOICE.getCode()){
|
||||
result = client.trainTicket(data, null);
|
||||
return JSON.parseObject(result.toString(), TrainResult.class);
|
||||
}else if(invoiceType == InvoiceTypeEnum.METRO_INVOICE.getCode()){
|
||||
return null;
|
||||
}else if(invoiceType == InvoiceTypeEnum.MEAL_INVOICE.getCode()){
|
||||
return null;
|
||||
}else {
|
||||
result = client.vatInvoice(data, null);
|
||||
return JSON.parseObject(result.toString(), VatInvoiceResult.class);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取图片字节数组
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
public static byte[] getDataByFile(File file){
|
||||
byte[] data = null;
|
||||
// 读取图片字节数组
|
||||
try {
|
||||
InputStream in = new FileInputStream(file);
|
||||
data = new byte[in.available()];
|
||||
|
|
@ -52,9 +79,7 @@ public class BaiduAipOCR {
|
|||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
JSONObject result = client.vatInvoice(data, null);
|
||||
VatInvoiceResult vatInvoiceResult = JSON.parseObject(result.toString(), VatInvoiceResult.class);
|
||||
return vatInvoiceResult;
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
package com.cwhelp.common.api.baidu.entity.vatinvoice;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Created by huangjc on 2019/12/3 0003.
|
||||
*/
|
||||
@Data
|
||||
public class TrainResult {
|
||||
|
||||
private String log_id;
|
||||
|
||||
private TrainWordsResult words_result;
|
||||
|
||||
private String words_result_num;
|
||||
|
||||
private String direction;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.cwhelp.common.api.baidu.entity.vatinvoice;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Created by Administrator on 2019/12/7 0007.
|
||||
*/
|
||||
@Data
|
||||
public class TrainWordsResult {
|
||||
|
||||
/**
|
||||
* 请求标识码,随机数,唯一。
|
||||
*/
|
||||
private long logId;
|
||||
|
||||
/**
|
||||
* 车票号
|
||||
*/
|
||||
private String ticketNum;
|
||||
|
||||
/**
|
||||
* 始发站
|
||||
*/
|
||||
private String startingStation;
|
||||
|
||||
/**
|
||||
* 车次号
|
||||
*/
|
||||
private String trainNum;
|
||||
|
||||
/**
|
||||
* 到达站
|
||||
*/
|
||||
private String destinationStation;
|
||||
|
||||
/**
|
||||
* 出发日期
|
||||
*/
|
||||
private String date;
|
||||
|
||||
/**
|
||||
* 车票金额
|
||||
*/
|
||||
private String ticketRates;
|
||||
|
||||
/**
|
||||
* 席别
|
||||
*/
|
||||
private String seatCategory;
|
||||
|
||||
/**
|
||||
* 乘客姓名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package com.cwhelp.common.constant;
|
||||
|
||||
/**
|
||||
* Created by huangjc on 2019/12/2 0002.
|
||||
*/
|
||||
public class ApiConst {
|
||||
|
||||
/**
|
||||
* 假定用户角色名中包含‘api’的为小程序权限用户
|
||||
*/
|
||||
public static final String API_PREMISSION_USER_STR = "api";
|
||||
|
||||
/**
|
||||
* 操作成功
|
||||
*/
|
||||
public static final int API_OPT_SUCCESS_CODE = 200;
|
||||
|
||||
public static final String API_OPT_SUCCESS_MSG = "操作成功";
|
||||
|
||||
public static final String API_LOGIN_SUCCESS_MSG = "登录成功";
|
||||
|
||||
public static final int API_PARAM_BLANK_CODE = 201;
|
||||
|
||||
public static final String API_PARAM_BLANK_MSG = "缺少必要参数";
|
||||
|
||||
public static final int API_NOT_PREMISSION_CODE = 202;
|
||||
|
||||
public static final String API_NOT_PREMISSION_MSG = "没有权限,请到财务帮后台进行授权";
|
||||
|
||||
public static final int API_LOGIN_PWD_ERR_CODE = 203;
|
||||
|
||||
public static final String API_LOGIN_PWD_ERR_MSG = "用户名或密码错误";
|
||||
|
||||
public static final int API_UPLOAD_PICTURE_FAILED_CODE = 204;
|
||||
|
||||
public static final String API_UPLOAD_PICTURE_FAILED_MSG = "上传图片失败";
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.cwhelp.common.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Created by huangjc on 2019/12/3 0003.
|
||||
*/
|
||||
@Getter
|
||||
public enum InvoiceTypeEnum {
|
||||
|
||||
TRAIN_INVOICE(1, "通用火车票"),
|
||||
METRO_INVOICE(2, "地铁票"),
|
||||
MEAL_INVOICE(3, "饭票"),
|
||||
ADD_VALUE_TAX_INVOICE(4, "增值税发票");
|
||||
|
||||
InvoiceTypeEnum(int code, String name){
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
private int code;
|
||||
|
||||
private String name;
|
||||
|
||||
}
|
||||
|
|
@ -15,4 +15,14 @@ public class ResultVo<T> {
|
|||
private String msg;
|
||||
// 响应数据
|
||||
private T data;
|
||||
|
||||
public ResultVo(){
|
||||
|
||||
}
|
||||
|
||||
public ResultVo(Integer code, String msg){
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ public class UserAction extends ActionMap {
|
|||
public static final String EDIT_PWD = "edit_pwd";
|
||||
public static final String EDIT_ROLE = "edit_role";
|
||||
|
||||
public static final String API_USER_LOGIN = "api_user_login";
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
// 用户登录行为
|
||||
|
|
@ -35,6 +37,9 @@ public class UserAction extends ActionMap {
|
|||
putMethod(EDIT_PWD, new BusinessMethod("用户密码","editPwd"));
|
||||
// 角色分配行为
|
||||
putMethod(EDIT_ROLE, new BusinessMethod("角色分配","editRole"));
|
||||
|
||||
// 用户登录行为
|
||||
putMethod(API_USER_LOGIN, new LoginMethod("API用户登录","apiUserLogin"));
|
||||
}
|
||||
|
||||
// 用户登录行为方法
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ public class ShiroConfig {
|
|||
*/
|
||||
LinkedHashMap<String, String> filterMap = new LinkedHashMap<>();
|
||||
filterMap.put("/login", "anon");
|
||||
filterMap.put("/api/me/login", "anon");
|
||||
filterMap.put("/logout", "anon");
|
||||
filterMap.put("/captcha", "anon");
|
||||
filterMap.put("/noAuth", "anon");
|
||||
|
|
|
|||
|
|
@ -44,4 +44,11 @@ public interface UserRepository extends BaseRepository<User, Long>, JpaSpecifica
|
|||
* @param ids ID列表
|
||||
*/
|
||||
Integer deleteByIdIn(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 根据手机号码查询用户数据
|
||||
* @param telephone 用户手机号码
|
||||
* @return 用户数据
|
||||
*/
|
||||
User findByPhone(String telephone);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
package com.cwhelp.modules.system.service;
|
||||
|
||||
import com.cwhelp.common.api.baidu.entity.vatinvoice.TrainWordsResult;
|
||||
import com.cwhelp.common.api.baidu.entity.vatinvoice.WordsResult;
|
||||
import com.cwhelp.modules.business.domain.BssVatInvoice;
|
||||
|
||||
/**
|
||||
* Created by huangjc on 2019/12/3 0003.
|
||||
*/
|
||||
public interface ApiBizService {
|
||||
|
||||
BssVatInvoice getResultByAddValue(WordsResult wordsResult, String path);
|
||||
|
||||
BssVatInvoice getResultByTrain(TrainWordsResult wordsResult, String path);
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.cwhelp.modules.system.service;
|
||||
|
||||
import com.cwhelp.modules.system.domain.User;
|
||||
|
||||
/**
|
||||
* Created by huangjc on 2019/12/1 0001.
|
||||
*/
|
||||
public interface ApiUserService {
|
||||
|
||||
User checkLoginPremission(String telephone);
|
||||
}
|
||||
|
|
@ -63,4 +63,6 @@ public interface UserService {
|
|||
*/
|
||||
@Transactional
|
||||
Boolean updateStatus(StatusEnum statusEnum, List<Long> idList);
|
||||
|
||||
User getByPhone(String telephone);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,144 @@
|
|||
package com.cwhelp.modules.system.service.impl;
|
||||
|
||||
import com.cwhelp.common.api.baidu.entity.vatinvoice.*;
|
||||
import com.cwhelp.common.api.baidu.entity.vatinvoice.enums.VatInvoiceTypeEnum;
|
||||
import com.cwhelp.common.enums.InvoiceTypeEnum;
|
||||
import com.cwhelp.common.utils.ToolUtil;
|
||||
import com.cwhelp.modules.business.domain.BssGoods;
|
||||
import com.cwhelp.modules.business.domain.BssTaxinfo;
|
||||
import com.cwhelp.modules.business.domain.BssVatInvoice;
|
||||
import com.cwhelp.modules.business.service.BssTaxinfoService;
|
||||
import com.cwhelp.modules.system.service.ApiBizService;
|
||||
import org.jsoup.helper.StringUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by huangjc on 2019/12/3 0003.
|
||||
*/
|
||||
@Service
|
||||
public class ApiBizServiceImpl implements ApiBizService{
|
||||
|
||||
@Autowired
|
||||
private BssTaxinfoService bssTaxinfoService;
|
||||
|
||||
@Override
|
||||
public BssVatInvoice getResultByAddValue(WordsResult wordsResult, String path) {
|
||||
BssVatInvoice vatInvoice = new BssVatInvoice();
|
||||
Long bssplatformId = 0L;
|
||||
//add by hjc 发票上扫到的买卖双方如果不在系统中先入库
|
||||
if(!StringUtil.isBlank(wordsResult.getSellerRegisterNum())){
|
||||
BssTaxinfo sellerTaxInfo = new BssTaxinfo();
|
||||
BssTaxinfo taxNo = bssTaxinfoService.getByTaxNo(wordsResult.getSellerRegisterNum());
|
||||
if(taxNo == null){
|
||||
//销售方
|
||||
sellerTaxInfo.setName(wordsResult.getSellerName());
|
||||
sellerTaxInfo.setTaxNo(wordsResult.getSellerRegisterNum());
|
||||
sellerTaxInfo.setAccount(wordsResult.getSellerBank());
|
||||
sellerTaxInfo.setAddressPhone(wordsResult.getSellerAddress());
|
||||
sellerTaxInfo.setPlatformId(bssplatformId);
|
||||
bssTaxinfoService.save(sellerTaxInfo);
|
||||
vatInvoice.setSalerTaxInfoId(sellerTaxInfo.getId());
|
||||
}else {
|
||||
vatInvoice.setSalerTaxInfoId(taxNo.getId());
|
||||
}
|
||||
}
|
||||
|
||||
if(!StringUtil.isBlank(wordsResult.getPurchaserRegisterNum())){
|
||||
BssTaxinfo purchaserTaxInfo = new BssTaxinfo();
|
||||
BssTaxinfo taxNo = bssTaxinfoService.getByTaxNo(wordsResult.getPurchaserRegisterNum());
|
||||
if(taxNo == null){
|
||||
//购买方
|
||||
purchaserTaxInfo.setName(wordsResult.getPurchaserName());
|
||||
purchaserTaxInfo.setTaxNo(wordsResult.getPurchaserRegisterNum());
|
||||
purchaserTaxInfo.setAccount(wordsResult.getPurchaserBank());
|
||||
purchaserTaxInfo.setAddressPhone(wordsResult.getPurchaserAddress());
|
||||
purchaserTaxInfo.setPlatformId(bssplatformId);
|
||||
bssTaxinfoService.save(purchaserTaxInfo);
|
||||
vatInvoice.setBuyTaxInfoId(purchaserTaxInfo.getId());
|
||||
}else{
|
||||
vatInvoice.setBuyTaxInfoId(taxNo.getId());
|
||||
}
|
||||
}
|
||||
|
||||
//商品
|
||||
List<BssGoods> goods = new ArrayList<>();
|
||||
List<CommodityName> commodityNames = wordsResult.getCommodityName();
|
||||
List<CommodityType> commodityTypes = wordsResult.getCommodityType();
|
||||
List<CommodityUnit> commodityUnits = wordsResult.getCommodityUnit();
|
||||
List<CommodityNum> commodityNums = wordsResult.getCommodityNum();
|
||||
List<CommodityPrice> commodityPrices = wordsResult.getCommodityPrice();
|
||||
List<CommodityAmount> commodityAmounts = wordsResult.getCommodityAmount();
|
||||
List<CommodityTaxRate> commodityTaxRates = wordsResult.getCommodityTaxRate();
|
||||
List<CommodityTax> commodityTaxs = wordsResult.getCommodityTax();
|
||||
|
||||
for (int i = 0; i < commodityNames.size(); i++) {
|
||||
BssGoods good = new BssGoods();
|
||||
good.setName(commodityNames.get(i).getWord());
|
||||
if (ToolUtil.checkListSize(commodityTypes) && commodityTypes.size() > i && !StringUtil.isBlank(commodityTypes.get(i).getWord())) {
|
||||
good.setSpecification(commodityTypes.get(i).getWord());
|
||||
}
|
||||
if (ToolUtil.checkListSize(commodityUnits) && commodityUnits.size() > i && !StringUtil.isBlank(commodityUnits.get(i).getWord())) {
|
||||
good.setUnit(commodityUnits.get(i).getWord());
|
||||
}
|
||||
if (ToolUtil.checkListSize(commodityNums) && !StringUtil.isBlank(commodityNums.get(i).getWord())) {
|
||||
good.setNum(Integer.valueOf(commodityNums.get(i).getWord()));
|
||||
}
|
||||
if (ToolUtil.checkListSize(commodityPrices) && commodityPrices.size() > i && !StringUtil.isBlank(commodityPrices.get(i).getWord())) {
|
||||
good.setUnitPrice(commodityPrices.get(i).getWord());
|
||||
}
|
||||
if (ToolUtil.checkListSize(commodityAmounts) && !StringUtil.isBlank(commodityAmounts.get(i).getWord())) {
|
||||
good.setDetailAmount(new BigDecimal(commodityAmounts.get(i).getWord()));
|
||||
}
|
||||
if (ToolUtil.checkListSize(commodityTaxRates) && !StringUtil.isBlank(commodityTaxRates.get(i).getWord())) {
|
||||
good.setTaxRate(commodityTaxRates.get(i).getWord());
|
||||
}
|
||||
if (ToolUtil.checkListSize(commodityTaxs) && !StringUtil.isBlank(commodityTaxs.get(i).getWord())) {
|
||||
good.setGoodTaxAmount(new BigDecimal(commodityTaxs.get(i).getWord()));
|
||||
}
|
||||
goods.add(good);
|
||||
}
|
||||
|
||||
vatInvoice.setInvoiceCode(wordsResult.getInvoiceCode());
|
||||
vatInvoice.setInvoiceNo(wordsResult.getInvoiceNum());
|
||||
vatInvoice.setInvoiceDate(wordsResult.getInvoiceDate());
|
||||
vatInvoice.setCheckCode(wordsResult.getCheckCode());
|
||||
vatInvoice.setInvoiceMoney(new BigDecimal(wordsResult.getTotalAmount()));
|
||||
vatInvoice.setTaxAmount(new BigDecimal(wordsResult.getTotalTax()));
|
||||
vatInvoice.setTotalAmount(new BigDecimal(wordsResult.getAmountInFiguers()));
|
||||
vatInvoice.setTotalAmountCn(wordsResult.getAmountInWords());
|
||||
vatInvoice.setRemark(wordsResult.getRemarks());
|
||||
vatInvoice.setBssGoods(goods);
|
||||
vatInvoice.setInvoiceImg(path);
|
||||
vatInvoice.setInvoiceType(VatInvoiceTypeEnum.getVatInvoiceCode(wordsResult.getInvoiceType()));
|
||||
|
||||
return vatInvoice;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BssVatInvoice getResultByTrain(TrainWordsResult wordsResult, String path) {
|
||||
BssVatInvoice vatInvoice = new BssVatInvoice();
|
||||
|
||||
//商品
|
||||
List<BssGoods> goods = new ArrayList<>();
|
||||
BssGoods good = new BssGoods();
|
||||
good.setName(InvoiceTypeEnum.TRAIN_INVOICE.getName());
|
||||
good.setDetailAmount(new BigDecimal(wordsResult.getTicketRates()));
|
||||
good.setNum(1);
|
||||
good.setUnit("张");
|
||||
good.setUnitPrice(wordsResult.getTicketRates());
|
||||
goods.add(good);
|
||||
|
||||
vatInvoice.setInvoiceMoney(new BigDecimal(wordsResult.getTicketRates()));
|
||||
vatInvoice.setTotalAmount(new BigDecimal(wordsResult.getTicketRates()));
|
||||
vatInvoice.setRemark(wordsResult.getStartingStation().concat("至").concat(wordsResult.getDestinationStation()));
|
||||
vatInvoice.setBssGoods(goods);
|
||||
vatInvoice.setInvoiceImg(path);
|
||||
|
||||
return vatInvoice;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.cwhelp.modules.system.service.impl;
|
||||
|
||||
import com.cwhelp.modules.system.domain.User;
|
||||
import com.cwhelp.modules.system.repository.UserRepository;
|
||||
import com.cwhelp.modules.system.service.ApiUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* Created by Administrator on 2019/12/2 0002.
|
||||
*/
|
||||
@Service
|
||||
public class ApiUserServiceImpl implements ApiUserService {
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Override
|
||||
public User checkLoginPremission(String telephone) {
|
||||
return userRepository.findByPhone(telephone);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -4,7 +4,6 @@ import com.cwhelp.common.constant.AdminConst;
|
|||
import com.cwhelp.common.data.PageSort;
|
||||
import com.cwhelp.common.enums.StatusEnum;
|
||||
import com.cwhelp.modules.business.domain.BssPlatform;
|
||||
import com.cwhelp.modules.business.repository.BssPlatformRepository;
|
||||
import com.cwhelp.modules.system.domain.Dept;
|
||||
import com.cwhelp.modules.system.domain.User;
|
||||
import com.cwhelp.modules.system.repository.UserRepository;
|
||||
|
|
@ -34,8 +33,6 @@ public class UserServiceImpl implements UserService {
|
|||
@Autowired
|
||||
private DeptService deptService;
|
||||
|
||||
@Autowired
|
||||
private BssPlatformRepository bssPlatformRepository;
|
||||
|
||||
/**
|
||||
* 根据用户名查询用户数据
|
||||
|
|
@ -161,4 +158,12 @@ public class UserServiceImpl implements UserService {
|
|||
}
|
||||
return userRepository.updateStatus(statusEnum.getCode(), ids) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据手机号获取员工信息
|
||||
*/
|
||||
@Override
|
||||
public User getByPhone(String telephone) {
|
||||
return userRepository.findByPhone(telephone);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
BIN
sdoc/~$设计.docx
BIN
sdoc/~$设计.docx
Binary file not shown.
Loading…
Reference in New Issue