Commit 58c219e6 authored by eddie.woo's avatar eddie.woo

modify

parent 708d8bd0
......@@ -195,14 +195,16 @@
<version>1.11</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
......
......@@ -17,6 +17,7 @@ import org.springframework.util.StringUtils;
import pwc.taxtech.atms.dao.UserMapper;
import pwc.taxtech.atms.entitiy.User;
import pwc.taxtech.atms.security.JwtUser;
@Component
public class AuthUserHelperImpl implements AuditorAware<String>, AuthUserHelper {
......@@ -56,12 +57,19 @@ public class AuthUserHelperImpl implements AuditorAware<String>, AuthUserHelper
*/
@Override
public String getCurrentUserID() {
String userName = getCurrentAuditor();
User user = userMapper.selectByUserNameIgnoreCase(userName); //todo 加缓存
if (user == null) {
SecurityContext context = SecurityContextHolder.getContext();
if (context == null) {
throw new ApplicationException("security context is null");
}
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null || !authentication.isAuthenticated()) {
throw new ApplicationException("authentication failed");
}
JwtUser jwtUser = (JwtUser) authentication.getPrincipal();
if (jwtUser == null) {
return "";
}
return user.getID();
return jwtUser.getUserid();
}
/*
......
......@@ -18,6 +18,7 @@ public class FTPClientPool {
private GenericObjectPool<FTPClient> pool;
private String ftpRootPath;
private static final String SYMBOL = "/";
private FTPClientConfig ftpClientConfig;
@Value("${ftp.host}")
private String ftpHost;
......@@ -36,6 +37,7 @@ public class FTPClientPool {
clientConfig.setPort(ftpPort);
clientConfig.setUsername(ftpUser);
clientConfig.setPassword(ftpPwd);
ftpClientConfig = clientConfig;
pool = new GenericObjectPool<>(new FtpClientFactory(clientConfig), config);
ftpRootPath = pool.borrowObject().printWorkingDirectory();
}
......@@ -129,4 +131,8 @@ public class FTPClientPool {
client.deleteFile(filePath);
}
}
public FTPClientConfig getFtpClientConfig() {
return ftpClientConfig;
}
}
package pwc.taxtech.atms.constant.task;
import java.util.HashMap;
import java.util.Map;
public class TaskListConstant {
/**
* 任务类型
*/
public enum Type {
ScanInvoice(1, "发票扫描");
private int code;
private String name;
Type(int code, String name) {
this.code = code;
this.name = name;
}
public int getCode() {
return code;
}
public String getName() {
return name;
}
}
/**
* 任务状态
*/
public enum Status {
Init(0, "初始状态"),
Processing(1, "执行中"),
Success(2, "任务成功"),
Failed(3, "任务失败");
private int code;
private String name;
public static final Map<Integer, String> MAP = new HashMap<>();
static {
for (Status status : Status.values()) {
MAP.put(status.getCode(), status.getName());
}
}
Status(int code, String name) {
this.code = code;
this.name = name;
}
public int getCode() {
return code;
}
public String getName() {
return name;
}
}
}
......@@ -4,15 +4,13 @@ import org.apache.http.HttpStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import com.github.pagehelper.PageHelper;
import io.swagger.annotations.ApiOperation;
import pwc.taxtech.atms.controller.BaseController;
import pwc.taxtech.atms.dto.ApiResultDto;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.input.CamelPagingDto;
import pwc.taxtech.atms.dto.input.CamelPagingResultDto;
......@@ -131,4 +129,26 @@ public class InvoiceManageController extends BaseController {
InvoiceFilterDto invoiceFilterDto=invoiceManageService.getInvoiceFilterBasicData();
return invoiceFilterDto;
}
@ResponseBody
@RequestMapping(value = "scan", method = RequestMethod.GET)
public ApiResultDto scan() {
try {
return ApiResultDto.success(invoiceManageService.scan());
} catch (Exception e) {
logger.error(" create scan error.", e);
}
return ApiResultDto.fail("创建扫描失败");
}
@ResponseBody
@RequestMapping(value = "scanResult", method = RequestMethod.GET)
public ApiResultDto getScanResult(@RequestParam Long taskId) {
try {
return ApiResultDto.success(invoiceManageService.scan());
} catch (Exception e) {
logger.error(" create scan error.", e);
}
return ApiResultDto.fail("创建扫描失败");
}
}
package pwc.taxtech.atms.controller.vendor;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import pwc.taxtech.atms.common.ServiceException;
import pwc.taxtech.atms.controller.BaseController;
import pwc.taxtech.atms.dto.ApiResultDto;
import pwc.taxtech.atms.dto.vendor.LgItemDto;
import pwc.taxtech.atms.dto.vendor.LgVendorDto;
import pwc.taxtech.atms.service.vendor.LongiService;
import java.util.List;
@RestController
@RequestMapping("/vendor/api/v1/scan")
public class ScanController extends BaseController {
@Autowired
private LongiService longiService;
@ApiOperation(value = "批量更新扫描结果")
@RequestMapping(value = "update", method = RequestMethod.POST)
public ApiResultDto updateItems(@RequestBody List<LgItemDto> lgItemDtoList) {
try {
longiService.updateItems(lgItemDtoList);
} catch (ServiceException e) {
return ApiResultDto.fail(e.getMessage());
}
return ApiResultDto.success();
}
}
......@@ -4,11 +4,13 @@ import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Repository;
import pwc.taxtech.atms.MyMapper;
import pwc.taxtech.atms.entitiy.InputInvoice;
import pwc.taxtech.atms.entitiy.InputInvoiceExample;
@Mapper
@Repository
public interface InputInvoiceMapper extends MyMapper {
/**
* This method was generated by MyBatis Generator.
......
package pwc.taxtech.atms.dao;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Repository;
import pwc.taxtech.atms.MyMapper;
import pwc.taxtech.atms.entitiy.TaskList;
import pwc.taxtech.atms.entitiy.TaskListExample;
@Mapper
@Repository
public interface TaskListMapper extends MyMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table task_list
*
* @mbg.generated
*/
long countByExample(TaskListExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table task_list
*
* @mbg.generated
*/
int deleteByExample(TaskListExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table task_list
*
* @mbg.generated
*/
int deleteByPrimaryKey(Long id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table task_list
*
* @mbg.generated
*/
int insert(TaskList record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table task_list
*
* @mbg.generated
*/
int insertSelective(TaskList record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table task_list
*
* @mbg.generated
*/
List<TaskList> selectByExampleWithRowbounds(TaskListExample example, RowBounds rowBounds);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table task_list
*
* @mbg.generated
*/
List<TaskList> selectByExample(TaskListExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table task_list
*
* @mbg.generated
*/
TaskList selectByPrimaryKey(Long id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table task_list
*
* @mbg.generated
*/
int updateByExampleSelective(@Param("record") TaskList record, @Param("example") TaskListExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table task_list
*
* @mbg.generated
*/
int updateByExample(@Param("record") TaskList record, @Param("example") TaskListExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table task_list
*
* @mbg.generated
*/
int updateByPrimaryKeySelective(TaskList record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table task_list
*
* @mbg.generated
*/
int updateByPrimaryKey(TaskList record);
}
\ No newline at end of file
package pwc.taxtech.atms.dao.dao;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.dao.InputDeviceMapper;
import pwc.taxtech.atms.entitiy.InputDevice;
import pwc.taxtech.atms.entitiy.InputDeviceExample;
import java.util.Optional;
@Service
public class InputDeviceDao {
@Autowired
private InputDeviceMapper mapper;
/**
* 获取扫描仪
* @return Optional
*/
public Optional<InputDevice> getScan() {
InputDeviceExample example = new InputDeviceExample();
InputDeviceExample.Criteria criteria = example.createCriteria();
criteria.andTypeEqualTo(1); //扫描仪
PageHelper.startPage(0, 1, false);
PageInfo<InputDevice> pageInfo = new PageInfo<>(mapper.selectByExample(example));
return pageInfo.getList().stream().findFirst();
}
}
package pwc.taxtech.atms.dto.input;
public class InvoiceItemDto {
private String productionName;//商品名称
private String specification;//规格
private String unit;//单位
private String quantity;//数量
private String unitPrice;//单价
private String amount;//金额
private String taxRate;//税率
private String taxAmount;//税额
private String remark;//备注
private Integer rowNo;//行号
public String getProductionName() {
return productionName;
}
public void setProductionName(String productionName) {
this.productionName = productionName;
}
public String getSpecification() {
return specification;
}
public void setSpecification(String specification) {
this.specification = specification;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
public String getQuantity() {
return quantity;
}
public void setQuantity(String quantity) {
this.quantity = quantity;
}
public String getUnitPrice() {
return unitPrice;
}
public void setUnitPrice(String unitPrice) {
this.unitPrice = unitPrice;
}
public String getAmount() {
return amount;
}
public void setAmount(String amount) {
this.amount = amount;
}
public String getTaxRate() {
return taxRate;
}
public void setTaxRate(String taxRate) {
this.taxRate = taxRate;
}
public String getTaxAmount() {
return taxAmount;
}
public void setTaxAmount(String taxAmount) {
this.taxAmount = taxAmount;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public Integer getRowNo() {
return rowNo;
}
public void setRowNo(Integer rowNo) {
this.rowNo = rowNo;
}
}
package pwc.taxtech.atms.dto.input;
import java.util.ArrayList;
import java.util.List;
public class InvoiceScanDto extends ScanDto {
private String invoiceCode; //发票代码
private String invoiceNumber;//发票号码
private String invoiceDate;//开票日期
private String invoiceName;//发票名称
private String buyerTaxNumber;//购货方税号
private String buyerName;//购货方名称
private String buyerAddress;//购货方地址
private String buyerPhone;//购货方电话
private String buyerBankName;//购货方银行名称
private String buyerBankAccountNumber;//购货方银行账号
private String sellerTaxNumber;//销货方税号
private String sellerName;//销货方名称
private String sellerAddress;//销货方地址
private String sellerPhone;//销货方电话
private String sellerBankName;//销货方银行名称
private String sellerBankAccountNumber;//销货方银行账号
private String amount;//金额
private String taxAmount;//税额
private String totalPriceUppercase;//加税合计大写
private String totalPriceLowercase;//加税合计小写
private String invoiceType;//发票类型
private String checkCode;//校验码
private String remark;//备注
private List<InvoiceItemDto> itemList = new ArrayList<>();
public String getInvoiceCode() {
return invoiceCode;
}
public void setInvoiceCode(String invoiceCode) {
this.invoiceCode = invoiceCode;
}
public String getInvoiceNumber() {
return invoiceNumber;
}
public void setInvoiceNumber(String invoiceNumber) {
this.invoiceNumber = invoiceNumber;
}
public String getInvoiceDate() {
return invoiceDate;
}
public void setInvoiceDate(String invoiceDate) {
this.invoiceDate = invoiceDate;
}
public String getInvoiceName() {
return invoiceName;
}
public void setInvoiceName(String invoiceName) {
this.invoiceName = invoiceName;
}
public String getBuyerTaxNumber() {
return buyerTaxNumber;
}
public void setBuyerTaxNumber(String buyerTaxNumber) {
this.buyerTaxNumber = buyerTaxNumber;
}
public String getBuyerName() {
return buyerName;
}
public void setBuyerName(String buyerName) {
this.buyerName = buyerName;
}
public String getBuyerAddress() {
return buyerAddress;
}
public void setBuyerAddress(String buyerAddress) {
this.buyerAddress = buyerAddress;
}
public String getBuyerPhone() {
return buyerPhone;
}
public void setBuyerPhone(String buyerPhone) {
this.buyerPhone = buyerPhone;
}
public String getBuyerBankName() {
return buyerBankName;
}
public void setBuyerBankName(String buyerBankName) {
this.buyerBankName = buyerBankName;
}
public String getBuyerBankAccountNumber() {
return buyerBankAccountNumber;
}
public void setBuyerBankAccountNumber(String buyerBankAccountNumber) {
this.buyerBankAccountNumber = buyerBankAccountNumber;
}
public String getSellerTaxNumber() {
return sellerTaxNumber;
}
public void setSellerTaxNumber(String sellerTaxNumber) {
this.sellerTaxNumber = sellerTaxNumber;
}
public String getSellerName() {
return sellerName;
}
public void setSellerName(String sellerName) {
this.sellerName = sellerName;
}
public String getSellerAddress() {
return sellerAddress;
}
public void setSellerAddress(String sellerAddress) {
this.sellerAddress = sellerAddress;
}
public String getSellerPhone() {
return sellerPhone;
}
public void setSellerPhone(String sellerPhone) {
this.sellerPhone = sellerPhone;
}
public String getSellerBankName() {
return sellerBankName;
}
public void setSellerBankName(String sellerBankName) {
this.sellerBankName = sellerBankName;
}
public String getSellerBankAccountNumber() {
return sellerBankAccountNumber;
}
public void setSellerBankAccountNumber(String sellerBankAccountNumber) {
this.sellerBankAccountNumber = sellerBankAccountNumber;
}
public String getAmount() {
return amount;
}
public void setAmount(String amount) {
this.amount = amount;
}
public String getTaxAmount() {
return taxAmount;
}
public void setTaxAmount(String taxAmount) {
this.taxAmount = taxAmount;
}
public String getTotalPriceUppercase() {
return totalPriceUppercase;
}
public void setTotalPriceUppercase(String totalPriceUppercase) {
this.totalPriceUppercase = totalPriceUppercase;
}
public String getTotalPriceLowercase() {
return totalPriceLowercase;
}
public void setTotalPriceLowercase(String totalPriceLowercase) {
this.totalPriceLowercase = totalPriceLowercase;
}
public String getInvoiceType() {
return invoiceType;
}
public void setInvoiceType(String invoiceType) {
this.invoiceType = invoiceType;
}
public String getCheckCode() {
return checkCode;
}
public void setCheckCode(String checkCode) {
this.checkCode = checkCode;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public List<InvoiceItemDto> getItemList() {
return itemList;
}
public void setItemList(List<InvoiceItemDto> itemList) {
this.itemList = itemList;
}
}
package pwc.taxtech.atms.dto.input;
public class ScanDto {
private String filePath;
private String fileName;
private Integer dtoType;
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public Integer getDtoType() {
return dtoType;
}
public void setDtoType(Integer dtoType) {
this.dtoType = dtoType;
}
}
package pwc.taxtech.atms.dto.input;
public class ScanParamDto {
private String ftpUser;
private String ftpPwd;
private String ftpHost;
private Integer ftpPort;
private Long jobId;//任务ID
public String getFtpUser() {
return ftpUser;
}
public void setFtpUser(String ftpUser) {
this.ftpUser = ftpUser;
}
public String getFtpPwd() {
return ftpPwd;
}
public void setFtpPwd(String ftpPwd) {
this.ftpPwd = ftpPwd;
}
public String getFtpHost() {
return ftpHost;
}
public void setFtpHost(String ftpHost) {
this.ftpHost = ftpHost;
}
public Integer getFtpPort() {
return ftpPort;
}
public void setFtpPort(Integer ftpPort) {
this.ftpPort = ftpPort;
}
public Long getJobId() {
return jobId;
}
public void setJobId(Long jobId) {
this.jobId = jobId;
}
}
package pwc.taxtech.atms.dto.input;
import java.util.ArrayList;
import java.util.List;
public class ScanResultDto {
private Integer total;
private Integer error;
private List<VoucherDto> scanList = new ArrayList<>();
private List<InvoiceScanDto> manualList = new ArrayList<>();
private Long jobId;//任务ID
public Integer getTotal() {
return total;
}
public void setTotal(Integer total) {
this.total = total;
}
public Integer getError() {
return error;
}
public void setError(Integer error) {
this.error = error;
}
public List<VoucherDto> getScanList() {
return scanList;
}
public void setScanList(List<VoucherDto> scanList) {
this.scanList = scanList;
}
public Long getJobId() {
return jobId;
}
public void setJobId(Long jobId) {
this.jobId = jobId;
}
public List<InvoiceScanDto> getManualList() {
return manualList;
}
public void setManualList(List<InvoiceScanDto> manualList) {
this.manualList = manualList;
}
}
package pwc.taxtech.atms.dto.input;
import java.util.ArrayList;
import java.util.List;
public class VoucherDto extends ScanDto {
private String voucherNo;
private List<InvoiceScanDto> invoiceList = new ArrayList<>();
public String getVoucherNo() {
return voucherNo;
}
public void setVoucherNo(String voucherNo) {
this.voucherNo = voucherNo;
}
public List<InvoiceScanDto> getInvoiceList() {
return invoiceList;
}
public void setInvoiceList(List<InvoiceScanDto> invoiceList) {
this.invoiceList = invoiceList;
}
}
......@@ -26,7 +26,7 @@ public class InputDevice extends BaseEntity {
*
* @mbg.generated
*/
private Short type;
private Integer type;
/**
* Database Column Remarks:
......@@ -71,7 +71,7 @@ public class InputDevice extends BaseEntity {
*
* @mbg.generated
*/
public Short getType() {
public Integer getType() {
return type;
}
......@@ -83,7 +83,7 @@ public class InputDevice extends BaseEntity {
*
* @mbg.generated
*/
public void setType(Short type) {
public void setType(Integer type) {
this.type = type;
}
......
......@@ -264,52 +264,52 @@ public class InputDeviceExample {
return (Criteria) this;
}
public Criteria andTypeEqualTo(Short value) {
public Criteria andTypeEqualTo(Integer value) {
addCriterion("`type` =", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(Short value) {
public Criteria andTypeNotEqualTo(Integer value) {
addCriterion("`type` <>", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThan(Short value) {
public Criteria andTypeGreaterThan(Integer value) {
addCriterion("`type` >", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(Short value) {
public Criteria andTypeGreaterThanOrEqualTo(Integer value) {
addCriterion("`type` >=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThan(Short value) {
public Criteria andTypeLessThan(Integer value) {
addCriterion("`type` <", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(Short value) {
public Criteria andTypeLessThanOrEqualTo(Integer value) {
addCriterion("`type` <=", value, "type");
return (Criteria) this;
}
public Criteria andTypeIn(List<Short> values) {
public Criteria andTypeIn(List<Integer> values) {
addCriterion("`type` in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<Short> values) {
public Criteria andTypeNotIn(List<Integer> values) {
addCriterion("`type` not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(Short value1, Short value2) {
public Criteria andTypeBetween(Integer value1, Integer value2) {
addCriterion("`type` between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(Short value1, Short value2) {
public Criteria andTypeNotBetween(Integer value1, Integer value2) {
addCriterion("`type` not between", value1, value2, "type");
return (Criteria) this;
}
......
package pwc.taxtech.atms.entitiy;
/**
*
* This class was generated by MyBatis Generator.
* This class corresponds to the database table task_list
*
* @mbg.generated do_not_delete_during_merge
*/
public class TaskList extends BaseEntity {
/**
* Database Column Remarks:
* 任务ID
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column task_list.id
*
* @mbg.generated
*/
private Long id;
/**
* Database Column Remarks:
* 任务名称
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column task_list.name
*
* @mbg.generated
*/
private String name;
/**
* Database Column Remarks:
* 任务类型 1:扫描发票
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column task_list.type
*
* @mbg.generated
*/
private Integer type;
/**
* Database Column Remarks:
* 0:初始 1:执行中 2:成功 3:失败
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column task_list.status
*
* @mbg.generated
*/
private Integer status;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column task_list.id
*
* @return the value of task_list.id
*
* @mbg.generated
*/
public Long getId() {
return id;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column task_list.id
*
* @param id the value for task_list.id
*
* @mbg.generated
*/
public void setId(Long id) {
this.id = id;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column task_list.name
*
* @return the value of task_list.name
*
* @mbg.generated
*/
public String getName() {
return name;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column task_list.name
*
* @param name the value for task_list.name
*
* @mbg.generated
*/
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column task_list.type
*
* @return the value of task_list.type
*
* @mbg.generated
*/
public Integer getType() {
return type;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column task_list.type
*
* @param type the value for task_list.type
*
* @mbg.generated
*/
public void setType(Integer type) {
this.type = type;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column task_list.status
*
* @return the value of task_list.status
*
* @mbg.generated
*/
public Integer getStatus() {
return status;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column task_list.status
*
* @param status the value for task_list.status
*
* @mbg.generated
*/
public void setStatus(Integer status) {
this.status = status;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table task_list
*
* @mbg.generated
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", name=").append(name);
sb.append(", type=").append(type);
sb.append(", status=").append(status);
sb.append("]");
return sb.toString();
}
}
\ No newline at end of file
package pwc.taxtech.atms.service;
import java.util.List;
import java.util.Optional;
import pwc.taxtech.atms.dto.input.CamelPagingDto;
import pwc.taxtech.atms.dto.input.CamelPagingResultDto;
......@@ -40,4 +41,10 @@ public interface InvoiceManageService {
*/
InvoiceFilterDto getInvoiceFilterBasicData();
/**
* 扫描识别
* @return task id
*/
Optional<Long> scan();
}
......@@ -3,6 +3,7 @@ package pwc.taxtech.atms.service.impl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.client.RestTemplate;
import pwc.taxtech.atms.common.AtmsApiSettings;
import pwc.taxtech.atms.common.AuthUserHelper;
import pwc.taxtech.atms.common.util.BeanUtil;
......@@ -21,5 +22,7 @@ public class BaseService {
protected DistributedIDService idService;
@Autowired
protected BeanUtil beanUtil;
@Autowired
protected RestTemplate restTemplate;
}
......@@ -3,14 +3,19 @@ package pwc.taxtech.atms.service.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.transaction.annotation.Transactional;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.ftp.FTPClientConfig;
import pwc.taxtech.atms.common.ftp.FTPClientPool;
import pwc.taxtech.atms.constant.enums.EnumInputInvoiceEntityType;
import pwc.taxtech.atms.constant.enums.EnumInputInvoiceRefundReason;
import pwc.taxtech.atms.constant.enums.EnumInputInvoiceSourceType;
......@@ -21,13 +26,10 @@ import pwc.taxtech.atms.constant.enums.EnumIsIncludedInTaxAmountType;
import pwc.taxtech.atms.constant.enums.EnumProductionServiceType;
import pwc.taxtech.atms.constant.enums.EnumProductionType;
import pwc.taxtech.atms.dao.InputInvoiceMapper;
import pwc.taxtech.atms.dto.input.CamelPagingDto;
import pwc.taxtech.atms.dto.input.CamelPagingResultDto;
import pwc.taxtech.atms.dto.input.InputInvoiceDto;
import pwc.taxtech.atms.dto.input.InputInvoiceQuery;
import pwc.taxtech.atms.dto.input.InputInvoiceQueryDto;
import pwc.taxtech.atms.dto.input.InvoiceDictionaryDto;
import pwc.taxtech.atms.dto.input.InvoiceFilterDto;
import pwc.taxtech.atms.dao.dao.InputDeviceDao;
import pwc.taxtech.atms.dto.ApiResultDto;
import pwc.taxtech.atms.dto.input.*;
import pwc.taxtech.atms.entitiy.InputDevice;
import pwc.taxtech.atms.entitiy.InputInvoice;
import pwc.taxtech.atms.entitiy.InputInvoiceExample;
import pwc.taxtech.atms.service.InvoiceManageService;
......@@ -40,6 +42,13 @@ public class InvoiceManageServiceImpl extends BaseService implements InvoiceMana
private InputInvoiceMapper inputInvoiceMapper;
@Autowired
private UserService userService;
@Autowired
private TaskListService taskListService;
@Autowired
private InputDeviceDao inputDeviceDao;
@Autowired
private FTPClientPool ftpClientPool;
private static final String SCAN_REQUEST_URL = "api/v1/ocr/scan";
@Override
public CamelPagingResultDto<InputInvoiceDto> getInputInvoiceList(InputInvoiceQuery inputInvoiceQuery,CamelPagingDto pagingDto) {
......@@ -152,8 +161,6 @@ public class InvoiceManageServiceImpl extends BaseService implements InvoiceMana
return null;
}
@Override
public String exportInvoiceAllInfoList(InputInvoiceQueryDto inputInvoiceQueryDto, CamelPagingDto pagingDto,
String fileName) {
......@@ -161,11 +168,6 @@ public class InvoiceManageServiceImpl extends BaseService implements InvoiceMana
return null;
}
@Override
public List<InputInvoiceDto> getInputInvoiceDtoList(InputInvoiceQueryDto inputInvoiceQueryDto) {
......@@ -250,7 +252,6 @@ public class InvoiceManageServiceImpl extends BaseService implements InvoiceMana
return inputInvoiceList;
}
@Override
public InvoiceFilterDto getInvoiceFilterBasicData() {
InvoiceFilterDto invoiceFilterDto=new InvoiceFilterDto();
......@@ -343,8 +344,29 @@ public class InvoiceManageServiceImpl extends BaseService implements InvoiceMana
return invoiceFilterDto;
}
@Transactional
@Override
public Optional<Long> scan() {
Optional<InputDevice> optional = inputDeviceDao.getScan();
if (!optional.isPresent()) {
return Optional.empty();
}
InputDevice inputDevice = optional.get();
long id = taskListService.addScanTask();
ScanParamDto paramDto = new ScanParamDto();
FTPClientConfig config = ftpClientPool.getFtpClientConfig();
paramDto.setFtpHost(config.getHost());
paramDto.setFtpPort(config.getPort());
paramDto.setFtpPwd(config.getPassword());
paramDto.setFtpUser(config.getUsername());
paramDto.setJobId(id);
String url = StringUtils.appendIfMissing(inputDevice.getUrl(), "/") + SCAN_REQUEST_URL;
ApiResultDto resultDto = restTemplate.postForObject(url, paramDto, ApiResultDto.class);
if (resultDto.getCode() == ApiResultDto.FAILED) {
return Optional.empty();
}
return Optional.of(id);
}
}
package pwc.taxtech.atms.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.constant.task.TaskListConstant;
import pwc.taxtech.atms.dao.TaskListMapper;
import pwc.taxtech.atms.entitiy.TaskList;
@Service
public class TaskListService extends BaseService {
@Autowired
private TaskListMapper taskListMapper;
/**
* 创建扫描任务
*
* @return ID
*/
public Long addScanTask() {
long id = idService.nextId();
TaskList taskList = new TaskList();
taskList.setId(id);
taskList.setType(TaskListConstant.Type.ScanInvoice.getCode());
taskList.setStatus(TaskListConstant.Status.Processing.getCode());
String user = authUserHelper.getCurrentUserID();
taskList.setCreateBy(user);
taskList.setUpdateBy(user);
taskListMapper.insertSelective(taskList);
return id;
}
}
package pwc.taxtech.atms.service.vendor;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.dto.input.ScanResultDto;
import pwc.taxtech.atms.service.impl.BaseService;
@Service
public class ScanService extends BaseService {
public void update(ScanResultDto resultDto){
}
}
......@@ -16,7 +16,7 @@ jwt.powerToken=xxxx
jwt.expireSecond=180000
jwt.refreshSecond=600
ftp.host=cnshaappulv004.asia.pwcinternal.com
ftp.host=cnshaappulv003.asia.pwcinternal.com
ftp.port=21
ftp.user=ftpuser
ftp.pwd=12345678
......
......@@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import pwc.taxtech.atms.dao.*;
import pwc.taxtech.atms.entitiy.*;
......@@ -17,6 +18,7 @@ import java.io.InputStreamReader;
import java.io.Reader;
import java.sql.Connection;
@WebAppConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:applicationContext.xml" })
public abstract class CommonIT {
......
......@@ -130,6 +130,12 @@
<!--</table>-->
<table tableName="input_device" domainObjectName="InputDevice">
<property name="ignoreQualifiersAtRuntime" value="true"/>
<columnOverride column="type" javaType="java.lang.Integer"/>
</table>
<table tableName="task_list" domainObjectName="TaskList">
<property name="ignoreQualifiersAtRuntime" value="true"/>
<columnOverride column="type" javaType="java.lang.Integer"/>
<columnOverride column="status" javaType="java.lang.Integer"/>
</table>
</context>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment