From 7141a778182232e1771e0916ec6c8ce51ddb6c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Wed, 2 Jan 2019 21:44:04 +0800 Subject: [PATCH 01/19] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- erp_web/js/print/print.js | 22 ++++++++++++------- erp_web/pages/reports/account_report.html | 3 +-- erp_web/pages/reports/buy_in_report.html | 3 +-- erp_web/pages/reports/customer_account.html | 3 +-- erp_web/pages/reports/in_detail.html | 3 +-- erp_web/pages/reports/in_material_count.html | 3 +-- .../pages/reports/in_out_stock_report.html | 3 +-- erp_web/pages/reports/out_detail.html | 3 +-- erp_web/pages/reports/out_material_count.html | 3 +-- erp_web/pages/reports/sale_out_report.html | 3 +-- erp_web/pages/reports/vendor_account.html | 3 +-- 11 files changed, 24 insertions(+), 28 deletions(-) diff --git a/erp_web/js/print/print.js b/erp_web/js/print/print.js index f52f822a..2da1d0d6 100644 --- a/erp_web/js/print/print.js +++ b/erp_web/js/print/print.js @@ -1,6 +1,6 @@ // strPrintName 打印任务名 // printDatagrid 要打印的datagrid -function CreateFormPage(strPrintName, printDatagrid, path) { +function CreateFormPage(strPrintName, printDatagrid) { var beginDate= $("#searchBeginTime").val(); var endDate= $("#searchEndTime").val(); var getMonth= $("#searchMonth").val(); @@ -10,16 +10,22 @@ function CreateFormPage(strPrintName, printDatagrid, path) { //加载公司信息 $.ajax({ type:"get", - url: path + "/systemConfig/findBy.action", + url: "/systemConfig/list", dataType: "json", + data: ({ + currentPage: 1, + pageSize: 100 + }), async: false, success: function (res) { - if(res && res.rows) { - var array = res.rows; - for(var i=0; i diff --git a/erp_web/pages/reports/buy_in_report.html b/erp_web/pages/reports/buy_in_report.html index d0e0efa6..1599f749 100644 --- a/erp_web/pages/reports/buy_in_report.html +++ b/erp_web/pages/reports/buy_in_report.html @@ -252,8 +252,7 @@ //报表打印 function print() { $("#printBtn").off("click").on("click", function () { - var path = "<%=path %>"; - CreateFormPage('打印报表', $('#tableData'), path); + CreateFormPage('打印报表', $('#tableData')); }); } diff --git a/erp_web/pages/reports/customer_account.html b/erp_web/pages/reports/customer_account.html index cc0a7e51..f3966d01 100644 --- a/erp_web/pages/reports/customer_account.html +++ b/erp_web/pages/reports/customer_account.html @@ -344,8 +344,7 @@ //报表打印 function print() { $("#printBtn").off("click").on("click", function () { - var path = "<%=path %>"; - CreateFormPage('打印报表', $('#tableData'), path); + CreateFormPage('打印报表', $('#tableData')); }); } diff --git a/erp_web/pages/reports/in_detail.html b/erp_web/pages/reports/in_detail.html index 7e713b2f..a151eec8 100644 --- a/erp_web/pages/reports/in_detail.html +++ b/erp_web/pages/reports/in_detail.html @@ -306,8 +306,7 @@ //报表打印 function print() { $("#printBtn").off("click").on("click", function () { - var path = "<%=path %>"; - CreateFormPage('打印报表', $('#tableData'), path); + CreateFormPage('打印报表', $('#tableData')); }); } diff --git a/erp_web/pages/reports/in_material_count.html b/erp_web/pages/reports/in_material_count.html index 50dc379c..4c0b91df 100644 --- a/erp_web/pages/reports/in_material_count.html +++ b/erp_web/pages/reports/in_material_count.html @@ -295,8 +295,7 @@ //报表打印 function print() { $("#printBtn").off("click").on("click", function () { - var path = "<%=path %>"; - CreateFormPage('打印报表', $('#tableData'), path); + CreateFormPage('打印报表', $('#tableData')); }); } diff --git a/erp_web/pages/reports/in_out_stock_report.html b/erp_web/pages/reports/in_out_stock_report.html index a8c006b9..07d351cf 100644 --- a/erp_web/pages/reports/in_out_stock_report.html +++ b/erp_web/pages/reports/in_out_stock_report.html @@ -411,8 +411,7 @@ //报表打印 function print() { $("#printBtn").off("click").on("click", function () { - var path = "<%=path %>"; - CreateFormPage('打印报表', $('#tableData'), path); + CreateFormPage('打印报表', $('#tableData')); }); } diff --git a/erp_web/pages/reports/out_detail.html b/erp_web/pages/reports/out_detail.html index d39f35b9..da318011 100644 --- a/erp_web/pages/reports/out_detail.html +++ b/erp_web/pages/reports/out_detail.html @@ -306,8 +306,7 @@ //报表打印 function print() { $("#printBtn").off("click").on("click", function () { - var path = "<%=path %>"; - CreateFormPage('打印报表', $('#tableData'), path); + CreateFormPage('打印报表', $('#tableData')); }); } diff --git a/erp_web/pages/reports/out_material_count.html b/erp_web/pages/reports/out_material_count.html index e1e7fcc7..5899db85 100644 --- a/erp_web/pages/reports/out_material_count.html +++ b/erp_web/pages/reports/out_material_count.html @@ -295,8 +295,7 @@ //报表打印 function print() { $("#printBtn").off("click").on("click", function () { - var path = "<%=path %>"; - CreateFormPage('打印报表', $('#tableData'), path); + CreateFormPage('打印报表', $('#tableData')); }); } diff --git a/erp_web/pages/reports/sale_out_report.html b/erp_web/pages/reports/sale_out_report.html index e35e33e2..f58bed7f 100644 --- a/erp_web/pages/reports/sale_out_report.html +++ b/erp_web/pages/reports/sale_out_report.html @@ -255,8 +255,7 @@ //报表打印 function print() { $("#printBtn").off("click").on("click", function () { - var path = "<%=path %>"; - CreateFormPage('打印报表', $('#tableData'), path); + CreateFormPage('打印报表', $('#tableData')); }); } diff --git a/erp_web/pages/reports/vendor_account.html b/erp_web/pages/reports/vendor_account.html index 8764803c..c5cb9740 100644 --- a/erp_web/pages/reports/vendor_account.html +++ b/erp_web/pages/reports/vendor_account.html @@ -343,8 +343,7 @@ //报表打印 function print() { $("#printBtn").off("click").on("click", function () { - var path = "<%=path %>"; - CreateFormPage('打印报表', $('#tableData'), path); + CreateFormPage('打印报表', $('#tableData')); }); } From 8a4d0347437750304d1920d0eeeda88c4371b676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Fri, 4 Jan 2019 22:48:45 +0800 Subject: [PATCH 02/19] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BA=93=E5=AD=98?= =?UTF-8?q?=E6=8A=A5=E8=A1=A8excel=E5=AF=BC=E5=87=BA=E7=9A=84=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/reports/in_out_stock_report.html | 2 +- pom.xml | 5 + .../erp/controller/DepotItemController.java | 66 +++++ .../java/com/jsh/erp/utils/ExcelUtils.java | 240 ++++++++++++++++++ .../com/jsh/erp/utils/ExportExecUtil.java | 28 ++ 5 files changed, 340 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/jsh/erp/utils/ExcelUtils.java create mode 100644 src/main/java/com/jsh/erp/utils/ExportExecUtil.java diff --git a/erp_web/pages/reports/in_out_stock_report.html b/erp_web/pages/reports/in_out_stock_report.html index 07d351cf..cd00cdb4 100644 --- a/erp_web/pages/reports/in_out_stock_report.html +++ b/erp_web/pages/reports/in_out_stock_report.html @@ -325,7 +325,7 @@ var mIds = res.data.mIds; if (mIds) { if (pageSize === 3000) { - window.location.href = "/depotItem/exportExcel.action?browserType=" + getOs() + "&pageNo=" + pageNo + "&pageSize=" + pageSize + "&ProjectId=" + $.trim($("#searchProjectId").val()) + "&MonthTime=" + $("#searchMonth").val() + "&HeadIds=" + HeadIds + "&MaterialIds=" + MIds; + window.location.href = "/depotItem/exportExcel?browserType=" + getOs() + "¤tPage=" + pageNo + "&pageSize=" + pageSize + "&projectId=" + $.trim($("#searchProjectId").val()) + "&monthTime=" + $("#searchMonth").val() + "&headIds=" + HeadIds + "&materialIds=" + mIds; } else { $.ajax({ diff --git a/pom.xml b/pom.xml index 67881160..d245e114 100644 --- a/pom.xml +++ b/pom.xml @@ -74,6 +74,11 @@ commons-httpclient 3.1 + + net.sourceforge.jexcelapi + jxl + 2.6.3 + diff --git a/src/main/java/com/jsh/erp/controller/DepotItemController.java b/src/main/java/com/jsh/erp/controller/DepotItemController.java index e33c8280..2e937db8 100644 --- a/src/main/java/com/jsh/erp/controller/DepotItemController.java +++ b/src/main/java/com/jsh/erp/controller/DepotItemController.java @@ -13,6 +13,8 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -841,6 +843,70 @@ public class DepotItemController { return res; } + /** + * 导出excel表格 + * @param request + * @return + */ + @GetMapping(value = "/exportExcel") + public BaseResponseInfo exportExcel(@RequestParam("currentPage") Integer currentPage, + @RequestParam("pageSize") Integer pageSize, + @RequestParam("projectId") Integer projectId, + @RequestParam("monthTime") String monthTime, + @RequestParam("headIds") String headIds, + @RequestParam("materialIds") String materialIds, + HttpServletRequest request, HttpServletResponse response) { + BaseResponseInfo res = new BaseResponseInfo(); + Map map = new HashMap(); + String message = "成功"; + try { + List dataList = depotItemService.findByAll(headIds, materialIds, currentPage, pageSize); + //存放数据json数组 + Integer pid = projectId; + String[] names = {"名称", "型号", "单位", "单价", "上月结存数量", "入库数量", "出库数量", "本月结存数量", "结存金额"}; + String title = "库存报表"; + List objects = new ArrayList(); + if (null != dataList) { + for (DepotItemVo4WithInfoEx diEx : dataList) { + String[] objs = new String[13]; + Double prevSum = sumNumber("入库", pid, diEx.getMaterialid(), monthTime, true) - sumNumber("出库", pid, diEx.getMaterialid(), monthTime, true); + Double InSum = sumNumber("入库", pid, diEx.getMaterialid(), monthTime, false); + Double OutSum = sumNumber("出库", pid, diEx.getMaterialid(), monthTime, false); + Double prevPrice = sumPrice("入库", pid, diEx.getMaterialid(), monthTime, true) - sumPrice("出库", pid, diEx.getMaterialid(), monthTime, true); + Double InPrice = sumPrice("入库", pid, diEx.getMaterialid(), monthTime, false); + Double OutPrice = sumPrice("出库", pid, diEx.getMaterialid(), monthTime, false); + Double unitPrice = 0.0; + if (prevSum + InSum - OutSum != 0.0) { + unitPrice = (prevPrice + InPrice - OutPrice) / (prevSum + InSum - OutSum); + } + Double thisSum = prevSum + InSum - OutSum; + Double thisAllPrice = prevPrice + InPrice - OutPrice; + objs[0] = diEx.getMName().toString(); + objs[1] = diEx.getMModel().toString(); + objs[2] = diEx.getMaterialUnit().toString(); + objs[3] = unitPrice.toString(); + objs[4] = prevSum.toString(); + objs[5] = InSum.toString(); + objs[6] = OutSum.toString(); + objs[7] = thisSum.toString(); + objs[8] = thisAllPrice.toString(); + objects.add(objs); + } + } + File file = ExcelUtils.exportObjectsWithoutTitle(title, names, title, objects); + ExportExecUtil.showExec(file, file.getName() + "-" + monthTime, response); + res.code = 200; + } catch (Exception e) { + e.printStackTrace(); + message = "导出失败"; + res.code = 500; + } finally { + map.put("message", message); + res.data = map; + } + return res; + } + /** * 数量合计 * diff --git a/src/main/java/com/jsh/erp/utils/ExcelUtils.java b/src/main/java/com/jsh/erp/utils/ExcelUtils.java new file mode 100644 index 00000000..c8e6849c --- /dev/null +++ b/src/main/java/com/jsh/erp/utils/ExcelUtils.java @@ -0,0 +1,240 @@ +package com.jsh.erp.utils; + +import java.io.File; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.alibaba.druid.util.StringUtils; +import jxl.Cell; +import jxl.Sheet; +import jxl.Workbook; +import jxl.format.*; +import jxl.write.Label; +import jxl.write.WritableCellFormat; +import jxl.write.WritableFont; +import jxl.write.WritableSheet; +import jxl.write.WritableWorkbook; + +public class ExcelUtils { + + public static WritableFont arial14font = null; + + public static File exportObjects(String fileName, String[] names, + String title, List objects) throws Exception { + File excelFile = new File("fileName.xls"); + WritableWorkbook wtwb = Workbook.createWorkbook(excelFile); + WritableSheet sheet = wtwb.createSheet(title, 0); + sheet.getSettings().setDefaultColumnWidth(20); + WritableFont wfont = new WritableFont(WritableFont.createFont("楷书"), 15); + WritableCellFormat format = new WritableCellFormat(wfont); + WritableFont wfc = new WritableFont(WritableFont.ARIAL, 20, + WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, + jxl.format.Colour.BLACK); + WritableCellFormat wcfFC = new WritableCellFormat(wfc); + wcfFC.setAlignment(Alignment.CENTRE); + wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE); + // CellView cellView = new CellView(); + // cellView.setAutosize(true); //设置自动大小 + format.setAlignment(Alignment.LEFT); + format.setVerticalAlignment(VerticalAlignment.TOP); + sheet.mergeCells(0, 0, names.length - 1, 0); + sheet.addCell(new Label(0, 0, title, wcfFC)); + int rowNum = 2; + for (int i = 0; i < names.length; i++) { + sheet.addCell(new Label(i, 1, names[i], format)); + } + for (int j = 0; j < objects.size(); j++) { + String[] obj = objects.get(j); + for (int h = 0; h < obj.length; h++) { + sheet.addCell(new Label(h, rowNum, obj[h], format)); + } + rowNum = rowNum + 1; + + } + wtwb.write(); + wtwb.close(); + return excelFile; + } + + /** + * 导出excel,不需要第一行的title + * + * @param fileName + * @param names + * @param title + * @param objects + * @return + * @throws Exception + */ + public static File exportObjectsWithoutTitle(String fileName, + String[] names, String title, List objects) + throws Exception { + File excelFile = new File(fileName); + WritableWorkbook wtwb = Workbook.createWorkbook(excelFile); + WritableSheet sheet = wtwb.createSheet(title, 0); + sheet.getSettings().setDefaultColumnWidth(20); + + // 第一行的格式 + WritableFont wfc = new WritableFont(WritableFont.ARIAL, 15, + WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, + jxl.format.Colour.BLACK); + WritableCellFormat wcfFC = new WritableCellFormat(wfc); + wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE); + + // 设置字体以及单元格格式 + WritableFont wfont = new WritableFont(WritableFont.createFont("楷书"), 15); + WritableCellFormat format = new WritableCellFormat(wfont); + format.setAlignment(Alignment.LEFT); + format.setVerticalAlignment(VerticalAlignment.TOP); + + // 第一行写入标题 + for (int i = 0; i < names.length; i++) { + sheet.addCell(new Label(i, 0, names[i], wcfFC)); + } + + // 其余行依次写入数据 + int rowNum = 1; + for (int j = 0; j < objects.size(); j++) { + String[] obj = objects.get(j); + for (int h = 0; h < obj.length; h++) { + sheet.addCell(new Label(h, rowNum, obj[h], format)); + } + rowNum = rowNum + 1; + } + wtwb.write(); + wtwb.close(); + return excelFile; + } + + public static String createTempFile(String[] names, String title, List objects) throws Exception { + File excelFile = File.createTempFile(System.currentTimeMillis() + "", ".xls"); + WritableWorkbook wtwb = Workbook.createWorkbook(excelFile); + WritableSheet sheet = wtwb.createSheet(title, 0); + sheet.getSettings().setDefaultColumnWidth(20); + WritableFont wfont = new WritableFont(WritableFont.createFont("楷书"), 15); + WritableCellFormat format = new WritableCellFormat(wfont); + WritableFont wfc = new WritableFont(WritableFont.ARIAL, 20, + WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, + jxl.format.Colour.BLACK); + WritableCellFormat wcfFC = new WritableCellFormat(wfc); + wcfFC.setAlignment(Alignment.CENTRE); + wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE); + // CellView cellView = new CellView(); + // cellView.setAutosize(true); //设置自动大小 + format.setAlignment(Alignment.LEFT); + format.setVerticalAlignment(VerticalAlignment.TOP); + sheet.mergeCells(0, 0, names.length - 1, 0); + sheet.addCell(new Label(0, 0, title, wcfFC)); + int rowNum = 2; + for (int i = 0; i < names.length; i++) { + sheet.addCell(new Label(i, 1, names[i], format)); + } + for (int j = 0; j < objects.size(); j++) { + String[] obj = objects.get(j); + for (int h = 0; h < obj.length; h++) { + sheet.addCell(new Label(h, rowNum, obj[h], format)); + } + rowNum = rowNum + 1; + } + wtwb.write(); + wtwb.close(); + return excelFile.getName(); + } + + public static String createCheckRandomTempFile(String[] names, String title, List objects,Map infoMap) throws Exception { + File excelFile = File.createTempFile(System.currentTimeMillis() + "", ".xls"); + WritableWorkbook wtwb = Workbook.createWorkbook(excelFile); + WritableSheet sheet = wtwb.createSheet(title, 0); + sheet.getSettings().setDefaultColumnWidth(20); + WritableFont wfont = new WritableFont(WritableFont.createFont("楷书"), 14); + + WritableCellFormat format = new WritableCellFormat(wfont); + format.setBorder(Border.ALL, BorderLineStyle.THIN); + format.setAlignment(Alignment.CENTRE); + format.setVerticalAlignment(VerticalAlignment.CENTRE); + + WritableFont wfc = new WritableFont(WritableFont.ARIAL, 20, + WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, + jxl.format.Colour.BLACK); + WritableCellFormat wcfFC = new WritableCellFormat(wfc); + wcfFC.setAlignment(Alignment.LEFT); + wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE); + + WritableFont nameWfc = new WritableFont(WritableFont.ARIAL, 14, + WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE, + jxl.format.Colour.BLACK); + WritableCellFormat nameFormat = new WritableCellFormat(nameWfc); + nameFormat.setBorder(Border.ALL, BorderLineStyle.THIN); + nameFormat.setAlignment(Alignment.CENTRE); + nameFormat.setVerticalAlignment(VerticalAlignment.CENTRE); + + WritableCellFormat infoFormat = new WritableCellFormat(wfont); + infoFormat.setAlignment(Alignment.LEFT); + infoFormat.setVerticalAlignment(VerticalAlignment.CENTRE); + + + sheet.mergeCells(0, 0, names.length - 1, 0); + sheet.addCell(new Label(0, 0, infoMap.get("title"), wcfFC)); + + sheet.addCell(new Label(0, 2, infoMap.get("info"), infoFormat)); + sheet.addCell(new Label(2, 2, infoMap.get("dvrnvr"), infoFormat)); + sheet.addCell(new Label(4, 2, infoMap.get("char"), infoFormat)); + sheet.addCell(new Label(0, 3, infoMap.get("infoPercent"), infoFormat)); + sheet.addCell(new Label(2, 3, infoMap.get("dvrnvrPercent"), infoFormat)); + sheet.addCell(new Label(4, 3, infoMap.get("charPercent"), infoFormat)); + + int rowNum = 5; + for (int i = 0; i < names.length; i++) { + sheet.addCell(new Label(i, 4, names[i], nameFormat)); + } + for (int j = 0; j < objects.size(); j++) { + String[] obj = objects.get(j); + for (int h = 0; h < obj.length; h++) { + sheet.addCell(new Label(h, rowNum, obj[h], format)); + } + rowNum = rowNum + 1; + } + wtwb.write(); + wtwb.close(); + return excelFile.getName(); + } + + + + public static String getContent(Sheet src, int rowNum, int colNum) { + return src.getRow(rowNum)[colNum].getContents().trim(); + } + + /** + * 从第i行开始到最后检测指定列的唯一性 + * + * @param src + * @param colNum + * @param fromRow + * 起始行 + * @return + */ + public static Boolean checkUnique(Sheet src, int colNum, int fromRow) { + Cell[] colCells = src.getColumn(colNum); + Set set = new HashSet(); + for (int i = fromRow; i < colCells.length; i++) { + if (!StringUtils.isEmpty(colCells[i].getContents()) + && !set.add(colCells[i].getContents())) { + return false; + } + } + return true; + } + + public static File getTempFile(String fileName) { + String dir = System.getProperty("java.io.tmpdir"); // 获取系统临时目录 + return new File(dir + File.separator + fileName); + } + + public static void main(String[] args) throws Exception { + String msg = "12345"; + System.out.println(msg.indexOf("@")); + } +} diff --git a/src/main/java/com/jsh/erp/utils/ExportExecUtil.java b/src/main/java/com/jsh/erp/utils/ExportExecUtil.java new file mode 100644 index 00000000..6ec7c371 --- /dev/null +++ b/src/main/java/com/jsh/erp/utils/ExportExecUtil.java @@ -0,0 +1,28 @@ +package com.jsh.erp.utils; + +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.FileInputStream; +import java.io.OutputStream; + +public class ExportExecUtil { + + public static void showExec(File excelFile,String fileName,HttpServletResponse response) throws Exception{ + response.setContentType("application/octet-stream"); + fileName = new String(fileName.getBytes("gbk"),"ISO8859_1"); + response.setHeader("Content-Disposition", "attachment;filename=\"" + fileName + ".xls" + "\""); + FileInputStream fis = new FileInputStream(excelFile); + OutputStream out = response.getOutputStream(); + + int SIZE = 1024 * 1024; + byte[] bytes = new byte[SIZE]; + int LENGTH = -1; + while((LENGTH = fis.read(bytes)) != -1){ + out.write(bytes,0,LENGTH); + } + + out.flush(); + fis.close(); + } + +} From 2b7a7bbdeb3e89d441e9658f2122c899c31a4e36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Sat, 5 Jan 2019 21:33:01 +0800 Subject: [PATCH 03/19] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- erp_web/js/pages/manage/supplier.js | 7 +- erp_web/pages/materials/material.html | 13 +- .../erp/controller/DepotItemController.java | 9 +- .../erp/controller/MaterialController.java | 133 +++++++++++++++++- .../erp/controller/SupplierController.java | 68 +++++++++ .../datasource/mappers/MaterialMapper.java | 6 + .../datasource/mappers/SupplierMapper.java | 7 + .../erp/service/material/MaterialService.java | 32 +++++ .../erp/service/supplier/SupplierService.java | 4 + .../resources/mapper_xml/MaterialMapperEx.xml | 18 +++ .../resources/mapper_xml/SupplierMapperEx.xml | 21 +++ 11 files changed, 311 insertions(+), 7 deletions(-) diff --git a/erp_web/js/pages/manage/supplier.js b/erp_web/js/pages/manage/supplier.js index 08deeb26..31983a1c 100644 --- a/erp_web/js/pages/manage/supplier.js +++ b/erp_web/js/pages/manage/supplier.js @@ -343,7 +343,12 @@ //导出数据 function setOutputFun(){ - window.location.href = "/supplier/exportExcel.action?browserType=" + getOs() + "&type=" + listTypeEn; + var supplier = $.trim($("#searchSupplier").val()); + var phonenum = $.trim($("#searchPhonenum").val()); + var telephone = $.trim($("#searchTelephone").val()); + var description = $.trim($("#searchDesc").val()); + window.location.href = "/supplier/exportExcel?browserType=" + getOs() + + "&supplier=" + supplier + "&type=" + listType + "&phonenum=" + phonenum + "&telephone=" + telephone + "&description=" + description; } //增加单位 diff --git a/erp_web/pages/materials/material.html b/erp_web/pages/materials/material.html index 9f78ccfb..59e0098d 100644 --- a/erp_web/pages/materials/material.html +++ b/erp_web/pages/materials/material.html @@ -244,7 +244,7 @@
-
+
@@ -259,7 +259,6 @@
-
导入 objects = new ArrayList(); if (null != dataList) { for (DepotItemVo4WithInfoEx diEx : dataList) { - String[] objs = new String[13]; + String[] objs = new String[9]; Double prevSum = sumNumber("入库", pid, diEx.getMaterialid(), monthTime, true) - sumNumber("出库", pid, diEx.getMaterialid(), monthTime, true); Double InSum = sumNumber("入库", pid, diEx.getMaterialid(), monthTime, false); Double OutSum = sumNumber("出库", pid, diEx.getMaterialid(), monthTime, false); diff --git a/src/main/java/com/jsh/erp/controller/MaterialController.java b/src/main/java/com/jsh/erp/controller/MaterialController.java index f3e52ca3..35cba0dd 100644 --- a/src/main/java/com/jsh/erp/controller/MaterialController.java +++ b/src/main/java/com/jsh/erp/controller/MaterialController.java @@ -1,18 +1,24 @@ package com.jsh.erp.controller; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.jsh.erp.datasource.entities.Material; import com.jsh.erp.datasource.entities.MaterialVo4Unit; import com.jsh.erp.service.material.MaterialService; -import com.jsh.erp.utils.BaseResponseInfo; -import com.jsh.erp.utils.ErpInfo; +import com.jsh.erp.utils.*; +import jxl.Sheet; +import jxl.Workbook; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -177,4 +183,127 @@ public class MaterialController { } return res; } + + /** + * 生成excel表格 + * @param name + * @param model + * @param categoryId + * @param categoryIds + * @param request + * @param response + * @return + */ + @GetMapping(value = "/exportExcel") + public BaseResponseInfo exportExcel(@RequestParam("name") String name, + @RequestParam("model") String model, + @RequestParam("categoryId") Long categoryId, + @RequestParam("categoryIds") String categoryIds, + HttpServletRequest request, HttpServletResponse response) { + BaseResponseInfo res = new BaseResponseInfo(); + Map map = new HashMap(); + String message = "成功"; + try { + List dataList = materialService.findByAll(name, model, categoryId, categoryIds); + String[] names = {"品名", "类型", "型号", "安全存量", "单位", "零售价", "最低售价", "预计采购价", "批发价", "备注", "状态"}; + String title = "商品信息"; + List objects = new ArrayList(); + if (null != dataList) { + for (MaterialVo4Unit m : dataList) { + String[] objs = new String[11]; + objs[0] = m.getName(); + objs[1] = m.getCategoryName(); + objs[2] = m.getModel(); + objs[3] = m.getSafetystock() == null? "" : m.getSafetystock().toString(); + objs[4] = m.getUnit(); + objs[5] = m.getRetailprice() == null ? "" : m.getRetailprice().toString(); + objs[6] = m.getLowprice() == null ? "" : m.getLowprice().toString(); + objs[7] = m.getPresetpriceone() == null ? "" : m.getPresetpriceone().toString(); + objs[8] = m.getPresetpricetwo() == null ? "" : m.getPresetpricetwo().toString(); + objs[9] = m.getRemark(); + objs[10] = m.getEnabled() ? "启用" : "禁用"; + objects.add(objs); + } + } + File file = ExcelUtils.exportObjectsWithoutTitle(title, names, title, objects); + ExportExecUtil.showExec(file, file.getName(), response); + res.code = 200; + } catch (Exception e) { + e.printStackTrace(); + message = "导出失败"; + res.code = 500; + } finally { + map.put("message", message); + res.data = map; + } + return res; + } + + /** + * excel表格导入 + * @param materialFile + * @param request + * @param response + * @return + */ + @PostMapping(value = "/importExcel") + public void importExcel(MultipartFile materialFile, + HttpServletRequest request, HttpServletResponse response) throws Exception{ + BaseResponseInfo info = new BaseResponseInfo(); + Map data = new HashMap(); + String message = "成功"; + try { + Sheet src = null; + //文件合法性校验 + try { + Workbook workbook = Workbook.getWorkbook(materialFile.getInputStream()); + src = workbook.getSheet(0); + } catch (Exception e) { + message = "导入文件不合法,请检查"; + data.put("message", message); + info.code = 400; + info.data = data; + } + //读取所有的摄像机编码 + //每行中数据顺序 "品名","类型","型号","安全存量","单位","零售价","最低售价","预计采购价","批发价","备注","状态" + List mList = new ArrayList(); + for (int i = 1; i < src.getRows(); i++) { + Material m = new Material(); + m.setName(ExcelUtils.getContent(src, i, 0)); + m.setCategoryid(1l); //根目录 + m.setModel(ExcelUtils.getContent(src, i, 2)); + String safetyStock = ExcelUtils.getContent(src, i, 3); + m.setSafetystock(parseDoubleEx(safetyStock)); + m.setUnit(ExcelUtils.getContent(src, i, 4)); + String retailprice = ExcelUtils.getContent(src, i, 5); + m.setRetailprice(parseDoubleEx(retailprice)); + String lowPrice = ExcelUtils.getContent(src, i, 6); + m.setLowprice(parseDoubleEx(lowPrice)); + String presetpriceone = ExcelUtils.getContent(src, i, 7); + m.setPresetpriceone(parseDoubleEx(presetpriceone)); + String presetpricetwo = ExcelUtils.getContent(src, i, 8); + m.setPresetpricetwo(parseDoubleEx(presetpricetwo)); + m.setRemark(ExcelUtils.getContent(src, i, 9)); + String enabled = ExcelUtils.getContent(src, i, 10); + m.setEnabled(enabled.equals("启用")? true: false); + mList.add(m); + } + info = materialService.importExcel(mList); + } catch (Exception e) { + e.printStackTrace(); + message = "导入失败"; + info.code = 500; + data.put("message", message); + info.data = data; + } + response.sendRedirect("../pages/materials/material.html"); + } + + public Double parseDoubleEx(String str){ + if(!StringUtil.isEmpty(str)) { + return Double.parseDouble(str); + } else { + return null; + } + } } diff --git a/src/main/java/com/jsh/erp/controller/SupplierController.java b/src/main/java/com/jsh/erp/controller/SupplierController.java index d2dc0fec..e61e79a8 100644 --- a/src/main/java/com/jsh/erp/controller/SupplierController.java +++ b/src/main/java/com/jsh/erp/controller/SupplierController.java @@ -7,6 +7,8 @@ import com.jsh.erp.service.supplier.SupplierService; import com.jsh.erp.service.userBusiness.UserBusinessService; import com.jsh.erp.utils.BaseResponseInfo; import com.jsh.erp.utils.ErpInfo; +import com.jsh.erp.utils.ExcelUtils; +import com.jsh.erp.utils.ExportExecUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.dao.DataAccessException; @@ -14,6 +16,9 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -259,4 +264,67 @@ public class SupplierController { } return arr; } + + /** + * 生成excel表格 + * @param supplier + * @param type + * @param phonenum + * @param telephone + * @param description + * @param request + * @param response + * @return + */ + @GetMapping(value = "/exportExcel") + public BaseResponseInfo exportExcel(@RequestParam("supplier") String supplier, + @RequestParam("type") String type, + @RequestParam("phonenum") String phonenum, + @RequestParam("telephone") String telephone, + @RequestParam("description") String description, + HttpServletRequest request, HttpServletResponse response) { + BaseResponseInfo res = new BaseResponseInfo(); + Map map = new HashMap(); + String message = "成功"; + try { + List dataList = supplierService.findByAll(supplier, type, phonenum, telephone, description); + String[] names = {"名称", "类型", "联系人", "电话", "电子邮箱", "预收款", "期初应收", "期初应付", "备注", "传真", "手机", "地址", "纳税人识别号", "开户行", "账号", "税率", "状态"}; + String title = "信息报表"; + List objects = new ArrayList(); + if (null != dataList) { + for (Supplier s : dataList) { + String[] objs = new String[17]; + objs[0] = s.getSupplier(); + objs[1] = s.getType(); + objs[2] = s.getContacts(); + objs[3] = s.getPhonenum(); + objs[4] = s.getEmail(); + objs[5] = s.getAdvancein() == null? "" : s.getAdvancein().toString(); + objs[6] = s.getBeginneedget() == null? "" : s.getBeginneedget().toString(); + objs[7] = s.getBeginneedpay() == null? "" : s.getBeginneedpay().toString(); + objs[8] = s.getDescription(); + objs[9] = s.getFax(); + objs[10] = s.getTelephone(); + objs[11] = s.getAddress(); + objs[12] = s.getTaxnum(); + objs[13] = s.getBankname(); + objs[14] = s.getAccountnumber(); + objs[15] = s.getTaxrate() == null? "" : s.getTaxrate().toString(); + objs[16] = s.getEnabled() ? "启用" : "禁用"; + objects.add(objs); + } + } + File file = ExcelUtils.exportObjectsWithoutTitle(title, names, title, objects); + ExportExecUtil.showExec(file, file.getName(), response); + res.code = 200; + } catch (Exception e) { + e.printStackTrace(); + message = "导出失败"; + res.code = 500; + } finally { + map.put("message", message); + res.data = map; + } + return res; + } } diff --git a/src/main/java/com/jsh/erp/datasource/mappers/MaterialMapper.java b/src/main/java/com/jsh/erp/datasource/mappers/MaterialMapper.java index d89547c8..b7e203bb 100644 --- a/src/main/java/com/jsh/erp/datasource/mappers/MaterialMapper.java +++ b/src/main/java/com/jsh/erp/datasource/mappers/MaterialMapper.java @@ -121,4 +121,10 @@ public interface MaterialMapper { int updatePriceNullByPrimaryKey(Long id); int updateUnitIdNullByPrimaryKey(Long id); + + List findByAll( + @Param("name") String name, + @Param("model") String model, + @Param("categoryId") Long categoryId, + @Param("categoryIds") String categoryIds); } \ No newline at end of file diff --git a/src/main/java/com/jsh/erp/datasource/mappers/SupplierMapper.java b/src/main/java/com/jsh/erp/datasource/mappers/SupplierMapper.java index d06df131..f6ecd8e6 100644 --- a/src/main/java/com/jsh/erp/datasource/mappers/SupplierMapper.java +++ b/src/main/java/com/jsh/erp/datasource/mappers/SupplierMapper.java @@ -109,4 +109,11 @@ public interface SupplierMapper { @Param("phonenum") String phonenum, @Param("telephone") String telephone, @Param("description") String description); + + List findByAll( + @Param("supplier") String supplier, + @Param("type") String type, + @Param("phonenum") String phonenum, + @Param("telephone") String telephone, + @Param("description") String description); } \ No newline at end of file diff --git a/src/main/java/com/jsh/erp/service/material/MaterialService.java b/src/main/java/com/jsh/erp/service/material/MaterialService.java index fec66c9b..ffad45e3 100644 --- a/src/main/java/com/jsh/erp/service/material/MaterialService.java +++ b/src/main/java/com/jsh/erp/service/material/MaterialService.java @@ -5,6 +5,7 @@ import com.jsh.erp.datasource.entities.Material; import com.jsh.erp.datasource.entities.MaterialExample; import com.jsh.erp.datasource.entities.MaterialVo4Unit; import com.jsh.erp.datasource.mappers.MaterialMapper; +import com.jsh.erp.utils.BaseResponseInfo; import com.jsh.erp.utils.StringUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -13,7 +14,9 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; @Service public class MaterialService { @@ -154,4 +157,33 @@ public class MaterialService { return materialMapper.selectByExample(example); } + public List findByAll(String name, String model, Long categoryId, String categoryIds) { + List resList = new ArrayList(); + List list = materialMapper.findByAll(name, model, categoryId, categoryIds); + if (null != list) { + for (MaterialVo4Unit m : list) { + resList.add(m); + } + } + return resList; + } + + public BaseResponseInfo importExcel(List mList) throws Exception { + BaseResponseInfo info = new BaseResponseInfo(); + Map data = new HashMap(); + try { + for(Material m: mList) { + materialMapper.insertSelective(m); + } + info.code = 200; + data.put("message", "成功"); + } catch (Exception e) { + e.printStackTrace(); + info.code = 500; + data.put("message", e.getMessage()); + } + info.data = data; + return info; + + } } diff --git a/src/main/java/com/jsh/erp/service/supplier/SupplierService.java b/src/main/java/com/jsh/erp/service/supplier/SupplierService.java index c113e745..6c3ce21d 100644 --- a/src/main/java/com/jsh/erp/service/supplier/SupplierService.java +++ b/src/main/java/com/jsh/erp/service/supplier/SupplierService.java @@ -116,4 +116,8 @@ public class SupplierService { List list = supplierMapper.selectByExample(example); return list; } + + public List findByAll(String supplier, String type, String phonenum, String telephone, String description) { + return supplierMapper.findByAll(supplier, type, phonenum, telephone, description); + } } diff --git a/src/main/resources/mapper_xml/MaterialMapperEx.xml b/src/main/resources/mapper_xml/MaterialMapperEx.xml index 0d33938d..4dea65a6 100644 --- a/src/main/resources/mapper_xml/MaterialMapperEx.xml +++ b/src/main/resources/mapper_xml/MaterialMapperEx.xml @@ -77,4 +77,22 @@ UnitId = null where Id = #{id,jdbcType=BIGINT} + + \ No newline at end of file diff --git a/src/main/resources/mapper_xml/SupplierMapperEx.xml b/src/main/resources/mapper_xml/SupplierMapperEx.xml index d890226e..d18af528 100644 --- a/src/main/resources/mapper_xml/SupplierMapperEx.xml +++ b/src/main/resources/mapper_xml/SupplierMapperEx.xml @@ -45,4 +45,25 @@ and description like '%${description}%' + + \ No newline at end of file From 74fc3875b29c2302a2314736829765caf52498bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Sat, 5 Jan 2019 22:29:41 +0800 Subject: [PATCH 04/19] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E5=95=86=E7=9A=84=E5=AF=BC=E5=85=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- erp_web/pages/manage/customer.html | 3 +- erp_web/pages/manage/member.html | 3 +- erp_web/pages/manage/vendor.html | 3 +- .../erp/controller/SupplierController.java | 112 +++++++++++++++++- .../erp/service/material/MaterialService.java | 1 - .../erp/service/supplier/SupplierService.java | 21 ++++ 6 files changed, 132 insertions(+), 11 deletions(-) diff --git a/erp_web/pages/manage/customer.html b/erp_web/pages/manage/customer.html index 80635dda..577354ee 100644 --- a/erp_web/pages/manage/customer.html +++ b/erp_web/pages/manage/customer.html @@ -160,7 +160,7 @@
+ action="/supplier/importExcelCustomer">
@@ -175,7 +175,6 @@
-
导入
+ action="/supplier/importExcelMember">
@@ -175,7 +175,6 @@
-
导入
+ action="/supplier/importExcelVendor">
@@ -175,7 +175,6 @@
-
导入 data = new HashMap(); + String message = "成功"; + try { + Sheet src = null; + //文件合法性校验 + try { + Workbook workbook = Workbook.getWorkbook(supplierFile.getInputStream()); + src = workbook.getSheet(0); + } catch (Exception e) { + message = "导入文件不合法,请检查"; + data.put("message", message); + info.code = 400; + info.data = data; + } + //读取所有的摄像机编码 + //每行中数据顺序 "名称","类型","联系人","电话","电子邮箱","预收款","期初应收","期初应付","备注","传真","手机","地址","纳税人识别号","开户行","账号","税率","状态" + List sList = new ArrayList(); + for (int i = 1; i < src.getRows(); i++) { + Supplier s = new Supplier(); + s.setSupplier(ExcelUtils.getContent(src, i, 0)); + s.setType(ExcelUtils.getContent(src, i, 1)); + s.setContacts(ExcelUtils.getContent(src, i, 2)); + s.setPhonenum(ExcelUtils.getContent(src, i, 3)); + s.setEmail(ExcelUtils.getContent(src, i, 4)); + s.setAdvancein(parseDoubleEx(ExcelUtils.getContent(src, i, 5))); + s.setBeginneedget(parseDoubleEx(ExcelUtils.getContent(src, i, 6))); + s.setBeginneedpay(parseDoubleEx(ExcelUtils.getContent(src, i, 7))); + s.setDescription(ExcelUtils.getContent(src, i, 8)); + s.setFax(ExcelUtils.getContent(src, i, 9)); + s.setTelephone(ExcelUtils.getContent(src, i, 10)); + s.setAddress(ExcelUtils.getContent(src, i, 11)); + s.setTaxnum(ExcelUtils.getContent(src, i, 12)); + s.setBankname(ExcelUtils.getContent(src, i, 13)); + s.setAccountnumber(ExcelUtils.getContent(src, i, 14)); + s.setTaxrate(parseDoubleEx(ExcelUtils.getContent(src, i, 15))); + String enabled = ExcelUtils.getContent(src, i, 16); + s.setIsystem(Byte.parseByte("1")); + s.setEnabled(enabled.equals("启用")? true: false); + sList.add(s); + } + info = supplierService.importExcel(sList); + } catch (Exception e) { + e.printStackTrace(); + message = "导入失败"; + info.code = 500; + data.put("message", message); + info.data = data; + } + return null; + } + + public Double parseDoubleEx(String str){ + if(!StringUtil.isEmpty(str)) { + return Double.parseDouble(str); + } else { + return null; + } + } + } diff --git a/src/main/java/com/jsh/erp/service/material/MaterialService.java b/src/main/java/com/jsh/erp/service/material/MaterialService.java index ffad45e3..fb68dce5 100644 --- a/src/main/java/com/jsh/erp/service/material/MaterialService.java +++ b/src/main/java/com/jsh/erp/service/material/MaterialService.java @@ -184,6 +184,5 @@ public class MaterialService { } info.data = data; return info; - } } diff --git a/src/main/java/com/jsh/erp/service/supplier/SupplierService.java b/src/main/java/com/jsh/erp/service/supplier/SupplierService.java index 6c3ce21d..dabe9f3e 100644 --- a/src/main/java/com/jsh/erp/service/supplier/SupplierService.java +++ b/src/main/java/com/jsh/erp/service/supplier/SupplierService.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject; import com.jsh.erp.datasource.entities.Supplier; import com.jsh.erp.datasource.entities.SupplierExample; import com.jsh.erp.datasource.mappers.SupplierMapper; +import com.jsh.erp.utils.BaseResponseInfo; import com.jsh.erp.utils.StringUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -11,7 +12,9 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; import java.util.List; +import java.util.Map; @Service public class SupplierService { @@ -120,4 +123,22 @@ public class SupplierService { public List findByAll(String supplier, String type, String phonenum, String telephone, String description) { return supplierMapper.findByAll(supplier, type, phonenum, telephone, description); } + + public BaseResponseInfo importExcel(List mList) throws Exception { + BaseResponseInfo info = new BaseResponseInfo(); + Map data = new HashMap(); + try { + for(Supplier s: mList) { + supplierMapper.insertSelective(s); + } + info.code = 200; + data.put("message", "成功"); + } catch (Exception e) { + e.printStackTrace(); + info.code = 500; + data.put("message", e.getMessage()); + } + info.data = data; + return info; + } } From fdcca244e6275110665593d563393ec322c692dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Sat, 5 Jan 2019 22:41:59 +0800 Subject: [PATCH 05/19] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E5=95=86=E7=9A=84=E5=AF=BC=E5=85=A5=E5=8A=9F=E8=83=BD=EF=BC=88?= =?UTF-8?q?=E5=AE=8C=E5=96=84=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/jsh/erp/controller/SupplierController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/jsh/erp/controller/SupplierController.java b/src/main/java/com/jsh/erp/controller/SupplierController.java index 00ce1f9d..9fd16f6f 100644 --- a/src/main/java/com/jsh/erp/controller/SupplierController.java +++ b/src/main/java/com/jsh/erp/controller/SupplierController.java @@ -408,8 +408,8 @@ public class SupplierController { s.setAccountnumber(ExcelUtils.getContent(src, i, 14)); s.setTaxrate(parseDoubleEx(ExcelUtils.getContent(src, i, 15))); String enabled = ExcelUtils.getContent(src, i, 16); - s.setIsystem(Byte.parseByte("1")); s.setEnabled(enabled.equals("启用")? true: false); + s.setIsystem(Byte.parseByte("1")); sList.add(s); } info = supplierService.importExcel(sList); From fde90c6622fa145db948a3e8364876f908df87ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Sun, 6 Jan 2019 11:35:46 +0800 Subject: [PATCH 06/19] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E4=B8=BAjdk1.8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index d245e114..2ad696e3 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ UTF-8 UTF-8 - 1.7 + 1.8 @@ -158,8 +158,8 @@ org.apache.maven.plugins maven-compiler-plugin - 1.7 - 1.7 + 1.8 + 1.8 From 19bb437559cba84927784cad4f52967221865223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Sun, 6 Jan 2019 12:20:47 +0800 Subject: [PATCH 07/19] =?UTF-8?q?=E6=9B=B4=E6=96=B0pom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 2ad696e3..b6be301e 100644 --- a/pom.xml +++ b/pom.xml @@ -157,6 +157,7 @@ org.apache.maven.plugins maven-compiler-plugin + 3.7.0 1.8 1.8 From 9cb4aab999e8f7103836b6f0f144ee3d2a60373d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Sun, 6 Jan 2019 13:23:49 +0800 Subject: [PATCH 08/19] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20README.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 683a309c..3681b8a0 100644 --- a/README.md +++ b/README.md @@ -16,22 +16,20 @@ * 日志管理:Log4j 1.2.16 * JS框架:Jquery 1.8.0 * UI框架: EasyUI 1.3.5 -* 桌面框架: HoorayOS -* 项目管理框架: Maven3.2.3 +* 桌面框架: HoorayOS 2.0.0 +* 项目管理框架: Maven 3.2.3 # 开发环境 建议开发者使用以下环境,可以避免版本带来的问题 -* IDE: MyEclipse8.5+/Eclipse4.4+ +* IDE: IntelliJ IDEA 2017+ * DB: Mysql5.1 -* JDK: JDK1.7+ -* WEB: Tomcat6.0+ +* JDK: JDK1.8 * Maven: Maven3.2.3+ * 为方便大家搭建开发环境,分享了下载地址 **http://pan.baidu.com/s/1nuKnlNV** # 运行环境 -* WEB服务器:Tomcat6.0+ * 数据库服务器:Mysql5.1 -* JAVA平台: JRE1.7+ +* JAVA平台: JRE1.8 * 操作系统:Windows、Linux等 # 开源说明 From d6c431089b463c200361f3e0e4102ac2819227a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Sun, 6 Jan 2019 13:26:16 +0800 Subject: [PATCH 09/19] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/conf/start.sh | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/main/conf/start.sh diff --git a/src/main/conf/start.sh b/src/main/conf/start.sh new file mode 100644 index 00000000..8d7fafb1 --- /dev/null +++ b/src/main/conf/start.sh @@ -0,0 +1 @@ +nohup ./jshERPStart.sh & \ No newline at end of file From 40155c27528e15e7e933e6cbc39b37a818786aa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Sun, 6 Jan 2019 15:07:33 +0800 Subject: [PATCH 10/19] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8A=A5=E8=A1=A8?= =?UTF-8?q?=E5=88=86=E7=BB=84sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../erp/controller/DepotItemController.java | 66 ++++++++----------- .../entities/DepotItemVo4WithInfoEx.java | 10 +++ .../mapper_xml/DepotItemMapperEx.xml | 26 +++++--- 3 files changed, 56 insertions(+), 46 deletions(-) diff --git a/src/main/java/com/jsh/erp/controller/DepotItemController.java b/src/main/java/com/jsh/erp/controller/DepotItemController.java index c8980c7b..41a7bdcf 100644 --- a/src/main/java/com/jsh/erp/controller/DepotItemController.java +++ b/src/main/java/com/jsh/erp/controller/DepotItemController.java @@ -580,14 +580,12 @@ public class DepotItemController { if (null != dataList) { for (DepotItemVo4WithInfoEx diEx : dataList) { JSONObject item = new JSONObject(); - Double prevSum = sumNumber("入库", pid, diEx.getMaterialid(), monthTime, true) - sumNumber("出库", pid, diEx.getMaterialid(), monthTime, true); - Double InSum = sumNumber("入库", pid, diEx.getMaterialid(), monthTime, false); - Double OutSum = sumNumber("出库", pid, diEx.getMaterialid(), monthTime, false); - Double prevPrice = sumPrice("入库", pid, diEx.getMaterialid(), monthTime, true) - sumPrice("出库", pid, diEx.getMaterialid(), monthTime, true); - Double InPrice = sumPrice("入库", pid, diEx.getMaterialid(), monthTime, false); - Double OutPrice = sumPrice("出库", pid, diEx.getMaterialid(), monthTime, false); - item.put("Id", diEx.getId()); - item.put("MaterialId", diEx.getMaterialid()); + Double prevSum = sumNumber("入库", pid, diEx.getMId(), monthTime, true) - sumNumber("出库", pid, diEx.getMId(), monthTime, true); + Double InSum = sumNumber("入库", pid, diEx.getMId(), monthTime, false); + Double OutSum = sumNumber("出库", pid, diEx.getMId(), monthTime, false); + Double prevPrice = sumPrice("入库", pid, diEx.getMId(), monthTime, true) - sumPrice("出库", pid, diEx.getMId(), monthTime, true); + Double InPrice = sumPrice("入库", pid, diEx.getMId(), monthTime, false); + Double OutPrice = sumPrice("出库", pid, diEx.getMId(), monthTime, false); item.put("MaterialName", diEx.getMName()); item.put("MaterialModel", diEx.getMColor()); //扩展信息 @@ -641,9 +639,9 @@ public class DepotItemController { Double thisAllPrice = 0.0; if (null != dataList) { for (DepotItemVo4WithInfoEx diEx : dataList) { - Double prevPrice = sumPrice("入库", pid, diEx.getMaterialid(), monthTime, true) - sumPrice("出库", pid, diEx.getMaterialid(), monthTime, true); - Double InPrice = sumPrice("入库", pid, diEx.getMaterialid(), monthTime, false); - Double OutPrice = sumPrice("出库", pid, diEx.getMaterialid(), monthTime, false); + Double prevPrice = sumPrice("入库", pid, diEx.getMId(), monthTime, true) - sumPrice("出库", pid, diEx.getMId(), monthTime, true); + Double InPrice = sumPrice("入库", pid, diEx.getMId(), monthTime, false); + Double OutPrice = sumPrice("出库", pid, diEx.getMId(), monthTime, false); thisAllPrice = thisAllPrice + (prevPrice + InPrice - OutPrice); } } @@ -689,12 +687,10 @@ public class DepotItemController { if (null != dataList) { for (DepotItemVo4WithInfoEx diEx : dataList) { JSONObject item = new JSONObject(); - Double InSum = sumNumberBuyOrSale("入库", "采购", diEx.getMaterialid(), monthTime); - Double OutSum = sumNumberBuyOrSale("出库", "采购退货", diEx.getMaterialid(), monthTime); - Double InSumPrice = sumPriceBuyOrSale("入库", "采购", diEx.getMaterialid(), monthTime); - Double OutSumPrice = sumPriceBuyOrSale("出库", "采购退货", diEx.getMaterialid(), monthTime); - item.put("Id", diEx.getId()); - item.put("MaterialId", diEx.getMaterialid()); + Double InSum = sumNumberBuyOrSale("入库", "采购", diEx.getMId(), monthTime); + Double OutSum = sumNumberBuyOrSale("出库", "采购退货", diEx.getMId(), monthTime); + Double InSumPrice = sumPriceBuyOrSale("入库", "采购", diEx.getMId(), monthTime); + Double OutSumPrice = sumPriceBuyOrSale("出库", "采购退货", diEx.getMId(), monthTime); item.put("MaterialName", diEx.getMName()); item.put("MaterialModel", diEx.getMModel()); //扩展信息 @@ -751,16 +747,14 @@ public class DepotItemController { if (null != dataList) { for (DepotItemVo4WithInfoEx diEx : dataList) { JSONObject item = new JSONObject(); - Double OutSumRetail = sumNumberBuyOrSale("出库", "零售", diEx.getMaterialid(), monthTime); - Double OutSum = sumNumberBuyOrSale("出库", "销售", diEx.getMaterialid(), monthTime); - Double InSumRetail = sumNumberBuyOrSale("入库", "零售退货", diEx.getMaterialid(), monthTime); - Double InSum = sumNumberBuyOrSale("入库", "销售退货", diEx.getMaterialid(), monthTime); - Double OutSumRetailPrice = sumPriceBuyOrSale("出库", "零售", diEx.getMaterialid(), monthTime); - Double OutSumPrice = sumPriceBuyOrSale("出库", "销售", diEx.getMaterialid(), monthTime); - Double InSumRetailPrice = sumPriceBuyOrSale("入库", "零售退货", diEx.getMaterialid(), monthTime); - Double InSumPrice = sumPriceBuyOrSale("入库", "销售退货", diEx.getMaterialid(), monthTime); - item.put("Id", diEx.getId()); - item.put("MaterialId", diEx.getMaterialid()); + Double OutSumRetail = sumNumberBuyOrSale("出库", "零售", diEx.getMId(), monthTime); + Double OutSum = sumNumberBuyOrSale("出库", "销售", diEx.getMId(), monthTime); + Double InSumRetail = sumNumberBuyOrSale("入库", "零售退货", diEx.getMId(), monthTime); + Double InSum = sumNumberBuyOrSale("入库", "销售退货", diEx.getMId(), monthTime); + Double OutSumRetailPrice = sumPriceBuyOrSale("出库", "零售", diEx.getMId(), monthTime); + Double OutSumPrice = sumPriceBuyOrSale("出库", "销售", diEx.getMId(), monthTime); + Double InSumRetailPrice = sumPriceBuyOrSale("入库", "零售退货", diEx.getMId(), monthTime); + Double InSumPrice = sumPriceBuyOrSale("入库", "销售退货", diEx.getMId(), monthTime); item.put("MaterialName", diEx.getMName()); item.put("MaterialModel", diEx.getMModel()); //扩展信息 @@ -817,10 +811,8 @@ public class DepotItemController { if (null != dataList) { for (DepotItemVo4WithInfoEx diEx : dataList) { JSONObject item = new JSONObject(); - Double InSum = sumNumberGift("礼品充值", pid, diEx.getMaterialid(), "in"); - Double OutSum = sumNumberGift("礼品销售", pid, diEx.getMaterialid(), "out"); - item.put("Id", diEx.getId()); - item.put("MaterialId", diEx.getMaterialid()); + Double InSum = sumNumberGift("礼品充值", pid, diEx.getMId(), "in"); + Double OutSum = sumNumberGift("礼品销售", pid, diEx.getMId(), "out"); item.put("MaterialName", diEx.getMName()); item.put("MaterialModel", diEx.getMModel()); //扩展信息 @@ -876,12 +868,12 @@ public class DepotItemController { if (null != dataList) { for (DepotItemVo4WithInfoEx diEx : dataList) { String[] objs = new String[9]; - Double prevSum = sumNumber("入库", pid, diEx.getMaterialid(), monthTime, true) - sumNumber("出库", pid, diEx.getMaterialid(), monthTime, true); - Double InSum = sumNumber("入库", pid, diEx.getMaterialid(), monthTime, false); - Double OutSum = sumNumber("出库", pid, diEx.getMaterialid(), monthTime, false); - Double prevPrice = sumPrice("入库", pid, diEx.getMaterialid(), monthTime, true) - sumPrice("出库", pid, diEx.getMaterialid(), monthTime, true); - Double InPrice = sumPrice("入库", pid, diEx.getMaterialid(), monthTime, false); - Double OutPrice = sumPrice("出库", pid, diEx.getMaterialid(), monthTime, false); + Double prevSum = sumNumber("入库", pid, diEx.getMId(), monthTime, true) - sumNumber("出库", pid, diEx.getMId(), monthTime, true); + Double InSum = sumNumber("入库", pid, diEx.getMId(), monthTime, false); + Double OutSum = sumNumber("出库", pid, diEx.getMId(), monthTime, false); + Double prevPrice = sumPrice("入库", pid, diEx.getMId(), monthTime, true) - sumPrice("出库", pid, diEx.getMId(), monthTime, true); + Double InPrice = sumPrice("入库", pid, diEx.getMId(), monthTime, false); + Double OutPrice = sumPrice("出库", pid, diEx.getMId(), monthTime, false); Double unitPrice = 0.0; if (prevSum + InSum - OutSum != 0.0) { unitPrice = (prevPrice + InPrice - OutPrice) / (prevSum + InSum - OutSum); diff --git a/src/main/java/com/jsh/erp/datasource/entities/DepotItemVo4WithInfoEx.java b/src/main/java/com/jsh/erp/datasource/entities/DepotItemVo4WithInfoEx.java index 697dd3e1..b0b88dd2 100644 --- a/src/main/java/com/jsh/erp/datasource/entities/DepotItemVo4WithInfoEx.java +++ b/src/main/java/com/jsh/erp/datasource/entities/DepotItemVo4WithInfoEx.java @@ -48,6 +48,8 @@ public class DepotItemVo4WithInfoEx { private String mtype; + private Long MId; + private String MName; private String MModel; @@ -258,6 +260,14 @@ public class DepotItemVo4WithInfoEx { this.mtype = mtype; } + public Long getMId() { + return MId; + } + + public void setMId(Long MId) { + this.MId = MId; + } + public String getMName() { return MName; } diff --git a/src/main/resources/mapper_xml/DepotItemMapperEx.xml b/src/main/resources/mapper_xml/DepotItemMapperEx.xml index 09c51cc1..604bf51c 100644 --- a/src/main/resources/mapper_xml/DepotItemMapperEx.xml +++ b/src/main/resources/mapper_xml/DepotItemMapperEx.xml @@ -33,6 +33,14 @@ + + + + + + + + - + select m.id MId, m.Name MName, m.Model MModel, m.Unit MaterialUnit, m.Color MColor from jsh_depotitem di inner join jsh_material m on di.MaterialId=m.id where 1=1 - and HeaderId in (${headIds}) + and di.HeaderId in (${headIds}) - and MaterialId in (${materialIds}) + and di.MaterialId in (${materialIds}) - group by MaterialId + group by m.id,m.Name, m.Model, m.Unit, m.Color limit #{offset},#{rows} - - 手机 + 手机号码 - - 电子邮箱 + + + 联系电话 + + + 传真 From b74b12be0a68253860deeececf1d797ede6b7565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Tue, 8 Jan 2019 23:10:32 +0800 Subject: [PATCH 13/19] =?UTF-8?q?=E9=87=87=E8=B4=AD=E5=85=A5=E5=BA=93?= =?UTF-8?q?=EF=BC=8C=E8=BF=87=E6=BB=A4=E6=8E=89=E5=8F=8C=E5=BC=95=E5=8F=B7?= =?UTF-8?q?=EF=BC=8C=E8=A7=A3=E5=86=B3=E5=A4=9A=E8=B4=A6=E6=88=B7=E6=97=B6?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E7=BC=96=E8=BE=91=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- erp_web/js/pages/materials/in_out.js | 1 + 1 file changed, 1 insertion(+) diff --git a/erp_web/js/pages/materials/in_out.js b/erp_web/js/pages/materials/in_out.js index f4c3fa09..6c63fae7 100644 --- a/erp_web/js/pages/materials/in_out.js +++ b/erp_web/js/pages/materials/in_out.js @@ -571,6 +571,7 @@ + 'AaBb' + rec.discount + 'AaBb' + rec.discountmoney + 'AaBb' + rec.discountlastmoney + 'AaBb' + rec.accountidlist + 'AaBb' + rec.accountmoneylist + 'AaBb' + rec.othermoney + 'AaBb' + rec.othermoneylist + 'AaBb' + rec.othermoneyitem + 'AaBb' + rec.accountday; + rowInfo = rowInfo.replace(/\"/g, ""); var orgId = rec.organid? rec.organid:0; str += '   '; str += '   '; From 7dd7f920082645345b0c05d3cdfac72acc7a599d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Tue, 8 Jan 2019 23:27:45 +0800 Subject: [PATCH 14/19] =?UTF-8?q?=E9=87=87=E8=B4=AD=E5=85=A5=E5=BA=93?= =?UTF-8?q?=EF=BC=8C=E8=BF=87=E6=BB=A4=E6=8E=89=E4=B8=AD=E6=8B=AC=E5=8F=B7?= =?UTF-8?q?=EF=BC=8C=E8=A7=A3=E5=86=B3=E5=A4=9A=E8=B4=A6=E6=88=B7=E6=97=B6?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E7=BC=96=E8=BE=91=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- erp_web/js/pages/materials/in_out.js | 1 + 1 file changed, 1 insertion(+) diff --git a/erp_web/js/pages/materials/in_out.js b/erp_web/js/pages/materials/in_out.js index 6c63fae7..59e32bba 100644 --- a/erp_web/js/pages/materials/in_out.js +++ b/erp_web/js/pages/materials/in_out.js @@ -572,6 +572,7 @@ + 'AaBb' + rec.accountidlist + 'AaBb' + rec.accountmoneylist + 'AaBb' + rec.othermoney + 'AaBb' + rec.othermoneylist + 'AaBb' + rec.othermoneyitem + 'AaBb' + rec.accountday; rowInfo = rowInfo.replace(/\"/g, ""); + rowInfo = rowInfo.replace(/\[|]/g,""); var orgId = rec.organid? rec.organid:0; str += '   '; str += '   '; From 3bc21efcf2501b523d872076f7502b38f8924ba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Tue, 8 Jan 2019 23:37:32 +0800 Subject: [PATCH 15/19] =?UTF-8?q?=E9=87=87=E8=B4=AD=E5=85=A5=E5=BA=93?= =?UTF-8?q?=EF=BC=8C=E8=A7=A3=E5=86=B3=E5=A4=9A=E8=B4=A6=E6=88=B7=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E6=98=BE=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- erp_web/js/pages/materials/in_out.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/erp_web/js/pages/materials/in_out.js b/erp_web/js/pages/materials/in_out.js index 59e32bba..d4305fda 100644 --- a/erp_web/js/pages/materials/in_out.js +++ b/erp_web/js/pages/materials/in_out.js @@ -1727,10 +1727,7 @@ $("#OperTimeShow").text(depotHeadInfo[4]); $('#OrganIdShow').text(depotHeadInfo[11]); $("#HandsPersonIdShow").text(depotHeadInfo[12]); - if(depotHeadInfo[13]){ - $("#AccountIdShow").text(depotHeadInfo[13]); //结算账户 - } - else if(depotHeadInfo[22] && depotHeadInfo[23]){ + if(depotHeadInfo[22]!="undefined" && depotHeadInfo[23]!="undefined"){ var accountArr = depotHeadInfo[22].split(","); //账户id列表 var accountMoneyArr = depotHeadInfo[23].split(","); //账户金额列表 var accountIdShow = ""; @@ -1750,7 +1747,9 @@ } } $("#AccountIdShow").text(accountIdShow); - } + } else if(depotHeadInfo[13]){ + $("#AccountIdShow").text(depotHeadInfo[13]); //结算账户 + } $("#ChangeAmountShow").text(depotHeadInfo[8]); $("#RemarkShow").text(depotHeadInfo[9]); $("#DiscountShow").text(depotHeadInfo[19]); From 9760cad7587dbd2474a8dd219d92c1f85fee9a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Wed, 9 Jan 2019 00:05:43 +0800 Subject: [PATCH 16/19] =?UTF-8?q?=E9=87=87=E8=B4=AD=E5=85=A5=E5=BA=93?= =?UTF-8?q?=EF=BC=8C=E8=A7=A3=E5=86=B3=E5=A4=9A=E8=B4=A6=E6=88=B7=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E6=98=BE=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=88?= =?UTF-8?q?=E5=AE=8C=E5=96=84=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- erp_web/js/pages/materials/in_out.js | 8 ++++---- .../com/jsh/erp/service/depotHead/DepotHeadService.java | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/erp_web/js/pages/materials/in_out.js b/erp_web/js/pages/materials/in_out.js index d4305fda..0f6582c8 100644 --- a/erp_web/js/pages/materials/in_out.js +++ b/erp_web/js/pages/materials/in_out.js @@ -1727,7 +1727,9 @@ $("#OperTimeShow").text(depotHeadInfo[4]); $('#OrganIdShow').text(depotHeadInfo[11]); $("#HandsPersonIdShow").text(depotHeadInfo[12]); - if(depotHeadInfo[22]!="undefined" && depotHeadInfo[23]!="undefined"){ + if(depotHeadInfo[13] && depotHeadInfo[13]!="undefined"){ + $("#AccountIdShow").text(depotHeadInfo[13]); //结算账户 + } else { var accountArr = depotHeadInfo[22].split(","); //账户id列表 var accountMoneyArr = depotHeadInfo[23].split(","); //账户金额列表 var accountIdShow = ""; @@ -1747,9 +1749,7 @@ } } $("#AccountIdShow").text(accountIdShow); - } else if(depotHeadInfo[13]){ - $("#AccountIdShow").text(depotHeadInfo[13]); //结算账户 - } + } $("#ChangeAmountShow").text(depotHeadInfo[8]); $("#RemarkShow").text(depotHeadInfo[9]); $("#DiscountShow").text(depotHeadInfo[19]); diff --git a/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java b/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java index d4c7f96f..e3fc753c 100644 --- a/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java +++ b/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java @@ -82,13 +82,17 @@ public class DepotHeadService { } depotHead.setCreatetime(new Timestamp(System.currentTimeMillis())); depotHead.setStatus(false); - return depotHeadMapper.insertSelective(depotHead); + return depotHeadMapper.insert(depotHead); } public int updateDepotHead(String beanJson, Long id) { + DepotHead dh = depotHeadMapper.selectByPrimaryKey(id); DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class); depotHead.setId(id); - return depotHeadMapper.updateByPrimaryKeySelective(depotHead); + depotHead.setStatus(dh.getStatus()); + depotHead.setCreatetime(dh.getCreatetime()); + depotHead.setOperpersonname(dh.getOperpersonname()); + return depotHeadMapper.updateByPrimaryKey(depotHead); } public int deleteDepotHead(Long id) { From a4ee6af8526ad03f98b9dbf5b11aff4ac50441c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Wed, 9 Jan 2019 23:57:00 +0800 Subject: [PATCH 17/19] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E5=92=8C=E5=8A=9F=E8=83=BD=E6=A8=A1=E5=9D=97=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- erp_web/pages/manage/app.html | 9 +++++++-- erp_web/pages/manage/functions.html | 13 ++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/erp_web/pages/manage/app.html b/erp_web/pages/manage/app.html index 591755e7..f254e044 100644 --- a/erp_web/pages/manage/app.html +++ b/erp_web/pages/manage/app.html @@ -369,13 +369,18 @@ if (checkAppName()) { return; } + var infoObj = $("#appFM").serializeObject(); + infoObj.ReSize = $("#ReSize").is(':checked'); + infoObj.OpenMax = $("#OpenMax").is(':checked'); + infoObj.Flash = $("#Flash").is(':checked'); + infoObj.Enabled = $("#Enabled").is(':checked'); $.ajax({ url: url, type: "post", dataType: "json", fileElementId: 'Icon', data: ({ - info: JSON.stringify($("#appFM").serializeObject()) + info: JSON.stringify(infoObj) }), success: function(res) { if(res && res.code === 200) { @@ -420,7 +425,7 @@ appID = appInfo[0]; //焦点在名称输入框==定焦在输入文字后面 $("#name").val("").focus().val(appInfo[1]); - url = '/depot/update?id=' + appInfo[0]; + url = '/app/update?id=' + appInfo[0]; } //检查名称是否存在 ++ 重名无法提示问题需要跟进 diff --git a/erp_web/pages/manage/functions.html b/erp_web/pages/manage/functions.html index 70ce2252..619db4e0 100644 --- a/erp_web/pages/manage/functions.html +++ b/erp_web/pages/manage/functions.html @@ -252,12 +252,14 @@ //绑定事件 function bindEvent() { + var url = '/js/pages/manage/pushBtn.json'; $('#PushBtn').combobox({ - url: '/js/pages/manage/pushBtn.json', + url: url, valueField: 'id', textField: 'text', panelHeight: 120, - multiple: true + multiple: true, + method: 'get' }); } @@ -353,12 +355,17 @@ if (checkFunctionsName()) { return; } + var infoObj = $("#functionsFM").serializeObject(); + infoObj.State = $("#State").is(':checked'); + infoObj.Enabled = $("#Enabled").is(':checked'); + var PushBtn = JSON.stringify($("#PushBtn").combobox('getValues')); + infoObj.PushBtn = PushBtn.replace(/\"/g, "").replace(/\[|]/g,""); $.ajax({ url: url, type: "post", dataType: "json", data: ({ - info: JSON.stringify($("#functionsFM").serializeObject()) + info: JSON.stringify(infoObj) }), success: function(res) { if(res && res.code === 200) { From a259136237e9f412ec08f306ae785e9b595e3236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Sun, 13 Jan 2019 12:57:34 +0800 Subject: [PATCH 18/19] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E4=B8=8D=E8=83=BD=E4=B8=8A=E4=BC=A0=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- erp_web/pages/manage/app.html | 6 +- .../com/jsh/erp/controller/AppController.java | 39 ++ .../java/com/jsh/erp/utils/FileUtils.java | 334 ++++++++++++++++++ 3 files changed, 377 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/jsh/erp/utils/FileUtils.java diff --git a/erp_web/pages/manage/app.html b/erp_web/pages/manage/app.html index f254e044..25e235c4 100644 --- a/erp_web/pages/manage/app.html +++ b/erp_web/pages/manage/app.html @@ -351,7 +351,7 @@ url = '/app/add'; $("#Icon").empty();//清除上传控件数据 $(".fileUploadContent").initUpload({ - "uploadUrl": "/app/uploadImg.action",//上传文件信息地址 + "uploadUrl": "/app/uploadImg",//上传文件信息地址 "progressUrl": "#",//获取进度信息地址,可选,注意需要返回的data格式如下({bytesRead: 102516060, contentLength: 102516060, items: 1, percent: 100, startTime: 1489223136317, useTime: 2767}) //"showSummerProgress":false,//总进度条,默认限制 //"size":350,//文件大小限制,单位kb,默认不限制 @@ -370,6 +370,9 @@ return; } var infoObj = $("#appFM").serializeObject(); + if($("#Icon .fileItem .fileName").length){ + infoObj.Icon = $.trim($("#Icon .fileItem .fileName").text()); + } infoObj.ReSize = $("#ReSize").is(':checked'); infoObj.OpenMax = $("#OpenMax").is(':checked'); infoObj.Flash = $("#Flash").is(':checked'); @@ -378,7 +381,6 @@ url: url, type: "post", dataType: "json", - fileElementId: 'Icon', data: ({ info: JSON.stringify(infoObj) }), diff --git a/src/main/java/com/jsh/erp/controller/AppController.java b/src/main/java/com/jsh/erp/controller/AppController.java index 8806830b..14f02ce3 100644 --- a/src/main/java/com/jsh/erp/controller/AppController.java +++ b/src/main/java/com/jsh/erp/controller/AppController.java @@ -5,13 +5,18 @@ import com.alibaba.fastjson.JSONObject; import com.jsh.erp.datasource.entities.App; import com.jsh.erp.service.app.AppService; import com.jsh.erp.service.userBusiness.UserBusinessService; +import com.jsh.erp.utils.BaseResponseInfo; +import com.jsh.erp.utils.FileUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.io.*; import java.util.List; +import java.util.Properties; /** * @author ji_sheng_hua 752*718*920 @@ -116,4 +121,38 @@ public class AppController { } return arr; } + + /** + * 上传图片 + * @param fileInfo + * @param request + */ + @PostMapping(value = "/uploadImg") + public BaseResponseInfo uploadImg(MultipartFile fileInfo, @RequestParam("fileInfoName") String fileName, + HttpServletRequest request) { + BaseResponseInfo res = new BaseResponseInfo(); + try { + if (fileInfo != null) { + String basePath = request.getSession().getServletContext().getRealPath("/"); //默认windows文件路径,linux环境下生成的目录与项目同级,而不是下级 + String path = basePath + "upload/images/deskIcon/"; //windows环境下的路径 + Properties pro = System.getProperties(); + String osName = pro.getProperty("os.name");//获得当前操作系统的名称 + if("Linux".equals(osName) || "linux".equals(osName) || "LINUX".equals(osName)){ + path = basePath + "/upload/images/deskIcon/"; //linux环境下的路径 + } + FileUtils.SaveFileFromInputStream(fileInfo.getInputStream(), path, fileName); + res.code = 200; + res.data = "上传图片成功"; + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + res.code = 500; + res.data = "获取图片失败"; + } catch (IOException e) { + e.printStackTrace(); + res.code = 500; + res.data = "上传图片失败"; + } + return res; + } } diff --git a/src/main/java/com/jsh/erp/utils/FileUtils.java b/src/main/java/com/jsh/erp/utils/FileUtils.java new file mode 100644 index 00000000..c574873c --- /dev/null +++ b/src/main/java/com/jsh/erp/utils/FileUtils.java @@ -0,0 +1,334 @@ +package com.jsh.erp.utils; + +import com.alibaba.druid.util.StringUtils; + +import java.io.*; +import java.util.*; + +/** + * + * 文件处理工具类 + * + */ +public class FileUtils { + + /** + * 功 能: 创建文件夹 + * + * @param path + * 参 数:要创建的文件夹名称 + * @return 返回值: 如果成功true;否则false 如:FileUtils.mkdir("/usr/apps/upload/"); + */ + public static boolean makedir(String path) { + File file = new File(path); + if (!file.exists()) + return file.mkdirs(); + else + return true; + } + + /** + * 保存文件 + * + * @param stream + * @param path + * 存放路径 + * @param filename + * 文件名 + * @throws IOException + */ + public static void SaveFileFromInputStream(InputStream stream, String path, String filename) + throws IOException { + File file = new File(path); + boolean flag=true; + if(!file.exists()){ + flag=file.mkdirs(); + } + if(flag){ + FileOutputStream fs = new FileOutputStream(new File(path+filename)); + byte[] buffer = new byte[1024 * 1024]; + int byteread = 0; + while ((byteread = stream.read(buffer)) != -1) { + fs.write(buffer, 0, byteread); + fs.flush(); + } + fs.close(); + stream.close(); + } + } + + + /** + * 列出某个目录下的所有文件,子目录不列出 + * @param folderPath:文件夹路径 + * @return + */ + public static List listFile(String folderPath){ + List fileList = new ArrayList(); //FileViewer.getListFiles(destPath, null, false); + File f = new File(folderPath); + File[] t = f.listFiles(); + for(int i = 0; i < t.length; i++){ + fileList.add(t[i].getAbsolutePath()); + } + return fileList; + } + + + /** + * 判断文件是否存在 + * + * @param fileName + * @return + */ + public static boolean exists(String fileName) { + File file = new File(fileName); + if (file.exists()) { + return true; + } else { + return false; + } + } + + /** + * 取当前路径 + * + * @return + */ + public static String getCurrentPath() { + File directory = new File("."); + String nowPath = ""; + try { + nowPath = directory.getCanonicalFile().toString(); + } catch (IOException e) { + e.printStackTrace(); + } + return nowPath; + } + + /** + * 获取文件扩展名 + * + * @param fileName + * @return + * */ + public static String getFileExtendName(String fileName) { + if (fileName == null) { + return ""; + } else { + return fileName.substring(fileName.lastIndexOf(".") + 1, fileName + .length()); + } + } + + /** + * 创建一个新文件,如果存在则报错 + * + * @param filePath + * @param fileName + * @return + */ + public static void createFile(String filePath, String fileName) + throws RuntimeException { + String file = null; + if (filePath == null) { + file = fileName; + } else { + file = filePath + File.separator + fileName; + } + createFile(file); + } + + /** + * 创建一个新文件(含路径),如果存在则报错 + * + * @param fileName + * 含有路径的文件名 + * @return + */ + public static void createFile(String fileName) throws RuntimeException { + File f = new File(fileName); + if (f.exists()) { + throw new RuntimeException("FILE_EXIST_ERROR"); + } else { + try { + File fileFolder = f.getParentFile(); + if (!fileFolder.exists()) + fileFolder.mkdirs(); + f.createNewFile(); + } catch (IOException ie) { + System.out.println("文件" + fileName + "创建失败:" + ie.getMessage()); + throw new RuntimeException("FILE_CREATE_ERROR"); + } + } + } + + + /** + * 创建目录,如果存在则不创建 + * + * @param path + * @return 返回结果null则创建成功,否则返回的是错误信息 + * @return + */ + public static String createDir(String path, boolean isCreateSubPah) { + String msg = null; + File dir = new File(path); + + if (dir == null) { + msg = "不能创建空目录"; + return msg; + } + if (dir.isFile()) { + msg = "已有同名文件存在"; + return msg; + } + if (!dir.exists()) { + if (isCreateSubPah && !dir.mkdirs()) { + msg = "目录创建失败,原因不明"; + } else if (!dir.mkdir()) { + msg = "目录创建失败,原因不明"; + } + } + return msg; + } + + /** + * 删除指定目录或文件。 如果要删除是目录,同时删除子目录下所有的文件 + * + * @file:File 目录 + * */ + public static void delFileOrFolder(String fileName) { + if (!exists(fileName)) + return; + File file = new File(fileName); + delFileOrFolder(file); + } + + /** + * 删除指定目录或文件。 如果要删除是目录,同时删除子目录下所有的文件 + * + * @file:File 目录 + * */ + public static void delFileOrFolder(File file) { + if (!file.exists()) + return; + if (file.isFile()) { + file.delete(); + } else { + File[] sub = file.listFiles(); + if (sub == null || sub.length <= 0) { + file.delete(); + } else { + for (int i = 0; i < sub.length; i++) { + delFileOrFolder(sub[i]); + } + file.delete(); + } + } + } + + /** + * 从Properties格式配置文件中获取所有参数并保存到HashMap中。 + * 配置中的key值即map表中的key值,如果配置文件保存时用的中文,则返回结果也会转成中文。 + * + * @param file + * @return + * @throws IOException + */ + @SuppressWarnings("unchecked") + public static HashMap readPropertyFile(String file, String charsetName) throws IOException { + if (charsetName==null || charsetName.trim().length()==0){ + charsetName="gbk"; + } + HashMap map = new HashMap(); + InputStream is =null; + if(file.startsWith("file:")) + is=new FileInputStream(new File(file.substring(5))); + else + is=FileUtils.class.getClassLoader().getResourceAsStream(file); + Properties properties = new Properties(); + properties.load(is); + Enumeration en = properties.propertyNames(); + while (en.hasMoreElements()) { + String key = (String) en.nextElement(); + String code = new String(properties.getProperty(key).getBytes( + "ISO-8859-1"), charsetName); + map.put(key, code); + } + return map; + } + /** + * + * @param path + * 文件路径 + * @param suffix + * 后缀名 + * @param isdepth + * 是否遍历子目录 + * @return + */ + @SuppressWarnings("unchecked") + public static List getListFiles(String path, String suffix, boolean isdepth) { + File file = new File(path); + return FileUtils.listFile(file, suffix, isdepth); + } + + /** + * @param f + * @param suffix:后缀名 + * @param isdepth:是否遍历子目录 + * @return + */ + @SuppressWarnings("unchecked") + public static List listFile(File f, String suffix, boolean isdepth) { + // 是目录,同时需要遍历子目录 + List fileList = new ArrayList(); + if (f.isDirectory() && isdepth == true) { + File[] t = f.listFiles(); + for (int i = 0; i < t.length; i++) { + listFile(t[i], suffix, isdepth); + } + } else { + String filePath = f.getAbsolutePath(); + + if (suffix != null) { + int begIndex = filePath.lastIndexOf(".");// 最后一个.(即后缀名前面的.)的索引 + String tempsuffix = ""; + + if (begIndex != -1)// 防止是文件但却没有后缀名结束的文件 + { + tempsuffix = filePath.substring(begIndex + 1, filePath + .length()); + } + + if (tempsuffix.equals(suffix)) { + fileList.add(filePath); + } + } else { + // 后缀名为null则为所有文件 + fileList.add(filePath); + } + + } + + return fileList; + } + + /** + * 方法追加文件:使用FileWriter + * + * @param fileName + * @param content + */ + public static void appendMethod(String fileName, String content) { + try { + // 打开一个写文件器,构造函数中的第二个参数true表示以追加形式写文件 + FileWriter writer = new FileWriter(fileName, true); + writer.write(content + "\r\n"); + writer.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + +} From 4afc188b7364c62fa6922aaa5676d399b791f1c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Sun, 13 Jan 2019 13:29:50 +0800 Subject: [PATCH 19/19] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=B0=83=E6=8B=A8?= =?UTF-8?q?=E5=8D=95=E6=8D=AE=E6=97=A0=E6=B3=95=E6=98=BE=E7=A4=BA=E5=AF=B9?= =?UTF-8?q?=E6=96=B9=E4=BB=93=E5=BA=93=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/mapper_xml/DepotItemMapperEx.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/mapper_xml/DepotItemMapperEx.xml b/src/main/resources/mapper_xml/DepotItemMapperEx.xml index 604bf51c..d4900218 100644 --- a/src/main/resources/mapper_xml/DepotItemMapperEx.xml +++ b/src/main/resources/mapper_xml/DepotItemMapperEx.xml @@ -133,7 +133,7 @@ from jsh_depotitem di left join jsh_material m on di.MaterialId=m.id left join jsh_unit u on m.UnitId = u.id left join jsh_depot dp1 on di.DepotId=dp1.id - left join jsh_depot dp2 on di.AnotherDepotId=dp1.id + left join jsh_depot dp2 on di.AnotherDepotId=dp2.id where di.HeaderId = ${headerId} order by di.id asc