Commit bc03804d authored by Memorydoc's avatar Memorydoc

#

parent 76041b65
......@@ -432,12 +432,23 @@
<profiles>
<profile>
<id>dev</id>
<build>
<filters>
<filter>src/main/resources/conf/conf_profile_dev.properties</filter>
</filters>
</build>
<properties>
<env>dev</env>
</properties>
</profile>
<profile>
<id>local</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<filters>
<filter>src/main/resources/conf/conf_profile_dev.properties</filter>
<filter>src/main/resources/conf/conf_profile_dev_local.properties</filter>
</filters>
</build>
<properties>
......
......@@ -315,11 +315,12 @@ public class FileExcelUtil {
/**
* 删除列
*
* @param sheet
* @param columnToDelete
* @param cols 制定哪些行不进行列偏移
* @param cols 制定哪些行不进行列偏移
*/
public static void deleteColumn(Sheet sheet, int columnToDelete, List<Integer> cols) {
public static void deleteColumn(Sheet sheet, int columnToDelete, List<Integer> cols) {
for (int rId = 0; rId <= sheet.getLastRowNum(); rId++) {
Row row = sheet.getRow(rId);
for (int cID = columnToDelete; cID <= row.getLastCellNum(); cID++) {
......@@ -330,7 +331,7 @@ public class FileExcelUtil {
Cell cNext = row.getCell(cID + 1);
if (cNext != null) {
Cell cNew = row.createCell(cID, cNext.getCellTypeEnum());
if(cols.contains(cID))
if (cols.contains(cID))
continue;
cloneCell(cNew, cNext);
//Set the column width only on the first row.
......@@ -346,30 +347,36 @@ public class FileExcelUtil {
/**
* 右边列左移
*
* @param cNew
* @param cOld
*/
public static void cloneCell(Cell cNew, Cell cOld) {
try{
cNew.setCellComment(cOld.getCellComment());
cNew.setCellStyle(cOld.getCellStyle());
String stringCellValue = cOld.getStringCellValue();
if("".equals(stringCellValue))
return;
if (CellType.BOOLEAN == cNew.getCellTypeEnum()) {
cNew.setCellValue(cOld.getBooleanCellValue());
} else if (CellType.NUMERIC == cNew.getCellTypeEnum()) {
cNew.setCellValue(cOld.getNumericCellValue());
} else if (CellType.STRING == cNew.getCellTypeEnum()) {
cNew.setCellValue(cOld.getStringCellValue());
} else if (CellType.ERROR == cNew.getCellTypeEnum()) {
cNew.setCellValue(cOld.getErrorCellValue());
} else if (CellType.FORMULA == cNew.getCellTypeEnum()) {
cNew.setCellValue(cOld.getCellFormula());
}
}catch (Exception e){
logger.warn("数据转换异常", e.getMessage());
}
public static void cloneCell(Cell cNew, Cell cOld) {
try {
cNew.setCellComment(cOld.getCellComment());
cNew.setCellStyle(cOld.getCellStyle());
try {
String stringCellValue = cOld.getStringCellValue();
if ("".equals(stringCellValue))
return;
} catch (Exception e) {
//do nothing
}
if (CellType.BOOLEAN == cNew.getCellTypeEnum() || CellType.BOOLEAN == cOld.getCellTypeEnum()) {
cNew.setCellValue(cOld.getBooleanCellValue());
} else if (CellType.NUMERIC == cNew.getCellTypeEnum() || CellType.NUMERIC == cOld.getCellTypeEnum()) {
cNew.setCellValue(cOld.getNumericCellValue());
} else if (CellType.STRING == cNew.getCellTypeEnum() || CellType.STRING == cOld.getCellTypeEnum()) {
cNew.setCellValue(cOld.getStringCellValue());
} else if (CellType.ERROR == cNew.getCellTypeEnum() || CellType.ERROR == cOld.getCellTypeEnum()) {
cNew.setCellValue(cOld.getErrorCellValue());
} else if (CellType.FORMULA == cNew.getCellTypeEnum() || CellType.FORMULA == cOld.getCellTypeEnum()) {
cNew.setCellValue(cOld.getCellFormula());
}
} catch (Exception e) {
e.printStackTrace();
logger.warn("数据转换异常", e.getMessage());
}
}
}
\ No newline at end of file
......@@ -347,6 +347,8 @@ public class TemplateGroupServiceImpl extends AbstractService {
List<PeriodDataSource> periodDataSourceList = Lists.newArrayList();
for (int r = sheet.getFirstRowNum(); r <= sheet.getLastRowNum(); r++) {
Row row = sheet.getRow(r);
if(row == null)
continue;
for (int c = row.getFirstCellNum(); c <= row.getLastCellNum(); c++) {
Cell cell = row.getCell(c);
if (cell == null) {
......
......@@ -2409,7 +2409,6 @@ public class ReportServiceImpl extends BaseService {
List<EbitSpreadData> ebitSpreadData = ebitSpreadDataMapper.selectByExample(example);
Workbook workbook1 = null;
Sheet sheetAt = null;
if (ebitSpreadData.size() == 0)
throw new Exception("没有可导出的数据");
for (int i = 0; i < ebitSpreadData.size(); i++) {
......@@ -2422,15 +2421,12 @@ public class ReportServiceImpl extends BaseService {
}
InputStream inputStream = httpFileService.getUserTemplate(path);
if (i == 0) {
workbook1 = new XSSFWorkbook(inputStream);
workbook1 = WorkbookFactory.create(inputStream);
sheetAt = workbook1.getSheetAt(0);
List<Integer> cols = Lists.newArrayList();
FileExcelUtil.deleteColumn(sheetAt, 1, cols);
sheetAt.setColumnWidth(1, 22 * 256);
sheetAt.setColumnWidth(2, 22 * 256);
} else {
Workbook workbook2 = new XSSFWorkbook(inputStream);
Workbook workbook2 = WorkbookFactory.create(inputStream);
Sheet sheetAt1 = workbook2.getSheetAt(0);
for (int m = 0; m < sheetAt1.getLastRowNum(); m++) {
switch (m) {
......@@ -2443,7 +2439,7 @@ public class ReportServiceImpl extends BaseService {
default:
if (i == 0)
break;
sheetAt.getRow(m).getCell(i + 1).setCellValue(getCellStringValue(sheetAt1.getRow(m).getCell(i + 1)));
sheetAt.getRow(m).getCell(i + 1).setCellValue(getCellStringValue(sheetAt1.getRow(m).getCell(2)));
}
}
}
......@@ -2454,7 +2450,7 @@ public class ReportServiceImpl extends BaseService {
//将workbook转成流
/* ByteArrayOutputStream bos = new ByteArrayOutputStream();
workbook.write(bos);
byte[] barray = bos.toByteArray();6
byte[] barray = bos.toByteArray();
InputStream is = new ByteArrayInputStream(barray);*/
// FileOutputStream fileOut = new FileOutputStream(path);
}
......@@ -2470,14 +2466,13 @@ public class ReportServiceImpl extends BaseService {
for (int m = 0; m < 3; m++) {
FileExcelUtil.cloneCell(sheetAt.getRow(m).getCell(2), sheetAt.getRow(m).getCell(1));
sheetAt.getRow(m).getCell(1).setCellValue("");
}
style1.setFillBackgroundColor(IndexedColors.YELLOW.getIndex());
sheetAt.getRow(2).getCell(2).setCellStyle(style1);
sheetAt.getRow(2).getCell(2).setCellValue("本期:" + spreadData.get(0).getPeriod());
}
public String getCellStringValue(Cell cell) {
/* public String getCellStringValue(Cell cell) {
String cellValue = null;
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_STRING://字符串类型
......@@ -2503,7 +2498,7 @@ public class ReportServiceImpl extends BaseService {
break;
}
return cellValue;
}
}*/
@Autowired
private OrganizationMapper organizationMapper;
......@@ -2517,12 +2512,12 @@ public class ReportServiceImpl extends BaseService {
@Autowired
private JdbcTemplate jdbcTemplate;
//获取利润表模板Id
//获取利润表模板Id 利润表固定模板VAT10086
public String getlxbId() throws Exception {
try {
String sql = "select * from template t where t.name = '利润表'";
String sql = "select * from template t where t.name = 'VAT10086' order by t.create_time desc ";
Map<String, Object> stringObjectMap = new HashMap<>();
stringObjectMap = jdbcTemplate.queryForList("select * from template t where t.name = '利润表' ").get(0);
stringObjectMap = jdbcTemplate.queryForList(sql).get(0);
return stringObjectMap.get("id").toString();
} catch (Exception e) {
e.printStackTrace();
......@@ -2530,7 +2525,7 @@ public class ReportServiceImpl extends BaseService {
}
}
/* private String getCellStringValue(Cell cell) {
private String getCellStringValue(Cell cell) {
if (cell.getCellTypeEnum().equals(CellType.STRING)) {
return cell.getStringCellValue();
} else if (cell.getCellTypeEnum().equals(CellType.NUMERIC)) {
......@@ -2539,5 +2534,5 @@ public class ReportServiceImpl extends BaseService {
}
logger.warn("获取单元格数据类型未匹配");
return null;
}*/
}
}
......@@ -59,7 +59,7 @@ org_sync_token=174af08f
dd_pubkey=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKUfMPRKV6I5num1dDWcxTrgTjXf5LctsVj0CpbwHE83mmjUO5CAlvA0Fwy30ajCX5sLmsyi+Eu/4uNmM6GQF3kCAwEAAQ==
ebs_call_url=http://172.20.3.109:8020/ebs-proxy-test/dts
ebs_call_url=http://172.20.3.109:8010/ebs-proxy-test/dts
#tableau config
tableau_get_ticket=http://47.94.233.173:16010/trusted?username=%s
......
......@@ -151,6 +151,26 @@
sheet.setColumnWidth(i, 180);
}
}
//创建自定义格式
function CustomPerFormat() {
}
CustomPerFormat.prototype = new GC.Spread.Formatter.FormatterBase();
CustomPerFormat.prototype.format = function (obj, formattedData) {
return perFormat(obj, formattedData);
}
function perFormat(value, formattedData){
value = value.toString();
if(0 <= value <= 100){
if( value.indexOf("%") != -1){
value += "%";
}
}else{
formattedData.conditionalForeColor = "red";
}
return value;
}
var initSpreadExcel = function (reportSpread) {
var spread = getSpreadControl();
......@@ -240,7 +260,9 @@
sheet.getCell(40, 2).locked(false);//ebit比率
//
sheet.setFormatter( 38, 2,"0.00");
sheet.setFormatter( 40, 2,"0.00");
sheet.setFormatter( 40, 2,"0.00%");
//sheet.setFormatter(40, 2, new CustomPerFormat());
//sheet.getCell(40, 2).formatter(new CustomPerFormat());
};
// 每个单元格大致由以下部分构成:_SumAll(_Inter(...)+_Manual(...)+C1)
......
......@@ -2943,7 +2943,7 @@
spreadTODb();
}
var spreadTODb = function () {
var spreadTODb = function (front) {
if ($scope.relation.period == undefined || $scope.relation.period == null) {
SweetAlert.error("请选择机构");
return;
......@@ -2970,7 +2970,9 @@
success: function (data) {
//alert("上传成功!");
if (data.result) {
SweetAlert.success("成功")
if(!front){
SweetAlert.success("操作成功")
}
} else {
SweetAlert.error(data.resultMsg);
}
......@@ -3087,7 +3089,7 @@
$scope.relation.addEbitRow(sheet);
calculateEbitAndInsert(sheet, true);
$scope.relation.lockCell($scope.spread);
spreadTODb();
spreadTODb(true);
}, function (e) {
alert(e.errorMessage);
if (e.errorCode === 2/*noPassword*/ || e.errorCode === 3 /*invalidPassword*/) {
......@@ -3102,35 +3104,43 @@
return this.replace(new RegExp(s1, "gm"), s2);
}
var nullToZero = function(value){
var calculateEbitAndInsert = function (sheet, insert) {
var yysr = Number(sheet.getValue(11, 2).toString().replaceAll(",", ""));//营业收入
var yycb = Number(sheet.getValue(12, 2).toString().replaceAll(",", ""));//营业成本
var yysjfj = Number(sheet.getValue(13, 2).toString().replaceAll(",", ""));//营业税金附加
var xsfy = Number(sheet.getValue(14, 2).toString().replaceAll(",", ""));//销售费用
var glfy = Number(sheet.getValue(15, 2).toString().replaceAll(",", ""));//管理费用
var yffy = Number(sheet.getValue(16, 2).toString().replaceAll(",", ""));//研发费用
var zcjzss = Number(sheet.getValue(18, 2).toString().replaceAll(",", ""));//资产减值损失
var ts = (sheet.getValue(38, 2) == "" || sheet.getValue(38, 2) == null) == true ? 0 : sheet.getValue(40, 2);
var rate = (sheet.getValue(40, 2) == "" || sheet.getValue(40, 2) == null) == true ? "1%" : sheet.getValue(40, 2);
return value !=null ? Number(value.toString().replaceAll("," , "")) : 0;
}
var calculateEbitAndInsert = function (sheet, insert) {
var yysr = nullToZero(sheet.getValue(11, 2));//营业成本
var yycb = nullToZero(sheet.getValue(12, 2));//营业成本
var yysjfj = nullToZero (sheet.getValue(13, 2) );//营业税金附加
var xsfy = nullToZero(sheet.getValue(14, 2));//销售费用
var glfy = nullToZero(sheet.getValue(15, 2));//管理费用
var yffy = nullToZero(sheet.getValue(16, 2));//研发费用
var zcjzss = nullToZero(sheet.getValue(18, 2));//资产减值损失
var ts = nullToZero(sheet.getValue(38, 2));
var rate = 1;
if(sheet.getValue(40, 2) != null){
if(sheet.getValue(40, 2).toString().indexOf("%") != -1){
rate = Number(sheet.getValue(40, 2).toString().replaceAll("%", "")) ;
}else{
rate = sheet.getValue(40, 2) * 100
}
}else{
rate = 1;
}
$scope._ebitResult.klzcjsz = Number((yysr - yycb - yysjfj - xsfy - glfy - yffy - zcjzss).toFixed(4));
$scope._ebitResult.tsyskl = Number((Number(ts)).toFixed(4));
$scope._ebitResult.kltsys = ($scope._ebitResult.klzcjsz + $scope._ebitResult.tsyskl).toFixed(4);
$scope._ebitResult.kltsys = Number(($scope._ebitResult.klzcjsz + $scope._ebitResult.tsyskl).toFixed(4));
$scope._ebitResult.rate = rate;
if($scope._ebitResult.rate.indexOf("%") != -1){
$scope._ebitResult.gljyye = Number((Number($scope._ebitResult.rate.replaceAll("%", "")) * $scope._ebitResult.kltsys).toFixed(4));
}else{
$scope._ebitResult.gljyye = Number(($scope._ebitResult.rate * $scope._ebitResult.kltsys).toFixed(4));
}
$scope._ebitResult.gljyye = Number(((rate/ 100) * $scope._ebitResult.kltsys).toFixed(4));
$scope._ebitResult.sixAddtax = Number((0.06 * $scope._ebitResult.gljyye).toFixed(4));
$scope._ebitResult.tsklys = Number(($scope._ebitResult.gljyye * 0.106).toFixed(4));
if (insert) {
sheet.setValue(37, 2, $scope._ebitResult.klzcjsz);
sheet.setValue(38, 2, $scope._ebitResult.tsklys);
sheet.setValue(38, 2, $scope._ebitResult.tsyskl);
sheet.setValue(39, 2, $scope._ebitResult.kltsys);
sheet.setValue(40, 2, $scope._ebitResult.rate);
sheet.setValue(40, 2, $scope._ebitResult.rate + "%");
sheet.setValue(41, 2, $scope._ebitResult.gljyye);
sheet.setValue(42, 2, $scope._ebitResult.sixAddtax);
sheet.setValue(43, 2, $scope._ebitResult.klzcjsz);
......
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