Commit bc0ba2ea authored by kevin's avatar kevin

#

parents dda9822c 1874cb8f
......@@ -59,7 +59,7 @@ public class AnalysisJob extends QuartzJobBean {
logger.info(String.format("开始分析%s返还后税数据",period));
analysisJobService.analysisTaxReturnEnd(orgs,period, EnumTbImportType.CoverImport.getCode());
logger.info(String.format("开始分析%税种税金计算数据",period));
logger.info(String.format("开始分析%s税种税金计算数据",period));
analysisJobService.analysisTax(orgs,period, EnumTbImportType.CoverImport.getCode());
}
......
package pwc.taxtech.atms.common.util;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.*;
/**
* author kevin
*/
public class DataBaseTableUtil {
private static String url;
private static String username;
private static String password;
private final static String driver = "com.mysql.jdbc.Driver";
static {
InputStream in = null;
in = DataBaseTableUtil.class.getClassLoader().getResourceAsStream("conf/conf.properties");
Properties p = new Properties();
try {
p.load(in);
} catch (IOException e) {
e.printStackTrace();
}
url = p.getProperty("jdbc_url");
username = p.getProperty("jdbc_user");
password = p.getProperty("jdbc_password");
}
/**
* 读取mysql某数据库下表的注释信息
*
* @author xxx
*/
public static Connection getMySQLConnection() throws Exception {
Class.forName(driver);
Connection conn = DriverManager.getConnection(url, username, password);
return conn;
}
/**
* 获取当前数据库下的所有表名称
* @return
* @throws Exception
*/
public static List getAllTableName() throws Exception {
List tables = new ArrayList();
Connection conn = getMySQLConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SHOW TABLES ");
while (rs.next()) {
String tableName = rs.getString(1);
tables.add(tableName);
}
rs.close();
stmt.close();
conn.close();
return tables;
}
/**
* 获得某表的建表语句
*
* @param tableName
* @return
* @throws Exception
*/
public static Map getCommentByTableName(List tableName) throws Exception {
Map map = new HashMap();
Connection conn = getMySQLConnection();
Statement stmt = conn.createStatement();
for (int i = 0; i < tableName.size(); i++) {
String table = (String) tableName.get(i);
ResultSet rs = stmt.executeQuery("SHOW CREATE TABLE " + table);
if (rs != null && rs.next()) {
String createDDL = rs.getString(2);
String comment = parse(createDDL);
map.put(table, comment);
}
rs.close();
}
stmt.close();
conn.close();
return map;
}
/**
* 获得某表中所有字段的注释
*
* @param tableName
* @return
* @throws Exception
*/
public static void getColumnCommentByTableName(List tableName) throws Exception {
Map map = new HashMap();
Connection conn = getMySQLConnection();
Statement stmt = conn.createStatement();
for (int i = 0; i < tableName.size(); i++) {
String table = (String) tableName.get(i);
ResultSet rs = stmt.executeQuery("show full columns from " + table);
System.out.println("【" + table + "】");
// if (rs != null && rs.next()) {
//map.put(rs.getString("Field"), rs.getString("Comment"));
while (rs.next()) {
// System.out.println("字段名称:" + rs.getString("Field") + "\t"+ "字段注释:" + rs.getString("Comment") );
System.out.println(rs.getString("Field") + "\t:\t" + rs.getString("Comment"));
}
// }
rs.close();
}
stmt.close();
conn.close();
// return map;
}
/**
* 返回注释信息
*
* @param all
* @return
*/
public static String parse(String all) {
String comment = null;
int index = all.indexOf("COMMENT='");
if (index < 0) {
return "";
}
comment = all.substring(index + 9);
comment = comment.substring(0, comment.length() - 1);
return comment;
}
public void main(String[] args) throws Exception {
List tables = getAllTableName();
Map tablesComment = getCommentByTableName(tables);
Set names = tablesComment.keySet();
Iterator iter = names.iterator();
while (iter.hasNext()) {
String name = (String) iter.next();
System.out.println("Table Name: " + name + ", Comment: " + tablesComment.get(name));
}
getColumnCommentByTableName(tables);
}
public static List<String> getTableComment(String tableName) {
List<String> commentComments = Lists.newArrayList();
Connection conn = null;
try {
conn = getMySQLConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("show full columns from " + tableName);
while (rs.next()) {
commentComments.add(rs.getString("Comment"));
}
} catch (Exception e) {
e.printStackTrace();
}
return commentComments;
}
}
......@@ -124,6 +124,7 @@ public class DateUtils {
return null;
}
}
/**
* 将短时间格式字符串转换为区间格式 yyyyMM
*
......@@ -131,7 +132,7 @@ public class DateUtils {
* @return
*/
public static Integer dateToPeriod(java.util.Date dateDate) {
if(dateDate==null){
if (dateDate == null) {
return null;
}
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMM");
......@@ -145,29 +146,33 @@ public class DateUtils {
* @return
*/
public static Integer strToPeriod(String dateStr) {
dateStr = dateStr.replace(" ","");
dateStr = dateStr.replace(" ", "");
Integer period = null;
if(dateStr.length()<7){
period = Integer.valueOf(dateStr.substring(0, 4) +"0"+ dateStr.substring(5, 6));
}else{
if (dateStr.length() < 7) {
period = Integer.valueOf(dateStr.substring(0, 4) + "0" + dateStr.substring(5, 6));
} else {
period = Integer.valueOf(dateStr.substring(0, 4) + dateStr.substring(5, 7));
}
return period;
}
/**
* 将yyyy- 等字符串转换为区间格式 yyyy
*
* @param dateStr
* @return
*/
public static Integer strToPeriodY(String dateStr) {
dateStr = dateStr.replace(" ","");
dateStr = dateStr.replace(" ", "");
Integer period = Integer.valueOf(dateStr.substring(0, 4));
return period;
}
/**
* 将yyyy- 等字符串转换为区间格式 yyyyMM
*
* @param dateStr
* @return
*/
......@@ -185,7 +190,7 @@ public class DateUtils {
* @return
*/
public static Integer strToPeriod2(String dateStr) {
dateStr = dateStr.replace(" ","");
dateStr = dateStr.replace(" ", "");
Integer period = Integer.valueOf(dateStr);
return period;
}
......@@ -223,7 +228,7 @@ public class DateUtils {
* @return
*/
public static Date strToDate3(String strDate) {
strDate = "20"+strDate;
strDate = "20" + strDate;
SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(strDate, pos);
......@@ -315,7 +320,7 @@ public class DateUtils {
return hour;
}
public static Date getZero(){
public static Date getZero() {
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.set(Calendar.HOUR_OF_DAY, 0);
......@@ -324,10 +329,10 @@ public class DateUtils {
return calendar.getTime();
}
public static Date getThreeDayZero(){
public static Date getThreeDayZero() {
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.set(Calendar.DAY_OF_MONTH,-3);
calendar.set(Calendar.DAY_OF_MONTH, -3);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
......@@ -649,17 +654,16 @@ public class DateUtils {
return newday;
}
public static Integer getNowMonth(){
public static Integer getNowMonth() {
Calendar cale = Calendar.getInstance();
return cale.get(Calendar.MONTH) + 1;
}
public static Integer getNowYear(){
public static Integer getNowYear() {
Calendar cale = Calendar.getInstance();
return cale.get(Calendar.YEAR);
}
/**
* 取得数据库主键 生成格式为yyyymmddhhmmss+k位随机数
*
......@@ -713,14 +717,15 @@ public class DateUtils {
/**
* 获得该月第一天
*
* @param year
* @param month
* @return
*/
public static String getFirstDayOfMonth(int year,int month){
public static String getFirstDayOfMonth(int year, int month) {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR,year);
cal.set(Calendar.MONTH, month-1);
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month - 1);
int firstDay = cal.getActualMinimum(Calendar.DAY_OF_MONTH);
cal.set(Calendar.DAY_OF_MONTH, firstDay);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
......@@ -729,20 +734,62 @@ public class DateUtils {
/**
* 获得该月最后一天
*
* @param year
* @param month
* @return
*/
public static String getLastDayOfMonth(int year,int month){
public static String getLastDayOfMonth(int year, int month) {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR,year);
cal.set(Calendar.MONTH, month-1);
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month - 1);
int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
cal.set(Calendar.DAY_OF_MONTH, lastDay);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.format(cal.getTime());
}
//获取档期那月 前N月的值 N的格式 : 201904
public static Integer getBeforeMonthN(Integer period, Integer N) {
Integer nowYear = period / 100;
Integer nowMonth = period % 100;
if (nowMonth - N < 0) {
nowYear--;
nowMonth = nowMonth - N + 12;
} else {
nowMonth -= N;
}
return Integer.parseInt(String.valueOf(nowYear) + String.valueOf(nowMonth));
}
public static Date convertIntertToDate(Integer period){
SimpleDateFormat format = new SimpleDateFormat("yyyyMM");
try {
return format.parse(String.valueOf(period));
} catch (ParseException e) {
e.printStackTrace();
System.out.println("日期转换失败");
}
return null;
}
public static Date convertStringToDate(String period){
SimpleDateFormat format = new SimpleDateFormat("yyyyMM");
try {
return format.parse(period);
} catch (ParseException e) {
e.printStackTrace();
System.out.println("日期转换失败");
}
return null;
}
public static String getPeriodBegin(int year, int period) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
......@@ -784,7 +831,7 @@ public class DateUtils {
public static String nowDateFormat() {
Date date = new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
return simpleDateFormat.format(date);
return simpleDateFormat.format(date);
}
// /***************************************************************************
......
......@@ -325,6 +325,8 @@ public class FileExcelUtil {
public static void deleteColumn(Sheet sheet, int columnToDelete, List<Integer> cols) {
for (int rId = 0; rId <= sheet.getLastRowNum(); rId++) {
Row row = sheet.getRow(rId);
if(row == null)
continue;
for (int cID = columnToDelete; cID <= row.getLastCellNum(); cID++) {
Cell cOld = row.getCell(cID);
if (cOld != null) {
......@@ -355,6 +357,8 @@ public class FileExcelUtil {
*/
public static void cloneCell(Cell cNew, Cell cOld) {
try {
if(cOld == null || cNew == null)
return;;
cNew.setCellComment(cOld.getCellComment());
cNew.setCellStyle(cOld.getCellStyle());
try {
......@@ -362,7 +366,7 @@ public class FileExcelUtil {
if ("".equals(stringCellValue))
return;
} catch (Exception e) {
//do nothing
//do nothing
}
if (CellType.BOOLEAN == cNew.getCellTypeEnum() || CellType.BOOLEAN == cOld.getCellTypeEnum()) {
cNew.setCellValue(cOld.getBooleanCellValue());
......@@ -382,7 +386,6 @@ public class FileExcelUtil {
}
/**
*
* @param cell 获取值的单元格
* @param zero 是否将空 或者null转换成 zero
* @return
......@@ -412,19 +415,18 @@ public class FileExcelUtil {
default:
break;
}
if("".equals(cellValue) && zero)
if ("".equals(cellValue) && zero)
return BigDecimal.ZERO;
if(zero){
try{
return new BigDecimal(cellValue);
}catch (Exception e){
if (zero) {
try {
return new BigDecimal(cellValue);
} catch (Exception e) {
logger.warn("获取Cell,在值转换成数字的地方出错");
return BigDecimal.ZERO;
return BigDecimal.ZERO;
}
}
return cellValue;
}
}
\ No newline at end of file
package pwc.taxtech.atms.common.util;
import java.util.ArrayList;
import java.util.List;
/**
* author kevin
* version 1.0
*/
public class LetterExcelUtil {
public static int excelToNum(String col) { // "AAA"
if (col == null)
return -1;
char[] chrs = col.toUpperCase().toCharArray(); // 转为大写字母组成的 char数组
int length = chrs.length;
int ret = -1;
for (int i = 0; i < length; i++) {
ret += (chrs[i] - 'A' + 1) * Math.pow(26, length - i - 1); // 当做26进制来算 AAA=111 26^2+26^1+26^0
}
return ret;// 702; 从0开始的下标
}
/**
* 数字下标转列
*
* @param index
* @return
*/
public static String NumToExcel(int index) {
int shang = 0;
int yu = 0;
List<Integer> list = new ArrayList<Integer>(); //10进制转26进制 倒序
while (true) {
shang = index / 26;
yu = index % 26;
index = shang;
list.add(yu);
if (shang == 0)
break;
}
StringBuilder sb = new StringBuilder();
for (int j = list.size() - 1; j >= 0; j--) {
sb.append((char) (list.get(j) + 'A' - (j > 1 ? 1 : j))); //倒序拼接 序号转字符 非末位 序号减去 1
}
return sb.toString();
}
}
\ No newline at end of file
package pwc.taxtech.atms.common.util;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFColor;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/**
* author kevin
* version 1.0
*/
public class POIStyleUtil {
public static void setCellAlign(XSSFWorkbook xssfWorkbook, Cell cell) {
CellStyle cellStyle = xssfWorkbook.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.CENTER);// 设置居中
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
cell.setCellStyle(cellStyle);
}
///new XSSFColor(java.awt.Color.YELLOW)
public static void setCellBackgroundColor(XSSFWorkbook xssfWorkbook, Cell cell, XSSFColor xssfColor ,FillPatternType fillPatternType) {
if(fillPatternType == null)
fillPatternType = FillPatternType.SOLID_FOREGROUND;
XSSFCellStyle cellStyle = xssfWorkbook.createCellStyle();
cellStyle.setFillPattern(fillPatternType);
cellStyle.setFillForegroundColor(xssfColor);
cell.setCellStyle(cellStyle);
}
public static void setCellBackgroundColor(XSSFWorkbook xssfWorkbook, Cell cell, XSSFColor xssfColor){
setCellBackgroundColor(xssfWorkbook, cell, xssfColor, null);
}
}
......@@ -126,4 +126,23 @@ public class AnalysisController extends BaseController {
}
return null;
}
@RequestMapping("analysisDataInit")
public OperationResultDto analysisDataInit(Integer type){
logger.info("开始分析模块数据初始化");
OperationResultDto operationResultDto = analysisServiceImpl.analysisDataInit( type);
logger.info("分析模块数据初始化完毕");
return operationResultDto;
}
@RequestMapping("handleAnalysisData")
public OperationResultDto handleAnalysisData(Integer type){
logger.info("开始分析模块手动加载数据");
OperationResultDto operationResultDto = analysisServiceImpl.handleAnalysisData( type);
logger.info("分析模块手动加载数据完毕");
return operationResultDto;
}
}
......@@ -173,7 +173,7 @@ public class ReportController {
resultDto.setResult(false);
return resultDto;
}*/
operationResultDto = reportService.getCellData(requestParameterDto.getReportId(), requestParameterDto.getOrgId(), requestParameterDto.getPeriod());
operationResultDto = reportService.getCellData( requestParameterDto.getOrgId(), requestParameterDto.getPeriod());
return operationResultDto;
}
......@@ -377,7 +377,6 @@ public class ReportController {
e.printStackTrace();
operationResultDto.error(e.getMessage());
return new ResponseEntity(HttpStatus.NO_CONTENT);
}
return new ResponseEntity(HttpStatus.OK);
}
......
......@@ -301,30 +301,22 @@ public class TemplateController extends BaseController {
File templateFile;
InputStream inputStream = null;
OperationResultDto operationResultDto = new OperationResultDto();
EbitSpreadDataExample ebitSpreadData = new EbitSpreadDataExample();
/* EbitSpreadDataExample ebitSpreadData = new EbitSpreadDataExample();
ebitSpreadData.createCriteria().andPeriodEqualTo(period).andOrganizationIdEqualTo(orgId);
List<EbitSpreadData> ebitSpreadData1 = ebitSpreadDataMapper.selectByExample(ebitSpreadData);
List<EbitSpreadData> ebitSpreadData1 = ebitSpreadDataMapper.selectByExample(ebitSpreadData);*/
OutputStream out = null;
//客户端保存的文件名
String customFileName = "template_" + DateTime.now().toString("yyyyMMddHHmmss") + ".xlsx";
response.setHeader("Content-Disposition", String.format("inline; filename=\"" + customFileName + "\""));
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
// int len = 0;
// byte[] buffer = new byte[1024];
// out = response.getOutputStream();
// while ((len = inputStream.read(buffer)) > 0) {
// out.write(buffer, 0, len);
// }
try {
out = response.getOutputStream();
} catch (IOException e) {
e.printStackTrace();
}
if (ebitSpreadData1.size() != 0) {
/*if (ebitSpreadData1.size() != 0) {
DidiFileIUploadParam didiFileIUploadParam = new DidiFileIUploadParam();
didiFileIUploadParam.setUuids(Arrays.asList(ebitSpreadData1.get(0).getFileKey()));
PageInfo<DidiFileUploadDetailResult> uploadDetail = didiFileUploadService.queryPage(didiFileIUploadParam);
String path = null;
if (CollectionUtils.isNotEmpty(uploadDetail.getList())) {
......@@ -359,7 +351,7 @@ public class TemplateController extends BaseController {
inputStream = null;
}
}
}
}*/
List<Template> templates = templateService.getTL(templateId);
MyAsserts.assertNotEmpty(templates, new NotFoundException());
Template template = templates.get(0);
......@@ -368,7 +360,6 @@ public class TemplateController extends BaseController {
filePath = this.getClass().getResource("").toURI().getPath();
String tempPath = filePath.substring(0, filePath.indexOf("classes") + "\\classes".length());
templateFile = new File(tempPath + templatePath);
try {
//如果是系统报表就取本地文件夹,如果不是就取FTP
if (template.getIsSystemType()) {
......
......@@ -3,6 +3,8 @@ package pwc.taxtech.atms.service.impl;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.*;
......@@ -40,7 +42,7 @@ import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @Auther: Gary J Li
* @Auther: kevin
* @Date: 19/03/2019 15:52
* @Description:
*/
......@@ -99,9 +101,11 @@ public class AnalysisJobServiceImpl extends BaseService {
private final static List<Integer> MONTH_LIST = Lists.newArrayList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
private final static List<Integer> Q_LIST = Lists.newArrayList(1, 4, 7, 10);
//private final static List<Integer> ZZS_DATE_LIST = Lists.newArrayList(1, 4, 7, 10);
private final static String MONEYTYPE = "CNY";
private static boolean DataSwitch = true;//当为true时候, 计算所有期间所有数据
/**
* 19/03/2019 15:55
* admin中获取
......@@ -109,7 +113,7 @@ public class AnalysisJobServiceImpl extends BaseService {
* [orgs,period]
*
* @return
* @author Gary J Li
* @author kevin
*/
public void analysisMaster(List<Organization> orgs, Integer period, Integer type) {
......@@ -123,9 +127,8 @@ public class AnalysisJobServiceImpl extends BaseService {
e1.createCriteria().andIsActiveEqualTo(true);*/
List<String> currencys = orgs.stream().map(Organization::getCurrencyCode).collect(Collectors.toList());
OrganizationAccountingRateExample e2 = new OrganizationAccountingRateExample();
e2.createCriteria().andCurrencyFromIn(currencys).andCurrencyToEqualTo("CNY");
e2.createCriteria().andCurrencyFromIn(currencys).andCurrencyToEqualTo(MONEYTYPE);
List<OrganizationAccountingRate> rates = accountingRateMapper.selectByExample(e2);
List<Area> areas = areaMapper.selectTopAreas();
Map<String, String> areaMap = new HashMap<>();
......@@ -212,7 +215,7 @@ public class AnalysisJobServiceImpl extends BaseService {
* [orgs,period]
*
* @return
* @author Gary J Li
* @author kevin
*/
public void analysisSales(List<Organization> orgs, Integer period, Integer type) {
List<String> orgIds = orgs.stream().map(Organization::getId).collect(Collectors.toList());
......@@ -419,7 +422,7 @@ public class AnalysisJobServiceImpl extends BaseService {
* [orgs,period]
*
* @return
* @author Gary J Li
* @author kevin
*/
public void analysisTaxReturnEnd(List<Organization> orgs, Integer period, Integer type) {
List<String> orgIds = orgs.stream().map(Organization::getId).collect(Collectors.toList());
......@@ -534,7 +537,7 @@ public class AnalysisJobServiceImpl extends BaseService {
* [orgs,period]
*
* @return
* @author Gary J Li
* @author kevin
*/
public void analysisExpectedTax(List<Organization> orgs, Integer period, Integer type) {
List<String> orgIds = orgs.stream().map(Organization::getId).collect(Collectors.toList());
......@@ -594,7 +597,7 @@ public class AnalysisJobServiceImpl extends BaseService {
* [orgs,period]
*
* @return
* @author Gary J Li
* @author kevin
*/
public void analysisFee(List<Organization> orgs, Integer period, Integer type) {
List<String> orgIds = orgs.stream().map(Organization::getId).collect(Collectors.toList());
......@@ -603,11 +606,14 @@ public class AnalysisJobServiceImpl extends BaseService {
example.createCriteria().andOrganizationIdIn(orgIds).andPeriodEqualTo(period);
analysisFeeMapper.deleteByExample(example);
}
List<TrialBalanceFinal> tbs = new ArrayList<>();
TrialBalanceFinalExample e1 = new TrialBalanceFinalExample();
e1.createCriteria().andPeriodEqualTo(period);
List<TrialBalanceFinal> tbs = trialBalanceFinalMapper.selectByExample(e1);
if (DataSwitch) {
tbs = trialBalanceFinalMapper.selectByExample(e1);
} else {
e1.createCriteria().andPeriodEqualTo(period);
tbs = trialBalanceFinalMapper.selectByExample(e1);
}
Map<String, List<TrialBalanceFinal>> tbMap = tbs.stream().collect(Collectors.groupingBy(TrialBalanceFinal::getOrganizationId));
Map<String, Organization> orgMap = orgs.stream().collect(Collectors.toMap(Organization::getId, Function.identity()));
......@@ -632,16 +638,29 @@ public class AnalysisJobServiceImpl extends BaseService {
} else if (subjectCode.startsWith("8002")) {
interrelatedDeal = "是";
}
af.setSubject(subjectCode.substring(-2) + "00");
af.setSubject(subjectCode.substring(0, subjectCode.length() - 2));
af.setInterrelatedDeal(interrelatedDeal);
af.setOrganizationId(org.getId());
af.setCompanyName(org.getName());
af.setPeriod(period);
if(DataSwitch){
af.setPeriod(tb.getPeriod());
}else{
af.setPeriod(period);
}
analysisFeeMapper.insertSelective(af);
});
});
}
@Autowired
private FileTypesMapper fileTypesMapper;
public static List<Integer> getThreeYear(Integer period) {
Integer nowYear = period / 100;
return Lists.newArrayList((nowYear - 1) * 100 + 12, (nowYear - 2) * 100 + 12, (nowYear - 3) * 100 + 12);
}
/**
* 19/03/2019 15:59
......@@ -649,16 +668,83 @@ public class AnalysisJobServiceImpl extends BaseService {
* [orgs,period]
*
* @return
* @author Gary J Li
* @author kevin
*/
public void analysisFileManagement(List<Organization> orgs, Integer period,Integer type) {
public void analysisFileManagement(List<Organization> orgs, Integer period, Integer type) {
Long current = System.currentTimeMillis();
System.out.println(System.currentTimeMillis());
List<String> orgIds = orgs.stream().map(Organization::getId).collect(Collectors.toList());
if(type.equals(EnumTbImportType.CoverImport.getCode())){
if (type.equals(EnumTbImportType.CoverImport.getCode())) {
AnalysisFileManagementExample example = new AnalysisFileManagementExample();
example.createCriteria().andOrganizationIdIn(orgIds).andPeriodEqualTo(period);
analysisFileManagementMapper.deleteByExample(example);
}
Map<String, Organization> orgMap = orgs.stream().collect(Collectors.toMap(Organization::getId, Function.identity()));
FileTypesExample fileTypesExample = new FileTypesExample();
List<FileTypes> fileTypes = fileTypesMapper.selectByExample(fileTypesExample);
SimpleDateFormat format = new SimpleDateFormat("yyyyMM");
orgs.forEach(o -> {
OrganizationTaxRuleExample example = new OrganizationTaxRuleExample();
example.createCriteria().andOrganizationIdEqualTo(o.getId());
List<OrganizationTaxRule> organizationTaxRules = organizationTaxRuleMapper.selectByExample(example);
fileTypes.forEach(f -> {
AnalysisFileManagement afm = new AnalysisFileManagement();
afm.setId(idService.nextId());
afm.setSeqNo(getSeqNoByPeriod(o.getId(), period));
afm.setFileType(f.getFileType());
afm.setOrganizationId(o.getId());
afm.setCompanyName(o.getName());
afm.setPeriod(period);
AtomicReference<String> archivingStatus = new AtomicReference<>("未归档");
if (f.getRequiredFieldJson().indexOf("税种") != -1 && f.getRequiredFieldJson().indexOf("所属期间") != -1) {
//满足此条件,周期性档案类型
organizationTaxRules.forEach(taxRule -> {
OrganizationTaxRuleExample exampleRule = new OrganizationTaxRuleExample();
/*Integer str = DateUtils.getNowYear() * 100;
Integer end = DateUtils.getNowYear() * 100 + 12;
Date endDate = new Date();
try {
endDate = format.parse(end.toString());
} catch (ParseException e) {
e.printStackTrace();
logger.warn("日期转换失败");
}*/
exampleRule.createCriteria().andOrganizationIdEqualTo(o.getId()).andGroupNameEqualTo(taxRule.getGroupName());
List<OrganizationTaxRule> organizationTaxRules1 = organizationTaxRuleMapper.selectByExample(exampleRule);
if (organizationTaxRules1.size() == 0)
return;
afm.setReportingFrequency(organizationTaxRules1.get(0).getTaxDecCycle());
if (organizationTaxRules1.size() != 0) {
for (OrganizationTaxRule organizationTaxRule : organizationTaxRules1) {
TaxDocumentExample example1 = new TaxDocumentExample();
if ("年度".equals(organizationTaxRule.getTaxDecCycle())) {
example1.createCriteria().andOwnTimeIn(getThreeYear(period));
} else if ("月度".equals(organizationTaxRule.getTaxDecCycle())) {
example1.createCriteria().andOwnTimeIn(MONTH_LIST);
} else if ("季度".equals(organizationTaxRule.getTaxDecCycle())) {
example1.createCriteria().andOwnTimeIn(Q_LIST);
}
if(taxDocumentMapper.selectByExample(example1).size() != 0)
archivingStatus.set("已归档");
}
} else {
archivingStatus.set("未归档");
afm.setReportingFrequency("/");
}
});
} else {
AnalysisFileManagementExample example1 = new AnalysisFileManagementExample();
example1.createCriteria().andOrganizationIdEqualTo(o.getId()).andFileTypeEqualTo(f.getFileType());
afm.setReportingFrequency("/");
if (analysisFileManagementMapper.selectByExample(example1).size() != 0)
archivingStatus.set("已归档");
archivingStatus.set("未归档");
}
afm.setArchivingStatus(archivingStatus.get());
analysisFileManagementMapper.insertSelective(afm);
});
});
/* Map<String, Organization> orgMap = orgs.stream().collect(Collectors.toMap(Organization::getId, Function.identity()));
TaxDocumentExample e1 = new TaxDocumentExample();
e1.createCriteria().andCompanyIdIn(orgIds).andOwnTimeEqualTo(period);
List<TaxDocument> taxDocuments = taxDocumentMapper.selectByExample(e1);
......@@ -669,7 +755,7 @@ public class AnalysisJobServiceImpl extends BaseService {
Map<String, List<OrganizationTaxRule>> ruleMap = taxRules.stream().collect(Collectors.groupingBy(OrganizationTaxRule::getGroupName));
for(TaxDocument td : taxDocuments){
for (TaxDocument td : taxDocuments) {
Organization o = orgMap.get(td.getCompanyId());
AnalysisFileManagement afm = new AnalysisFileManagement();
afm.setId(idService.nextId());
......@@ -679,9 +765,9 @@ public class AnalysisJobServiceImpl extends BaseService {
// 周期性上传 校验当年的当前及之前的周期是否有上传文件
if (StringUtils.isNotEmpty(td.getTaxType()) && null != td.getOwnTime()) {
List<OrganizationTaxRule> otrs = ruleMap.get(td.getTaxType());
Optional<OrganizationTaxRule> otrOP= otrs.stream().filter(otr->otr.getGroupName().equals(td.getTaxType())).map(OrganizationTaxRule::getUpdateTime).max(new ComparatorDate());
Optional<OrganizationTaxRule> otrOP = otrs.stream().filter(otr -> otr.getGroupName().equals(td.getTaxType())).map(OrganizationTaxRule::getUpdateTime).max(new ComparatorDate());
OrganizationTaxRule rule = otrOP.get();
if(null==rule){
if (null == rule) {
break;
}
afm.setReportingFrequency(rule.getTaxDecCycle());
......@@ -706,7 +792,7 @@ public class AnalysisJobServiceImpl extends BaseService {
archivingStatus = taxDocumentMapper.countByExample(example) > 0 ? "已归档" : archivingStatus;
}
afm.setArchivingStatus(archivingStatus);
}else{
} else {
afm.setReportingFrequency("/");
// 由于是根据文档列表查询 必然已归档
afm.setArchivingStatus("已归档");
......@@ -715,7 +801,8 @@ public class AnalysisJobServiceImpl extends BaseService {
afm.setCompanyName(o.getName());
afm.setPeriod(period);
analysisFileManagementMapper.insertSelective(afm);
}
}*/
System.out.println("消耗时间:" + String.valueOf(System.currentTimeMillis() - current));
}
......@@ -733,7 +820,10 @@ public class AnalysisJobServiceImpl extends BaseService {
List<String> orgIds = orgs.stream().map(Organization::getId).collect(Collectors.toList());
if (type.equals(EnumTbImportType.CoverImport.getCode())) {
AnalysisTaxExample example = new AnalysisTaxExample();
example.createCriteria().andOrganizationIdIn(orgIds).andPeriodEqualTo(period).andTaxGroupNotEqualTo("企业所得税")
AnalysisTaxExample.Criteria criteria = example.createCriteria();
if(!DataSwitch)
criteria.andPeriodEqualTo(period);
criteria.andOrganizationIdIn(orgIds).andTaxGroupNotEqualTo("企业所得税")
.andTaxGroupNotEqualTo("员工个税")
.andTaxGroupNotEqualTo("印花税")
.andTaxGroupNotEqualTo("司机个税")
......@@ -760,7 +850,12 @@ public class AnalysisJobServiceImpl extends BaseService {
values.forEach(v -> {
vMap.put(v.getRowIndex() + ":" + v.getColumnIndex(), v.getData());
});
BigDecimal zzse = getSegmentAmount(vMap, 42, 35).add(getSegmentAmount(vMap, 42, 18));
if(DataSwitch){
as.setPeriod(vatDto.getPeriod());
}else{
as.setPeriod(period);
}
as.setTaxAmount(getSegmentAmount(vMap, 42, 35).add(getSegmentAmount(vMap, 42, 18)));
analysisTaxMapper.insertSelective(as);
} catch (Exception e) {
logger.error(String.format("公司:[%s]生成应缴税额表分析数据失败!", o.getName()), e);
......@@ -783,7 +878,12 @@ public class AnalysisJobServiceImpl extends BaseService {
values.forEach(v -> {
vMap.put(v.getRowIndex() + ":" + v.getColumnIndex(), v.getData());
});
BigDecimal zzse = getSegmentAmount(vMap, 24, 10);
if(DataSwitch){
as.setPeriod(qd.getPeriod());
}else{
as.setPeriod(period);
}
as.setTaxAmount(getSegmentAmount(vMap, 24, 10));
analysisTaxMapper.insertSelective(as);
} catch (Exception e) {
logger.error(String.format("公司:[%s]生成应缴税额表分析数据失败!", o.getName()), e);
......@@ -794,19 +894,19 @@ public class AnalysisJobServiceImpl extends BaseService {
}
public class ComparatorDate implements Comparator {
public class ComparatorDate implements Comparator {
public static final String TAG = "ComparatorDate";
public static final String TAG = "ComparatorDate";
@Override
public int compare(Object obj1, Object obj2) {
Date d1 = (Date) obj1;
Date d2 = (Date) obj2;
if (d1.before(d2)) {
return 1;
} else {
return -1;
@Override
public int compare(Object obj1, Object obj2) {
Date d1 = (Date) obj1;
Date d2 = (Date) obj2;
if (d1.before(d2)) {
return 1;
} else {
return -1;
}
}
}
}
}
......@@ -3,17 +3,26 @@ package pwc.taxtech.atms.service.impl;
import cn.pwc.soap.ws.sysnotify.Exception_Exception;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.*;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import pwc.taxtech.atms.analysis.dao.*;
import pwc.taxtech.atms.analysis.entity.*;
import pwc.taxtech.atms.common.message.ErrorMessage;
import pwc.taxtech.atms.common.message.ErrorMessageCN;
import pwc.taxtech.atms.common.schedule.AnalysisJob;
import pwc.taxtech.atms.common.util.DateUtils;
import pwc.taxtech.atms.constant.TemplateHeaderCheck;
import pwc.taxtech.atms.constant.enums.EnumAnalysisExpTempPath;
import pwc.taxtech.atms.constant.enums.EnumAnalysisImportType;
import pwc.taxtech.atms.constant.enums.EnumTbImportType;
import pwc.taxtech.atms.dao.OrganizationMapper;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.analysis.*;
......@@ -25,11 +34,13 @@ import pwc.taxtech.atms.thirdparty.ExcelUtil;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
......@@ -73,7 +84,7 @@ public class AnalysisServiceImpl extends BaseService {
public List<Object> displayAnalysisImportData(AnalysisDomesticlParam param) {
List<Object> objects = new ArrayList<>();
Integer period = DateUtils.strToPeriod(param.getPeriod());
switch (param.getType()){
switch (param.getType()) {
case 0:
AnalysisTaxExample analysisTaxExample = new AnalysisTaxExample();
analysisTaxExample.createCriteria().andPeriodEqualTo(period);
......@@ -81,7 +92,7 @@ public class AnalysisServiceImpl extends BaseService {
List<AnalysisTaxDto> dtos = Lists.newArrayList();
Map<String, List<AnalysisTax>> actrs =
list.stream().collect(Collectors.groupingBy(AnalysisTax::getCompanyName));
actrs.forEach((k, v) -> processAts(k, v,dtos));
actrs.forEach((k, v) -> processAts(k, v, dtos));
objects.addAll(dtos);
break;
case 1:
......@@ -91,7 +102,7 @@ public class AnalysisServiceImpl extends BaseService {
List<AnalysisActualTaxReturnDto> dtos2 = Lists.newArrayList();
Map<String, List<AnalysisActualTaxReturn>> actrs2 =
list2.stream().collect(Collectors.groupingBy(AnalysisActualTaxReturn::getCompanyName));
actrs2.forEach((k, v) -> processActrs(k, v,dtos2));
actrs2.forEach((k, v) -> processActrs(k, v, dtos2));
objects.addAll(dtos2);
return objects;
case 2:
......@@ -137,29 +148,29 @@ public class AnalysisServiceImpl extends BaseService {
private void processAts(String k, List<AnalysisTax> v, List<AnalysisTaxDto> dtos) {
AnalysisTaxDto dto = new AnalysisTaxDto();
dto.setCompanyName(k);
dto.setSegment1(getAmountByGroup(v,"城建税"));
dto.setSegment2(getAmountByGroup(v,"教育费附加"));
dto.setSegment3(getAmountByGroup(v,"地方教育费附加"));
dto.setSegment4(getAmountByGroup(v,"员工个税"));
dto.setSegment5(getAmountByGroup(v,"司机个税"));
dto.setSegment6(getAmountByGroup(v,"印花税"));
dto.setSegment1(getAmountByGroup(v, "城建税"));
dto.setSegment2(getAmountByGroup(v, "教育费附加"));
dto.setSegment3(getAmountByGroup(v, "地方教育费附加"));
dto.setSegment4(getAmountByGroup(v, "员工个税"));
dto.setSegment5(getAmountByGroup(v, "司机个税"));
dto.setSegment6(getAmountByGroup(v, "印花税"));
dtos.add(dto);
}
private void processActrs(String k, List<AnalysisActualTaxReturn> v,List<AnalysisActualTaxReturnDto> dtos) {
private void processActrs(String k, List<AnalysisActualTaxReturn> v, List<AnalysisActualTaxReturnDto> dtos) {
AnalysisActualTaxReturnDto dto = new AnalysisActualTaxReturnDto();
dto.setCompanyName(k);
dto.setSegment1(getTaxAmountByGroup(v,"增值税返还"));
dto.setSegment2(getTaxAmountByGroup(v,"城建税返还"));
dto.setSegment3(getTaxAmountByGroup(v,"教育费附加返还"));
dto.setSegment4(getTaxAmountByGroup(v,"地方教育费附加返还"));
dto.setSegment5(getTaxAmountByGroup(v,"个人所得税返还"));
dto.setSegment1(getTaxAmountByGroup(v, "增值税返还"));
dto.setSegment2(getTaxAmountByGroup(v, "城建税返还"));
dto.setSegment3(getTaxAmountByGroup(v, "教育费附加返还"));
dto.setSegment4(getTaxAmountByGroup(v, "地方教育费附加返还"));
dto.setSegment5(getTaxAmountByGroup(v, "个人所得税返还"));
dtos.add(dto);
}
private List<AnalysisDriverNumDto> processDns(List<AnalysisDriverNum> list) {
List<AnalysisDriverNumDto> dtos = Lists.newArrayList();
list.forEach(l->{
list.forEach(l -> {
AnalysisDriverNumDto dto1 = new AnalysisDriverNumDto();
dto1.setDriverType("加盟");
dto1.setDriverNum(l.getJoinInAmount());
......@@ -181,33 +192,33 @@ public class AnalysisServiceImpl extends BaseService {
}
private BigDecimal getTaxAmountByGroup(List<AnalysisActualTaxReturn> v, String group) {
List<AnalysisActualTaxReturn> filterRes = v.stream().filter(o-> group.equals(o.getTaxReturnGroup())).collect(Collectors.toList());
BigDecimal res = filterRes.size()>0?filterRes.get(0).getTaxReturnAmount():BigDecimal.ZERO;
List<AnalysisActualTaxReturn> filterRes = v.stream().filter(o -> group.equals(o.getTaxReturnGroup())).collect(Collectors.toList());
BigDecimal res = filterRes.size() > 0 ? filterRes.get(0).getTaxReturnAmount() : BigDecimal.ZERO;
return res;
}
private BigDecimal getAmountByGroup(List<AnalysisTax> v, String group) {
List<AnalysisTax> filterRes = v.stream().filter(o-> group.equals(o.getTaxGroup())).collect(Collectors.toList());
BigDecimal res = filterRes.size()>0?filterRes.get(0).getTaxAmount():BigDecimal.ZERO;
List<AnalysisTax> filterRes = v.stream().filter(o -> group.equals(o.getTaxGroup())).collect(Collectors.toList());
BigDecimal res = filterRes.size() > 0 ? filterRes.get(0).getTaxAmount() : BigDecimal.ZERO;
return res;
}
public OperationResultDto importDomesitcExcelFile(MultipartFile file, String periodDate, Integer type) {
switch (type){
switch (type) {
case 0:
importAnalysisTaxExcelFile(file,periodDate);
importAnalysisTaxExcelFile(file, periodDate);
break;
case 1:
importAnalysisReturnTaxExcelFile(file,periodDate);
importAnalysisReturnTaxExcelFile(file, periodDate);
break;
case 2:
importAnalysisGMVSubsidyExcelFile(file,periodDate);
importAnalysisGMVSubsidyExcelFile(file, periodDate);
break;
case 3:
importAnalysisEmployeeNumExcelFile(file,periodDate);
importAnalysisEmployeeNumExcelFile(file, periodDate);
break;
case 4:
importAnalysisDriverNumExcelFile(file,periodDate);
importAnalysisDriverNumExcelFile(file, periodDate);
break;
default:
break;
......@@ -216,19 +227,20 @@ public class AnalysisServiceImpl extends BaseService {
}
public OperationResultDto importInterNationalExcelFile(MultipartFile file, String periodDate, Integer type,
String companyName,String country) {
switch (type){
String companyName, String country) {
switch (type) {
case 100:
importAnalysisInterBuDataExcelFile(file,periodDate,companyName,country);
importAnalysisInterBuDataExcelFile(file, periodDate, companyName, country);
break;
case 101:
importAnalysisInterTaxDataExcelFile(file,periodDate,companyName,country);
importAnalysisInterTaxDataExcelFile(file, periodDate, companyName, country);
break;
default:
break;
}
return OperationResultDto.success();
}
private String[] headerArr = null;
......@@ -257,7 +269,7 @@ public class AnalysisServiceImpl extends BaseService {
OrganizationExample example = new OrganizationExample();
example.createCriteria().andNameEqualTo(companyName);
List<Organization> orgs = organizationMapper.selectByExample(example);
if(orgs.isEmpty()){
if (orgs.isEmpty()) {
break;
}
for (int k = 1; k < sheet.getRow(0).getLastCellNum(); k++) {
......@@ -268,7 +280,7 @@ public class AnalysisServiceImpl extends BaseService {
AnalysisTaxExample example = new AnalysisTaxExample();
example.createCriteria().andPeriodEqualTo(selectedPer);
analysisTaxMapper.deleteByExample(example);
if(lists.size() == 0)
if (lists.size() == 0)
throw new Exception("数据校验失败");
lists.forEach(l -> {
analysisTaxMapper.insertSelective(l);
......@@ -281,7 +293,7 @@ public class AnalysisServiceImpl extends BaseService {
}
}
private AnalysisTax getAnalysisTax(Integer period, Sheet sheet,int k, int j,Organization org) {
private AnalysisTax getAnalysisTax(Integer period, Sheet sheet, int k, int j, Organization org) {
AnalysisTax model = new AnalysisTax();
model.setId(idService.nextId());
model.setOrganizationId(org.getId());
......@@ -293,18 +305,18 @@ public class AnalysisServiceImpl extends BaseService {
return model;
}
public String getSeqNoByPeriod(String orgId, Integer period){
public String getSeqNoByPeriod(String orgId, Integer period) {
AnalysisMasterExample analysisMasterExample = new AnalysisMasterExample();
analysisMasterExample.createCriteria().andPeriodEqualTo(period).andOrganizationIdEqualTo(orgId);
List<AnalysisMaster> analysisMasters = analysisMasterMapper.selectByExample(analysisMasterExample);
if(analysisMasters.size() != 0)
return analysisMasters.get(0).getSeqNo();
return null;
if (analysisMasters.size() != 0)
return analysisMasters.get(0).getSeqNo();
return null;
}
private void importAnalysisReturnTaxExcelFile(MultipartFile file, String periodDate) {
try{
try {
InputStream inputStream = file.getInputStream();
Workbook workbook = WorkbookFactory.create(inputStream);
if (StringUtils.isBlank(periodDate) || "null".equals(periodDate)) {
......@@ -327,32 +339,32 @@ public class AnalysisServiceImpl extends BaseService {
OrganizationExample example = new OrganizationExample();
example.createCriteria().andNameEqualTo(companyName);
List<Organization> orgs = organizationMapper.selectByExample(example);
if(orgs.isEmpty()){
if (orgs.isEmpty()) {
break;
}
for(int k = 1; k < sheet.getRow(0).getLastCellNum(); k++){
AnalysisActualTaxReturn model = getAnalysisActualTaxReturn(selectedPer, sheet,k, j, orgs.get(0));
for (int k = 1; k < sheet.getRow(0).getLastCellNum(); k++) {
AnalysisActualTaxReturn model = getAnalysisActualTaxReturn(selectedPer, sheet, k, j, orgs.get(0));
lists.add(model);
}
}
AnalysisActualTaxReturnExample example = new AnalysisActualTaxReturnExample();
example.createCriteria().andPeriodEqualTo(selectedPer);
analysisActualTaxReturnMapper.deleteByExample(example);
if(lists.size() == 0)
if (lists.size() == 0)
throw new Exception("数据校验失败");
lists.forEach(l->{
lists.forEach(l -> {
analysisActualTaxReturnMapper.insertSelective(l);
});
}
}catch (ServiceException se){
} catch (ServiceException se) {
throw se;
}catch (Exception e){
} catch (Exception e) {
throw new ServiceException(e);
}
}
private AnalysisActualTaxReturn getAnalysisActualTaxReturn(Integer period, Sheet sheet,int k, int j, Organization org) {
private AnalysisActualTaxReturn getAnalysisActualTaxReturn(Integer period, Sheet sheet, int k, int j, Organization org) {
AnalysisActualTaxReturn model = new AnalysisActualTaxReturn();
model.setId(idService.nextId());
model.setOrganizationId(org.getId());
......@@ -365,7 +377,7 @@ public class AnalysisServiceImpl extends BaseService {
}
private void importAnalysisEmployeeNumExcelFile(MultipartFile file, String periodDate) {
try{
try {
InputStream inputStream = file.getInputStream();
Workbook workbook = WorkbookFactory.create(inputStream);
if (StringUtils.isBlank(periodDate) || "null".equals(periodDate)) {
......@@ -396,9 +408,9 @@ public class AnalysisServiceImpl extends BaseService {
example.createCriteria().andNameEqualTo(getCellStringValue(sheet.getRow(j).getCell(0)));
/* if(organizationMapper.selectByExample(example).size() == 0)
continue;*/
try{
try {
model.setSeqNo(getSeqNoByPeriod(organizationMapper.selectByExample(example).get(0).getId(), DateUtils.strToPeriod(periodDate)));
}catch (Exception e){
} catch (Exception e) {
System.out.println(getCellStringValue(sheet.getRow(j).getCell(0)));
}
lists.add(model);
......@@ -406,22 +418,22 @@ public class AnalysisServiceImpl extends BaseService {
AnalysisEmployeeNumExample example = new AnalysisEmployeeNumExample();
example.createCriteria().andPeriodEqualTo(selectedPer);
analysisEmployeeNumMapper.deleteByExample(example);
if(lists.size() == 0)
if (lists.size() == 0)
throw new Exception("数据格式不正确");
lists.forEach(l->{
lists.forEach(l -> {
analysisEmployeeNumMapper.insertSelective(l);
});
}
}catch (ServiceException se){
} catch (ServiceException se) {
throw se;
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
throw new ServiceException(e);
}
}
private void importAnalysisGMVSubsidyExcelFile(MultipartFile file, String periodDate) {
try{
try {
InputStream inputStream = file.getInputStream();
Workbook workbook = WorkbookFactory.create(inputStream);
if (StringUtils.isBlank(periodDate) || "null".equals(periodDate)) {
......@@ -455,19 +467,19 @@ public class AnalysisServiceImpl extends BaseService {
AnalysisGmvSubsidyExample example = new AnalysisGmvSubsidyExample();
example.createCriteria().andPeriodEqualTo(selectedPer);
analysisGmvSubsidyMapper.deleteByExample(example);
lists.forEach(l->{
lists.forEach(l -> {
analysisGmvSubsidyMapper.insertSelective(l);
});
}
}catch (ServiceException se){
} catch (ServiceException se) {
throw se;
}catch (Exception e){
} catch (Exception e) {
throw new ServiceException(e);
}
}
private void importAnalysisDriverNumExcelFile(MultipartFile file, String periodDate) {
try{
try {
InputStream inputStream = file.getInputStream();
Workbook workbook = WorkbookFactory.create(inputStream);
if (StringUtils.isBlank(periodDate) || "null".equals(periodDate)) {
......@@ -487,13 +499,13 @@ public class AnalysisServiceImpl extends BaseService {
continue;
}
Cell cell2 = sheet.getRow(j).getCell(1);
if("加盟".equals(getCellStringValue(cell1))){
if ("加盟".equals(getCellStringValue(cell1))) {
model.setJoinInAmount(getCellBigDecimalValue(cell2));
}else if("自营".equals(getCellStringValue(cell1))){
} else if ("自营".equals(getCellStringValue(cell1))) {
model.setSelfSupportAmount(getCellBigDecimalValue(cell2));
}else if("直营".equals(getCellStringValue(cell1))){
} else if ("直营".equals(getCellStringValue(cell1))) {
model.setDirectSaleAmount(getCellBigDecimalValue(cell2));
}else if("对公".equals(getCellStringValue(cell1))){
} else if ("对公".equals(getCellStringValue(cell1))) {
model.setRightPublicAmount(getCellBigDecimalValue(cell2));
}
}
......@@ -501,22 +513,23 @@ public class AnalysisServiceImpl extends BaseService {
//todo 这里先写死滴滴出行科技有限公司
example2.createCriteria().andNameEqualTo("滴滴出行科技有限公司");
List<AnalysisMaster> size = analysisMasterMapper.selectByExample(example2);
if(size.size() != 0)
if (size.size() != 0)
model.setSeqNo(size.get(0).getSeqNo());
AnalysisDriverNumExample example = new AnalysisDriverNumExample();
example.createCriteria().andPeriodEqualTo(selectedPer);
analysisDriverNumMapper.deleteByExample(example);
analysisDriverNumMapper.insertSelective(model);
}
}catch (ServiceException se){
} catch (ServiceException se) {
throw se;
}catch (Exception e){
} catch (Exception e) {
throw new ServiceException(e);
}
}
private void importAnalysisInterTaxDataExcelFile(MultipartFile file, String periodDate,
String companyName,String country) {
try{
String companyName, String country) {
try {
InputStream inputStream = file.getInputStream();
Workbook workbook = WorkbookFactory.create(inputStream);
if (StringUtils.isBlank(periodDate) || "null".equals(periodDate)) {
......@@ -546,22 +559,22 @@ public class AnalysisServiceImpl extends BaseService {
AnalysisInternationalTaxDataExample example = new AnalysisInternationalTaxDataExample();
example.createCriteria().andPeriodEqualTo(selectedPer).andCountryEqualTo(country).andCompanyNameEqualTo(companyName);
analysisInternationalTaxDataMapper.deleteByExample(example);
lists.forEach(l->{
lists.forEach(l -> {
analysisInternationalTaxDataMapper.insertSelective(l);
});
}
}catch (ServiceException se){
} catch (ServiceException se) {
throw se;
}catch (Exception e){
} catch (Exception e) {
String errMsg = "分析模块-导入国际税务数据异常";
logger.error(errMsg,e);
logger.error(errMsg, e);
throw new ServiceException(errMsg);
}
}
private void importAnalysisInterBuDataExcelFile(MultipartFile file, String periodDate,
String companyName,String country) {
try{
String companyName, String country) {
try {
InputStream inputStream = file.getInputStream();
Workbook workbook = WorkbookFactory.create(inputStream);
if (StringUtils.isBlank(periodDate) || "null".equals(periodDate)) {
......@@ -574,7 +587,7 @@ public class AnalysisServiceImpl extends BaseService {
if (isSheetEmpty(sheet)) continue;
List<AnalysisInternationalBusinessData> lists = Lists.newArrayList();
for (int j = 1; j <= sheet.getLastRowNum(); j++) {
if(j>2)
if (j > 1)
break;
AnalysisInternationalBusinessData model = new AnalysisInternationalBusinessData();
model.setId(idService.nextId());
......@@ -602,15 +615,15 @@ public class AnalysisServiceImpl extends BaseService {
AnalysisInternationalBusinessDataExample example = new AnalysisInternationalBusinessDataExample();
example.createCriteria().andPeriodEqualTo(selectedPer).andCountryEqualTo(country).andCompanyNameEqualTo(companyName);
analysisInternationalBusinessDataMapper.deleteByExample(example);
lists.forEach(l->{
lists.forEach(l -> {
analysisInternationalBusinessDataMapper.insertSelective(l);
});
}
}catch (ServiceException se){
} catch (ServiceException se) {
throw se;
}catch (Exception e){
} catch (Exception e) {
String errMsg = "分析模块-导入国际业务数据异常";
logger.error(errMsg,e);
logger.error(errMsg, e);
throw new ServiceException(errMsg);
}
}
......@@ -620,7 +633,7 @@ public class AnalysisServiceImpl extends BaseService {
Integer period = DateUtils.strToPeriod(param.getPeriod());
String country = param.getCountry();
String companyName = param.getCompanyName();
switch (param.getType()){
switch (param.getType()) {
case 100:
AnalysisInternationalBusinessDataExample analysisInternationalBusinessDataExample = new AnalysisInternationalBusinessDataExample();
analysisInternationalBusinessDataExample.createCriteria().andPeriodEqualTo(period).andCompanyNameEqualTo(companyName).andCountryEqualTo(country);
......@@ -666,8 +679,8 @@ public class AnalysisServiceImpl extends BaseService {
analysisInternationalTaxDataExample.createCriteria().andPeriodEqualTo(period).andCompanyNameEqualTo(companyName).andCountryEqualTo(country);
List<AnalysisInternationalTaxData> list2 = analysisInternationalTaxDataMapper.selectByExample(analysisInternationalTaxDataExample);
List<AnalysisInternationalTaxDataDto> dtos2 = Lists.newArrayList();
list2.forEach(l2->{
dtos2.add(beanUtil.copyProperties(l2,new AnalysisInternationalTaxDataDto()));
list2.forEach(l2 -> {
dtos2.add(beanUtil.copyProperties(l2, new AnalysisInternationalTaxDataDto()));
});
objects.addAll(dtos2);
return objects;
......@@ -682,13 +695,13 @@ public class AnalysisServiceImpl extends BaseService {
List<Object> datas = displayAnalysisImportData(param);
try {
if(datas.size()<1){
if (datas.size() < 1) {
throw new Exception("无可导出的数据");
}
OutputStream outputStream = commonDocumentHelper.toXlsxFileUsingJxls(datas, excelTemplatePathInClassPath);
return responseMessageBuilder.getDownloadTmpResponseMessage(response, outputStream, fileName);
} catch (Exception e) {
logger.error(String.format("导出国内税数据异常:%s",e.getMessage()));
logger.error(String.format("导出国内税数据异常:%s", e.getMessage()));
}
return null;
}
......@@ -696,7 +709,7 @@ public class AnalysisServiceImpl extends BaseService {
public HttpServletResponse downloadInternationalFile(HttpServletResponse response, AnalysisInternationlParam param, String fileName) {
String excelTemplatePathInClassPath = EnumAnalysisExpTempPath.getPath(param.getType());
List<Object> datas = Lists.newArrayList();
if(param.getType().equals(EnumAnalysisImportType.InternationalBuData.getCode())){
if (param.getType().equals(EnumAnalysisImportType.InternationalBuData.getCode())) {
Integer period = DateUtils.strToPeriod(param.getPeriod());
String country = param.getCountry();
String companyName = param.getCompanyName();
......@@ -704,17 +717,17 @@ public class AnalysisServiceImpl extends BaseService {
analysisInternationalBusinessDataExample.createCriteria().andPeriodEqualTo(period).andCompanyNameEqualTo(companyName).andCountryEqualTo(country);
List<AnalysisInternationalBusinessData> list = analysisInternationalBusinessDataMapper.selectByExample(analysisInternationalBusinessDataExample);
datas.addAll(list);
}else{
} else {
datas = displayAnalysisInternationalImportData(param);
}
if(datas.size()<1){
if (datas.size() < 1) {
throw new ServiceException(ErrorMessage.ExportFailed);
}
OutputStream outputStream = commonDocumentHelper.toXlsxFileUsingJxls(datas, excelTemplatePathInClassPath);
try {
return responseMessageBuilder.getDownloadTmpResponseMessage(response, outputStream, fileName);
} catch (Exception e) {
logger.error(String.format("导出国际税数据异常:%s",e.getMessage()));
logger.error(String.format("导出国际税数据异常:%s", e.getMessage()));
}
return null;
}
......@@ -722,7 +735,7 @@ public class AnalysisServiceImpl extends BaseService {
public List<String> getAnalysisInternationalCompanyList(Integer type, String periodStr) {
List<String> companyList = Lists.newArrayList();
Integer period = DateUtils.strToPeriod(periodStr);
switch (type){
switch (type) {
case 100:
companyList = analysisInternationalBusinessDataMapper.selectCompanyList(period);
break;
......@@ -738,7 +751,7 @@ public class AnalysisServiceImpl extends BaseService {
public List<String> getAnalysisInternationalCountryList(Integer type, String periodStr) {
List<String> countryList = Lists.newArrayList();
Integer period = DateUtils.strToPeriod(periodStr);
switch (type){
switch (type) {
case 100:
countryList = analysisInternationalBusinessDataMapper.selectCountryList(period);
break;
......@@ -754,9 +767,9 @@ public class AnalysisServiceImpl extends BaseService {
private String getCellStringValue(Cell cell) {
if (cell.getCellTypeEnum().equals(CellType.STRING)) {
return cell.getStringCellValue();
} else if(cell.getCellTypeEnum().equals(CellType.NUMERIC)) {
} else if (cell.getCellTypeEnum().equals(CellType.NUMERIC)) {
// 取整
return String.valueOf((int)cell.getNumericCellValue());
return String.valueOf((int) cell.getNumericCellValue());
}
logger.warn("获取单元格数据类型未匹配");
return null;
......@@ -776,7 +789,7 @@ public class AnalysisServiceImpl extends BaseService {
default:
return null;
}
}else if (cell.getCellTypeEnum().equals(CellType.BOOLEAN)) {
} else if (cell.getCellTypeEnum().equals(CellType.BOOLEAN)) {
return cell.getBooleanCellValue();
}
logger.warn("获取单元格数据类型未匹配");
......@@ -786,8 +799,8 @@ public class AnalysisServiceImpl extends BaseService {
private Integer getCellIntegerValue(Cell cell) {
if (cell.getCellTypeEnum().equals(CellType.STRING)) {
return Integer.valueOf(cell.getStringCellValue());
} else if(cell.getCellTypeEnum().equals(CellType.NUMERIC)) {
return (int)cell.getNumericCellValue();
} else if (cell.getCellTypeEnum().equals(CellType.NUMERIC)) {
return (int) cell.getNumericCellValue();
}
logger.warn("获取单元格数据类型未匹配");
return null;
......@@ -796,8 +809,8 @@ public class AnalysisServiceImpl extends BaseService {
private BigDecimal getCellBigDecimalValue(Cell cell) {
if (cell.getCellTypeEnum().equals(CellType.STRING)) {
String replace = cell.getStringCellValue().replace("%", "");
return new BigDecimal(Double.parseDouble(replace)/100);
} else if(cell.getCellTypeEnum().equals(CellType.NUMERIC)) {
return new BigDecimal(Double.parseDouble(replace) / 100);
} else if (cell.getCellTypeEnum().equals(CellType.NUMERIC)) {
return new BigDecimal(cell.getNumericCellValue());
}
logger.warn("获取单元格数据类型未匹配");
......@@ -807,7 +820,7 @@ public class AnalysisServiceImpl extends BaseService {
private Long getCellLongDecimalValue(Cell cell) {
if (cell.getCellTypeEnum().equals(CellType.STRING)) {
return Long.valueOf(cell.getStringCellValue());
} else if(cell.getCellTypeEnum().equals(CellType.NUMERIC)) {
} else if (cell.getCellTypeEnum().equals(CellType.NUMERIC)) {
return new Double(cell.getNumericCellValue()).longValue();
}
logger.warn("获取单元格数据类型未匹配");
......@@ -822,4 +835,330 @@ public class AnalysisServiceImpl extends BaseService {
}
return false;
}
/*分析模块数据初始化*/
private static List<Integer> SALE_LIST = Lists.newArrayList(10, 11, 12, 13, 14, 16, 18, 19, 32);
private static List<Integer> TAX_LIST = Lists.newArrayList(38, 39, 40, 41, 42, 46, 47, 75, 76, 77, 78, 80);
@Autowired
private JdbcTemplate jdbcTemplate;
//分析模块数据初始化, 使用java命令直接运行该类的class文件
public OperationResultDto analysisDataInit(Integer type) {
OperationResultDto operationResultDto = new OperationResultDto();
Long now = System.currentTimeMillis();
InputStream resourceAsStream = AnalysisServiceImpl.class.getClassLoader().getResourceAsStream("analysis_excel_init/analysis_init_data.xlsx");
if (resourceAsStream == null) {
logger.warn("获取分析数据初始化文件失败");
operationResultDto.error();
return operationResultDto;
}
Workbook workbook = null;
try {
workbook = WorkbookFactory.create(resourceAsStream);
} catch (IOException e) {
e.printStackTrace();
} catch (InvalidFormatException e) {
e.printStackTrace();
}
AnalysisMaster analysisMaster = null;
AnalysisSales sales = null;
AnalysisTax tax = null;
Sheet sheetAt = workbook.getSheetAt(0);
List<AnalysisTax> taxList = new ArrayList<>();
List<AnalysisSales> salesList = new ArrayList<>();
int breakFlag = 0;
try {
for (int i = 5; i < sheetAt.getLastRowNum(); i++) {
if (sheetAt.getRow(i).getCell(1) == null) {
break;//解决excel无限行的问题
}
AnalysisMasterExample example = new AnalysisMasterExample();
System.out.println(getCellValue(sheetAt.getRow(i).getCell(1), false).toString());
Integer period = Integer.parseInt(getCellValue(sheetAt.getRow(i).getCell(1), false).toString().substring(0, 6));
example.createCriteria()
.andCompanyNameEqualTo(getCellValue(sheetAt.getRow(i).getCell(3), false).toString())
.andPeriodEqualTo(period);
List<AnalysisMaster> analysisMasters = analysisMasterMapper.selectByExample(example);
if(breakFlag >3){
logger.info("大于三条数据不匹配,直接停止进程");
break;
}
if (analysisMasters.size() == 0) {
logger.warn("公司名称不匹配");
breakFlag++;
continue;
}
analysisMaster = analysisMasters.get(0);
sales = new AnalysisSales();
for (int j = 0; j < sheetAt.getRow(0).getLastCellNum(); j++) {
Cell cell = sheetAt.getRow(i).getCell(j);
if (SALE_LIST.contains(j)) {
insertAnalysisSaleData(period, sales, cell, j, analysisMaster);
} else if (TAX_LIST.contains(j)) {
tax = new AnalysisTax();
taxData(period,
j,
tax,
analysisMaster,
cell,
taxList);
}
}
if (sales.getSeqNo() != null) {
sales.setPeriod(period);
salesList.add(sales);
}
period = null;
analysisMaster = null;
tax = null;
sales = null;
System.gc();
if (type == 0) {
String sql = "truncate table analysis_sales; truncate table analysis_tax";
jdbcTemplate.update(sql);
}
}
int salesInt = analysisSalesMapper.insertBatch(salesList);
int taxInt = analysisTaxMapper.insertBatch(taxList);
logger.info("analysis_salesInt 更新数据条数" + salesInt);
logger.info("analysis_tax 更新数据条数" + taxInt);
System.out.println("数据初始化消耗: " + (System.currentTimeMillis() - now));
operationResultDto.success();
operationResultDto.setResultMsg(String.valueOf(System.currentTimeMillis() - now));
} catch (Exception e) {
e.printStackTrace();
logger.warn("插入失败");
operationResultDto.setResult(false);
operationResultDto.setResultMsg("插入失败");
}
return operationResultDto;
}
@Autowired
protected DistributedIdService idService;
public void taxData(Integer period, Integer j, AnalysisTax tax, AnalysisMaster analysisMaster, Cell cell, List<AnalysisTax> taxList) {
seqNo = analysisMaster.getSeqNo();
conpanyName = analysisMaster.getCompanyName();
organizationId = analysisMaster.getOrganizationId();
tax.setSeqNo(seqNo);
tax.setTaxAmount((BigDecimal) getCellValue(cell, true));
tax.setCompanyName(conpanyName);
tax.setOrganizationId(organizationId);
tax.setCreateTime(new Date());
tax.setUpdateTime(new Date());
tax.setId(idService.nextId());
tax.setPeriod(period);
switch (j) {
case 38:
tax.setTaxGroup("企业所得税");
break;
case 39:
tax.setTaxGroup("增值税");
break;
case 40:
tax.setTaxGroup("城建税");
break;
case 41:
tax.setTaxGroup("教育费附加");
break;
case 42:
tax.setTaxGroup("地方教育费附加");
break;
case 46:
tax.setTaxGroup("员工个税");
break;
case 47:
tax.setTaxGroup("司机个税");
break;
case 75:
tax.setTaxGroup("返还后增值税");
break;
case 76:
tax.setTaxGroup("返还后城建税");
break;
case 77:
tax.setTaxGroup("返还后教育费附加");
break;
case 78:
tax.setTaxGroup("返还后地方教育费附加");
break;
case 80:
tax.setTaxGroup("返还后个人所得税");
break;
}
taxList.add(tax);
tax = null;
seqNo = null;
conpanyName = null;
organizationId = null;
}
public void saleData(AnalysisSales sales, String seqNo, String conpanyName, String organizationId, Cell cell) {
sales.setSeqNo(seqNo);
sales.setCompanyName(conpanyName);
sales.setOrganizationId(organizationId);
sales.setCreateTime(new Date());
sales.setUpdateTime(new Date());
sales.setId(idService.nextId());
}
private String seqNo = null;
private String conpanyName = null;
private String organizationId = null;
public void insertAnalysisSaleData(Integer period, AnalysisSales sale, Cell cell, Integer col, AnalysisMaster analysisMaster) {
seqNo = analysisMaster.getSeqNo();
conpanyName = analysisMaster.getCompanyName();
organizationId = analysisMaster.getOrganizationId();
switch (col) {
//10, 11, 12, 13, 14, 16, 18, 19, 32
case 10:
saleData(sale, seqNo, conpanyName, organizationId, cell);
sale.setSegment1((BigDecimal) getCellValue(cell, true));
break;
case 11:
saleData(sale, seqNo, conpanyName, organizationId, cell);
sale.setSegment2((BigDecimal) getCellValue(cell, true));
break;
case 12:
saleData(sale, seqNo, conpanyName, organizationId, cell);
sale.setSegment3((BigDecimal) getCellValue(cell, true));
break;
case 13:
saleData(sale, seqNo, conpanyName, organizationId, cell);
sale.setSegment5((BigDecimal) getCellValue(cell, true));
case 14:
saleData(sale, seqNo, conpanyName, organizationId, cell);
sale.setSegment6((BigDecimal) getCellValue(cell, true));
break;
case 16:
saleData(sale, seqNo, conpanyName, organizationId, cell);
sale.setSegment9((BigDecimal) getCellValue(cell, true));
break;
case 18:
saleData(sale, seqNo, conpanyName, organizationId, cell);
sale.setSegment15((BigDecimal) getCellValue(cell, true));
break;
case 19:
saleData(sale, seqNo, conpanyName, organizationId, cell);
sale.setSegment16((BigDecimal) getCellValue(cell, true));
break;
case 32:
saleData(sale, seqNo, conpanyName, organizationId, cell);
sale.setSegment17((BigDecimal) getCellValue(cell, true));
break;
}
}
/**
* @param cell 获取值的单元格
* @param zero 是否将空 或者null转换成 zero
* @return
*/
public static Object getCellValue(Cell cell, Boolean zero) {
String cellValue = null;
if (cell == null)
return BigDecimal.ZERO;
switch (cell.getCellType()) {
case Cell.CELL_TYPE_STRING://字符串类型
cellValue = cell.getStringCellValue();
if (cellValue.trim().equals("") || cellValue.trim().length() <= 0)
cellValue = "";
break;
case Cell.CELL_TYPE_NUMERIC: //数值类型
cellValue = String.valueOf(cell.getNumericCellValue());
break;
case Cell.CELL_TYPE_FORMULA: //公式
cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
cellValue = String.valueOf(cell.getNumericCellValue());
break;
case Cell.CELL_TYPE_BLANK:
cellValue = "";
break;
case Cell.CELL_TYPE_BOOLEAN:
break;
case Cell.CELL_TYPE_ERROR:
break;
default:
break;
}
if ("".equals(cellValue) && zero)
return BigDecimal.ZERO;
if (zero) {
try {
return new BigDecimal(cellValue);
} catch (Exception e) {
System.out.println("获取Cell,在值转换成数字的地方出错");
return BigDecimal.ZERO;
}
}
return cellValue;
}
@Autowired
private AnalysisJobServiceImpl analysisJobService;
public OperationResultDto handleAnalysisData(Integer type) {
OperationResultDto operationResultDto = new OperationResultDto();
Long now = System.currentTimeMillis();
try {
if (type == 0) {
String sql = "TRUNCATE TABLE analysis_tax_return_end;\n" +
"TRUNCATE TABLE analysis_employee_num;\n" +
"TRUNCATE TABLE analysis_actual_tax_return;\n" +
"TRUNCATE TABLE analysis_fee;\n" +
"TRUNCATE TABLE analysis_expected_tax_return;\n" +
"TRUNCATE TABLE analysis_file_management;\n" +
"TRUNCATE TABLE analysis_international_tax_data;\n" +
"TRUNCATE TABLE analysis_sales;\n" +
"TRUNCATE TABLE analysis_tax;\n" +
"TRUNCATE TABLE analysis_master;";
int deleteCount = jdbcTemplate.update(sql);
logger.info("成功删除数据,删除数量:" + deleteCount);
}
Integer period = DateUtils.getPeriodNow();
OrganizationExample e = new OrganizationExample();
//e.createCriteria().andIsActiveEqualTo(true);
List<Organization> orgs = organizationMapper.selectByExample(e);
logger.info(String.format("开始分析%s机构数据", period));
analysisJobService.analysisMaster(orgs, period, EnumTbImportType.CoverImport.getCode());
logger.info(String.format("开始分析%s预期返还税数据", period));
analysisJobService.analysisExpectedTax(orgs, period, EnumTbImportType.CoverImport.getCode());
logger.info(String.format("开始分析%s费用数据", period));
analysisJobService.analysisFee(orgs, period, EnumTbImportType.CoverImport.getCode());
logger.info(String.format("开始分析%s档案管理数据", period));
analysisJobService.analysisFileManagement(orgs, period, EnumTbImportType.CoverImport.getCode());
logger.info(String.format("开始分析%s申报表数据", period));
analysisJobService.analysisSales(orgs, period, EnumTbImportType.CoverImport.getCode());
logger.info(String.format("开始分析%s返还后税数据", period));
analysisJobService.analysisTaxReturnEnd(orgs, period, EnumTbImportType.CoverImport.getCode());
logger.info(String.format("开始分析%s税种税金计算数据", period));
analysisJobService.analysisTax(orgs, period, EnumTbImportType.CoverImport.getCode());
} catch (Exception ex) {
ex.printStackTrace();
operationResultDto.setResult(false);
}
operationResultDto.setResultMsg(String.valueOf((System.currentTimeMillis() - now) / 100));
operationResultDto.setResult(true);
return operationResultDto;
}
}
......@@ -1265,7 +1265,7 @@ public class DataImportService extends BaseService {
* @return
*/
public OperationResultDto importCILExcelFile(MultipartFile file,List<String> orgIds, String periodDate, Integer importType) throws ServiceException {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
InputStream inputStream = file.getInputStream();
Workbook workbook = WorkbookFactory.create(inputStream);
......@@ -1360,8 +1360,12 @@ public class DataImportService extends BaseService {
cil.setInvoiceNum(getCellStringValue(cell3));
Cell cell4 = row.getCell(3);
cil.setBillingDate(DateUtils.strToDate4(getCellStringValue(cell4)));
try{
String BillingDate = format.format(cell4.getDateCellValue());
cil.setBillingDate(DateUtils.strToDate4(BillingDate));
}catch (Exception e){
cil.setBillingDate(DateUtils.strToDate4(getCellStringValue(cell4)));
}
Cell cell5 = row.getCell(4);
cil.setSalesTaxNum(getCellStringValue(cell5));
......@@ -1378,7 +1382,10 @@ public class DataImportService extends BaseService {
cil.setVerificationMethod(getCellStringValue(cell9));
Cell cell10 = row.getCell(9);
cil.setCertifiedDate(DateUtils.strToDate4(getCellStringValue(cell10)));
Date dateCellValue = cell10.getDateCellValue();
String format1 = format.format(dateCellValue);
cil.setCertifiedDate(DateUtils.strToDate4(format1));
Cell cell11 = row.getCell(10);
cil.setInvoiceType(getCellStringValue(cell11));
......
......@@ -126,7 +126,8 @@ public class EbsApiServiceImpl implements EbsApiService {
}
@Override
public void queryRemoteServerThenUpdateCF(Long id ,List<CashFlowQueryDto> items) {
public void
queryRemoteServerThenUpdateCF(Long id ,List<CashFlowQueryDto> items) {
long start = System.currentTimeMillis();
logger.debug("start queryRemoteServerThenUpdateCF 现金流量表");
//判断数据是否存在
......@@ -260,11 +261,12 @@ public class EbsApiServiceImpl implements EbsApiService {
//唯一则更新否则插入
JournalEntry journalEntry = new JournalEntry();
if (journalEntryList.size() == 1) {
logger.debug("exist and update journalEntry headerId:{},lineNum:{},taskId:{}", item.getHeaderId(), item.getLineNum(),item.getTaskId());
//todo 待验证
/*logger.debug("exist and update journalEntry headerId:{},lineNum:{},taskId:{}", item.getHeaderId(), item.getLineNum(),item.getTaskId());
journalEntry = journalEntryList.get(0);
populateFieldsJE(item, journalEntry);
journalEntry.setId(journalEntryList.get(0).getId());
journalEntryMapper.updateByPrimaryKeySelective(journalEntry);
journalEntryMapper.updateByPrimaryKeySelective(journalEntry);*/
} else {
logger.debug("miss and insert journalEntry headerId:{},lineNum:{},taskId:{}", item.getHeaderId(), item.getLineNum(),item.getTaskId());
populateFieldsJE(item, journalEntry);
......@@ -870,9 +872,10 @@ public class EbsApiServiceImpl implements EbsApiService {
}
private void updateDataImportLog(Long id, int size) {
DataImportLog dataImportLogTemp = dataImportLogMapper.selectByPrimaryKey(id);
DataImportLog dataImportLog = new DataImportLog();
dataImportLog.setId(id);
dataImportLog.setRecordSize(size);
dataImportLog.setRecordSize((dataImportLogTemp==null?0:dataImportLogTemp.getRecordSize())+size);
dataImportLog.setImportResult(true);
dataImportLog.setUpdateTime(new Date());
int res = dataImportLogMapper.updateByPrimaryKeySelective(dataImportLog);
......
......@@ -9,13 +9,14 @@ import com.google.common.collect.Sets;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Mapper;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.xssf.usermodel.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
......@@ -28,10 +29,7 @@ import org.springframework.web.multipart.MultipartHttpServletRequest;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.POIUtil;
import pwc.taxtech.atms.common.message.ErrorMessage;
import pwc.taxtech.atms.common.util.DataUtil;
import pwc.taxtech.atms.common.util.FileExcelUtil;
import pwc.taxtech.atms.common.util.MyAsserts;
import pwc.taxtech.atms.common.util.SpringContextUtil;
import pwc.taxtech.atms.common.util.*;
import pwc.taxtech.atms.constant.Constant;
import pwc.taxtech.atms.constant.enums.*;
import pwc.taxtech.atms.dao.*;
......@@ -59,10 +57,7 @@ import pwc.taxtech.atms.vat.service.impl.report.functions.FormulaHelper;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
......@@ -485,9 +480,9 @@ public class ReportServiceImpl extends BaseService {
continue;//todo cell == null 如何处理
}
if (r <= addRowIndex + 1) {
if(r == addRowIndex + 1 && c>TaxesCalculateReportEnum.Column.Column_14.getIndex()){
assembleOriginalTemplateData(template,projectId,period,r,c,addRowIndex,cellTemplateList,cellTemplateConfigList);
}else{
if (r == addRowIndex + 1 && c > TaxesCalculateReportEnum.Column.Column_14.getIndex()) {
assembleOriginalTemplateData(template, projectId, period, r, c, addRowIndex, cellTemplateList, cellTemplateConfigList);
} else {
String cellId = projectId + template.getId() + period + r + c;
if ((r - 1) >= 0 && (r - 1) < configIds.size()) {
cellId += configIds.get(configIds.size() - r);
......@@ -551,7 +546,7 @@ public class ReportServiceImpl extends BaseService {
}
}
} else {
assembleOriginalTemplateData(template,projectId,period,r,c,addRowIndex,cellTemplateList,cellTemplateConfigList);
assembleOriginalTemplateData(template, projectId, period, r, c, addRowIndex, cellTemplateList, cellTemplateConfigList);
}
}
}
......@@ -636,6 +631,7 @@ public class ReportServiceImpl extends BaseService {
}
}
}
private void addManualConfig(PeriodCellTemplate cellTemplate, Cell cell, Date now, List<PeriodCellTemplateConfig> list) {
PeriodCellTemplateConfig configManual = new PeriodCellTemplateConfig();
configManual.setId(distributedIdService.nextId());
......@@ -1243,22 +1239,18 @@ public class ReportServiceImpl extends BaseService {
}
private static final String specialConsideration = "";//特殊因素考虑
@Autowired
private ProfitLossStatementPrcMapper profitLossStatementPrcMapper;
public List<CellTemplateReferenceDto> getTemplateReferences(int period) {
return new ArrayList<>();
}
public OperationResultDto<ReportDataDto> getCellData(String reportId, String orgId, Integer period) {
public OperationResultDto<ReportDataDto> getCellData(String orgId, Integer period) {
OperationResultDto<ReportDataDto> cellData = new OperationResultDto<>();
ReportDataDto reportDataDto = new ReportDataDto();
cellData.setData(reportDataDto);
EbitCellDataExample example = new EbitCellDataExample();
example.createCriteria().andOrganizationIdEqualTo(orgId).andPeriodEqualTo(period);
List<EbitCellData> ebitCellData = ebitCellDataMapper.selectByExample(example);
if (ebitCellData.size() != 0) {
cellData.getData().setEbitData(_getEbitData(ebitCellData));
}
if (reportId != null) {
/*if (reportId != null) {
cellData = getCellData(Long.parseLong(reportId), getProjId(orgId, period));
List<CellDataDto> cellDataDtoList = cellData.getData().getCellData();
if (cellDataDtoList.size() != 0) {
......@@ -1267,10 +1259,133 @@ public class ReportServiceImpl extends BaseService {
cellData.getData().setEbitData(ebitDataDto);
}
return cellData;
}*/
//获取profit_loss_statement_final表数据
ProfitLossStatementPrcExample example1 = new ProfitLossStatementPrcExample();
example1.createCriteria().andTmsPeriodEqualTo(period).andOrganizationIdEqualTo(orgId);
List<ProfitLossStatementPrc> profitLossStatements = profitLossStatementPrcMapper.selectByExample(example1);
EbitCellDataExample example = new EbitCellDataExample();
example.createCriteria().andOrganizationIdEqualTo(orgId).andPeriodEqualTo(period);
List<EbitCellData> ebitCellData = ebitCellDataMapper.selectByExample(example);
if (ebitCellData.size() != 0) {
cellData.getData().setEbitData(_getEbitData(ebitCellData));
cellData.getData().setCellData(converToCellData2(ebitCellData));
} else {
//如果有数据直接插入,如果没有则需要计算
cellData.getData().setCellData(convertToCellData(profitLossStatements));
cellData.getData().setEbitData(calculateEbitData(convertToCellData(profitLossStatements), specialConsideration, ebitRate));
}
return cellData;
}
//ebitData -> Celldata
private List<CellDataDto> converToCellData2(List<EbitCellData> ebitCellData) {
List<CellDataDto> list = new ArrayList<>();
CellDataDto cellDataDto = null;
for (EbitCellData ebitCellData1 : ebitCellData) {
cellDataDto = new CellDataDto();
cellDataDto.setCellValue(ebitCellData1.getData());
cellDataDto.setRowIndex(ebitCellData1.getRow());
cellDataDto.setColumnIndex(ebitCellData1.getCol());
list.add(cellDataDto);
}
return list;
}
//ProfitLossStatementPrc 转成 cellData
private List<CellDataDto> convertToCellData(List<ProfitLossStatementPrc> list) {
List<CellDataDto> list1 = Lists.newArrayList();
CellDataDto cellDataDto = null;
CellDataDto cellDataDto1 = null;
for (int i = 0; i < list.size(); i++) {
cellDataDto = new CellDataDto();
cellDataDto1 = new CellDataDto();
if (list.get(i).getItemName().equals(""))
continue;
cellDataDto.setCellValue(list.get(i).getYtdAmt() == null ? "" : list.get(i).getYtdAmt().toString());
cellDataDto1.setCellValue(list.get(i).getPeriodAmt() == null ? "" : list.get(i).getPeriodAmt().toString());
cellDataDto.setColumnIndex(2);
cellDataDto.setRowIndex(i + 11);
cellDataDto1.setColumnIndex(1);
cellDataDto1.setRowIndex(i + 11);
list1.add(cellDataDto);
list1.add(cellDataDto1);
}
return list1;
}
//ProfitLossStatement 转成 cellData
private List<EbitCellData> convertToEbitData(List<ProfitLossStatementPrc> list) {
List<EbitCellData> list1 = Lists.newArrayList();
EbitCellData ebit = null;
for (ProfitLossStatementPrc profitLossStatement : list) {
ebit = new EbitCellData();
switch (profitLossStatement.getItemName().trim()) {
case "一、营业收入":
ebit.setData(profitLossStatement.getYtdAmt().toString());
ebit.setCol(2);
ebit.setRow(11);
ebit.setOrganizationId(profitLossStatement.getOrganizationId());
ebit.setPeriod(profitLossStatement.getPeriod());
break;
case "减:营业成本":
ebit.setData(profitLossStatement.getYtdAmt().toString());
ebit.setCol(2);
ebit.setRow(12);
ebit.setOrganizationId(profitLossStatement.getOrganizationId());
ebit.setPeriod(profitLossStatement.getPeriod());
break;
case "营业税金及附加":
ebit.setData(profitLossStatement.getYtdAmt().toString());
ebit.setCol(2);
ebit.setRow(13);
ebit.setOrganizationId(profitLossStatement.getOrganizationId());
ebit.setPeriod(profitLossStatement.getPeriod());
break;
case "销售费用":
ebit.setData(profitLossStatement.getYtdAmt().toString());
ebit.setCol(2);
ebit.setRow(14);
ebit.setOrganizationId(profitLossStatement.getOrganizationId());
ebit.setPeriod(profitLossStatement.getPeriod());
break;
case "管理费用":
ebit.setData(profitLossStatement.getYtdAmt().toString());
ebit.setCol(2);
ebit.setRow(15);
ebit.setOrganizationId(profitLossStatement.getOrganizationId());
ebit.setPeriod(profitLossStatement.getPeriod());
break;
case "研发费用":
ebit.setData(profitLossStatement.getYtdAmt().toString());
ebit.setCol(2);
ebit.setRow(16);
ebit.setOrganizationId(profitLossStatement.getOrganizationId());
ebit.setPeriod(profitLossStatement.getPeriod());
break;
case "财务费用":
ebit.setData(profitLossStatement.getYtdAmt().toString());
ebit.setCol(2);
ebit.setRow(17);
ebit.setOrganizationId(profitLossStatement.getOrganizationId());
ebit.setPeriod(profitLossStatement.getPeriod());
break;
case "资产减值损失":
ebit.setData(profitLossStatement.getYtdAmt().toString());
ebit.setCol(2);
ebit.setRow(18);
ebit.setOrganizationId(profitLossStatement.getOrganizationId());
ebit.setPeriod(profitLossStatement.getPeriod());
break;
}
list1.add(ebit);
}
return list1;
}
private EbitDataDto _getEbitData(List<EbitCellData> ebitCellDataList) {
EbitDataDto ebitDataDto = new EbitDataDto();
for (EbitCellData ebitCellData : ebitCellDataList) {
......@@ -1303,8 +1418,7 @@ public class ReportServiceImpl extends BaseService {
continue;
}
if (ebitCellData.getCol() == 2 && ebitCellData.getRow() == 41) {
if ("".equals(ebitCellData.getData()))
{
if ("".equals(ebitCellData.getData())) {
ebitDataDto.setTransactionAmount(new BigDecimal(0));
continue;
}
......@@ -1464,7 +1578,6 @@ public class ReportServiceImpl extends BaseService {
} else {
dataSourceDto.setDataSourceType(0);
}
DataSourceDtoExtend dataSourceDtoExtend = new DataSourceDtoExtend();
dataSourceDtoExtend.setItem1(a.getCellTemplateId().toString());
dataSourceDtoExtend.setItem2(dataSourceDto);
......@@ -1536,6 +1649,7 @@ public class ReportServiceImpl extends BaseService {
}
}
});
modifiedReportCellList = null;
dataDto.setCellData(cellDataDtoList);
//将cellData复制给静态变量
resultDto.setData(dataDto);
......@@ -1544,6 +1658,7 @@ public class ReportServiceImpl extends BaseService {
logger.error(ex.getMessage(), ex);
resultDto.setResult(false);
}
System.gc();
return resultDto;
}
......@@ -2339,12 +2454,19 @@ public class ReportServiceImpl extends BaseService {
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
MultipartFile file = fileMap.get("llb.xlsx");
String fileName = orgId + period + "利润表";
EbitSpreadDataExample example = new EbitSpreadDataExample();
//注释的 是将ebit文件上传逻辑
/* EbitSpreadDataExample example = new EbitSpreadDataExample();
example.createCriteria().andPeriodEqualTo(period).andOrganizationIdEqualTo(orgId);
List<EbitSpreadData> ebitSpreadData1 = ebitSpreadDataMapper.selectByExample(example);
if (ebitSpreadData1.size() != 0) {
List<EbitSpreadData> ebitSpreadData1 = ebitSpreadDataMapper.selectByExample(example);*/
/*if (ebitSpreadData1.size() != 0) {
didiFileUploadService.delData(ebitSpreadData1.get(0).getFileKey());
ebitSpreadDataMapper.deleteByExample(example);
}*/
EbitCellDataExample exampleCellData = new EbitCellDataExample();
exampleCellData.createCriteria().andPeriodEqualTo(period).andOrganizationIdEqualTo(orgId);
if (ebitCellDataMapper.selectByExample(exampleCellData).size() != 0) {
ebitCellDataMapper.deleteByExample(exampleCellData);
}
InputStream inputStream = null;
try {
......@@ -2358,9 +2480,11 @@ public class ReportServiceImpl extends BaseService {
ebitCellDataMapper.deleteByExample(example1);
}
for (int j = 1; j <= sheet.getLastRowNum(); j++) {
if (j <= 36)
continue;
/* if (j <= 36)
continue;*/
for (int k = 1; k < sheet.getRow(0).getLastCellNum(); k++) {
if (k != 1 || k != 2)//这里只保存两列
continue;
EbitCellData ebitCellData1 = new EbitCellData();
ebitCellData1.setId(idService.nextId());
ebitCellData1.setOrganizationId(orgId);
......@@ -2372,20 +2496,24 @@ public class ReportServiceImpl extends BaseService {
ebitCellDataList.add(ebitCellData1);
}
}
if (ebitCellDataList.size() == 0) {
logger.warn("导入文件没有要插入的数据");
return operationResultDto.success();
}
ebitCellDataMapper.insertBatch(ebitCellDataList);
} catch (IOException e) {
e.printStackTrace();
} catch (InvalidFormatException e) {
e.printStackTrace();
}
FileUpload fileUpload = didiFileUploadService.uploadFile(file, fileName, "ebit利润表");
/* FileUpload fileUpload = didiFileUploadService.uploadFile(file, fileName, "ebit利润表");
EbitSpreadData ebitSpreadData = new EbitSpreadData();
ebitSpreadData.setPeriod(period);
ebitSpreadData.setOrganizationId(orgId);
ebitSpreadData.setFileKey(fileUpload.getUid());
ebitSpreadData.setFileName(fileName);
ebitSpreadData.setId(idService.nextId());
ebitSpreadDataMapper.insert(ebitSpreadData);
ebitSpreadDataMapper.insert(ebitSpreadData);*/
return operationResultDto.success();
}
......@@ -2402,20 +2530,121 @@ public class ReportServiceImpl extends BaseService {
@Autowired
TemplateServiceImpl templateService;
@Autowired
private JdbcTemplate jdbcTemplate;
/**
* 批量导出Excel ebit利润表
*
* @param requestParameterDto
*/
public void manyExport(RequestParameterDto requestParameterDto, HttpServletRequest request, HttpServletResponse response) throws Exception {
EbitSpreadDataExample example = new EbitSpreadDataExample();
/* EbitSpreadDataExample example = new EbitSpreadDataExample();
example.createCriteria().andPeriodEqualTo(requestParameterDto.getPeriod());
List<EbitSpreadData> ebitSpreadData = ebitSpreadDataMapper.selectByExample(example);
Workbook workbook1 = null;
List<EbitSpreadData> ebitSpreadData = ebitSpreadDataMapper.selectByExample(example);*/
String filePath;
File templateFile;
InputStream inputStream = null;
TemplateExample templateExample = new TemplateExample();
templateExample.createCriteria().andCodeEqualTo("VAT10086").andNameEqualTo("VAT10086");//todo 这里是利润表模板的固定code,禁止重复
List<Template> templates1 = templateMapper.selectByExample(templateExample);
if (templates1.size() == 0)
throw new Exception("没有利润表模板,无法批量导出,请上传模板");
MyAsserts.assertNotEmpty(templates1, new NotFoundException());
Template template = templates1.get(0);
String templatePath = template.getPath();
MyAsserts.assertNotEmpty(templatePath, new NotFoundException());
filePath = this.getClass().getResource("").toURI().getPath();
String tempPath = filePath.substring(0, filePath.indexOf("classes") + "\\classes".length());
templateFile = new File(tempPath + templatePath);
XSSFWorkbook workbook1 = null;
Sheet sheetAt = null;
if (ebitSpreadData.size() == 0)
throw new Exception("没有可导出的数据");
for (int i = 0; i < ebitSpreadData.size(); i++) {
if (template.getIsSystemType()) {
inputStream = new BufferedInputStream(new FileInputStream(templateFile));
} else {
if (templatePath.indexOf("/") <= 0) {
DidiFileIUploadParam fileParam = new DidiFileIUploadParam();
fileParam.setUuids(Arrays.asList(templatePath));
PageInfo<DidiFileUploadDetailResult> uploadDetail = didiFileUploadService.queryPage(fileParam);
Map<String, String> urlMap = null;
if (CollectionUtils.isNotEmpty(uploadDetail.getList())) {
templatePath = uploadDetail.getList().get(0).getViewHttpUrl();
}
}
inputStream = httpFileService.getUserTemplate(templatePath);
}
ProfitLossStatementPrcExample profitLossStatementExample = new ProfitLossStatementPrcExample();
profitLossStatementExample.createCriteria().andPeriodEqualTo(requestParameterDto.getPeriod());
List<ProfitLossStatementPrc> profitLossStatements2 = profitLossStatementPrcMapper.selectByExample(profitLossStatementExample);
Map<String, List<ProfitLossStatementPrc>> collect2 = profitLossStatements2.stream().collect(Collectors.groupingBy(ProfitLossStatementPrc::getOrganizationId));
EbitCellDataExample cellDataExample = new EbitCellDataExample();
cellDataExample.createCriteria().andPeriodEqualTo(requestParameterDto.getPeriod());
List<EbitCellData> list2 = ebitCellDataMapper.selectByExample(cellDataExample);
Map<String, List<EbitCellData>> collect1 = list2.stream().collect(Collectors.groupingBy(EbitCellData::getOrganizationId));
Map<String, List<ProfitLossStatementPrc>> newMap = new HashMap<>();
///如果ebitCellData 中已经存在当前机构的数,将取 ebit中,否则取利润表中
for (Map.Entry<String, List<EbitCellData>> entry1 : collect1.entrySet()) {
for (Map.Entry<String, List<ProfitLossStatementPrc>> entry2 : collect2.entrySet()) {
/*System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());*/
if (entry2.getKey() == entry1.getKey())
continue;
newMap.put(entry2.getKey(), entry2.getValue());
}
}
Map<String, List<EbitCellData>> _newMap = new HashMap<>();
for (Map.Entry<String, List<ProfitLossStatementPrc>> entry : newMap.entrySet()) {
_newMap.put(entry.getKey(), convertToEbitData(entry.getValue()));
}
Map<String, List<EbitCellData>> finalMap = new HashMap<>();
finalMap.putAll(_newMap);
finalMap.putAll(collect1);
int _index = 0;
workbook1 = new XSSFWorkbook(inputStream);
sheetAt = workbook1.getSheetAt(0);
List<Integer> cols = Lists.newArrayList();
FileExcelUtil.deleteColumn(sheetAt, 1, cols);
for (Map.Entry<String, List<EbitCellData>> entry : finalMap.entrySet()) {
for (int m = 0; m < sheetAt.getLastRowNum(); m++) {
switch (m) {
case 7:
try{
sheetAt.getRow(m).getCell(_index + 1).setCellValue(getOrgName(entry.getKey()));
}catch (Exception e){
sheetAt.createRow(m).createCell(_index + 1).setCellValue(getOrgName(entry.getKey()));
}
break;
case 8:
try {
sheetAt.getRow(m).getCell(_index + 1).setCellValue("本年累计");
} catch (Exception ex) {
sheetAt.getRow(m).createCell(_index + 1).setCellValue("本年累计");
}
break;
default:
if (_index == 0 && m <= 10)
break;
if (sheetAt.getRow(m) != null && sheetAt.getRow(m).getCell(_index + 1) != null) {
for (EbitCellData ebitCellData : entry.getValue()) {
if (m == ebitCellData.getRow() && ebitCellData.getCol() == (_index + 1)) {
try{
sheetAt.getRow(m).getCell(_index + 1).setCellValue(ebitCellData.getData());
}catch (Exception e){
sheetAt.getRow(m).createCell(_index + 1).setCellValue(ebitCellData.getData());
}
}
}
}
//cell.setCellType(cellStyle.getAlignment());
}
}
_index++;
}
/* for (int i = 0; i < ebitSpreadData.size(); i++) {
DidiFileIUploadParam fileParam = new DidiFileIUploadParam();
fileParam.setUuids(Arrays.asList(ebitSpreadData.get(i).getFileKey()));
PageInfo<DidiFileUploadDetailResult> uploadDetail = didiFileUploadService.queryPage(fileParam);
......@@ -2424,60 +2653,121 @@ public class ReportServiceImpl extends BaseService {
path = uploadDetail.getList().get(0).getViewHttpUrl();
}
InputStream inputStream = httpFileService.getUserTemplate(path);
if (i == 0) {
workbook1 = WorkbookFactory.create(inputStream);
sheetAt = workbook1.getSheetAt(0);
List<Integer> cols = Lists.newArrayList();
FileExcelUtil.deleteColumn(sheetAt, 1, cols);
}*/
/* if (sheetAt == null) {
String filePath;
File templateFile;
Template template = templateService.getTemplateById(Long.parseLong(requestParameterDto.getTemplateId()));
String templatePath = templateService.getTemplatePath(Long.parseLong(requestParameterDto.getTemplateId()));
MyAsserts.assertNotEmpty(templatePath, new NotFoundException());
filePath = this.getClass().getResource("").toURI().getPath();
String tempPath = filePath.substring(0, filePath.indexOf("classes") + "\\classes".length());
templateFile = new File(tempPath + templatePath);
InputStream inputStream = null;
//如果是系统报表就取本地文件夹,如果不是就取FTP
if (template.getIsSystemType()) {
inputStream = new BufferedInputStream(new FileInputStream(templateFile));
} else {
Workbook workbook2 = WorkbookFactory.create(inputStream);
Sheet sheetAt1 = workbook2.getSheetAt(0);
for (int m = 0; m < sheetAt1.getLastRowNum(); m++) {
switch (m) {
case 6:
sheetAt.getRow(m).getCell(i + 1).setCellValue(getOrgName(ebitSpreadData.get(i).getOrganizationId()));
break;
case 8:
sheetAt.getRow(m).getCell(i + 1).setCellValue("本年累计");
break;
default:
if (i == 0)
break;
Cell cell = sheetAt.getRow(m).getCell(i + 1);
cell.setCellValue(getCellStringValue(sheetAt1.getRow(m).getCell(2)));
cell.setCellFormula("B2 + C3");
//cell.setCellType(cellStyle.getAlignment());
}
}
inputStream = httpFileService.getUserTemplate(templatePath);
}
}
insertExcelOne(sheetAt, ebitSpreadData, workbook1);
workbook1 = new XSSFWorkbook(inputStream);
sheetAt = workbook1.getSheetAt(0);
List<Integer> cols = Lists.newArrayList();
FileExcelUtil.deleteColumn(sheetAt, 1, cols);
}*/
//加载所有当前期间所有利润的数据
/* insertData(requestParameterDto.getTemplateId(), requestParameterDto.getPeriod(), sheetAt, index);*/
//insertExcelOne(sheetAt, ebitSpreadData, workbook1, requestParameterDto.getPeriod());
FileExcelUtil.setExcelHeadInfo(response, request, requestParameterDto.getPeriod() + "-汇总利润表.xlsx");
FileExcelUtil.downloadExcel(request, response, requestParameterDto.getPeriod() + "-汇总利润表.xlsx", workbook1);
//将workbook转成流
/* ByteArrayOutputStream bos = new ByteArrayOutputStream();
workbook.write(bos);
byte[] barray = bos.toByteArray();
InputStream is = new ByteArrayInputStream(barray);*/
// FileOutputStream fileOut = new FileOutputStream(path);
}
public void insertExcelOne(Sheet sheetAt, List<EbitSpreadData> spreadData, Workbook workbook) {
CellStyle style1 = workbook.createCellStyle();
style1.setFillBackgroundColor(IndexedColors.YELLOW.getIndex());
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:MM:ss");
}
/* public void insertData(String templateId, Integer period, Sheet sheet, int beginCell) {
List<Project> projects = projectMapper.selectByExample(example1);
for (EbitCell project : ebitCellData) {
String projectId = getProjId(project.getOrganizationId(), period);
List<CellDataDto> list = getCellData(getReportByTemplateEbit(Long.parseLong(templateId), period % 100, projectId).getData().getId(), projectId).getData().getCellData();
if (list.size() == 0)
return;
EbitDataDto ebitDataDto = calculateEbitData(list, specialConsideration, ebitRate);
for (CellDataDto cellDataDto : list) {
if (cellDataDto.getColumnIndex() == 2 && cellDataDto.getRowIndex() > 10)
sheet.getRow(cellDataDto.getRowIndex()).getCell(beginCell).setCellValue(cellDataDto.getCellValue());
}
for (int i = 37; i < 43; i++) {
if (i == 37) {
sheet.getRow(i).getCell(beginCell).setCellValue(ebitDataDto.getEbitSubtraction().toString());
sheet.getRow(i).getCell(beginCell).setCellFormula(LetterExcelUtil.NumToExcel(beginCell) + "11 - " +
LetterExcelUtil.NumToExcel(beginCell) + "12 -" +
LetterExcelUtil.NumToExcel(beginCell) + "13 -" +
LetterExcelUtil.NumToExcel(beginCell) + "14 -" +
LetterExcelUtil.NumToExcel(beginCell) + "15 -" +
LetterExcelUtil.NumToExcel(beginCell) + "16 -" +
LetterExcelUtil.NumToExcel(beginCell) + "18");
continue;
}
if (i == 38) {
sheet.getRow(i).getCell(beginCell).setCellValue(ebitDataDto.getSpecialConsiderations());
continue;
}
if (i == 39) {
sheet.getRow(i).getCell(beginCell).setCellValue(ebitDataDto.getEbitRate());
sheet.getRow(i).getCell(beginCell).setCellFormula(LetterExcelUtil.NumToExcel(beginCell) + "37 + " + LetterExcelUtil.NumToExcel(beginCell) + "38");
continue;
}
if (i == 40) {
sheet.getRow(i).getCell(beginCell).setCellValue(ebitDataDto.getTransactionAmount().toString());
continue;
}
if (i == 41) {
sheet.getRow(i).getCell(beginCell).setCellValue(ebitDataDto.getSixAddTax().toString());
sheet.getRow(i).getCell(beginCell).setCellFormula(LetterExcelUtil.NumToExcel(beginCell) + "39 * " + LetterExcelUtil.NumToExcel(beginCell) + "40");
}
if (i == 42) {
sheet.getRow(i).getCell(beginCell).setCellValue(ebitDataDto.getTotalAmountTax().toString());
sheet.getRow(i).getCell(beginCell).setCellFormula(LetterExcelUtil.NumToExcel(beginCell) + "41 * 6%");
continue;
}
if (i == 43) {
sheet.getRow(i).getCell(beginCell).setCellValue(ebitDataDto.getEbitSubtraction().toString());
sheet.getRow(i).getCell(beginCell).setCellFormula(LetterExcelUtil.NumToExcel(beginCell) + "41 * 1.06");
continue;
}
}
sheet.getRow(8).getCell(1).setCellValue("本年累计");
sheet.getRow(6).getCell(1).setCellValue(getOrgName(project.getOrganizationId()));
beginCell++;
}
}*/
public void insertExcelOne(Sheet sheetAt, List<EbitSpreadData> spreadData, XSSFWorkbook workbook, Integer period) {
XSSFCellStyle cellStyle = workbook.createCellStyle();
XSSFFont font = workbook.createFont();
font.setFontHeight(20);
font.setBold(true);
cellStyle.setAlignment(HorizontalAlignment.CENTER);// 设置居中
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
cellStyle.setFont(font);
if (spreadData.size() != 0) {
sheetAt.getRow(6).getCell(1).setCellValue(getOrgName(spreadData.get(0).getOrganizationId()));
}
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
sheetAt.getRow(8).getCell(1).setCellValue("本年累计");
sheetAt.getRow(6).getCell(1).setCellValue(getOrgName(spreadData.get(0).getOrganizationId()));
sheetAt.getRow(0).getCell(4).setCellValue("日期:" + format.format(new Date()));
sheetAt.getRow(0).createCell(4).setCellValue("日期:" + format.format(new Date()));
for (int m = 0; m < 3; m++) {
FileExcelUtil.cloneCell(sheetAt.getRow(m).getCell(2), sheetAt.getRow(m).getCell(1));
sheetAt.getRow(m).getCell(3).setCellValue("");
sheetAt.getRow(m).getCell(1).setCellValue("");
if (sheetAt.getRow(m) == null)
continue;
}
style1.setFillBackgroundColor(IndexedColors.YELLOW.getIndex());
sheetAt.getRow(2).getCell(2).setCellStyle(style1);
sheetAt.getRow(2).getCell(2).setCellValue("本期:" + spreadData.get(0).getPeriod());
sheetAt.createRow(2).createCell(3).setCellValue("本期" + period);
POIStyleUtil.setCellBackgroundColor(workbook, sheetAt.createRow(2).createCell(3), new XSSFColor(java.awt.Color.YELLOW));//设置背景颜色
sheetAt.getRow(0).getCell(1).setCellValue("");
sheetAt.getRow(0).createCell(3).setCellValue("利润表汇总");
sheetAt.getRow(0).getCell(3).setCellStyle(cellStyle);
}
public String getCellStringValue(Cell cell) {
......@@ -2486,7 +2776,7 @@ public class ReportServiceImpl extends BaseService {
case HSSFCell.CELL_TYPE_STRING://字符串类型
cellValue = cell.getStringCellValue();
if (cellValue.trim().equals("") || cellValue.trim().length() <= 0)
cellValue = " ";
cellValue = "";
break;
case HSSFCell.CELL_TYPE_NUMERIC: //数值类型
cellValue = String.valueOf(cell.getNumericCellValue());
......@@ -2514,12 +2804,12 @@ public class ReportServiceImpl extends BaseService {
public String getOrgName(String orgId) {
OrganizationExample example = new OrganizationExample();
example.createCriteria().andIdEqualTo(orgId);
return organizationMapper.selectByExample(example).get(0).getName();
List<Organization> organizations = organizationMapper.selectByExample(example);
if (organizations.size() != 0)
return organizations.get(0).getName();
return "";
}
@Autowired
private JdbcTemplate jdbcTemplate;
//获取利润表模板Id 利润表固定模板VAT10086
public String getlxbId() throws Exception {
try {
......
......@@ -41,7 +41,7 @@
<property name="rootInterface" value="pwc.taxtech.atms.MyAnalysisMapper" />
</javaClientGenerator>
<table tableName="analysis_international_business_data" domainObjectName="AnalysisInternationalBusinessData">
<table tableName="analysis_employee_num" domainObjectName="AnalysisEmployeeNum">
<property name="useActualColumnNames" value="false"/>
<property name="ignoreQualifiersAtRuntime" value="true"/>
</table>
......
......@@ -105,4 +105,6 @@ public interface AnalysisSalesMapper extends MyAnalysisMapper {
* @mbg.generated
*/
int updateByPrimaryKey(AnalysisSales record);
int insertBatch(List<AnalysisSales> salesList);
}
\ No newline at end of file
......@@ -105,4 +105,6 @@ public interface AnalysisTaxMapper extends MyAnalysisMapper {
* @mbg.generated
*/
int updateByPrimaryKey(AnalysisTax record);
int insertBatch(List<AnalysisTax> taxList);
}
\ No newline at end of file
......@@ -222,6 +222,16 @@ public class AnalysisSales extends BaseEntity implements Serializable {
*/
private BigDecimal segment17;
public BigDecimal getSegment18() {
return segment18;
}
public void setSegment18(BigDecimal segment18) {
this.segment18 = segment18;
}
private BigDecimal segment18;
/**
* Database Column Remarks:
* 创建时间
......@@ -863,35 +873,32 @@ public class AnalysisSales extends BaseEntity implements Serializable {
*/
@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(", seqNo=").append(seqNo);
sb.append(", segment1=").append(segment1);
sb.append(", segment2=").append(segment2);
sb.append(", segment3=").append(segment3);
sb.append(", segment4=").append(segment4);
sb.append(", segment5=").append(segment5);
sb.append(", segment6=").append(segment6);
sb.append(", segment7=").append(segment7);
sb.append(", segment8=").append(segment8);
sb.append(", segment9=").append(segment9);
sb.append(", segment10=").append(segment10);
sb.append(", segment11=").append(segment11);
sb.append(", segment12=").append(segment12);
sb.append(", segment13=").append(segment13);
sb.append(", segment14=").append(segment14);
sb.append(", segment15=").append(segment15);
sb.append(", segment16=").append(segment16);
sb.append(", segment17=").append(segment17);
sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", organizationId=").append(organizationId);
sb.append(", companyName=").append(companyName);
sb.append(", period=").append(period);
sb.append("]");
return sb.toString();
return "AnalysisSales{" +
"id=" + id +
", seqNo='" + seqNo + '\'' +
", segment1=" + segment1 +
", segment2=" + segment2 +
", segment3=" + segment3 +
", segment4=" + segment4 +
", segment5=" + segment5 +
", segment6=" + segment6 +
", segment7=" + segment7 +
", segment8=" + segment8 +
", segment9=" + segment9 +
", segment10=" + segment10 +
", segment11=" + segment11 +
", segment12=" + segment12 +
", segment13=" + segment13 +
", segment14=" + segment14 +
", segment15=" + segment15 +
", segment16=" + segment16 +
", segment17=" + segment17 +
", segment18=" + segment18 +
", createTime=" + createTime +
", updateTime=" + updateTime +
", organizationId='" + organizationId + '\'' +
", companyName='" + companyName + '\'' +
", period=" + period +
'}';
}
}
\ No newline at end of file
......@@ -10,13 +10,21 @@ public class ProjectAnaylsisDto {
private String reportId;
private String projectId;
private Integer period;
private String orgId;
private String templateName;
private String serviceTypeId;
public Integer getPeriod() {
return period;
}
public void setPeriod(Integer period) {
this.period = period;
}
public String getReportId() {
return reportId;
}
......
......@@ -6,8 +6,7 @@
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="seq_no" jdbcType="VARCHAR" property="seqNo" />
<result column="segment_1" jdbcType="DECIMAL" property="segment1" />
<result column="segment_2" jdbcType="DECIMAL" property="segment2" />
<result column="segment_3" jdbcType="DECIMAL" property="segment3" />
......@@ -25,6 +24,7 @@
<result column="segment_15" jdbcType="DECIMAL" property="segment15" />
<result column="segment_16" jdbcType="DECIMAL" property="segment16" />
<result column="segment_17" jdbcType="DECIMAL" property="segment17" />
<result column="segment_18" jdbcType="DECIMAL" property="segment18"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="organization_id" jdbcType="VARCHAR" property="organizationId" />
......@@ -104,7 +104,7 @@
-->
id, seq_no, segment_1, segment_2, segment_3, segment_4, segment_5, segment_6, segment_7,
segment_8, segment_9, segment_10, segment_11, segment_12, segment_13, segment_14,
segment_15, segment_16, segment_17, create_time, update_time, organization_id, company_name,
segment_15, segment_16, segment_17, segment_18, create_time, update_time, organization_id, company_name,
period
</sql>
<select id="selectByExample" parameterType="pwc.taxtech.atms.analysis.entity.AnalysisSalesExample" resultMap="BaseResultMap">
......@@ -173,7 +173,7 @@
#{segment8,jdbcType=DECIMAL}, #{segment9,jdbcType=DECIMAL}, #{segment10,jdbcType=DECIMAL},
#{segment11,jdbcType=DECIMAL}, #{segment12,jdbcType=DECIMAL}, #{segment13,jdbcType=DECIMAL},
#{segment14,jdbcType=DECIMAL}, #{segment15,jdbcType=DECIMAL}, #{segment16,jdbcType=DECIMAL},
#{segment17,jdbcType=DECIMAL}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{segment17,jdbcType=DECIMAL},#{segment17,jdbcType=DECIMAL}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{organizationId,jdbcType=VARCHAR}, #{companyName,jdbcType=VARCHAR}, #{period,jdbcType=INTEGER}
)
</insert>
......
......@@ -351,4 +351,52 @@
order by ${orderByClause}
</if>
</select>
<insert id="insertBatch" parameterType="java.util.List">
insert into analysis_tax
(<include refid="Base_Column_List"/>)
values
<foreach collection="list" item="item" index="index" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=",">
<choose>
<when test="item.id != null">#{item.id,jdbcType=BIGINT},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.organizationId != null">#{item.organizationId,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.companyName != null">#{item.companyName,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.period != null">#{item.period,jdbcType=INTEGER} ,</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.seqNo != null">#{item.seqNo,jdbcType=VARCHAR},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.taxGroup != null">#{item.taxGroup,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.taxAmount != null">#{item.taxAmount,jdbcType=DECIMAL},</when>
<otherwise>0.000,</otherwise>
</choose>
<choose>
<when test="item.createTime != null">#{item.createTime,jdbcType=TIMESTAMP},</when>
<otherwise>CURRENT_TIMESTAMP,</otherwise>
</choose>
<choose>
<when test="item.updateTime != null">#{item.updateTime,jdbcType=TIMESTAMP},</when>
<otherwise>CURRENT_TIMESTAMP,</otherwise>
</choose>
</trim>
</foreach>;
SELECT 1 FROM DUAL;
</insert>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="pwc.taxtech.atms.analysis.dao.AnalysisSalesMapper">
<insert id="insertBatch" parameterType="java.util.List">
insert into analysis_sales
(<include refid="Base_Column_List"/>)
values
<foreach collection="list" item="item" index="index" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=",">
<choose>
<when test="item.id != null">#{item.id,jdbcType=BIGINT},</when>
<otherwise>0,</otherwise>
</choose>
<choose>
<when test="item.seqNo != null">#{item.seqNo,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.segment1 != null">#{item.segment1,jdbcType=DECIMAL},</when>
<otherwise>0.0000,</otherwise>
</choose>
<choose>
<when test="item.segment2 != null">#{item.segment2,jdbcType=DECIMAL},</when>
<otherwise>0.0000,</otherwise>
</choose>
<choose>
<when test="item.segment3 != null">#{item.segment3,jdbcType=DECIMAL},</when>
<otherwise>0.0000,</otherwise>
</choose>
<choose>
<when test="item.segment4 != null">#{item.segment4,jdbcType=DECIMAL},</when>
<otherwise>0.0000,</otherwise>
</choose>
<choose>
<when test="item.segment5 != null">#{item.segment5,jdbcType=DECIMAL},</when>
<otherwise>0.0000,</otherwise>
</choose>
<choose>
<when test="item.segment6 != null">#{item.segment6,jdbcType=DECIMAL},</when>
<otherwise>0.0000,</otherwise>
</choose>
<choose>
<when test="item.segment7 != null">#{item.segment7,jdbcType=DECIMAL},</when>
<otherwise>0.0000,</otherwise>
</choose>
<choose>
<when test="item.segment8 != null">#{item.segment8,jdbcType=DECIMAL},</when>
<otherwise>0.0000,</otherwise>
</choose>
<choose>
<when test="item.segment9 != null">#{item.segment9,jdbcType=DECIMAL},</when>
<otherwise>0.0000,</otherwise>
</choose>
<choose>
<when test="item.segment10 != null">#{item.segment10,jdbcType=DECIMAL},</when>
<otherwise>0.0000,</otherwise>
</choose>
<choose>
<when test="item.segment11 != null">#{item.segmen11,jdbcType=DECIMAL},</when>
<otherwise>0.0000,</otherwise>
</choose>
<choose>
<when test="item.segment12 != null">#{item.segment12,jdbcType=DECIMAL},</when>
<otherwise>0.0000,</otherwise>
</choose> <choose>
<when test="item.segment13 != null">#{item.segment13,jdbcType=DECIMAL},</when>
<otherwise>0.0000,</otherwise>
</choose>
<choose>
<when test="item.segment14 != null">#{item.segment14,jdbcType=DECIMAL},</when>
<otherwise>0.0000,</otherwise>
</choose>
<choose>
<when test="item.segment15 != null">#{item.segment15,jdbcType=DECIMAL},</when>
<otherwise>0.0000,</otherwise>
</choose>
<choose>
<when test="item.segment16 != null">#{item.segment16,jdbcType=DECIMAL},</when>
<otherwise>0.0000,</otherwise>
</choose>
<choose>
<when test="item.segment17 != null">#{item.segment17,jdbcType=DECIMAL},</when>
<otherwise>0.0000,</otherwise>
</choose>
<choose>
<when test="item.segment18 != null">#{item.segment18,jdbcType=DECIMAL},</when>
<otherwise>0.0000,</otherwise>
</choose>
<choose>
<when test="item.createTime != null">#{item.createTime,jdbcType=TIMESTAMP},</when>
<otherwise>CURRENT_TIMESTAMP,</otherwise>
</choose>
<choose>
<when test="item.updateTime != null">#{item.updateTime,jdbcType=TIMESTAMP},</when>
<otherwise>CURRENT_TIMESTAMP,</otherwise>
</choose>
<choose>
<when test="item.organizationId != null">#{item.organizationId,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.companyName != null">#{item.companyName,jdbcType=VARCHAR},</when>
<otherwise>'',</otherwise>
</choose>
<choose>
<when test="item.period != null">#{item.period,jdbcType=INTEGER} ,</when>
<otherwise>0,</otherwise>
</choose>
</trim>
</foreach>;
SELECT 1 FROM DUAL;
</insert>
</mapper>
......@@ -3,7 +3,8 @@
<mapper namespace="pwc.taxtech.atms.dao.ProjectMapper">
<select id="getTemlateWithServiceType" resultType="pwc.taxtech.atms.dpo.ProjectAnaylsisDto">
select pp.id as reportId,p.id as projectId,p.organization_id as orgId,pst.service_type_id,t.name as templateName
select pp.id as reportId,p.id as projectId,p.organization_id as orgId,pst.service_type_id,t.name as templateName,
pp.period as period
from period_report pp
left join project p on
pp.project_id = p.id
......@@ -46,4 +47,7 @@
</select>
</mapper>
\ No newline at end of file
......@@ -1322,9 +1322,7 @@
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from journal_entry
<if test="_parameter != null">
......
......@@ -2286,7 +2286,7 @@
"Country": "国家",
"Company": "公司",
"CompanySimpleName": "公司简称",
"SaveAnalysisData" : "是否保留原始数据?",
"DriverType": "司机类型",
"FileExportSuccess": "文件下载成功!",
"FileExportFailed": "文件下载失败!",
......
......@@ -648,8 +648,8 @@
case 101:
$scope.showInternationalTaxDataGrid = true;
loadInternationalTaxDataGrid();
/* $scope.selectCountry = '';
$scope.selectCompany = '';*/
/* $scope.selectCountry = '';
$scope.selectCompany = '';*/
break;
default:
break;
......@@ -678,19 +678,89 @@
$scope.selectCountry = e.currentTarget[clickedIndex].value;
});
var initContryList = function(){
var initContryList = function () {
var joinText = "";
if(constant.countryCNList){
for(var i =0; i< constant.countryCNList.length; i++){
joinText += "<option value =" + constant.countryCNList[i]+ " style ='text-align: left;' >" + constant.countryCNList[i] + "</option>";
if (constant.countryCNList) {
for (var i = 0; i < constant.countryCNList.length; i++) {
joinText += "<option value =" + constant.countryCNList[i] + " style ='text-align: left;' >" + constant.countryCNList[i] + "</option>";
}
$('#contryList').html(joinText);
$('#contryList').selectpicker('refresh');
}
};
$('#orgList').on('shown.bs.select', function(){
$('#orgList').on('shown.bs.select', function () {
$(this).find('.dropdown-menu').width("200px");
});
$scope.analysisInitData = function () {
SweetAlert.swal({
title: $translate.instant('WarningTitle'),
text: $translate.instant('SaveAnalysisData'),
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: $translate.instant('ConfirmYes'),
cancelButtonText: $translate.instant('No'),
closeOnConfirm: true,
showCloseButton : true
}, function (isConfirm) {
var type = 1;//默认保留原始数据
if (isConfirm) {
type = 1;
vatImportService.analysisInitData(type).success(function (res) {
if (res.resultMsg) {
SweetAlert.success("分析数据初始化成功!" + '消耗' + Number(res.resultMsg / 1000) + "秒");
}
}).error(function (error) {
SweetAlert.error(error);
});
} else if (isConfirm == false) {
type = 0;
vatImportService.analysisInitData(type).success(function (res) {
if (res.resultMsg) {
SweetAlert.success("分析数据初始化成功!" + '消耗' + Number(res.resultMsg / 1000) + "秒");
}
}).error(function (error) {
SweetAlert.error(error);
});
}
});
};
$scope.handleAnalysisData = function () {
SweetAlert.swal({
title: $translate.instant('WarningTitle'),
text: $translate.instant('SaveAnalysisData'),
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: $translate.instant('ConfirmYes'),
cancelButtonText: $translate.instant('No'),
closeOnConfirm: true,
showCloseButton : true
}, function (isConfirm) {
var type = 1;//默认保留原始数据
if (isConfirm) {
type = 1;
vatImportService.handleAnalysisData(type).success(function (res) {
if (res.resultMsg) {
SweetAlert.success("手动加载分析模块数据成功!" + '消耗' + Number(res.resultMsg) + "秒");
}
}).error(function (error) {
SweetAlert.error(error);
});
} else if (isConfirm == false) {
type = 0;
vatImportService.handleAnalysisData(type).success(function (res) {
if (res.resultMsg) {
SweetAlert.success("手动加载分析模块数据成功!" + '消耗' + Number(res.resultMsg) + "秒");
}
}).error(function (error) {
SweetAlert.error(error);
});
}
});
};
/*------------------------------------------------------------------------------------------------------------*/
//开始
......
......@@ -121,7 +121,15 @@
</div>
</div>
</form>
<div class="row">
<button type="button"
class="btn btn-vat-primary col-sm-2" style="margin-left: 20px!important; margin-top: 10px!important;display: none;"
ng-click="analysisInitData()">数据初始化</button>
<div class=""></div>
<button type="button"
class="btn btn-vat-primary col-sm-2" style="margin-left: 20px!important; margin-top: 10px!important; display: none;"
ng-click="handleAnalysisData()">(手动)加载按分析模块数据</button>
</div>
<div class="dt-init-wrapper">
<div class="dx-viewport grid-container">
<div id="internationalBUDataGridContainer" dx-data-grid="internationalBUDataGridOptions"
......
......@@ -1104,7 +1104,7 @@
$scope.relation.loadSheet($scope.templateId);
return;
}
vatReportService.getReportEbitData($scope.reportId, $scope.relation.orgId, period != undefined ? period : ($scope.relation.period == undefined ? period : $scope.relation.period)).success(function (reportData) {
vatReportService.getReportEbitData( $scope.relation.orgId, period != undefined ? period : ($scope.relation.period == undefined ? period : $scope.relation.period)).success(function (reportData) {
if (reportData && reportData.data) {
_.each(reportData.data.cellData, function (x) {
x.value = x.cellValue;
......@@ -1112,13 +1112,9 @@
});
$scope.relation.data = reportData.data.ebitData;
$scope.reportData = reportData.data.cellData;
$scope.formulaBlocks = reportData.data.formulaBlocks;
$scope.manualDataSources = reportData.data.manualDataSources;
$scope.relation.loadSheet($scope.templateId);
} else {
$scope.reportData = [];
$scope.formulaBlocks = [];
$scope.manualDataSources = [];
$scope.relation.data = [];
$scope.relation.loadSheet($scope.templateId);
}
......@@ -1129,7 +1125,7 @@
//period = Number(period);
if ($scope.templateId !== undefined) {
//todo: according to templateId and period get reportId
period = Number(period);//转成Number类型
/*period = Number(period);//转成Number类型
vatReportService.getReportByTemplateIdEbit($scope.templateId, period, orgId).success(function (report) {
if (report.data) {
$scope.reportId = report.data.id;
......@@ -1139,7 +1135,8 @@
$scope.manualDataSources = [];
}
getReportData(period);
});
});*/
getReportData(period);
}
};
$scope.periodChange = function (data) {
......@@ -3090,10 +3087,9 @@
$scope.relation.addEbitRow(sheet);
calculateEbitAndInsert(sheet, true);
$scope.relation.lockCell($scope.spread);
$('#busy-indicator-container').hide();
//关闭弹出层
spreadTODb(true);
$('#busy-indicator-container').hide();
spreadTODb();
}, function (e) {
alert(e.errorMessage);
if (e.errorCode === 2/*noPassword*/ || e.errorCode === 3 /*invalidPassword*/) {
......@@ -3148,6 +3144,7 @@
sheet.setValue(42, 2, $scope._ebitResult.sixAddtax);
sheet.setValue(43, 2, $scope._ebitResult.klzcjsz);
}
}
$scope.singleExport = function () {
......@@ -3174,6 +3171,7 @@
var param = {
period: $scope.relation.period,
templateId: $scope.templateId
}
/* $timeout(function () {
......
webservices.factory('vatImportService', ['$http', 'apiConfig', 'vatSessionService','FileSaver', function ($http, apiConfig, vatSessionService,FileSaver) {
webservices.factory('vatImportService', ['$http', 'apiConfig', 'vatSessionService', 'FileSaver', function ($http, apiConfig, vatSessionService, FileSaver) {
'use strict';
return {
sample: function () {
......@@ -7,7 +7,7 @@
/************************************************input invoice*********************************************************/
importInputInvoiceData: function (inputInvoiceList, importType) {
return $http.post('/inputInvoiceImport/importInputInvoice',
{ InputInvoiceList: inputInvoiceList, ImportType: importType }, apiConfig.createVat());
{InputInvoiceList: inputInvoiceList, ImportType: importType}, apiConfig.createVat());
},
getInputInvoiceList: function (period) {
return $http.get('/inputInvoiceImport/getInputInvoiceList/' + period, apiConfig.createVat());
......@@ -25,7 +25,7 @@
/************************************************input invoice item*********************************************************/
importInputInvoiceItemData: function (inputInvoiceItemList, importType) {
return $http.post('/inputInvoiceImport/importInputInvoiceItem',
{ InputInvoiceItemList: inputInvoiceItemList, ImportType: importType }, apiConfig.createVat());
{InputInvoiceItemList: inputInvoiceItemList, ImportType: importType}, apiConfig.createVat());
},
getInputInvoiceItemList: function (period) {
return $http.get('/inputInvoiceImport/getInputInvoiceItemList/' + period, apiConfig.createVat());
......@@ -39,7 +39,10 @@
/************************************************journal entry*********************************************************/
importJournalEntryData: function (journalEntryList, importType) {
return $http.post('/journalEntryImport/importJournalEntry', { VoucherList: journalEntryList, ImportType: importType }, apiConfig.createVat());
return $http.post('/journalEntryImport/importJournalEntry', {
VoucherList: journalEntryList,
ImportType: importType
}, apiConfig.createVat());
},
getValidationDtoInfo: function (type, period) {
return $http.get('/journalEntryImport/getValidationInfo/' + type + '/' + period, apiConfig.createVat());
......@@ -55,7 +58,7 @@
}, apiConfig.createVat());
},
deleteAdjustAudit: function (deleteDto){
deleteAdjustAudit: function (deleteDto) {
return $http.post('/journalEntryImport/deleteAdjustAudit',
{
ServiceTypeId: deleteDto.serviceTypeId,
......@@ -73,10 +76,13 @@
return $http.get('/journalEntryImport/clearJournalEntryData/' + period, apiConfig.createVat());
},
//auditAdjust
ImportAuditAdjust: function (list, period, importType) {
return $http.post('/journalEntryImport/importAuditAdjust/' + period, { VoucherList: list, ImportType: importType }, apiConfig.createVat());
return $http.post('/journalEntryImport/importAuditAdjust/' + period, {
VoucherList: list,
ImportType: importType
}, apiConfig.createVat());
},
GetAuditAdjust: function (period) {
return $http.get('/journalEntryImport/getAuditAdjust/' + period, apiConfig.createVat());
......@@ -89,7 +95,7 @@
}, apiConfig.createVat());
},
IsImportAuditAdjustOnly: function(projectId,periodId){
IsImportAuditAdjustOnly: function (projectId, periodId) {
return $http.get('/journalEntryImport/isImportAuditAdjustOnly/' + projectId + '/' + periodId, apiConfig.createVat());
},
......@@ -97,14 +103,18 @@
importOutputInvoiceData: function (outputInvoiceList, outputInvoiceItemList, importType) {
return $http.post('/outputInvoiceImport/importOutputInvoice',
{ OutputInvoiceList: outputInvoiceList, OutputInvoiceItemList: outputInvoiceItemList, ImportType: importType }, apiConfig.createVat());
{
OutputInvoiceList: outputInvoiceList,
OutputInvoiceItemList: outputInvoiceItemList,
ImportType: importType
}, apiConfig.createVat());
},
importOutputValidate: function (outputInvoiceList) {
return $http.post('/outputInvoiceImport/importValidate', outputInvoiceList, apiConfig.createVat());
},
getOutputInvoiceList: function (period) {
return $http.get('/outputInvoiceImport/getOutputInvoiceList' + '/' + period, apiConfig.createVat());
},
},
deleteOutputDupData: function (invoiceIDs) {
return $http.post('/outputInvoiceImport/deleteOutputDuplicateData', invoiceIDs, apiConfig.createVat());
},
......@@ -131,16 +141,16 @@
return $http.post('/outputInvoiceImport/DownLoadEvidence', {
filePath: param.filePath,
fileName: param.fileName
}, apiConfig.createVat({ responseType: 'arraybuffer' }));
}, apiConfig.createVat({responseType: 'arraybuffer'}));
},
/************************************************Tb entry*********************************************************/
deleteTbData: function (periodID) {
return $http.get('/DataImport/ClearTbData/' + periodID, apiConfig.createVat());
},
clearServiceTbData: function (dto){
clearServiceTbData: function (dto) {
return $http.post('/DataImport/ClearServiceTbData', {
ServiceTypeId: dto.serviceTypeId,
Periods: dto.periods,
......@@ -150,7 +160,7 @@
clearErpData: function (periodId) {
return $http.get('/financeImportData/clearErpTable/' + periodId, apiConfig.create());
},
},
updatePeriodStatus: function (queryImportDto) {
return $http.post('/ProjectInfo/updatePeriodStatus', {
serviceTypeId: queryImportDto.serviceTypeId,
......@@ -169,14 +179,18 @@
//getFileContentByDbName: function(tempFileName, selectedSheetIndex,topRowNumber){
// return $http.get('/DataImport/FileContent/' + tempFileName + '/' + selectedSheetIndex + '/' + topRowNumber, apiConfig.createVat({dbName:dbName}));
//},
importBalanceList: function (balanceList, importType,serviceTypeId) {
return $http.post('/DataImport/ImportBalance', { balanceList: balanceList, importType: importType, serviceTypeId: serviceTypeId }, apiConfig.createVat());
importBalanceList: function (balanceList, importType, serviceTypeId) {
return $http.post('/DataImport/ImportBalance', {
balanceList: balanceList,
importType: importType,
serviceTypeId: serviceTypeId
}, apiConfig.createVat());
},
getBalanceList: function (period,projectId) {
getBalanceList: function (period, projectId) {
return $http.get('/DataImport/GetBalanceList/' + period + '/' + projectId, apiConfig.createVat());
},
queryTrialBalanceData: function(queryDto){
queryTrialBalanceData: function (queryDto) {
return $http.post('/DataImport/queryTrialBalanceData', {
PageInfo: queryDto.pageInfo,
PeriodId: queryDto.periodId,
......@@ -188,7 +202,7 @@
deleteDuplicateTbData: function (balanceIds) {
return $http.post('/DataImport/DeleteDuplicateTbData', balanceIds, apiConfig.createVat());
},
refreshTrialBalance: function (period,serviceTypeId) {
refreshTrialBalance: function (period, serviceTypeId) {
return $http.get('/DataImport/RefreshTrialBalance/' + period + "/" + serviceTypeId, apiConfig.createVat());
},
......@@ -203,7 +217,7 @@
return $http.get('/DataImport/GetValidationList/' + type + '/' + period, apiConfig.createVat());
},
getServiceValidationList : function (type, period, serviceTypeId, projectId){
getServiceValidationList: function (type, period, serviceTypeId, projectId) {
return $http.get('/DataImport/GetServiceValidationList/' + type + '/' + period + '/' + serviceTypeId + '/' + projectId, apiConfig.createVat());
},
......@@ -224,7 +238,7 @@
},
clearTableByPeriods: function (periods) {
return $http.post("/DataImport/clearTableByPeriods", { periods: periods }, apiConfig.createVat());
return $http.post("/DataImport/clearTableByPeriods", {periods: periods}, apiConfig.createVat());
},
getAdjustAuditPeriods: function () {
......@@ -246,7 +260,7 @@
criteria: criteria,
orgId: orgId
}, apiConfig.createVat());
// return $http.get('/DataImport/GetBalanceDataForDisplay?category=' + category + '&fromPeriod=' + fromPeriod + '&toPeriod=' + toPeriod + '&criteria=' + criteria, apiConfig.createVat());
// return $http.get('/DataImport/GetBalanceDataForDisplay?category=' + category + '&fromPeriod=' + fromPeriod + '&toPeriod=' + toPeriod + '&criteria=' + criteria, apiConfig.createVat());
},
queryGlBalance: function (fromPeriod, toPeriod, orgId) {
......@@ -265,10 +279,10 @@
return $http.get('/CustomsInvoice/GetCustomsInvoiceDataForDisplay?fromPeriod=' + fromPeriod + '&toPeriod=' + toPeriod + '&criteria=' + criteria + '&pagination=' + pagination, apiConfig.createVat());
},
getExportCustomInvoiceList: function (criteria) {
return $http.post('/CustomsInvoice/ExportQueryData/get?criteria=' + criteria, {},apiConfig.createVat({ responseType: 'arraybuffer' }));
return $http.post('/CustomsInvoice/ExportQueryData/get?criteria=' + criteria, {}, apiConfig.createVat({responseType: 'arraybuffer'}));
},
getParentCodesForDisplay: function (category) {
return $http.get('/DataImport/GetParentCodesForDisplay?category=' + category , apiConfig.createVat());
return $http.get('/DataImport/GetParentCodesForDisplay?category=' + category, apiConfig.createVat());
},
/* workflow */
......@@ -287,7 +301,7 @@
getJePeriods: function () {
return $http.get("/journalEntryImport/getJePeriods", apiConfig.createVat());
},
/************************************************Mappings*********************************************************/
SaveVourcherMappings: function (list, period, isAddition) {
return $http.post('/vimapping/savevmappings' + '/' + period + '/' + isAddition, list, apiConfig.createVat());
......@@ -300,13 +314,13 @@
},
GetInvoiceMappings: function (period) {
return $http.get('/vimapping/getimappings' + '/' + period, apiConfig.createVat());
},
},
deleteVourcherMappings: function (ids) {
return $http.post('/vimapping/deletevmappings', ids, apiConfig.createVat());
},
validDBVoucherMapping: function (period) {
return $http.post('/vimapping/validvmappings/' + '/' + period, null, apiConfig.createVat());
},
},
deleteInvoiceMappings: function (ids) {
return $http.post('/vimapping/deleteimappings', ids, apiConfig.createVat());
},
......@@ -316,7 +330,10 @@
/************************************************CustomsInvoice*********************************************************/
importCustomsInvoiceList: function (custList, importType) {
return $http.post('/CustomsInvoice/ImportCustomsInvoice', { customsList: custList, importType: importType }, apiConfig.createVat());
return $http.post('/CustomsInvoice/ImportCustomsInvoice', {
customsList: custList,
importType: importType
}, apiConfig.createVat());
},
getCustomsInvoiceList: function () {
......@@ -340,15 +357,15 @@
},
deleteCustomInvoiceByIds: function (customsIds) {
return $http.post('/CustomsInvoice/deleteCustomInvoiceByIds',customsIds,apiConfig.createVat());
return $http.post('/CustomsInvoice/deleteCustomInvoiceByIds', customsIds, apiConfig.createVat());
},
updateCustomsInvoiceValidation: function (periodId) {
return $http.get('/CustomsInvoice/updateCustomsInvoiceValidation/'+ periodId,apiConfig.createVat());
return $http.get('/CustomsInvoice/updateCustomsInvoiceValidation/' + periodId, apiConfig.createVat());
},
/************************************************CustomsInvoice*********************************************************/
/************************************************CustomsInvoice*********************************************************/
/***************************************批量数据导入服务 start**************************************************************/
getAllTables: function (serviceType) {
return $http.get('/DataImport/getAllTables/' + serviceType, apiConfig.createVat());
......@@ -360,7 +377,7 @@
return $http.get('/DataImport/getMappedList/' + tableInfoId + '/' + orgID, apiConfig.createVat());
},
getTableMenuList: function () {
return $http.get('/DataImport/getTableMenuList', apiConfig.createVat());
},
......@@ -410,15 +427,22 @@
return $http.post('/DataImport/displayProcessLog', queryParams, apiConfig.create());
},
displayAnalysisImportData: function (param) {
return $http.post('/Analysis/displayAnalysisImportData' , param ,apiConfig.create());
return $http.post('/Analysis/displayAnalysisImportData', param, apiConfig.create());
},
analysisInitData: function (type) {
return $http.get("/Analysis/analysisDataInit?type=" + type , apiConfig.create());
},
handleAnalysisData : function (type) {
return $http.get("/Analysis/handleAnalysisData?type=" + type , apiConfig.create());
}
,
displayAnalysisInternationalImportData: function (param) {
return $http.post('/Analysis/displayAnalysisInternationalImportData',param,apiConfig.create());
return $http.post('/Analysis/displayAnalysisInternationalImportData', param, apiConfig.create());
},
getAnalysisInternationalCompanyList: function (type,period) {
getAnalysisInternationalCompanyList: function (type, period) {
return $http.get('/Analysis/getAnalysisInternationalCompanyList?type=' + type + '&period=' + period, apiConfig.create());
},
getAnalysisInternationalCountryList: function (type,period) {
getAnalysisInternationalCountryList: function (type, period) {
return $http.get('/Analysis/getAnalysisInternationalCountryList?type=' + type + '&period=' + period, apiConfig.create());
},
downloadDomesticFile: function (queryParm, fileName) {
......
......@@ -60,9 +60,8 @@
getReportData: function (reportId) {
return $http.get('/Report/reportData/' + reportId, apiConfig.createVat());
},
getReportEbitData: function (reportId, orgId, period) {
getReportEbitData: function (orgId, period) {
var param = {
reportId: reportId,
period: period,
orgId: orgId
}
......
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