Commit a0a31f33 authored by frank.xa.zhang's avatar frank.xa.zhang

add invoice and voucher datasource manually --part3 ---not finished yet

parent 446acf7e
......@@ -93,4 +93,10 @@ public class ReportController {
public OperationResultDto<String> getAllDataItems(@PathVariable Integer dataSourceType){
return reportService.getAllDataItems(dataSourceType);
}
@RequestMapping(value = "addDataSourceItems",method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto addDataSourceItems(@RequestBody DataSourceDto dataSource){
return reportService.addDataSourceItems(dataSource);
}
}
\ No newline at end of file
......@@ -39,4 +39,6 @@ public interface ReportService {
OperationResultDto<String> addDataSource(DataSourceDto datasource);
OperationResultDto<String> getAllDataItems(Integer dataSourceType);
OperationResultDto addDataSourceItems(DataSourceDto dataSource);
}
......@@ -805,6 +805,51 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
return operationResultDto;
}
@Override
public OperationResultDto addDataSourceItems(DataSourceDto dataSource) {
OperationResultDto operationResultDto = new OperationResultDto();
if (dataSource.getItems() == null || dataSource.getItems().isEmpty()) {
operationResultDto.setResultMsg("NoData");
operationResultDto.setResult(false);
return operationResultDto;
}
if (dataSource == null || StringUtils.isBlank(dataSource.getId())) {
operationResultDto.setResultMsg("DataSourceInvalid");
operationResultDto.setResult(false);
return operationResultDto;
}
DataSource datasourceEntity = dataSourceMapper.selectByPrimaryKey(Long.parseLong(dataSource.getId()));
if (datasourceEntity == null) {
operationResultDto.setResultMsg("DatasourceInvalid");
operationResultDto.setResult(false);
return operationResultDto;
}
updateCellValueForDataSourceChange(datasourceEntity, dataSource.getAmount());
dataSourceMapper.updateByPrimaryKeySelective(datasourceEntity);
//todo:MarkProjectModelDirty(dataSource.projectID, dataSource.serviceTypeID, dataSource.Updater);
List<DataSourceDetail> dataSourceItems = new ArrayList<>();
dataSource.getItems().forEach(a -> {
DataSourceDetail dataSourceDetail = new DataSourceDetail();
dataSourceDetail.setId(distributedIDService.nextId());
dataSourceDetail.setDataSourceId(Long.parseLong(dataSource.getId()));
dataSourceDetail.setDataSourceType(dataSource.getDataSourceType());
dataSourceDetail.setItemValue(a);
dataSourceItems.add(dataSourceDetail);
});
DataSourceDetailExample example = new DataSourceDetailExample();
example.createCriteria().andDataSourceIdEqualTo(Long.parseLong(dataSource.getId()));
List<DataSourceDetail> dataSourceDetailList = dataSourceDetailMapper.selectByExample(example);
//todo: TBC tomorrow
return null;
}
private void updateCellValueForDataSourceChange(Long cellDataID, BigDecimal originalAmount, BigDecimal newAmount) {
BigDecimal aValue = newAmount != null ? newAmount : new BigDecimal("0");
BigDecimal bValue = originalAmount != null ? originalAmount : new BigDecimal("0");
......
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