Commit 911b5ce8 authored by neo.wang's avatar neo.wang

Merge branch 'dev_oracle_neo' into 'dev_oracle'

Dev oracle neo

See merge request root/atms!115
parents 30419404 1a2cc057
...@@ -32,7 +32,7 @@ public class MybatisConfig implements InitializingBean { ...@@ -32,7 +32,7 @@ public class MybatisConfig implements InitializingBean {
MapperScannerConfigurer bean = new MapperScannerConfigurer(); MapperScannerConfigurer bean = new MapperScannerConfigurer();
bean.setMarkerInterface(MyVatMapper.class); bean.setMarkerInterface(MyVatMapper.class);
bean.setBasePackage(BASE_PACKAGE); bean.setBasePackage(BASE_PACKAGE);
bean.setSqlSessionTemplateBeanName("dynamicSqlSessionTemplate"); bean.setSqlSessionTemplateBeanName("sqlSessionTemplate");
return bean; return bean;
} }
......
package pwc.taxtech.atms.agent;
import com.mysql.jdbc.MysqlErrorNumbers;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.sql.SQLException;
import static pwc.taxtech.atms.constant.Constant.CREATE_DB_EXISTS;
import static pwc.taxtech.atms.constant.Constant.CREATE_DB_FAILED;
import static pwc.taxtech.atms.constant.Constant.CREATE_DB_SUCCESS;
@Service
public class DatabaseAgent {
private static Logger LOGGER = LoggerFactory.getLogger(DatabaseAgent.class);
@Autowired
private JdbcTemplate jdbcTemplate;
public int createDatabase(String dbName) {
try {
jdbcTemplate.execute("CREATE DATABASE " + dbName + " default charset utf8mb4 COLLATE utf8mb4_general_ci");
return CREATE_DB_SUCCESS;
} catch (Exception exception) {
if (exception.getCause() instanceof SQLException) {
SQLException ex = (SQLException) exception.getCause();
if (ex.getErrorCode() == MysqlErrorNumbers.ER_DB_CREATE_EXISTS) {
LOGGER.warn("db is exists {}", dbName);
return CREATE_DB_EXISTS;
}
}
LOGGER.warn("Unknown Exception {}", exception.getMessage(), exception);
return CREATE_DB_FAILED;
}
}
}
package pwc.taxtech.atms.common; package pwc.taxtech.atms.common;
import java.io.IOException; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.servlet.FilterChain; import javax.servlet.FilterChain;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
@Component @Component
public class CorsFilter extends OncePerRequestFilter { public class CorsFilter extends OncePerRequestFilter {
...@@ -34,3 +32,4 @@ public class CorsFilter extends OncePerRequestFilter { ...@@ -34,3 +32,4 @@ public class CorsFilter extends OncePerRequestFilter {
} }
} }
package pwc.taxtech.atms.common;
public enum ModelTypeEnum {
SystemCommon(1,"SystemCommon","系统公共模型"),
OrganizationCommon(2,"OrganizationCommon","机构公共模型"),
OrganizationCustomize(3,"OrganizationCustomize","机构自定义模型");
private Integer code;
private String name;
private String displayName;
ModelTypeEnum(Integer code,String name,String displayName){
this.code= code;
this.name= name;
this.displayName = displayName;
}
public String toName() {
return this.name == null ? this.name() : this.name;
}
public Integer toCode() {
return this.code == null ? this.ordinal() : this.code;
}
public String toDisplayName() {
return this.displayName == null ? this.name() : this.displayName;
}
}
package pwc.taxtech.atms.common.datasource;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
@Component
@Aspect
public class AopShardingHolder {
private static Logger logger = LoggerFactory.getLogger(AopShardingHolder.class);
private static final String DATABASE_NAME_HEADER = "from";
private static final String DATABASE_NAME_SPLIT = "@";
@Autowired
HttpServletRequest request;
@Pointcut("execution(public * pwc.taxtech.atms.controller.*.*(..))")
public void pointCut() {
// 定义Pointcut 此方法不能有返回值,该方法只是一个标示
}
@Before("pointCut()")
public void before(JoinPoint joinPoint) {
try {
String header = request.getHeader(DATABASE_NAME_HEADER);
if (StringUtils.isNotBlank(header)) {
if (logger.isDebugEnabled()) {
logger.debug("aop set datasource:{}", header);
}
String[] arr = StringUtils.split(header, DATABASE_NAME_SPLIT);
String name = arr[0];
if (name.length() > 0 && !StringUtils.contains(name, DATABASE_NAME_SPLIT)) {
ShardingContextHolder.setDataSourceKey(name);
}
}
} catch (Exception e) {
logger.error("aop set database error.", e);
}
}
@After("pointCut()")
public void after(JoinPoint joinPoint) {
}
@AfterThrowing(pointcut = "pointCut()", throwing = "error")
public void afterThrowing(JoinPoint joinPoint, Throwable error) {
}
}
\ No newline at end of file
package pwc.taxtech.atms.common.datasource;
public class DataSourceConfig {
private String url;
private String username;
private String password;
private Integer clientTimeout;
private Integer threadNum;
private Integer transferFileType;
private boolean renameUploaded;
private Integer retryTimes;
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Integer getClientTimeout() {
return clientTimeout;
}
public void setClientTimeout(Integer clientTimeout) {
this.clientTimeout = clientTimeout;
}
public Integer getThreadNum() {
return threadNum;
}
public void setThreadNum(Integer threadNum) {
this.threadNum = threadNum;
}
public Integer getTransferFileType() {
return transferFileType;
}
public void setTransferFileType(Integer transferFileType) {
this.transferFileType = transferFileType;
}
public boolean isRenameUploaded() {
return renameUploaded;
}
public void setRenameUploaded(boolean renameUploaded) {
this.renameUploaded = renameUploaded;
}
public Integer getRetryTimes() {
return retryTimes;
}
public void setRetryTimes(Integer retryTimes) {
this.retryTimes = retryTimes;
}
}
package pwc.taxtech.atms.common.datasource;
import com.alibaba.druid.pool.DruidDataSource;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.pool2.KeyedPooledObjectFactory;
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pwc.taxtech.atms.exception.ParameterException;
public class DataSourceFactory implements KeyedPooledObjectFactory<String, DruidDataSource> {
private static final Logger logger = LoggerFactory.getLogger(DataSourceFactory.class);
private DataSourceConfig dataSourceConfig;
private static final String SYMBOL = "demo_db_name";
public DataSourceFactory(DataSourceConfig dataSourceConfig) {
this.dataSourceConfig = dataSourceConfig;
}
@Override
public PooledObject<DruidDataSource> makeObject(String s) throws Exception {
if (StringUtils.isBlank(s)) {
throw new ParameterException("empty database name.");
}
DruidDataSource dynamicDataSource = new DruidDataSource();
String url = StringUtils.replace(dataSourceConfig.getUrl(), SYMBOL, s);
dynamicDataSource.setUrl(url);
dynamicDataSource.setUsername(dataSourceConfig.getUsername());
dynamicDataSource.setPassword(dataSourceConfig.getPassword());
dynamicDataSource.init();
return new DefaultPooledObject<>(dynamicDataSource);
}
@Override
public void destroyObject(String s, PooledObject<DruidDataSource> pooledObject) throws Exception {
pooledObject.getObject().close();
}
@Override
public boolean validateObject(String s, PooledObject<DruidDataSource> pooledObject) {
try {
return pooledObject.getObject().isEnable();
} catch (Exception e) {
logger.error("Failed to validate DruidDataSource: ", e);
}
return false;
}
@Override
public void activateObject(String s, PooledObject<DruidDataSource> pooledObject) throws Exception {
}
@Override
public void passivateObject(String s, PooledObject<DruidDataSource> pooledObject) throws Exception {
}
}
package pwc.taxtech.atms.common.datasource;
public class ShardingContextHolder {
private static final ThreadLocal<String> contextHolder = new ThreadLocal<>();
/**
* 设置数据库名
*
* @param key key
*/
public static void setDataSourceKey(String key) {
contextHolder.set(key);
}
/**
* 获取数据库名
*
* @return key
*/
public static String getDataSourceKey() {
return contextHolder.get();
}
}
package pwc.taxtech.atms.common.util; package pwc.taxtech.atms.common.util;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.exception.ApiException; import pwc.taxtech.atms.exception.ApiException;
import pwc.taxtech.atms.exception.FormulaException; import pwc.taxtech.atms.exception.FormulaException;
......
package pwc.taxtech.atms.common.util;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import pwc.taxtech.atms.constant.VATCommon;
import pwc.taxtech.atms.vat.dao.DataImportModel;
import java.io.FileInputStream;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import static org.apache.poi.ss.usermodel.CellType.NUMERIC;
import static pwc.taxtech.atms.constant.Constant.DEFAULT_RESULT;
public class NPOIHelper {
public static DataImportModel renderTBDataTableFromExcel(FileInputStream fis, Integer selectedSheetIndex,
int headerRowIndex, boolean haveHeader, Integer topRowNumber) {
DataImportModel dataImportModel = new DataImportModel();
Workbook workbook = null;
try {
workbook = WorkbookFactory.create(fis);
Sheet sheet = workbook.getSheetAt(selectedSheetIndex);
dataImportModel.setDataList(new ArrayList<>());
dataImportModel.setSheetNameList(new ArrayList<>());
dataImportModel.setResult(DEFAULT_RESULT);
try {
//TODO:should be replace by biz exception (neo)
if (!(workbook instanceof XSSFWorkbook)) throw new RuntimeException("not support workbook type");
XSSFFormulaEvaluator eva = new XSSFFormulaEvaluator((XSSFWorkbook) workbook);
int numberOfSheets = workbook.getNumberOfSheets();
for (int index = 0; index < numberOfSheets; index++) {
dataImportModel.getSheetNameList().add(workbook.getSheetAt(index).getSheetName());
}
//判断文件是否为空
if (sheet.getPhysicalNumberOfRows() == 0) {
dataImportModel.setResult(false);
dataImportModel.setResultMsg(VATCommon.Const_ImportFileError);
} else {
//var headerRow = sheet.GetRow(HeaderRowIndex);
int cellCount = 0;
for (int i = 0; i <= sheet.getLastRowNum(); i++) {
Row row = sheet.getRow(i);
if (row != null && row.getPhysicalNumberOfCells() > cellCount) {
cellCount = row.getPhysicalNumberOfCells();
}
}
List<String> rowList = new ArrayList<>();
//dataImportModel.dataList.Add(rowList);
dataImportModel.setLastRowIndex(sheet.getLastRowNum());
int RowStart = sheet.getFirstRowNum();
for (int i = RowStart; i <= sheet.getLastRowNum(); i++) {
Row row = sheet.getRow(i);
if (row != null) {
rowList = getOutputInvoiceRowValueList(eva, row, cellCount);
dataImportModel.getDataList().add(rowList);
}
}
}
} catch (Exception ex) {
dataImportModel.setResult(false);
dataImportModel.setResultMsg(VATCommon.Const_ImportFileError);
}
if (topRowNumber > 0) {
//第一行为列头的话就多输出一行
int startIndex = (haveHeader ? topRowNumber + 1 : topRowNumber)-1;
int endIndex=dataImportModel.getDataList().size() - 1;
if (startIndex < dataImportModel.getDataList().size()) {
dataImportModel.setDataList(dataImportModel.getDataList().subList(startIndex, endIndex));
}
// dataImportModel.setDataList(dataImportModel.getDataList().subList(0,topRowNumber));
}
return dataImportModel;
} catch (IOException e) {
e.printStackTrace();
} catch (InvalidFormatException e) {
e.printStackTrace();
}
return null;
}
private static List<String> getOutputInvoiceRowValueList(XSSFFormulaEvaluator eva, Row row, int cellCount) {
List<String> rowList = new ArrayList<>();
for (int j = 0; j < cellCount; j++) {
if (row.getCell(j) != null) {
rowList.add(getStringCellValue(eva, row.getCell(j)));
} else {
rowList.add(null);
}
}
return rowList;
}
private static String getStringCellValue(XSSFFormulaEvaluator eva, Cell cell) {
// 获取单元格数据内容为字符串类型的数据
DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String strCell = "";
switch (cell.getCellTypeEnum()) {
case NUMERIC:
if (HSSFDateUtil.isCellDateFormatted(cell)) {
strCell = sdf.format(cell.getDateCellValue());
} else {
long longVal = Math.round(cell.getNumericCellValue());
if (Double.parseDouble(longVal + ".0") == cell.getNumericCellValue())
strCell = longVal + "";
else
strCell = cell.getNumericCellValue() + "";
}
break;
case FORMULA:
try {
if (eva.evaluate(cell).getCellTypeEnum() == NUMERIC) {
strCell = eva.evaluate(cell).getNumberValue() + "";
} else {
strCell = eva.evaluate(cell).getStringValue();
}
} catch (Exception ex) {
strCell = "#N/A";
}
break;
default:
strCell = cell.toString();
break;
}
return strCell;
}
}
...@@ -6,13 +6,11 @@ import org.springframework.context.ApplicationContextAware; ...@@ -6,13 +6,11 @@ import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import pwc.taxtech.atms.dao.FormulaAdminMapper; import pwc.taxtech.atms.dao.FormulaAdminMapper;
import pwc.taxtech.atms.dao.OrganizationMapper; import pwc.taxtech.atms.dao.OrganizationMapper;
import pwc.taxtech.atms.dao.ProjectDao;
import pwc.taxtech.atms.dao.ProjectMapper; import pwc.taxtech.atms.dao.ProjectMapper;
import pwc.taxtech.atms.dao.ProjectServiceTypeMapper; import pwc.taxtech.atms.dao.ProjectServiceTypeMapper;
import pwc.taxtech.atms.dao.ProjectDao;
import pwc.taxtech.atms.service.impl.DistributedIdService; import pwc.taxtech.atms.service.impl.DistributedIdService;
import pwc.taxtech.atms.vat.dao.*; import pwc.taxtech.atms.vat.dao.*;
import pwc.taxtech.atms.vat.dao.InputVatInvoiceDao;
import pwc.taxtech.atms.vat.dao.VatEnterpriseAccountDao;
//用来获取spring托管的bean //用来获取spring托管的bean
@Component @Component
...@@ -20,7 +18,6 @@ public class SpringContextUtil implements ApplicationContextAware { ...@@ -20,7 +18,6 @@ public class SpringContextUtil implements ApplicationContextAware {
private static ApplicationContext webApplicationContext; private static ApplicationContext webApplicationContext;
public static FormulaProjectMapper formulaProjectMapper;
public static FormulaAdminMapper formulaAdminMapper; public static FormulaAdminMapper formulaAdminMapper;
public static ReportMapper reportMapper; public static ReportMapper reportMapper;
public static CellDataMapper cellDataMapper; public static CellDataMapper cellDataMapper;
...@@ -61,7 +58,6 @@ public class SpringContextUtil implements ApplicationContextAware { ...@@ -61,7 +58,6 @@ public class SpringContextUtil implements ApplicationContextAware {
@Override @Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
webApplicationContext = applicationContext; webApplicationContext = applicationContext;
formulaProjectMapper = webApplicationContext.getBean(FormulaProjectMapper.class);
formulaAdminMapper = webApplicationContext.getBean(FormulaAdminMapper.class); formulaAdminMapper = webApplicationContext.getBean(FormulaAdminMapper.class);
reportMapper = webApplicationContext.getBean(ReportMapper.class); reportMapper = webApplicationContext.getBean(ReportMapper.class);
cellDataMapper = webApplicationContext.getBean(CellDataMapper.class); cellDataMapper = webApplicationContext.getBean(CellDataMapper.class);
......
...@@ -8,7 +8,7 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -8,7 +8,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import pwc.taxtech.atms.dto.OperationResultDto; import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.vat.entity.CellComment; import pwc.taxtech.atms.vat.entity.CellComment;
import pwc.taxtech.atms.vat.service.CellCommentService; import pwc.taxtech.atms.vat.service.impl.CellCommentServiceImpl;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
...@@ -17,7 +17,7 @@ import java.util.Optional; ...@@ -17,7 +17,7 @@ import java.util.Optional;
@RequestMapping(value = "api/v1/CellComment") @RequestMapping(value = "api/v1/CellComment")
public class CellCommentController { public class CellCommentController {
@Autowired @Autowired
CellCommentService cellCommentService; CellCommentServiceImpl cellCommentService;
@RequestMapping(value = "List", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "List", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto<List<CellComment>> getCellComments(@RequestParam("cellDataId") Optional<Long> cellDataId) { public OperationResultDto<List<CellComment>> getCellComments(@RequestParam("cellDataId") Optional<Long> cellDataId) {
......
package pwc.taxtech.atms.controller;
import com.google.errorprone.annotations.FormatString;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
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.dto.vatdto.ImportVoucherDto;
import pwc.taxtech.atms.dto.vatdto.QueryJeDto;
import pwc.taxtech.atms.service.IdentityService;
import pwc.taxtech.atms.vat.service.impl.JournalEntryImportServiceImpl;
@RestController
@RequestMapping(value = "/api/v1/journalEntryImport")
public class JournalEntryImportController {
@Autowired
private JournalEntryImportServiceImpl journalEntryDataImportService;
@Autowired
private IdentityService identityService;
@ApiOperation(value = "queryJournalEntryData", notes = "")
@RequestMapping(value = "/queryJournalEntryData", method = RequestMethod.POST)
public ResponseEntity queryJournalEntryData(@RequestBody QueryJeDto queryJeDto) {
return ResponseEntity.ok(journalEntryDataImportService.qeryJournalEntryData(queryJeDto));
}
@ApiOperation(value = "getValidationInfo", notes = "")
@RequestMapping(value = "getValidationInfo/{type}/{period}", method = RequestMethod.GET)
public ResponseEntity getValidationInfo(@PathVariable Integer type, @PathVariable Integer period) {
return ResponseEntity.ok(journalEntryDataImportService.getValidationInfoList(type, period));
}
@RequestMapping(value = "importJournalEntry", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity ImportJournalEntryData(@RequestBody ImportVoucherDto importParam) {
journalEntryDataImportService.ImportJournalEntryData(importParam.VoucherList, importParam.ImportType,
identityService.getIdentityUser().getId());
return ResponseEntity.ok().build();
}
@RequestMapping(value = "importAuditAdjust/{period}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity ImportAuditAdjust(@RequestBody ImportVoucherDto importParam, @PathVariable Integer period) {
return ResponseEntity.ok().body(journalEntryDataImportService.ImportAuditAdjust(importParam.VoucherList,
period, importParam.ImportType, identityService.getIdentityUser().getId()));
}
@RequestMapping(value = "getAuditAdjust/{period}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity GetAuditAdjust(@PathVariable Integer period) {
return ResponseEntity.ok().body(journalEntryDataImportService.GetAuditAdjust(period));
}
@RequestMapping(value = "queryAuditAdjust", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity QueryAuditAdjust(QueryJeDto queryDto) {
return ResponseEntity.ok().body(journalEntryDataImportService.QueryAuditAdjust(queryDto));
}
}
package pwc.taxtech.atms.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
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.constant.enums.VoucherSearchEnum;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.vatdto.QueryVoucherParmDto;
import pwc.taxtech.atms.dto.vatdto.VatEnterpriseAccountDto;
import pwc.taxtech.atms.vat.service.TBDataImportService;
import pwc.taxtech.atms.vat.service.VoucherService;
import java.util.List;
@RequestMapping(value = "api/v1/voucher")
@RestController
public class VoucherController {
@Autowired
VoucherService voucherService;
@Autowired
TBDataImportService tbDataImportService;
private static final Logger logger = LoggerFactory.getLogger(VoucherController.class);
@RequestMapping(value = "voucherSelectAdvancedByEntry", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto<Object> voucherSelectAdvancedByEntry(@RequestBody QueryVoucherParmDto parmDto) {
try {
return voucherService.voucherSelectAdvancedByEntry(parmDto.getListQueryCondition(), VoucherSearchEnum.values()[parmDto.getMainRelation()], parmDto.isAllJe(), parmDto.getPagingInfo());
} catch (Exception ex) {
logger.error("voucherSelectAdvancedByEntryError", ex);
}
OperationResultDto<Object> result = new OperationResultDto<>();
result.setResult(false);
return result;
}
@RequestMapping(value = "voucherSelectAdvancedCount", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto<Object> voucherSelectAdvancedCount(@RequestBody QueryVoucherParmDto parmDto) {
try {
return voucherService.voucherSelectAdvancedCount(parmDto.getListQueryCondition(), VoucherSearchEnum.values()[parmDto.getMainRelation()], parmDto.isEntryShow(), parmDto.isAllJe());
} catch (Exception ex) {
logger.error("voucherSelectAdvancedCountError", ex);
}
OperationResultDto<Object> result = new OperationResultDto<>();
result.setResult(false);
return result;
}
@RequestMapping(value = "getEnterpriseAccount",method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public List<VatEnterpriseAccountDto> getEnterpriseAccount(){
return tbDataImportService.getEnterpriseAccount();
}
@RequestMapping(value = "voucherSelectAdvancedByVoucher", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto<Object> voucherSelectAdvancedByVoucher(QueryVoucherParmDto parmDto)
{
try {
return voucherService.voucherSelectAdvancedByVoucher(parmDto.getListQueryCondition(), VoucherSearchEnum.values()[parmDto.getMainRelation()], parmDto.isAllJe(), parmDto.getPagingInfo());
} catch (Exception ex) {
logger.error("voucherSelectAdvancedByVoucherError", ex);
}
OperationResultDto<Object> result = new OperationResultDto<>();
result.setResult(false);
return result;
}
}
package pwc.taxtech.atms.dto.vatdto;
import java.util.List;
public class ImportVoucherDto {
public List<VoucherDtoOnlyForImport> VoucherList;
public Integer ImportType;
}
package pwc.taxtech.atms.dto.vatdto;
import java.math.BigDecimal;
import java.util.List;
public class QueryVoucherDto {
private List<VoucherDto> voucherList;
//凭证总数
private int vidCount;
//分录总数
private int itemIdCount;
private BigDecimal debitSum;
private BigDecimal creditSum;
public List<VoucherDto> getVoucherList() {
return voucherList;
}
public void setVoucherList(List<VoucherDto> voucherList) {
this.voucherList = voucherList;
}
public int getVidCount() {
return vidCount;
}
public void setVidCount(int vidCount) {
this.vidCount = vidCount;
}
public int getItemIdCount() {
return itemIdCount;
}
public void setItemIdCount(int itemIdCount) {
this.itemIdCount = itemIdCount;
}
public BigDecimal getDebitSum() {
return debitSum;
}
public void setDebitSum(BigDecimal debitSum) {
this.debitSum = debitSum;
}
public BigDecimal getCreditSum() {
return creditSum;
}
public void setCreditSum(BigDecimal creditSum) {
this.creditSum = creditSum;
}
}
package pwc.taxtech.atms.dto.vatdto;
import org.thymeleaf.util.StringUtils;
import pwc.taxtech.atms.vat.entity.Voucher;
import java.math.BigDecimal;
import java.util.Date;
public class VoucherDto {
private String voucherId;
private String vid;
private Date date;
//private String GroupNum ;
private String group;
private Integer period;
private String customerCode;
private String customerName;
private String summary;
private String acctCode;
private BigDecimal debit;
private BigDecimal credit;
private BigDecimal debitQty;
private BigDecimal creditQty;
private Long attach;
private Long itemId;
private Integer status;
private Date createdTime;
private Integer isManual;
private Integer manualUser;
private Date manualTime;
private String stdCode;
private String mappingReason;
private Integer mappingUser;
private Date mappingTime;
private String manualReason;
private String foreignCurrency;
private BigDecimal foreignDebit;
private BigDecimal foreignCredit;
private String checkedBy;
private String issuedBy;
private String bookedBy;
private String cashier;
/**
* 是否被凭证重分类过
*/
private Boolean isRecate;
private Integer originalPeriod;
private String acctCodeAndNameShow; //界面显示
private String customerCodeAndNameShow; //界面显示
private String stdCodeAndNameShow; //界面显示
private String groupShow; //界面显示
private int vIdCount;//凭证总数
private int itemIdCount;//分录总数
private BigDecimal debitSum;
private BigDecimal creditSum;
private int auditCount;//审计调整总数
public String getVoucherId() {
return voucherId;
}
public void setVoucherId(String voucherId) {
this.voucherId = voucherId;
}
public String getvId() {
return vid;
}
public void setvId(String vid) {
this.vid = vid;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public String getGroup() {
return group;
}
public void setGroup(String group) {
this.group = group;
}
public Integer getPeriod() {
return period;
}
public void setPeriod(Integer period) {
this.period = period;
}
public String getCustomerCode() {
return customerCode;
}
public void setCustomerCode(String customerCode) {
this.customerCode = customerCode;
}
public String getCustomerName() {
return customerName;
}
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
public String getAcctCode() {
return acctCode;
}
public void setAcctCode(String acctCode) {
this.acctCode = acctCode;
}
public BigDecimal getDebit() {
return debit;
}
public void setDebit(BigDecimal debit) {
this.debit = debit;
}
public BigDecimal getCredit() {
return credit;
}
public void setCredit(BigDecimal credit) {
this.credit = credit;
}
public BigDecimal getDebitQty() {
return debitQty;
}
public void setDebitQty(BigDecimal debitQty) {
this.debitQty = debitQty;
}
public BigDecimal getCreditQty() {
return creditQty;
}
public void setCreditQty(BigDecimal creditQty) {
this.creditQty = creditQty;
}
public Long getAttach() {
return attach;
}
public void setAttach(Long attach) {
this.attach = attach;
}
public Long getItemId() {
return itemId;
}
public void setItemId(Long itemId) {
this.itemId = itemId;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Date getCreatedTime() {
return createdTime;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public Integer getIsManual() {
return isManual;
}
public void setIsManual(Integer isManual) {
this.isManual = isManual;
}
public Integer getManualUser() {
return manualUser;
}
public void setManualUser(Integer manualUser) {
this.manualUser = manualUser;
}
public Date getManualTime() {
return manualTime;
}
public void setManualTime(Date manualTime) {
this.manualTime = manualTime;
}
public String getStdCode() {
return stdCode;
}
public void setStdCode(String stdCode) {
this.stdCode = stdCode;
}
public String getMappingReason() {
return mappingReason;
}
public void setMappingReason(String mappingReason) {
this.mappingReason = mappingReason;
}
public Integer getMappingUser() {
return mappingUser;
}
public void setMappingUser(Integer mappingUser) {
this.mappingUser = mappingUser;
}
public Date getMappingTime() {
return mappingTime;
}
public void setMappingTime(Date mappingTime) {
this.mappingTime = mappingTime;
}
public String getManualReason() {
return manualReason;
}
public void setManualReason(String manualReason) {
this.manualReason = manualReason;
}
public String getForeignCurrency() {
return foreignCurrency;
}
public void setForeignCurrency(String foreignCurrency) {
this.foreignCurrency = foreignCurrency;
}
public BigDecimal getForeignDebit() {
return foreignDebit;
}
public void setForeignDebit(BigDecimal foreignDebit) {
this.foreignDebit = foreignDebit;
}
public BigDecimal getForeignCredit() {
return foreignCredit;
}
public void setForeignCredit(BigDecimal foreignCredit) {
this.foreignCredit = foreignCredit;
}
public String getCheckedBy() {
return checkedBy;
}
public void setCheckedBy(String checkedBy) {
this.checkedBy = checkedBy;
}
public String getIssuedBy() {
return issuedBy;
}
public void setIssuedBy(String issuedBy) {
this.issuedBy = issuedBy;
}
public String getBookedBy() {
return bookedBy;
}
public void setBookedBy(String bookedBy) {
this.bookedBy = bookedBy;
}
public String getCashier() {
return cashier;
}
public void setCashier(String cashier) {
this.cashier = cashier;
}
public Boolean getRecate() {
return isRecate;
}
public void setRecate(Boolean recate) {
isRecate = recate;
}
public Integer getOriginalPeriod() {
return originalPeriod;
}
public void setOriginalPeriod(Integer originalPeriod) {
this.originalPeriod = originalPeriod;
}
public String getAcctCodeAndNameShow() {
return acctCodeAndNameShow;
}
public void setAcctCodeAndNameShow(String acctCodeAndNameShow) {
this.acctCodeAndNameShow = acctCodeAndNameShow;
}
public String getCustomerCodeAndNameShow() {
return customerCodeAndNameShow;
}
public void setCustomerCodeAndNameShow(String customerCodeAndNameShow) {
this.customerCodeAndNameShow = customerCodeAndNameShow;
}
public String getStdCodeAndNameShow() {
return stdCodeAndNameShow;
}
public void setStdCodeAndNameShow(String stdCodeAndNameShow) {
this.stdCodeAndNameShow = stdCodeAndNameShow;
}
public String getGroupShow() {
return groupShow;
}
public void setGroupShow(String groupShow) {
this.groupShow = groupShow;
}
public int getvIdCount() {
return vIdCount;
}
public void setvIdCount(int vIdCount) {
this.vIdCount = vIdCount;
}
public int getItemIdCount() {
return itemIdCount;
}
public void setItemIdCount(int itemIdCount) {
this.itemIdCount = itemIdCount;
}
public BigDecimal getDebitSum() {
return debitSum;
}
public void setDebitSum(BigDecimal debitSum) {
this.debitSum = debitSum;
}
public BigDecimal getCreditSum() {
return creditSum;
}
public void setCreditSum(BigDecimal creditSum) {
this.creditSum = creditSum;
}
public int getAuditCount() {
return auditCount;
}
public void setAuditCount(int auditCount) {
this.auditCount = auditCount;
}
public VoucherDto extractFromVoucher(Voucher v) {
setVoucherId(v.getVoucherId());
setvId(v.getVid());
setDate(v.getDate());
setGroup(v.getGroup());
setPeriod(v.getPeriod());
setCustomerCode(v.getCustomerCode());
setCustomerName(v.getCustomerName());
setSummary(v.getSummary());
setAcctCode(v.getAcctCode());
setDebit(v.getDebit());
setCredit(v.getCredit());
setAttach(v.getAttach());
if (v.getItemId() != null)
setItemId(Long.parseLong(v.getItemId()));
setCreatedTime(v.getCreateTime());
setOriginalPeriod(v.getOriginalPeriod());
setStatus(v.getStatus());
setStdCode(v.getStdCode());
setMappingReason(v.getMappingReason());
if (!StringUtils.isEmpty(v.getMappingReason()))
setMappingUser(Integer.valueOf(v.getMappingUser()));
setMappingTime(v.getMappingTime());
return this;
}
}
package pwc.taxtech.atms.dto.vatdto;
import pwc.taxtech.atms.vat.entity.Voucher;
import java.math.BigDecimal;
import java.util.Date;
public class VoucherDtoOnlyForImport {
public String VoucherId;
public String vid;
public Date date;
public String Group;
public Integer Period;
public String CustomerCode;
public String CustomerName;
public String Summary;
public String AcctCode;
public BigDecimal Debit;
public BigDecimal Credit;
public Long Attach;
public String ItemId;
public Date CreateTime;
public Integer ImportType;
public String CreatorId;
public Integer MonthId;
public Integer OriginalPeriod;
public Integer Status;
public Integer PartBilledPeriod;
public Integer BilledPeriod;
public Integer getPeriod() {
return Period;
}
public Voucher extractVoucher() {
Voucher voucher = new Voucher();
voucher.setVoucherId(VoucherId);
voucher.setVid(vid);
voucher.setDate(date);
voucher.setGroup(Group);
voucher.setPeriod(Period);
voucher.setCustomerCode(CustomerCode);
voucher.setCustomerName(CustomerName);
voucher.setSummary(Summary);
voucher.setAcctCode(AcctCode);
voucher.setDebit(Debit);
voucher.setCredit(Credit);
voucher.setAttach(Attach);
voucher.setItemId(ItemId);
voucher.setCreateTime(CreateTime);
voucher.setImportType(ImportType);
voucher.setCreatorId(CreatorId);
voucher.setMonthId(MonthId);
voucher.setOriginalPeriod(OriginalPeriod);
voucher.setStatus(Status);
voucher.setPartBilledPeriod(PartBilledPeriod);
voucher.setBilledPeriod(BilledPeriod);
return voucher;
}
}
...@@ -5,6 +5,6 @@ public class Exceptions { ...@@ -5,6 +5,6 @@ public class Exceptions {
public static final FormulaException BB_REPORT_NULL = new FormulaException("cell report is null"); public static final FormulaException BB_REPORT_NULL = new FormulaException("cell report is null");
public static final FormulaException BB_CELL_DATA_NULL = new FormulaException("cell data is null"); public static final FormulaException BB_CELL_DATA_NULL = new FormulaException("cell data is null");
public static final FormulaException BB_CELL_DATA_EMPTY = new FormulaException("cell data is empty"); public static final FormulaException BB_CELL_DATA_EMPTY = new FormulaException("cell data is empty");
public static final FormulaException BB_EMPTY = new FormulaException("db name is empty"); public static final FormulaException PROJECT_EMPTY = new FormulaException("project is empty");
public static final FormulaException BAD_BBVO_PARAMS = new FormulaException("bad params for bb fromular express data"); public static final FormulaException BAD_BBVO_PARAMS = new FormulaException("bad params for bb fromular express data");
} }
package pwc.taxtech.atms.service;
import pwc.taxtech.atms.dto.OperationResultDto;
import java.util.List;
public interface ICitTBDataImportService {
OperationResultDto<Boolean> clearTableByPeriods(List<Integer> periods);
}
package pwc.taxtech.atms.service.impl;
import com.alibaba.druid.pool.DruidDataSource;
import com.google.common.collect.Maps;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.datasource.DataSourceConfig;
import pwc.taxtech.atms.common.datasource.DataSourceFactory;
import pwc.taxtech.atms.common.datasource.ShardingContextHolder;
import pwc.taxtech.atms.exception.ParameterException;
import javax.annotation.PostConstruct;
import javax.sql.DataSource;
@Service("DynamicDataSource")
public class DataSourcePoolService extends AbstractRoutingDataSource {
private GenericKeyedObjectPool<String, DruidDataSource> dataSourcePool;
@Value("${jdbc_url_demo}")
private String demoUrl;
@Value("${jdbc_user}")
private String jdbcUser;
@Value("${jdbc_password}")
private String jdbcPwd;
@PostConstruct
public void init() throws Exception {
DataSourceConfig config = new DataSourceConfig();
config.setUrl(demoUrl);
config.setUsername(jdbcUser);
config.setPassword(jdbcPwd);
GenericKeyedObjectPoolConfig poolConfig = new GenericKeyedObjectPoolConfig();
poolConfig.setTestOnBorrow(true);
poolConfig.setTestOnReturn(true);
poolConfig.setMaxTotalPerKey(1);
poolConfig.setMaxIdlePerKey(1);
dataSourcePool = new GenericKeyedObjectPool<>(new DataSourceFactory(config), poolConfig);
this.setTargetDataSources(Maps.newHashMap());
}
@Override
protected Object determineCurrentLookupKey() {
return ShardingContextHolder.getDataSourceKey();
}
@Override
protected synchronized DataSource determineTargetDataSource() {
try {
String key = ShardingContextHolder.getDataSourceKey();
DruidDataSource dataSource = dataSourcePool.borrowObject(key);
dataSourcePool.returnObject(key, dataSource);
return dataSource;
} catch (Exception e) {
throw new RuntimeException("determineTargetDataSource error.", e);
}
}
private void createDataSource(String key) {
if (StringUtils.isBlank(key)) {
throw new ParameterException("DataSource name is empty.");
}
try {
dataSourcePool.addObject(key);
} catch (Exception e) {
throw new RuntimeException("createDataSource error.", e);
}
}
@Bean
public SqlSessionFactory dynamicSqlSessionFactory(
@Qualifier("DynamicDataSource") DataSource dynamicDataSource)
throws Exception {
SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
bean.setDataSource(dynamicDataSource);
bean.setMapperLocations(new PathMatchingResourcePatternResolver()
.getResources("classpath*:pwc/taxtech/atms/vat/dao/**/*Mapper.xml"));
return bean.getObject();
}
@Bean
public SqlSessionTemplate dynamicSqlSessionTemplate(
@Qualifier("dynamicSqlSessionFactory") SqlSessionFactory sqlSessionFactory)
throws Exception {
return new SqlSessionTemplate(sqlSessionFactory);
}
@Bean
public JdbcTemplate dynamicJdbcTemplate(@Qualifier("DynamicDataSource")DataSource dynamicDataSource) {
return new JdbcTemplate(dynamicDataSource);
}
}
package pwc.taxtech.atms.service.impl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.constant.VatErpImportValidation;
import pwc.taxtech.atms.dao.CitTBDataImportMapper;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.service.ICitTBDataImportService;
import java.util.List;
@Service
public class ICitTBDataImportServiceImpl implements ICitTBDataImportService {
private static Logger LOGGER = LoggerFactory.getLogger(ICitTBDataImportServiceImpl.class);
@Autowired
CitTBDataImportMapper citTBDataImportMapper;
@Override
public OperationResultDto<Boolean> clearTableByPeriods(List<Integer> periods) {
return clearTableByPeriods(periods, true);
}
public OperationResultDto<Boolean> clearTableByPeriods(List<Integer> periods, Boolean isClearTb) {
try {
periods.forEach(period -> {
clearCustTable(period, VatErpImportValidation.CompanyBalanceTbName);
if (isClearTb) {
clearCustTable(period, VatErpImportValidation.CustBalanceTb);
}
clearCustTable(period, VatErpImportValidation.BalanceTb);
clearVoucherTable(period);
clearRemapTable(period);
});
return OperationResultDto.SUCCESS_EMPTY;
}catch (Exception e){
LOGGER.error("ClearTableByPeriods method error",e);
return OperationResultDto.errorFor(e.getMessage());
}
}
private void clearRemapTable(Integer period) {
citTBDataImportMapper.deleteByNameAndPeriod(VatErpImportValidation.AccountRemapTb, isImportByPeriod(period) ? period : null);
}
private void clearVoucherTable(Integer period) {
citTBDataImportMapper.deleteByNameAndPeriod(VatErpImportValidation.VoucherTbName, isImportByPeriod(period) ? period : null);
}
//清除试算平衡相关的Table
private void clearCustTable(Integer period, String tbName) {
if (isImportByPeriod(period) && !tbName.equals(VatErpImportValidation.BalanceTb))
if (tbName.equals(VatErpImportValidation.CompanyBalanceTbName) || tbName.equals(VatErpImportValidation.CustBalanceTb)) {
citTBDataImportMapper.deleteByPeriod(period, tbName);
if(tbName.equals(VatErpImportValidation.CustBalanceTb)){
citTBDataImportMapper.deleteByGreaterPeriod(period, tbName);
}
}
else citTBDataImportMapper.deleteByNameAndPeriod(tbName, null);
}
private Boolean isImportByPeriod(int period) {
return period >= 0;
}
}
...@@ -2,22 +2,14 @@ package pwc.taxtech.atms.service.impl; ...@@ -2,22 +2,14 @@ package pwc.taxtech.atms.service.impl;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.jdbc.ScriptRunner;
import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.SqlSessionTemplate; import org.mybatis.spring.SqlSessionTemplate;
import org.reflections.util.Utils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import pwc.taxtech.atms.agent.DatabaseAgent;
import pwc.taxtech.atms.common.CommonUtils; import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.OperateLogType; import pwc.taxtech.atms.common.OperateLogType;
import pwc.taxtech.atms.common.OperationModule;
import pwc.taxtech.atms.common.datasource.ShardingContextHolder;
import pwc.taxtech.atms.constant.Constant;
import pwc.taxtech.atms.dao.OrganizationServiceTemplateGroupMapper; import pwc.taxtech.atms.dao.OrganizationServiceTemplateGroupMapper;
import pwc.taxtech.atms.dao.ProjectClientMapper; import pwc.taxtech.atms.dao.ProjectClientMapper;
import pwc.taxtech.atms.dao.ProjectMapper; import pwc.taxtech.atms.dao.ProjectMapper;
...@@ -25,39 +17,28 @@ import pwc.taxtech.atms.dao.ProjectServiceTypeMapper; ...@@ -25,39 +17,28 @@ import pwc.taxtech.atms.dao.ProjectServiceTypeMapper;
import pwc.taxtech.atms.dao.ServiceTypeMapper; import pwc.taxtech.atms.dao.ServiceTypeMapper;
import pwc.taxtech.atms.dao.StandardAccountMapper; import pwc.taxtech.atms.dao.StandardAccountMapper;
import pwc.taxtech.atms.dao.TemplateGroupMapper; import pwc.taxtech.atms.dao.TemplateGroupMapper;
import pwc.taxtech.atms.dpo.ProjectDisplayDto;
import pwc.taxtech.atms.dto.FieldsMapper; import pwc.taxtech.atms.dto.FieldsMapper;
import pwc.taxtech.atms.dto.ProjectClientDto; import pwc.taxtech.atms.dto.ProjectClientDto;
import pwc.taxtech.atms.dto.ServiceTypeDto; import pwc.taxtech.atms.dto.ServiceTypeDto;
import pwc.taxtech.atms.dto.TemplateGroupDto; import pwc.taxtech.atms.dto.TemplateGroupDto;
import pwc.taxtech.atms.dto.taxadmin.AddProjectResult; import pwc.taxtech.atms.dto.taxadmin.AddProjectResult;
import pwc.taxtech.atms.dpo.ProjectDisplayDto;
import pwc.taxtech.atms.dto.taxadmin.ProjectYearParam; import pwc.taxtech.atms.dto.taxadmin.ProjectYearParam;
import pwc.taxtech.atms.entity.*; import pwc.taxtech.atms.entity.*;
import pwc.taxtech.atms.entity.ProjectClientExample.Criteria; import pwc.taxtech.atms.entity.ProjectClientExample.Criteria;
import pwc.taxtech.atms.service.OperationLogService; import pwc.taxtech.atms.service.OperationLogService;
import pwc.taxtech.atms.service.ProjectService; import pwc.taxtech.atms.service.ProjectService;
import pwc.taxtech.atms.vat.dao.VatStandardAccountMapper; import pwc.taxtech.atms.vat.dao.VatStandardAccountMapper;
import pwc.taxtech.atms.vat.entity.VatStandardAccount;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
import java.nio.charset.Charset;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static pwc.taxtech.atms.constant.Constant.*;
@Service @Service
public class ProjectServiceImpl implements ProjectService { public class ProjectServiceImpl implements ProjectService {
/** /**
...@@ -86,9 +67,6 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -86,9 +67,6 @@ public class ProjectServiceImpl implements ProjectService {
@Autowired @Autowired
private OperationLogService operationLogService; private OperationLogService operationLogService;
@Autowired
private DatabaseAgent databaseAgent;
@Autowired @Autowired
private SqlSessionTemplate dynamicSqlSessionTemplate; private SqlSessionTemplate dynamicSqlSessionTemplate;
......
package pwc.taxtech.atms.vat.dao;
import java.util.List;
public class DataImportModel {
private List<String> sheetNameList;
private List<List<String>> dataList;
private List<String> mappingResult;
private int selectedSheetIndex;
private int lastRowIndex;
private Boolean result;
private String resultMsg;
public List<String> getSheetNameList() {
return sheetNameList;
}
public void setSheetNameList(List<String> sheetNameList) {
this.sheetNameList = sheetNameList;
}
public List<List<String>> getDataList() {
return dataList;
}
public void setDataList(List<List<String>> dataList) {
this.dataList = dataList;
}
public List<String> getMappingResult() {
return mappingResult;
}
public void setMappingResult(List<String> mappingResult) {
this.mappingResult = mappingResult;
}
public int getSelectedSheetIndex() {
return selectedSheetIndex;
}
public void setSelectedSheetIndex(int selectedSheetIndex) {
this.selectedSheetIndex = selectedSheetIndex;
}
public int getLastRowIndex() {
return lastRowIndex;
}
public void setLastRowIndex(int lastRowIndex) {
this.lastRowIndex = lastRowIndex;
}
public Boolean getResult() {
return result;
}
public void setResult(Boolean result) {
this.result = result;
}
public String getResultMsg() {
return resultMsg;
}
public void setResultMsg(String resultMsg) {
this.resultMsg = resultMsg;
}
}
package pwc.taxtech.atms.vat.service;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.vat.entity.CellComment;
import java.util.List;
import java.util.Optional;
public interface CellCommentService {
OperationResultDto<List<CellComment>> getCellComments(Optional<Long> cellDataId);
}
package pwc.taxtech.atms.vat.service;
import pwc.taxtech.atms.dto.vatdto.VatEnterpriseAccountDto;
import pwc.taxtech.atms.vat.dpo.TrialBalanceDto;
import pwc.taxtech.atms.vat.entity.VatEnterpriseAccount;
import java.util.List;
public interface TBDataImportService {
List<TrialBalanceDto> getTrialBalanceData(int fromPeriod, int toPeriod);
List<TrialBalanceDto> getTrialBalanceStdData(int fromPeriod, int toPeriod);
List<VatEnterpriseAccountDto> getEnterpriseAccount();
List<VatEnterpriseAccountDto> getStandardAccount();
}
package pwc.taxtech.atms.vat.service;
import pwc.taxtech.atms.constant.enums.VoucherSearchEnum;
import pwc.taxtech.atms.dpo.PagingDto;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.vatdto.QueryConditionDto;
import java.util.List;
public interface VoucherService {
/**
* 按分录显示查询
*
* @param listQueryCondition 查询条件模板
* @param mainRelation 查询条件之间的逻辑关系
* @param allJe 显示全部凭证
* @param pagingInfo 分页信息
* @return 分录信息
*/
OperationResultDto<Object> voucherSelectAdvancedByEntry(List<QueryConditionDto> listQueryCondition, VoucherSearchEnum mainRelation, boolean allJe, PagingDto pagingInfo) throws Exception;
/**
* 根据满足查询条件返回总数
*
* @param listQueryCondition 查询条件模板
* @param mainRelation 查询条件之间的逻辑关系
* @param isEntryShow 是否为分录显示
* @param allJe 显示全部凭证
* @return 满足条件的总条数
*/
OperationResultDto<Object> voucherSelectAdvancedCount(List<QueryConditionDto> listQueryCondition, VoucherSearchEnum mainRelation, boolean isEntryShow, boolean allJe) throws Exception;
/**
* 按凭证显示查询
*
* @param listQueryCondition 查询条件模板
* @param mainRelation 查询条件之间的逻辑关系
* @param allJe 显示全部凭证
* @param pagingInfo 分页信息
* @return 凭证信息
*/
OperationResultDto<Object> voucherSelectAdvancedByVoucher(List<QueryConditionDto> listQueryCondition, VoucherSearchEnum voucherSearchEnum, boolean allJe, PagingDto pagingInfo) throws Exception;
}
...@@ -4,14 +4,12 @@ import org.springframework.stereotype.Service; ...@@ -4,14 +4,12 @@ import org.springframework.stereotype.Service;
import pwc.taxtech.atms.dto.OperationResultDto; import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.vat.entity.CellComment; import pwc.taxtech.atms.vat.entity.CellComment;
import pwc.taxtech.atms.vat.entity.CellCommentExample; import pwc.taxtech.atms.vat.entity.CellCommentExample;
import pwc.taxtech.atms.vat.service.CellCommentService;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@Service @Service
public class CellCommentServiceImpl extends VatAbstractService implements CellCommentService { public class CellCommentServiceImpl extends VatAbstractService {
@Override
public OperationResultDto<List<CellComment>> getCellComments(Optional<Long> cellDataId) { public OperationResultDto<List<CellComment>> getCellComments(Optional<Long> cellDataId) {
OperationResultDto resultDto = new OperationResultDto(); OperationResultDto resultDto = new OperationResultDto();
try { try {
......
package pwc.taxtech.atms.vat.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.constant.enums.EnumTbImportType;
import pwc.taxtech.atms.constant.enums.EnumValidationType;
import pwc.taxtech.atms.dto.FieldsMapper;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.vatdto.CustomsInvoiceDto;
import pwc.taxtech.atms.vat.dao.ValidationInfoMapper;
import pwc.taxtech.atms.vat.entity.CustomsInvoice;
import pwc.taxtech.atms.vat.entity.CustomsInvoiceExample;
import pwc.taxtech.atms.vat.entity.ValidationInfo;
import pwc.taxtech.atms.vat.entity.ValidationInfoExample;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
@Service
public class CustomsInvoiceServiceImpl extends VatAbstractService {
@Autowired
private ValidationInfoMapper validationInfoMapper;
public List<CustomsInvoiceDto> getCustomsInvoicesByPeriodIds(int fromPeriod, int toPeriod) {
CustomsInvoiceExample example = new CustomsInvoiceExample();
example.setOrderByClause(" PayNum");
example.createCriteria().andPeriodIdBetween(fromPeriod, toPeriod);
List<CustomsInvoiceDto> result = new ArrayList<>();
customsInvoiceMapper.selectByExample(example).forEach(a -> {
CustomsInvoiceDto dto = new CustomsInvoiceDto();
CommonUtils.copyProperties(a, dto);
result.add(dto);
});
int seqNo = 1;
DecimalFormat df = new DecimalFormat("#.00");
for (CustomsInvoiceDto dto : result) {
dto.setSeqNo(seqNo++);
if (dto.getInvoiceAmount() != null) {
dto.setInvoiceAmount(new BigDecimal(df.format(dto.getInvoiceAmount())));
}
if (dto.getInvoiceTaxAmount() != null) {
dto.setInvoiceTaxAmount(new BigDecimal(df.format(dto.getInvoiceTaxAmount())));
}
}
return result;
}
public List<CustomsInvoiceDto> getCustomsInvoicesByPeriodId(Integer periodId) {
CustomsInvoiceExample example = new CustomsInvoiceExample();
example.createCriteria().andPeriodIdEqualTo(periodId);
List<CustomsInvoice> result = customsInvoiceMapper.selectByExample(example);
result.sort(Comparator.comparing(CustomsInvoice::getPayNum));
int seqNo = 1;
List<CustomsInvoiceDto> dtos = new ArrayList<>(result.size());
for (CustomsInvoice ci : result) {
CustomsInvoiceDto dto = new CustomsInvoiceDto();
try {
FieldsMapper.map(ci, dto);
dto.setSeqNo(seqNo++);
dto.setInvoiceAmount(ci.getInvoiceAmount().setScale(2, BigDecimal.ROUND_HALF_UP));
dto.setInvoiceTaxAmount(ci.getInvoiceTaxAmount().setScale(2, BigDecimal.ROUND_HALF_UP));
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
return dtos;
}
public OperationResultDto<List<ValidationInfo>> getCustomsInvoicesValidates(Integer periodId) {
ValidationInfoExample example = new ValidationInfoExample();
List<ValidationInfo> result = new ArrayList<>();
if (periodId == null) {
example.createCriteria().andImportTypeIdEqualTo(EnumValidationType.CustomInvoice.getCode());
result = validationInfoMapper.selectByExample(example);
} else {
example.createCriteria().andImportTypeIdEqualTo(EnumValidationType.CustomInvoice.getCode()).andPeriodIdEqualTo(periodId);
result.addAll(validationInfoMapper.selectByExample(example));
example.createCriteria().andImportTypeIdEqualTo(EnumValidationType.CustomInvoice.getCode()).andPeriodIdIsNull();
result.addAll(validationInfoMapper.selectByExample(example));
}
OperationResultDto<List<ValidationInfo>> resultOpt = new OperationResultDto<>();
resultOpt.setResult(true);
resultOpt.setResultMsg("");
resultOpt.setData(result);
return resultOpt;
}
public OperationResultDto ImportCustomsInvoice(List<CustomsInvoice> custList, int importType, String userId) {
try {
int periodId = 0;
if (importType == EnumTbImportType.CoverImport.getCode()) {
periodId = custList.get(0).getPeriodId().intValue();
CustomsInvoiceExample example = new CustomsInvoiceExample();
example.createCriteria().andPeriodIdEqualTo(periodId);
customsInvoiceMapper.deleteByExample(example);
}
custList.forEach(c -> {
c.setCreatorId(userId);
});
custList.forEach(m -> customsInvoiceMapper.insert(m));
// UpdateCustomsInvoiceValidation(userId, periodId);//todo:[validation] to be continue (neo)
return new OperationResultDto(true, "");
} catch (Exception ex) {
return new OperationResultDto(false, ex.getMessage());
}
}
}
...@@ -11,7 +11,6 @@ import pwc.taxtech.atms.entity.ProjectServiceType; ...@@ -11,7 +11,6 @@ import pwc.taxtech.atms.entity.ProjectServiceType;
import pwc.taxtech.atms.entity.ProjectServiceTypeExample; import pwc.taxtech.atms.entity.ProjectServiceTypeExample;
import pwc.taxtech.atms.exception.Exceptions; import pwc.taxtech.atms.exception.Exceptions;
import pwc.taxtech.atms.vat.dao.CellDataMapper; import pwc.taxtech.atms.vat.dao.CellDataMapper;
import pwc.taxtech.atms.vat.dao.FormulaProjectMapper;
import pwc.taxtech.atms.vat.dao.ReportMapper; import pwc.taxtech.atms.vat.dao.ReportMapper;
import pwc.taxtech.atms.vat.entity.CellData; import pwc.taxtech.atms.vat.entity.CellData;
import pwc.taxtech.atms.vat.entity.CellDataExample; import pwc.taxtech.atms.vat.entity.CellDataExample;
...@@ -27,8 +26,6 @@ public class FormulaAgent extends VatAbstractService { ...@@ -27,8 +26,6 @@ public class FormulaAgent extends VatAbstractService {
@Autowired @Autowired
public FormulaAdminMapper adminMp; public FormulaAdminMapper adminMp;
@Autowired @Autowired
public FormulaProjectMapper projectMp;
@Autowired
public ReportMapper reportMapper; public ReportMapper reportMapper;
@Autowired @Autowired
public CellDataMapper cellDataMapper; public CellDataMapper cellDataMapper;
...@@ -72,8 +69,8 @@ public class FormulaAgent extends VatAbstractService { ...@@ -72,8 +69,8 @@ public class FormulaAgent extends VatAbstractService {
return null; return null;
} }
public String getPastProjectDbName(int year, String orgId) { public String getPastProjectId(int year, String orgId) {
return adminMp.getPastProjectDbName(year, orgId); return adminMp.getPastProjectId(year, orgId);
} }
public CellData getCellData(String templateId, String cellId, int periodId) { public CellData getCellData(String templateId, String cellId, int periodId) {
......
...@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON; ...@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import pwc.taxtech.atms.common.CommonUtils; import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.datasource.ShardingContextHolder;
import pwc.taxtech.atms.common.util.SpringContextUtil; import pwc.taxtech.atms.common.util.SpringContextUtil;
import pwc.taxtech.atms.constant.enums.CellDataSourceType; import pwc.taxtech.atms.constant.enums.CellDataSourceType;
import pwc.taxtech.atms.constant.enums.EnumOperationType; import pwc.taxtech.atms.constant.enums.EnumOperationType;
...@@ -24,8 +23,6 @@ import pwc.taxtech.atms.dto.vatdto.ReportCellDataSourceDto; ...@@ -24,8 +23,6 @@ import pwc.taxtech.atms.dto.vatdto.ReportCellDataSourceDto;
import pwc.taxtech.atms.dto.vatdto.ReportDataDto; import pwc.taxtech.atms.dto.vatdto.ReportDataDto;
import pwc.taxtech.atms.dto.vatdto.VatEnterpriseAccountResultDto; import pwc.taxtech.atms.dto.vatdto.VatEnterpriseAccountResultDto;
import pwc.taxtech.atms.entity.*; import pwc.taxtech.atms.entity.*;
import pwc.taxtech.atms.entity.EnterpriseAccount;
import pwc.taxtech.atms.entity.EnterpriseAccountExample;
import pwc.taxtech.atms.exception.NotSupportedException; import pwc.taxtech.atms.exception.NotSupportedException;
import pwc.taxtech.atms.service.impl.CellConfigTranslater; import pwc.taxtech.atms.service.impl.CellConfigTranslater;
import pwc.taxtech.atms.vat.dpo.DataSourceCellDataDto; import pwc.taxtech.atms.vat.dpo.DataSourceCellDataDto;
...@@ -97,9 +94,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi ...@@ -97,9 +94,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
} }
} }
String dbName = ShardingContextHolder.getDataSourceKey();
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("dbName", dbName);
map.put("period", period); map.put("period", period);
map.put("projectId", projectId); map.put("projectId", projectId);
map.put("templateGroupId", templateGroupId); map.put("templateGroupId", templateGroupId);
...@@ -910,9 +905,6 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi ...@@ -910,9 +905,6 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
CellDataSourceType cellDataSourceType = CellDataSourceType.getDSType(dataSourceType); CellDataSourceType cellDataSourceType = CellDataSourceType.getDSType(dataSourceType);
String result = StringUtils.EMPTY; String result = StringUtils.EMPTY;
switch (cellDataSourceType) { switch (cellDataSourceType) {
case Voucher:
result = JSON.toJSONString(voucherMapper.selectVoucherWithEnterpriseAccount());
break;
case OutputInvoice: case OutputInvoice:
result = JSON.toJSONString(outputVATInvoiceMapper.selectOutputInvoiceAndItem()); result = JSON.toJSONString(outputVATInvoiceMapper.selectOutputInvoiceAndItem());
break; break;
...@@ -1018,18 +1010,6 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi ...@@ -1018,18 +1010,6 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
} }
} }
itemStrValue = JSON.toJSONString(inputVATInvoiceItemExtendDtos); itemStrValue = JSON.toJSONString(inputVATInvoiceItemExtendDtos);
} else if (dataSource.getType().equals(FormulaDataSourceType.Voucher.getCode())) {
DataSourceDetailExample dataSourceDetailExample = new DataSourceDetailExample();
dataSourceDetailExample.createCriteria().andDataSourceIdEqualTo(datasSourceId).andDataSourceTypeEqualTo(CellDataSourceType.Voucher.getCode());
List<DataSourceDetail> dataSourceDetails = dataSourceDetailMapper.selectByExample(dataSourceDetailExample);
List<Voucher> vouchers = new ArrayList<>();
for (DataSourceDetail dataSourceDetail : dataSourceDetails) {
if (StringUtils.isNotBlank(dataSourceDetail.getItemValue())) {
Voucher voucher = voucherMapper.selectByPrimaryKey(dataSourceDetail.getItemValue());
vouchers.add(voucher);
}
}
itemStrValue = JSON.toJSONString(vouchers);
} else { } else {
itemStrValue = StringUtils.EMPTY; itemStrValue = StringUtils.EMPTY;
} }
......
...@@ -85,7 +85,5 @@ public class VatAbstractService { ...@@ -85,7 +85,5 @@ public class VatAbstractService {
public FtpService ftpService; public FtpService ftpService;
@Autowired @Autowired
public CellDataSourceMapper cellDataSourceMapper; public CellDataSourceMapper cellDataSourceMapper;
@Autowired
public VoucherMapper voucherMapper;
} }
...@@ -9,7 +9,6 @@ import org.apache.poi.ss.formula.eval.ValueEval; ...@@ -9,7 +9,6 @@ import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.functions.FreeRefFunction; import org.apache.poi.ss.formula.functions.FreeRefFunction;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import pwc.taxtech.atms.common.datasource.ShardingContextHolder;
import pwc.taxtech.atms.common.util.MyAsserts; import pwc.taxtech.atms.common.util.MyAsserts;
import pwc.taxtech.atms.constant.enums.FormulaDataSourceDetailType; import pwc.taxtech.atms.constant.enums.FormulaDataSourceDetailType;
import pwc.taxtech.atms.dpo.CellTemplatePerGroupDto; import pwc.taxtech.atms.dpo.CellTemplatePerGroupDto;
...@@ -110,26 +109,12 @@ public class BB extends FunctionBase implements FreeRefFunction { ...@@ -110,26 +109,12 @@ public class BB extends FunctionBase implements FreeRefFunction {
// bo.disCount(); // bo.disCount();
CellData cellData = null; CellData cellData = null;
String dbName = agent.getPastProjectDbName(curPeriod.getCurYear(), String projectId = agent.getPastProjectId(curPeriod.getCurYear(),
formulaContext.getOrganizationId()); formulaContext.getOrganizationId());
MyAsserts.assertNotEmpty(dbName, Exceptions.BB_EMPTY); MyAsserts.assertNotEmpty(projectId, Exceptions.PROJECT_EMPTY);
String currentProjectDb = ShardingContextHolder.getDataSourceKey();
if (currentProjectDb.equals(dbName)) {
cellData = agent.getCellData(cellTemplateData.getReportTemplateId(), cellData = agent.getCellData(cellTemplateData.getReportTemplateId(),
cellTemplateData.getCellTemplateId(), curPeriod.getCurPeriod()); cellTemplateData.getCellTemplateId(), curPeriod.getCurPeriod());
} else {
try {
ShardingContextHolder.setDataSourceKey(dbName);
cellData = agent.getCellData(cellTemplateData.getReportTemplateId(),
cellTemplateData.getCellTemplateId(), curPeriod.getCurPeriod());
} catch (Exception e) {
LOGGER.warn("get data exception with dbName{} currentDb {}", dbName, currentProjectDb, e);
throw e;
} finally {
ShardingContextHolder.setDataSourceKey(currentProjectDb);
}
}
nullCellDto.extractFromGroup(bo, curPeriod, cellData, cellTemplateData); nullCellDto.extractFromGroup(bo, curPeriod, cellData, cellTemplateData);
// todo: fix datasource name by templateList(neo) // todo: fix datasource name by templateList(neo)
......
This diff is collapsed.
This diff is collapsed.
{
"Url": "/signalr",
"ConnectionToken": "TIrLI7u2wCPhYeNH541ZTUgyTaesz/HjNWn5YRnI96DR6Z4C1oaD+FnCJD1jj73OPbQbl4q9aP2F0PCToaubRa9aYnmvr6W9ZP7vqQdH5q9EJXj9",
"ConnectionId": "5c0e6c44-37a7-406f-8240-ccea89d7e0d5",
"KeepAliveTimeout": 20.0,
"DisconnectTimeout": 30.0,
"ConnectionTimeout": 110.0,
"TryWebSockets": true,
"ProtocolVersion": "1.5",
"TransportConnectTimeout": 5.0,
"LongPollDelay": 0.0
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
package pwc.taxtech.atms.common;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.util.StringUtils;
public class StringHelperTest {
@Test
public void getPwd() {
StringHelper stringHelper = new StringHelper();
Assert.assertTrue(StringUtils.hasText(stringHelper.generateRandomPassword()));
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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