批量导入测试
parent
2a9ddc35fa
commit
9132b59478
|
@ -1034,7 +1034,8 @@ public class ProjectController extends BaseController {
|
|||
Collection<Map> maps = ExcelUtil.importExcel(Map.class, file.getInputStream(),
|
||||
"yyyy/MM/dd HH:mm:ss", logs, 0);
|
||||
synchronized (this) {
|
||||
return JSON.toJSONString(projectBudgetService.checkIncome(maps, id));
|
||||
ResponseMsg responseMsg = projectBudgetService.checkIncome(maps, id);
|
||||
return JSON.toJSONString(responseMsg);
|
||||
}
|
||||
} catch (OfficeXmlFileException | EncryptedDocumentException | InvalidFormatException e) {
|
||||
logger.error("", e);
|
||||
|
|
|
@ -955,9 +955,11 @@ public class ProjectBudgetService {
|
|||
int errorCount = 0;
|
||||
List<String> errorList = new ArrayList<>();
|
||||
List<ProjectBudgetIncomeDetailTemp> incomeDetailTempList = new ArrayList<>();
|
||||
List<ProjectBudgetIncomeDetail> incomeDetailList = new ArrayList<>();
|
||||
for (Map m : excelMap) {
|
||||
try {
|
||||
saveIncomeTemp(m, id, incomeDetailTempList);
|
||||
successCount++;
|
||||
} catch (Exception e) {
|
||||
logger.error("", e);
|
||||
errorCount++;
|
||||
|
@ -967,6 +969,11 @@ public class ProjectBudgetService {
|
|||
}
|
||||
}
|
||||
projectBudgetIncomeDetailTempRepository.save(incomeDetailTempList);
|
||||
for (ProjectBudgetIncomeDetailTemp projectBudgetIncomeDetailTemp : incomeDetailTempList) {
|
||||
ProjectBudgetIncomeDetail projectBudgetIncomeDetail = projectBudgetIncomeDetailTemp.toProjectBudgetIncomeDetail();
|
||||
incomeDetailList.add(projectBudgetIncomeDetail);
|
||||
}
|
||||
projectBudgetIncomeDetailRepository.save(incomeDetailList);
|
||||
final ResponseMsg msg = ResponseMsg.buildSuccessMsg(String.format("成功:%d, 失败:%d", successCount, errorCount));
|
||||
msg.setData(errorList);
|
||||
return msg;
|
||||
|
@ -995,13 +1002,19 @@ public class ProjectBudgetService {
|
|||
temp.setUnit((String) o1);
|
||||
key = "数量";
|
||||
o1 = m.get(key);
|
||||
temp.setAmount(Integer.parseInt((String) o1));
|
||||
if (o1 != null) {
|
||||
temp.setAmount(Integer.parseInt((String) o1));
|
||||
}
|
||||
key = "单价";
|
||||
o1 = m.get(key);
|
||||
temp.setPrice(new BigDecimal((String) o1));
|
||||
if (o1 != null) {
|
||||
temp.setPrice(new BigDecimal((String) o1));
|
||||
}
|
||||
key = "税率(%)";
|
||||
o1 = m.get(key);
|
||||
temp.setTaxRate(new BigDecimal((String) o1));
|
||||
if (o1 != null) {
|
||||
temp.setTaxRate(new BigDecimal((String) o1));
|
||||
}
|
||||
incomeDetailTempList.add(temp);
|
||||
}
|
||||
|
||||
|
@ -1011,9 +1024,11 @@ public class ProjectBudgetService {
|
|||
int errorCount = 0;
|
||||
List<String> errorList = new ArrayList<>();
|
||||
List<ProjectBudgetCostDetailTemp> costDetailTempList = new ArrayList<>();
|
||||
List<ProjectBudgetCostDetail> CostDetailList = new ArrayList<>();
|
||||
for (Map m : excelMap) {
|
||||
try {
|
||||
saveCostTemp(m, id, costDetailTempList);
|
||||
successCount++;
|
||||
} catch (Exception e) {
|
||||
logger.error("", e);
|
||||
errorCount++;
|
||||
|
@ -1023,6 +1038,11 @@ public class ProjectBudgetService {
|
|||
}
|
||||
}
|
||||
projectBudgetCostDetailTempRepository.save(costDetailTempList);
|
||||
for (ProjectBudgetCostDetailTemp projectBudgetCostDetailTemp : costDetailTempList) {
|
||||
ProjectBudgetCostDetail projectBudgetCostDetail = projectBudgetCostDetailTemp.toProjectBudgetCostDetail();
|
||||
CostDetailList.add(projectBudgetCostDetail);
|
||||
}
|
||||
projectBudgetCostDetailRepository.save(CostDetailList);
|
||||
final ResponseMsg msg = ResponseMsg.buildSuccessMsg(String.format("成功:%d, 失败:%d", successCount, errorCount));
|
||||
msg.setData(errorList);
|
||||
return msg;
|
||||
|
@ -1060,13 +1080,19 @@ public class ProjectBudgetService {
|
|||
temp.setUnit((String) o1);
|
||||
key = "数量";
|
||||
o1 = m.get(key);
|
||||
temp.setAmount(Integer.parseInt((String) o1));
|
||||
if (o1 != null) {
|
||||
temp.setAmount(Integer.parseInt((String) o1));
|
||||
}
|
||||
key = "单价";
|
||||
o1 = m.get(key);
|
||||
temp.setPrice(new BigDecimal((String) o1));
|
||||
if (o1 != null) {
|
||||
temp.setPrice(new BigDecimal((String) o1));
|
||||
}
|
||||
key = "税率(%)";
|
||||
o1 = m.get(key);
|
||||
temp.setTaxRate(new BigDecimal((String) o1));
|
||||
if (o1 != null) {
|
||||
temp.setTaxRate(new BigDecimal((String) o1));
|
||||
}
|
||||
key = "签约方";
|
||||
o1 = m.get(key);
|
||||
temp.setContractParty((String) o1);
|
||||
|
@ -1082,13 +1108,19 @@ public class ProjectBudgetService {
|
|||
}
|
||||
key = "预估垫资金额(元)";
|
||||
o1 = m.get(key);
|
||||
temp.setUnderwrittenAmount(new BigDecimal((String) o1));
|
||||
if (o1 != null) {
|
||||
temp.setUnderwrittenAmount(new BigDecimal((String) o1));
|
||||
}
|
||||
key = "支出时间";
|
||||
o1 = m.get(key);
|
||||
temp.setPayTime(DateKit.getDate((String) o1, DateKit.DATE_FORMAT));
|
||||
if (o1 != null) {
|
||||
temp.setPayTime(DateKit.getDate((String) o1, DateKit.DATE_FORMAT));
|
||||
}
|
||||
key = "支出金额(元)";
|
||||
o1 = m.get(key);
|
||||
temp.setPayAmount(new BigDecimal((String) o1));
|
||||
if (o1 != null) {
|
||||
temp.setPayAmount(new BigDecimal((String) o1));
|
||||
}
|
||||
key = "付款方式";
|
||||
o1 = m.get(key);
|
||||
temp.setPayWay((String) o1);
|
||||
|
|
|
@ -758,7 +758,7 @@
|
|||
<span class="am-icon-archive"></span>
|
||||
批量导入
|
||||
</button>
|
||||
<input id="doc-form-file" type="file" name="file" onChange="ajaxUploadFile('doc-form-file','${base}/project/batchCostImport')">
|
||||
<input id="doc-form-file2" type="file" name="file" onChange="ajaxUploadFile2('doc-form-file2','${base}/project/batchCostImport?id=' + ${project.id})">
|
||||
</div>
|
||||
|
||||
<button type="button" class="am-btn am-btn-default" onclick="location.href='${base}/project/costTemplate'">
|
||||
|
@ -1440,6 +1440,52 @@
|
|||
});
|
||||
}
|
||||
|
||||
function ajaxUploadFile2(id, url) {
|
||||
// if($('#modal')){
|
||||
// $('#modal').modal('open');
|
||||
// $('#span-'+id).html(" 数据正在导入,请等待");
|
||||
// }
|
||||
$.ajaxFileUpload({
|
||||
url: url,
|
||||
secureuri: false,
|
||||
fileElementId: id,// file标签的id
|
||||
dataType: 'json',// 返回数据的类型
|
||||
success: function (data, status) {
|
||||
console.log("--------success---------" + data)
|
||||
// if($('#modal')){
|
||||
// $('#modal').modal('close');
|
||||
// $('#span-'+id).html("导入完成");
|
||||
// }
|
||||
if(data.status ==0) {
|
||||
var list = data.data;
|
||||
var content = '';
|
||||
$.each(list, function (i, r) {
|
||||
content += (i+1) + '、' + r + '<br>';
|
||||
});
|
||||
console.log('---> ' + content);
|
||||
parent.layer.open({
|
||||
title: '导入结果:' ,
|
||||
content: data.msg + '<br><br>' + content
|
||||
});
|
||||
}else{
|
||||
parent.layer.msg(data.msg);
|
||||
}
|
||||
|
||||
window.location.reload();
|
||||
$("#" + id).val("");
|
||||
},
|
||||
error: function (data, status, e) {
|
||||
console.log("--------error---------" + data)
|
||||
alert("-----------------" + data);
|
||||
// if ($('#modal')) {
|
||||
// $('#modal').modal('close');
|
||||
// }
|
||||
alert(e);
|
||||
$("#" + id).val("");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var generateFileupload = function (name) {
|
||||
var progressArea = $("#progress-area-" + name);//div
|
||||
var progressText = $("#progress-text-" + name);//进度条提示
|
||||
|
|
Loading…
Reference in New Issue