|
@@ -12,10 +12,13 @@ import com.jeeplus.common.utils.excel.ImportExcel;
|
|
import com.jeeplus.core.persistence.Page;
|
|
import com.jeeplus.core.persistence.Page;
|
|
import com.jeeplus.core.web.BaseController;
|
|
import com.jeeplus.core.web.BaseController;
|
|
import com.jeeplus.modules.sg.audit.information.entity.Information;
|
|
import com.jeeplus.modules.sg.audit.information.entity.Information;
|
|
|
|
+import com.jeeplus.modules.sg.audit.information.entity.append;
|
|
import com.jeeplus.modules.sg.financial.expense.entity.Expense;
|
|
import com.jeeplus.modules.sg.financial.expense.entity.Expense;
|
|
import com.jeeplus.modules.sg.financial.expense.service.ExpenseService;
|
|
import com.jeeplus.modules.sg.financial.expense.service.ExpenseService;
|
|
|
|
+import com.jeeplus.modules.test.onetomany.dialog.entity.TestDataMain1;
|
|
import com.jeeplus.modules.test.onetomany.form.entity.TestDataMain2;
|
|
import com.jeeplus.modules.test.onetomany.form.entity.TestDataMain2;
|
|
import com.jeeplus.modules.test.onetomany.form.service.TestDataMain2Service;
|
|
import com.jeeplus.modules.test.onetomany.form.service.TestDataMain2Service;
|
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
import org.apache.shiro.authz.annotation.Logical;
|
|
import org.apache.shiro.authz.annotation.Logical;
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -27,6 +30,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.validation.ConstraintViolationException;
|
|
import javax.validation.ConstraintViolationException;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -81,6 +85,13 @@ public class ExpenseController extends BaseController {
|
|
return "modules/sg/financial/expense/expenseForm";
|
|
return "modules/sg/financial/expense/expenseForm";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //添加数据页面
|
|
|
|
+ @RequestMapping(value = "editForm")
|
|
|
|
+ public String editForm(Expense expense, Model model) {
|
|
|
|
+ model.addAttribute("expense", expense);
|
|
|
|
+ return "modules/sg/financial/expense/expenseEditForm";
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 批量删除
|
|
* 批量删除
|
|
*/
|
|
*/
|
|
@@ -114,138 +125,133 @@ public class ExpenseController extends BaseController {
|
|
@RequestMapping(value = "save")
|
|
@RequestMapping(value = "save")
|
|
public AjaxJson save(Expense expense, Model model) throws Exception{
|
|
public AjaxJson save(Expense expense, Model model) throws Exception{
|
|
AjaxJson j = new AjaxJson();
|
|
AjaxJson j = new AjaxJson();
|
|
- expenseService.save(expense);//保存
|
|
|
|
- j.setSuccess(true);
|
|
|
|
- j.setMsg("保存票务代理成功");
|
|
|
|
|
|
+ Expense expense1 = expenseService.selectByProjectId(expense.getProjectId());
|
|
|
|
+ if (expense1 == null) {
|
|
|
|
+ expenseService.insertData(expense);//保存
|
|
|
|
+ j.setSuccess(true);
|
|
|
|
+ j.setMsg("保存票务代理成功");
|
|
|
|
+ } else {
|
|
|
|
+ j.setSuccess(false);
|
|
|
|
+ j.setMsg("项目定义号已存在不可重复");
|
|
|
|
+ }
|
|
return j;
|
|
return j;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 保存票务代理
|
|
|
|
|
|
+ * 修改
|
|
*/
|
|
*/
|
|
@ResponseBody
|
|
@ResponseBody
|
|
@RequestMapping(value = "update")
|
|
@RequestMapping(value = "update")
|
|
public AjaxJson update(Expense expense, Model model) throws Exception{
|
|
public AjaxJson update(Expense expense, Model model) throws Exception{
|
|
AjaxJson j = new AjaxJson();
|
|
AjaxJson j = new AjaxJson();
|
|
- expenseService.insertData(expense);//保存
|
|
|
|
|
|
+ expenseService.updateData(expense);//保存
|
|
j.setSuccess(true);
|
|
j.setSuccess(true);
|
|
j.setMsg("保存票务代理成功");
|
|
j.setMsg("保存票务代理成功");
|
|
return j;
|
|
return j;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * 删除票务代理
|
|
|
|
- *//*
|
|
|
|
- @ResponseBody
|
|
|
|
- @RequiresPermissions("test:onetomany:form:testDataMain2:del")
|
|
|
|
- @RequestMapping(value = "delete")
|
|
|
|
- public AjaxJson delete(TestDataMain2 testDataMain2) {
|
|
|
|
- AjaxJson j = new AjaxJson();
|
|
|
|
- testDataMain2Service.delete(testDataMain2);
|
|
|
|
- j.setMsg("删除票务代理成功");
|
|
|
|
- return j;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- *//**
|
|
|
|
- * 批量删除票务代理
|
|
|
|
- *//*
|
|
|
|
- @ResponseBody
|
|
|
|
- @RequiresPermissions("test:onetomany:form:testDataMain2:del")
|
|
|
|
- @RequestMapping(value = "deleteAll")
|
|
|
|
- public AjaxJson deleteAll(String ids) {
|
|
|
|
- AjaxJson j = new AjaxJson();
|
|
|
|
- String idArray[] =ids.split(",");
|
|
|
|
- for(String id : idArray){
|
|
|
|
- testDataMain2Service.delete(testDataMain2Service.get(id));
|
|
|
|
- }
|
|
|
|
- j.setMsg("删除票务代理成功");
|
|
|
|
- return j;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- *//**
|
|
|
|
- * 导出excel文件
|
|
|
|
- *//*
|
|
|
|
|
|
+ * 导出模板文件
|
|
|
|
+ */
|
|
@ResponseBody
|
|
@ResponseBody
|
|
- @RequiresPermissions("test:onetomany:form:testDataMain2:export")
|
|
|
|
- @RequestMapping(value = "export")
|
|
|
|
- public AjaxJson exportFile(TestDataMain2 testDataMain2, HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
|
|
+ @RequestMapping(value = "templates")
|
|
|
|
+ public AjaxJson templates(HttpServletResponse response) {
|
|
AjaxJson j = new AjaxJson();
|
|
AjaxJson j = new AjaxJson();
|
|
try {
|
|
try {
|
|
- String fileName = "票务代理"+DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
|
|
|
|
- Page<TestDataMain2> page = testDataMain2Service.findPage(new Page<TestDataMain2>(request, response, -1), testDataMain2);
|
|
|
|
- new ExportExcel("票务代理", TestDataMain2.class).setDataList(page.getList()).write(response, fileName).dispose();
|
|
|
|
- j.setSuccess(true);
|
|
|
|
- j.setMsg("导出成功!");
|
|
|
|
- return j;
|
|
|
|
|
|
+ String fileName = "费用入账模板文件.xlsx";
|
|
|
|
+ List<append> list = Lists.newArrayList();
|
|
|
|
+ new ExportExcel("", Expense.class, 1).setDataList(list).write(response, fileName).dispose();
|
|
|
|
+ return null;
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
j.setSuccess(false);
|
|
j.setSuccess(false);
|
|
- j.setMsg("导出票务代理记录失败!失败信息:"+e.getMessage());
|
|
|
|
|
|
+ j.setMsg("费用入账模板文件!失败信息:" + e.getMessage());
|
|
}
|
|
}
|
|
- return j;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @ResponseBody
|
|
|
|
- @RequestMapping(value = "detail")
|
|
|
|
- public TestDataMain2 detail(String id) {
|
|
|
|
- return testDataMain2Service.get(id);
|
|
|
|
|
|
+ return j;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
|
|
- *//**
|
|
|
|
- * 导入Excel数据
|
|
|
|
-
|
|
|
|
- *//*
|
|
|
|
- @ResponseBody
|
|
|
|
- @RequiresPermissions("test:onetomany:form:testDataMain2:import")
|
|
|
|
- @RequestMapping(value = "import")
|
|
|
|
- public AjaxJson importFile(@RequestParam("file")MultipartFile file, HttpServletResponse response, HttpServletRequest request) {
|
|
|
|
- AjaxJson j = new AjaxJson();
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 导入费用入账数据
|
|
|
|
+ */
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequestMapping(value = "importExpense")
|
|
|
|
+ public AjaxJson importExpense(@RequestParam("file") MultipartFile file, Expense expense, HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
|
|
+ AjaxJson j = new AjaxJson();
|
|
|
|
+ List<Expense> expenseList = new ArrayList<>();
|
|
try {
|
|
try {
|
|
int successNum = 0;
|
|
int successNum = 0;
|
|
- int failureNum = 0;
|
|
|
|
StringBuilder failureMsg = new StringBuilder();
|
|
StringBuilder failureMsg = new StringBuilder();
|
|
ImportExcel ei = new ImportExcel(file, 1, 0);
|
|
ImportExcel ei = new ImportExcel(file, 1, 0);
|
|
- List<TestDataMain2> list = ei.getDataList(TestDataMain2.class);
|
|
|
|
- for (TestDataMain2 testDataMain2 : list){
|
|
|
|
- try{
|
|
|
|
- testDataMain2Service.save(testDataMain2);
|
|
|
|
- successNum++;
|
|
|
|
- }catch(ConstraintViolationException ex){
|
|
|
|
- failureNum++;
|
|
|
|
- }catch (Exception ex) {
|
|
|
|
- failureNum++;
|
|
|
|
|
|
+ int lastDataRowNum = ei.getLastDataRowNum();
|
|
|
|
+ String reg = "\\d+(\\.\\d+)?";
|
|
|
|
+ for (int i = 1; i < lastDataRowNum; i++) {
|
|
|
|
+ Expense insertExpense = new Expense();
|
|
|
|
+ Row row = ei.getRow(i);
|
|
|
|
+ String projectId = ei.getCellValue(row, 0).toString();
|
|
|
|
+ String projectName = ei.getCellValue(row, 1).toString();
|
|
|
|
+ String projectBatch = ei.getCellValue(row, 2).toString();
|
|
|
|
+ String constructionCost = ei.getCellValue(row, 3).toString();
|
|
|
|
+ String designCost = ei.getCellValue(row, 4).toString();
|
|
|
|
+ String designTypeicalCost = ei.getCellValue(row, 5).toString();
|
|
|
|
+ String supervisionCost = ei.getCellValue(row, 6).toString();
|
|
|
|
+ String supervisionTypeicalCost = ei.getCellValue(row, 7).toString();
|
|
|
|
+ String documentDesignCost = ei.getCellValue(row, 8).toString();
|
|
|
|
+ String documentSupervisionCost = ei.getCellValue(row, 9).toString();
|
|
|
|
+ if ("".equals(projectId)) {
|
|
|
|
+ failureMsg.append("有数据填写有误");
|
|
|
|
+ continue;
|
|
|
|
+ } else if ("".equals(projectName)) {
|
|
|
|
+ failureMsg.append("有数据填写有误");
|
|
|
|
+ continue;
|
|
|
|
+ }else if ("".equals(projectBatch)) {
|
|
|
|
+ failureMsg.append("有数据填写有误");
|
|
|
|
+ continue;
|
|
|
|
+ }else if ("".equals(constructionCost)||!constructionCost.matches(reg)) {
|
|
|
|
+ failureMsg.append(projectId+"有数据填写有误</br>");
|
|
|
|
+ continue;
|
|
|
|
+ }else if ("".equals(designCost)||!designCost.matches(reg)) {
|
|
|
|
+ failureMsg.append(projectId+"有数据填写有误</br>");
|
|
|
|
+ continue;
|
|
|
|
+ }else if ("".equals(designTypeicalCost)||!designTypeicalCost.matches(reg)) {
|
|
|
|
+ failureMsg.append(projectId+"有数据填写有误</br>");
|
|
|
|
+ continue;
|
|
|
|
+ }else if ("".equals(supervisionCost)||!supervisionCost.matches(reg)) {
|
|
|
|
+ failureMsg.append(projectId+"有数据填写有误</br>");
|
|
|
|
+ continue;
|
|
|
|
+ }else if ("".equals(supervisionTypeicalCost)||!supervisionTypeicalCost.matches(reg)) {
|
|
|
|
+ failureMsg.append(projectId+"有数据填写有误</br>");
|
|
|
|
+ continue;
|
|
|
|
+ }else if ("".equals(documentDesignCost)||!documentDesignCost.matches(reg)) {
|
|
|
|
+ failureMsg.append(projectId+"有数据填写有误</br>");
|
|
|
|
+ continue;
|
|
|
|
+ } else if ("".equals(documentSupervisionCost)||!documentSupervisionCost.matches(reg)) {
|
|
|
|
+ failureMsg.append(projectId+"有数据填写有误</br>");
|
|
|
|
+ continue;
|
|
|
|
+ } else {
|
|
|
|
+ insertExpense.setProjectId(projectId);
|
|
|
|
+ insertExpense.setProjectName(projectName);
|
|
|
|
+ insertExpense.setProjectBatch(projectBatch);
|
|
|
|
+ insertExpense.setConstructionCost(Double.valueOf(constructionCost));
|
|
|
|
+ insertExpense.setDesignCost(Double.valueOf(designCost));
|
|
|
|
+ insertExpense.setDesignTypeicalCost(Double.valueOf(designTypeicalCost));
|
|
|
|
+ insertExpense.setSupervisionCost(Double.valueOf(supervisionCost));
|
|
|
|
+ insertExpense.setSupervisionTypeicalCost(Double.valueOf(supervisionTypeicalCost));
|
|
|
|
+ insertExpense.setDocumentDesignCost(Double.valueOf(documentDesignCost));
|
|
|
|
+ insertExpense.setDocumentSupervisionCost(Double.valueOf(documentSupervisionCost));
|
|
}
|
|
}
|
|
|
|
+ expenseList.add(insertExpense);
|
|
}
|
|
}
|
|
- if (failureNum>0){
|
|
|
|
- failureMsg.insert(0, ",失败 "+failureNum+" 条票务代理记录。");
|
|
|
|
|
|
+ if (expenseList.size() > 0) {
|
|
|
|
+ expenseService.insertList(expenseList);
|
|
|
|
+ j.setSuccess(true);
|
|
|
|
+ j.setMsg("已成功导入 " + expenseList.size() + " 条费用入账记录" + failureMsg);
|
|
|
|
+ } else {
|
|
|
|
+ j.setSuccess(true);
|
|
|
|
+ j.setMsg( "没有符合规定的数据");
|
|
}
|
|
}
|
|
- j.setMsg( "已成功导入 "+successNum+" 条票务代理记录"+failureMsg);
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
j.setSuccess(false);
|
|
j.setSuccess(false);
|
|
j.setMsg("导入票务代理失败!失败信息:"+e.getMessage());
|
|
j.setMsg("导入票务代理失败!失败信息:"+e.getMessage());
|
|
}
|
|
}
|
|
- return j;
|
|
|
|
|
|
+ return j;
|
|
}
|
|
}
|
|
-
|
|
|
|
- *//**
|
|
|
|
- * 下载导入票务代理数据模板
|
|
|
|
- *//*
|
|
|
|
- @ResponseBody
|
|
|
|
- @RequiresPermissions("test:onetomany:form:testDataMain2:import")
|
|
|
|
- @RequestMapping(value = "import/template")
|
|
|
|
- public AjaxJson importFileTemplate(HttpServletResponse response) {
|
|
|
|
- AjaxJson j = new AjaxJson();
|
|
|
|
- try {
|
|
|
|
- String fileName = "票务代理数据导入模板.xlsx";
|
|
|
|
- List<TestDataMain2> list = Lists.newArrayList();
|
|
|
|
- new ExportExcel("票务代理数据", TestDataMain2.class, 1).setDataList(list).write(response, fileName).dispose();
|
|
|
|
- return null;
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- j.setSuccess(false);
|
|
|
|
- j.setMsg( "导入模板下载失败!失败信息:"+e.getMessage());
|
|
|
|
- }
|
|
|
|
- return j;
|
|
|
|
- }*/
|
|
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|