Commit 7c05ad7d authored by chase's avatar chase

Merge branch 'dev_mysql' of http://code.tech.tax.asia.pwcinternal.com/root/atms into dev_mysql

parents f2ea6f88 c67a1648
......@@ -215,9 +215,32 @@ public class EbsApiController {
}
}
/**
* callback服务
* @param callBackDto
* @return
*/
@RequestMapping(value = "/callback", method = RequestMethod.POST)
public ApiResultDto callback(@RequestBody EbsCallBackDto callBackDto) {
logger.info("EBS callback 调用,taskId :{}",callBackDto.getTaskId());
ApiResultDto apiResultDto = new ApiResultDto();
try{
ebsApiService.changeCallBackStatus(callBackDto);
logger.debug("ebs callback taskId:{},status:{} end ",callBackDto.getTaskId(),callBackDto.getTaskStatus());
setApiResult(apiResultDto,EnumErrorCodeMsg.SUCCESS);
return apiResultDto;
}catch(Exception e){
logger.error("ebs callback error.", e);
setApiResult(apiResultDto,EnumErrorCodeMsg.APIERROR);
return apiResultDto;
}
}
private void setApiResult(ApiResultDto apiResultDto,EnumErrorCodeMsg error) {
apiResultDto.setCode(error.getCode());
apiResultDto.setMessage(error.getMsg());
}
}
......@@ -26,5 +26,7 @@ public class TableRule {
map.put("ZXXJLLB", "cash_flow_final");
map.put("CITZCFZB", "cit_balance_sheet_prc_adjust");
map.put("CITLRB", "cit_profit_prc_adjust");
map.put("CIT_TBAM", "cit_tbam");
}
}
package pwc.taxtech.atms.dto.ebsdto;
public class EbsCallBackDto {
private Long taskId;
private String taskStatus;
private String taskDesc;
public Long getTaskId() {
return taskId;
}
public void setTaskId(Long taskId) {
this.taskId = taskId;
}
public String getTaskStatus() {
return taskStatus;
}
public void setTaskStatus(String taskStatus) {
this.taskStatus = taskStatus;
}
public String getTaskDesc() {
return taskDesc;
}
public void setTaskDesc(String taskDesc) {
this.taskDesc = taskDesc;
}
}
......@@ -68,4 +68,10 @@ public interface EbsApiService {
* @param items
*/
void queryRemoteServerThenUpdateOrg(Long id, List<OrganizationQueryDto> items);
/**
* ebs最后调用更新状态
* @param ebsCallBackDto
*/
void changeCallBackStatus(EbsCallBackDto ebsCallBackDto);
}
......@@ -82,7 +82,7 @@ public class EbsApiServiceImpl implements EbsApiService {
logger.debug("requestJEItems 日记账表条目:" + JSON.toJSONString(items));
for (JournalEntryQueryDto a : items) {
try {
processJE(a);
processJE(id,a);
} catch (Exception e) {
logger.error("break loop as catch:" + e, e);
}
......@@ -238,8 +238,9 @@ public class EbsApiServiceImpl implements EbsApiService {
logger.debug("end queryRemoteServerThenUpdateOAR 汇率表,took [{}] ms", System.currentTimeMillis() - start);
}
private void processJE(JournalEntryQueryDto item) {
private void processJE(Long id,JournalEntryQueryDto item) {
JournalEntryExample journalEntryExample = new JournalEntryExample();
item.setTaskId(String.valueOf(id));
//日记账头ID和日记账行号
journalEntryExample.createCriteria().andHeaderIdEqualTo(item.getHeaderId()).andLineNumEqualTo(item.getLineNum()).andTaskIdNotEqualTo(item.getTaskId());
List<JournalEntry> journalEntryList = journalEntryMapper.selectByExample(journalEntryExample);
......@@ -264,6 +265,7 @@ public class EbsApiServiceImpl implements EbsApiService {
private void processTB(Long id,TrialBalanceQueryDto item) {
TrialBalanceExample example = new TrialBalanceExample();
item.setTaskId(String.valueOf(id));
//机构编码和期间
example.createCriteria().andSegment1EqualTo(item.getSegment1()).andPeriodEqualTo(convertPeriodStr2Int(item.getPeriod())).andTaskIdNotEqualTo(item.getTaskId());
List<TrialBalance> itemList = trialBalanceMapper.selectByExample(example);
......@@ -283,6 +285,7 @@ public class EbsApiServiceImpl implements EbsApiService {
private void processCF(Long id,CashFlowQueryDto item) {
CashFlowExample example = new CashFlowExample();
item.setTaskId(String.valueOf(id));
//机构编码和期间
example.createCriteria().andEntityCodeEqualTo(item.getEntityCode()).andPeriodEqualTo(convertPeriodStr2Int(item.getPeriod())).andTaskIdNotEqualTo(item.getTaskId());
List<CashFlow> itemList = cashFlowMapper.selectByExample(example);
......@@ -303,6 +306,7 @@ public class EbsApiServiceImpl implements EbsApiService {
private void processBS(Long id,BalanceSheetQueryDto item) {
BalanceSheetExample example = new BalanceSheetExample();
item.setTaskId(String.valueOf(id));
//机构编码和期间
example.createCriteria().andEntityCodeEqualTo(item.getEntityCode()).andPeriodEqualTo(convertPeriodStr2Int(item.getPeriod())).andTaskIdNotEqualTo(item.getTaskId());
List<BalanceSheet> itemList = balanceSheetMapper.selectByExample(example);
......@@ -331,6 +335,7 @@ public class EbsApiServiceImpl implements EbsApiService {
private void processBSprc(Long id,BalanceSheetPrcQueryDto item) {
BalanceSheetPrcExample example = new BalanceSheetPrcExample();
item.setTaskId(String.valueOf(id));
//机构编码和期间
example.createCriteria().andEntityCodeEqualTo(item.getEntityCode()).andPeriodEqualTo(convertPeriodStr2Int(item.getPeriod())).andTaskIdNotEqualTo(item.getTaskId());
List<BalanceSheetPrc> itemList = balanceSheetPrcMapper.selectByExample(example);
......@@ -358,6 +363,7 @@ public class EbsApiServiceImpl implements EbsApiService {
private void processPL(Long id,ProfitLossStatementQueryDto item) {
ProfitLossStatementExample example = new ProfitLossStatementExample();
item.setTaskId(String.valueOf(id));
//机构编码和期间
example.createCriteria().andEntityCodeEqualTo(item.getEntityCode()).andPeriodEqualTo(convertPeriodStr2Int(item.getPeriod())).andTaskIdNotEqualTo(item.getTaskId());
List<ProfitLossStatement> itemList = profitLossStatementMapper.selectByExample(example);
......@@ -385,6 +391,7 @@ public class EbsApiServiceImpl implements EbsApiService {
private void processPLprc(Long id,ProfitLossStatementPrcQueryDto item) {
ProfitLossStatementPrcExample example = new ProfitLossStatementPrcExample();
item.setTaskId(String.valueOf(id));
//机构编码和期间
example.createCriteria().andEntityCodeEqualTo(item.getEntityCode()).andPeriodEqualTo(convertPeriodStr2Int(item.getPeriod())).andTaskIdNotEqualTo(item.getTaskId());
List<ProfitLossStatementPrc> itemList = profitLossStatementPrcMapper.selectByExample(example);
......@@ -412,6 +419,7 @@ public class EbsApiServiceImpl implements EbsApiService {
private void processOAR(Long id,OrganizationAccountingRateQueryDto item) {
OrganizationAccountingRateExample example = new OrganizationAccountingRateExample();
item.setTaskId(String.valueOf(id));
//期间
example.createCriteria().andPeriodEqualTo(convertPeriod12(item.getPeriod())).andTaskIdNotEqualTo(item.getTaskId());
List<OrganizationAccountingRate> itemList = organizationAccountingRateMapper.selectByExample(example);
......@@ -783,6 +791,19 @@ public class EbsApiServiceImpl implements EbsApiService {
logger.debug("end queryRemoteServerThenUpdateOrg 机构表,took [{}] ms", System.currentTimeMillis() - start);
}
@Override
public void changeCallBackStatus(EbsCallBackDto ebsCallBackDto) {
DataImportLog dataImportLog = new DataImportLog();
dataImportLog.setId(ebsCallBackDto.getTaskId());
dataImportLog.setImportResult(ebsCallBackDto.getTaskStatus().equals("S")?true:false);
dataImportLog.setErrorMsg(ebsCallBackDto.getTaskDesc());
dataImportLog.setUpdateTime(new Date());
int res = dataImportLogMapper.updateByPrimaryKeySelective(dataImportLog);
if (res < 0) {
logger.warn(String.format("warn callBack end [%s]", ebsCallBackDto.getTaskId()));
}
}
private void processORG(OrganizationQueryDto a) {
// 机构信息
OrganizationExample organizationExample = new OrganizationExample();
......@@ -833,8 +854,6 @@ public class EbsApiServiceImpl implements EbsApiService {
organizationEmployeeMapper.insertSelective(oe);
}
private void updateDataImportLog(Long id, int size) {
DataImportLog dataImportLog = new DataImportLog();
dataImportLog.setId(id);
......
......@@ -146,18 +146,18 @@ public class FormulaAgent {
public static String buildSql(String tableName, String getField, String filter, String filterValue, Integer period, String year, FormulaContext formulaContext) {
String sql = "";
String[] split = filterValue.split(" ");
String para3 = null;
/*
if (split[0].indexOf(">=") != -1) {
filterValue = "> " + split[1] + "and" + filter + " =" + split[1];
filterValue = " > " + split[1] + " or " + filter + " = " + split[1];
} else if (split[0].indexOf("<=") != -1) {
filterValue = "< " + split[1] + "and" + filter + " =" + split[1];
filterValue = " < " + split[1] + " or " + filter + " = " + split[1];
} else {
filterValue = split[0] + "'" + split[1] + "'";
filterValue = split[0] + " = " + split[1] + "";
}
if ("cit_balance_sheet_prc_adjust".equals(tableName) || ("cit_profit_prc_adjust".equals(tableName))) {
*/
if (tableName.substring(0, 3).equals("cit")) {
try {
return _buildSql(getField, tableName, filter, filterValue, period, formulaContext, year, true);
} catch (Exception e) {
......@@ -180,16 +180,16 @@ public class FormulaAgent {
String per = insertZero((formulaContext.getPeriod() - 1));
if (!bool) {
if (period == 0) {
sql += " and tms_period = " + year + _period;
sql += " and tms_period = " + Integer.parseInt(year + _period);
} else if (period == -99) {
sql += " and tms_period between " + year + "01 and " + year + per;
sql += " and tms_period between " + Integer.parseInt(year+"01") + " and " + Integer.parseInt(year + per);
} else if (period == 99) {
sql += " and tms_period between " + year + "01 and " + year + _period;
sql += " and tms_period between " + Integer.parseInt(year+"01") + " and " + Integer.parseInt(year + _period);
} else {
if (period > 0)
throw new Exception("参数不正确");
sql += " and tms_period between " + year + _p + " and " + year + per;
sql += " and tms_period between " + Integer.parseInt(year + _p )+ " and " + Integer.parseInt(year + per);
}
}
if (bool)
......@@ -211,16 +211,16 @@ public class FormulaAgent {
@Autowired
JdbcTemplate jdbcTemplate;
/* public static void main(String[] args) {
public static void main(String[] args) {
FormulaAgent formulaAgent = new FormulaAgent();
FormulaContext formulaContext = new FormulaContext();
formulaContext.setPeriod(3);
formulaAgent.getTableDataByName("CITLRB", "end_bal", "item_name", "= 小帅哥", -3, "2018", formulaContext);
}*/
formulaAgent.getTableDataByName("CIT_TBAM", "ending_balance", "attribute", "= '销售费用-财产损耗、盘亏及毁损损失'", 0, "2018", formulaContext);
}
public Long getTableDataByName(String tableName, String getField, String filter, String filterValue, Integer period, String year, FormulaContext formulaContext) {
public double getTableDataByName(String tableName, String getField, String filter, String filterValue, Integer period, String year, FormulaContext formulaContext) {
List<Map<String, Object>> stringObjectMap = jdbcTemplate.queryForList(buildSql(TableRule.map.get(tableName), getField, filter, filterValue, period, year, formulaContext));
Long rev = 0L;
double rev = 0.00;
for (int i = 0, j = stringObjectMap.size(); i < j; i++) {
if (i == 1) {
rev = Long.parseLong(String.valueOf(stringObjectMap.get(i).get(StringUtil.underline2Camel(getField))));
......
......@@ -28,7 +28,7 @@ public class TABLESUMIF extends FunctionBase implements FreeRefFunction {
//进行参数验证
public void parameterCheck(ValueEval[] args, OperationEvaluationContext ec) {
argsLength = args.length;
if (argsLength != 6) //参数小于当做异常处理, 最后俩参数可以取默认值
if (argsLength != 6) //参数小于6当做异常处理, 最后俩参数可以取默认值
throw Exceptions.parameterError;
try {
tableName = resolverString(args, ec, 0);
......@@ -42,7 +42,6 @@ public class TABLESUMIF extends FunctionBase implements FreeRefFunction {
}
Integer argsLength;
String getField;
Integer period;
String year;
......
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