| fzzy-igdss-core/src/main/java/com/fzzy/igds/service/ExportService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| fzzy-igdss-view/src/main/java/com/fzzy/igds/InoutDataPR.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| fzzy-igdss-view/src/main/java/com/fzzy/igds/InoutList.view.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| fzzy-igdss-web/src/main/java/com/fzzy/sys/controller/SysIndexController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| fzzy-igdss-web/src/main/resources/templates/index.html | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
fzzy-igdss-core/src/main/java/com/fzzy/igds/service/ExportService.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,354 @@ package com.fzzy.igds.service; import com.fzzy.igds.constant.FoodVariety; import com.fzzy.igds.domain.InoutRecord; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateUtils; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; /** * @Description * @Author CZT * @Date 2026/01/19 18:52 */ @Service public class ExportService { private static final String XLS = "xls"; private static final String XLSX = "xlsx"; @Resource private FileService fileService; /** * 读åExcelæä»¶å 容 * * @param * @return */ public List<InoutRecord> readExcel(String fileName) { //è·åæä»¶åç¼å并夿 String fileType = fileName.substring(fileName.lastIndexOf(".") + 1); //è·åä¿åè·¯å¾ String path = fileService.getFileSavePath("TEMP"); path = path + fileName; Workbook workbook = null; FileInputStream inputStream = null; try { // è·åExcelæä»¶ File excelFile = new File(path); if (!excelFile.exists()) { return null; } // è·åExcelå·¥ä½ç°¿ inputStream = new FileInputStream(excelFile); workbook = getWorkbook(inputStream, fileType); // 读åexcelä¸çæ°æ® return parseExcel(workbook); } catch (Exception e) { return null; } finally { try { if (null != inputStream) { inputStream.close(); } } catch (IOException e) { e.printStackTrace(); } } } /** * è§£æExcelæ°æ® * * @param workbook * @return */ private static List<InoutRecord> parseExcel(Workbook workbook) throws Exception{ List<InoutRecord> resultDataList = new ArrayList<>(); // è§£æsheet for (int sheetNum = 0; sheetNum < workbook.getNumberOfSheets(); sheetNum++) { Sheet sheet = workbook.getSheetAt(sheetNum); // æ ¡éªsheetæ¯å¦åæ³ if (sheet == null) { continue; } // è·å第ä¸è¡æ°æ®,ä¸ç¨å¤ç int firstRowNum = sheet.getFirstRowNum(); // è§£ææ¯ä¸è¡çæ°æ®ï¼æé æ°æ®å¯¹è±¡ int rowStart = firstRowNum + 2; int rowEnd = sheet.getPhysicalNumberOfRows(); //å®ä¹åé,ç¨äºå¤ææ°æ®æ¯å¦è§£æå® boolean flag = false; for (int rowNum = rowStart; rowNum < rowEnd; rowNum++) { Row row = sheet.getRow(rowNum); if (null == row) { //æ¤è¡ä¸ºç©ºï¼åä¹åä¸åè§£æï¼å¤å®ä¸ºè§£æå®æ flag = true; break; } InoutRecord resultData = convertRowToData(row); resultDataList.add(resultData); } if(flag){ break; } } return resultDataList; } /** * æ ¹æ®æä»¶åç¼åç±»åè·å对åºçå·¥ä½ç°¿å¯¹è±¡ * @param inputStream 读åæä»¶çè¾å ¥æµ * @param fileType æä»¶åç¼åç±»åï¼xlsæxlsxï¼ * @return å å«æä»¶æ°æ®çå·¥ä½ç°¿å¯¹è±¡ * @throws IOException */ public static Workbook getWorkbook(InputStream inputStream, String fileType) throws IOException { Workbook workbook = null; if (fileType.equalsIgnoreCase(XLS)) { workbook = new HSSFWorkbook(inputStream); } else if (fileType.equalsIgnoreCase(XLSX)) { workbook = new XSSFWorkbook(inputStream); } return workbook; } /** * æåæ¯ä¸è¡ä¸éè¦çæ°æ®ï¼æé æä¸ºä¸ä¸ªç»ææ°æ®å¯¹è±¡ * * @param row * @return */ private static InoutRecord convertRowToData(Row row) throws Exception { InoutRecord resultData = new InoutRecord(); Cell cell; int cellNum = 0; //第ä¸ååºå·ï¼ä¸åå¤ç cell = row.getCell(cellNum++); //æ¥æ cell = row.getCell(cellNum++); if(cell == null || cell.getCellType() == CellType.BLANK){ resultData.setCustomerName(""); }else { cell.setCellType(CellType.STRING); String time = cell.getStringCellValue().trim().replaceAll(" ",""); if(StringUtils.isNotEmpty(time)){ resultData.setRegisterTime(DateUtils.parseDate(time,"yyyy-MM-dd")); } } //ç±»å cell = row.getCell(cellNum++); if(cell == null || cell.getCellType() == CellType.BLANK){ resultData.setType(""); }else { cell.setCellType(CellType.STRING); String type = cell.getStringCellValue().trim(); if(StringUtils.isNotEmpty(type)){ resultData.setType(type); } } //车çå· cell = row.getCell(cellNum++); if(cell == null || cell.getCellType() == CellType.BLANK){ resultData.setPlateNum(""); }else { cell.setCellType(CellType.STRING); String plateNum = cell.getStringCellValue().trim(); if(StringUtils.isNotEmpty(plateNum)){ resultData.setPlateNum(plateNum); } } //æ¿è¿äºº cell = row.getCell(cellNum++); if(cell == null || cell.getCellType() == CellType.BLANK){ resultData.setUserName(""); }else { cell.setCellType(CellType.STRING); String userName = cell.getStringCellValue().trim(); if(StringUtils.isNotEmpty(userName)){ resultData.setUserName(userName); } } //徿¥åä½ cell = row.getCell(cellNum++); if(cell == null || cell.getCellType() == CellType.BLANK){ resultData.setCustomerName(""); }else { cell.setCellType(CellType.STRING); String customerName = cell.getStringCellValue().trim(); if(StringUtils.isNotEmpty(customerName)){ resultData.setCustomerName(customerName); } } //è£ å¸ä»åº cell = row.getCell(cellNum++); if(cell == null || cell.getCellType() == CellType.BLANK){ resultData.setDepotId(""); }else { cell.setCellType(CellType.STRING); String depotName = cell.getStringCellValue().trim(); if(StringUtils.isNotEmpty(depotName)){ resultData.setDepotId(depotName); } } //ç²®é£åç§ cell = row.getCell(cellNum++); if(cell == null || cell.getCellType() == CellType.BLANK){ resultData.setFoodVariety(""); }else { cell.setCellType(CellType.STRING); String foodVariety = cell.getStringCellValue().trim(); if(StringUtils.isNotEmpty(foodVariety)){ resultData.setFoodVariety(FoodVariety.getCode(foodVariety.trim())); } } //ç²®é£å¹´ä»½ cell = row.getCell(cellNum++); if(cell == null || cell.getCellType() == CellType.BLANK){ resultData.setFoodYear(""); }else { cell.setCellType(CellType.STRING); String year = cell.getStringCellValue().trim(); if(StringUtils.isNotEmpty(year)){ resultData.setFoodYear(year); } } //满车éé cell = row.getCell(cellNum++); if(cell == null || cell.getCellType() == CellType.BLANK){ resultData.setFullWeight(0.0); }else { cell.setCellType(CellType.STRING); String fullWeight = cell.getStringCellValue().trim(); if(StringUtils.isNotEmpty(fullWeight)){ resultData.setFullWeight(Double.valueOf(fullWeight)); } } //空车éé cell = row.getCell(cellNum++); if(cell == null || cell.getCellType() == CellType.BLANK){ resultData.setEmptyWeight(0.0); }else { cell.setCellType(CellType.STRING); String emptyWeight = cell.getStringCellValue().trim(); if(StringUtils.isNotEmpty(emptyWeight)){ resultData.setEmptyWeight(Double.valueOf(emptyWeight)); } } //æ£é cell = row.getCell(cellNum++); if(cell == null || cell.getCellType() == CellType.BLANK){ resultData.setDeOther(0.0); }else { cell.setCellType(CellType.STRING); String deOther = cell.getStringCellValue().trim(); if(StringUtils.isNotEmpty(deOther)){ resultData.setDeOther(Double.valueOf(deOther)); } } //ç»ç®éé cell = row.getCell(cellNum++); if(cell == null || cell.getCellType() == CellType.BLANK){ resultData.setSettleWeight(0.0); resultData.setRecordWeight(0.0); }else { cell.setCellType(CellType.STRING); String recordWeight = cell.getStringCellValue().trim(); if(StringUtils.isNotEmpty(recordWeight)){ resultData.setSettleWeight(Double.valueOf(recordWeight)); resultData.setRecordWeight(Double.valueOf(recordWeight)); } } //åä»· cell = row.getCell(cellNum++); if(cell == null || cell.getCellType() == CellType.BLANK){ resultData.setPrice(0.0); }else { cell.setCellType(CellType.STRING); String price = cell.getStringCellValue().trim(); if(StringUtils.isNotEmpty(price)){ resultData.setPrice(Double.valueOf(price)); } } //æ°´å cell = row.getCell(cellNum++); if(cell == null || cell.getCellType() == CellType.BLANK){ resultData.setPerWet(0.0); }else { cell.setCellType(CellType.STRING); String perWet = cell.getStringCellValue().trim(); if(StringUtils.isNotEmpty(perWet)){ resultData.setPerWet(Double.valueOf(perWet)); } } //æè´¨ cell = row.getCell(cellNum++); if(cell == null || cell.getCellType() == CellType.BLANK){ resultData.setPerImpurity(0.0); }else { cell.setCellType(CellType.STRING); String perImpurity = cell.getStringCellValue().trim(); if(StringUtils.isNotEmpty(perImpurity)){ resultData.setPerImpurity(Double.valueOf(perImpurity)); } } //夿³¨ cell = row.getCell(cellNum++); if(null == cell || cell.getCellType() == CellType.BLANK){ resultData.setRemarks(""); }else { cell.setCellType(CellType.STRING); String remarks = cell.getStringCellValue().trim(); if(StringUtils.isNotEmpty(remarks)){ resultData.setRemarks(remarks); } } return resultData; } } fzzy-igdss-view/src/main/java/com/fzzy/igds/InoutDataPR.java
@@ -8,13 +8,15 @@ import com.fzzy.igds.data.InoutData; import com.fzzy.igds.data.InoutParam; import com.fzzy.igds.domain.InoutRecord; import com.fzzy.igds.service.ExportService; import com.fzzy.igds.service.InoutRecordService; import com.fzzy.igds.utils.ContextUtil; import com.ruoyi.common.core.domain.entity.SysUser; import org.apache.commons.lang3.time.DateUtils; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.Date; import java.util.*; /** * @Description åºå ¥åºè¯¦å页é¢ç®¡ç @@ -26,6 +28,8 @@ @Resource private InoutRecordService inoutRecordService; @Resource private ExportService exportService; /** * inoutDataPR#pageInoutData @@ -37,7 +41,7 @@ public void pageInoutData(Page<InoutRecord> page, InoutParam param) { com.baomidou.mybatisplus.extension.plugins.pagination.Page<InoutRecord> corePage = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(page.getPageNo(), page.getPageSize()); if(null == param) { if (null == param) { param = new InoutParam(); } inoutRecordService.listPageInout(corePage, param); @@ -157,4 +161,181 @@ return inoutRecordService.outWeightBill(data); } } /** * inoutDataPR#analysisExcel * * @param fileName * @return */ @Expose public String analysisExcel(String fileName) { return "å¯¼å ¥åè½å¾ ä¸çº¿ï¼ï¼"; // try { // List<InoutRecord> inoutRecords = exportService.readExcel(fileName); // if (null == inoutRecords || inoutRecords.isEmpty()) { // return "å¯¼å ¥å¤±è´¥ï¼åå -->æªè·åå°excelä¸ææ¡£æ°æ®ï¼"; // } // // // for (InoutRecord inoutRecord : inoutRecords) { // // //TODO å¤ææ°æ®æ¯å¦æ£å¸¸æ°æ®ï¼æ£å¸¸åæ°å¢ï¼å¼å¸¸åå¿½ç¥ // //è®¾ç½®æ°æ®ç¶æåæµç¨ // inoutRecord.setRecordStatus(Constant.RECORD_STATUS_ADD); // inoutRecord.setProgress(Constant.PROGRESS_RECORD); // // inoutRecord.setCompleteTime(new Date()); // // // inoutRecord.setRegisterTime(DateUtils.addHours(new Date(), -2)); // // // // // inoutRecordService.addInoutRecord(inoutRecord); // } // // // // // return null; // } catch (Exception e) { // return "å¯¼å ¥å¤±è´¥ï¼åå -->" + e.getMessage(); // } // // 读åçExcelæä»¶æ°æ® // List<NoticeInData> readResult = readExcel(fileName); // if (null == readResult) { // return new PageResponse<String>(RespCodeEnum.CODE_1111.getCode(), // "å¯¼å ¥å¤±è´¥ï¼æ²¡æè§£æå°æä»¶ä¸æ°æ®ï¼"); // } // // // æ¥è¯¢å°çææä¾åºåä¿¡æ¯ // InoutParam param = new InoutParam(); // param.setTagSupplier(Constant.TR_TRUE + ""); // List<InoutCustomer> allCustomer = inoutCommonService.listCustomer(param); // // //æ°å»ºä»»å¡åæ¾éå // List<NoticeInData> newCustomerTaskList = new ArrayList<>(); // Map<String, NoticeInData> newMap = new HashMap<>(); // // //åæ¾ç¼ç ååç§°ä¸ä¸è´çä¿¡æ¯ // StringBuilder stringBuilder = new StringBuilder(); // // //ç¨tempFlagå¨å颿¥å¤æè§£æå°çå®¢æ·æ¯å¦å¨å®¢æ·è¡¨ä¸åå¨ // boolean tempFlag; // // int max = 0; // for (NoticeInData noticeInData : readResult) { // //è·å客æ·ä»»å¡æ°æ®ä¸ç客æ·åç§°åç¼ç // String customerName = noticeInData.getCustomerName(); // String customerId = noticeInData.getCustomerId(); // //夿ç¼ç æ¯å¦ä¸ºç©º,为空åç»åºæç¤º,ä¸è¿è¡æä½ // if(StringUtils.isEmpty(customerName)){ // stringBuilder.append("客æ·â").append(customerName).append("âä¿¡æ¯ä¸å®æ´ï¼ä¸å¯¼å ¥æ¤æ¡æ°æ®ï¼\n"); // continue; // } // // tempFlag = true; // // for (InoutCustomer customer : allCustomer) { // //è·åä¾åºååç§°åç¼ç // String name = customer.getName(); // String id = customer.getId(); // //夿åç§°æ¯å¦ç¸å // if(customerName.equals(name)){ // //åç§°ç¸åï¼å客æ·å¨è¡¨ä¸åå¨ // tempFlag = false; // //夿ç¼ç æ¯å¦ç¸å // if(StringUtils.isEmpty(customerId) || !id.equals(customerId)){ // // noticeInData.setCustomerId(id); // } // noticeInData.setCompanyId(customer.getCompanyId()); // //身份è¯å· // if(StringUtils.isEmpty(noticeInData.getCardId())){ // noticeInData.setCardId(customer.getCardId()); // } // //å°å // if(StringUtils.isEmpty(noticeInData.getAddress())){ // noticeInData.setAddress(customer.getAddress()); // } // //çµè¯ // if(StringUtils.isEmpty(noticeInData.getPhone())){ // noticeInData.setPhone(customer.getPhone()); // } // //ä¸å¡éå· // if(StringUtils.isEmpty(noticeInData.getBankNum())){ // noticeInData.setBankNum(customer.getBankNum()); // } // } // } // // if(tempFlag){ // if(max == 0){ // max = Integer.parseInt(inoutCommonService.getMaxCustomerId(null)); // } // max += 1; // noticeInData.setCustomerId(max + ""); // } // // newCustomerTaskList.add(noticeInData); // // newMap.putIfAbsent(noticeInData.getCustomerName(), noticeInData); // } // // //æ´æ°å®¢æ·ä¿¡æ¯è¡¨ // if(newMap.size() > 0){ // for (NoticeInData noticeInData : newMap.values()) { // int i = inoutCommonService.updateCustomer(noticeInData); // if (i == 0) { // //è¯´ææ²¡ææ´æ°å°å®¢æ·ä¿¡æ¯ï¼è¿è¡æ°å¢ // InoutCustomer data = new InoutCustomer(); // data.setId(noticeInData.getCustomerId()); // data.setName(noticeInData.getCustomerName()); // data.setCardId(noticeInData.getCardId()); // data.setBankNum(noticeInData.getBankNum()); // data.setAddress(noticeInData.getAddress()); // data.setPhone(noticeInData.getPhone()); // data.setTagSupplier(Constant.TR_TRUE + ""); // customerService.saveOrUpdataData(data); // } // } // } // // //夿任å¡é忝å¦ä¸ºç©º // if (newCustomerTaskList.isEmpty()) { // return new PageResponse<String>(RespCodeEnum.CODE_1111.getCode(), // "å¯¼å ¥å¤±è´¥ï¼\n" + stringBuilder.toString()); // } else { // //æ´æ°ä»»å¡è¡¨ // int temp = 1; // for (NoticeInData noticeInData : newCustomerTaskList) { // //设置客æ·éç¥åçç»ç»ç¼ç çä¿¡æ¯ // noticeInData.setCompanyId(ContextUtil.getCompanyId()); // noticeInData.setDeptId(ContextUtil.subDeptId(null)); // noticeInData.setCreateUser(ContextUtil.getLoginUserCName()); // if(temp < 10){ // noticeInData.setId(ContextUtil.getTimeId() + "00" + temp); // }else if(temp < 100){ // noticeInData.setId(ContextUtil.getTimeId() + "0" + temp); // }else { // noticeInData.setId(ContextUtil.getTimeId() + temp); // } // // //æ´æ°å®¢æ·ä»»å¡ä¿¡æ¯,å¦ææ´æ°å¤±è´¥,åè¿è¡æå ¥æä½ // inoutCommonService.updateNoticeIn(noticeInData); // temp += 1; // } // if(StringUtils.isEmpty(stringBuilder.toString())){ // return new PageResponse<String>(RespCodeEnum.CODE_0000.getCode(), "æ°æ®å ¨é¨å¯¼å ¥æåï¼"); // }else { // String message = "æ°æ®é¨åå¯¼å ¥æåï¼\n"+ stringBuilder.toString(); // return new PageResponse<String>(RespCodeEnum.CODE_0000.getCode(), message); // } // // } } } fzzy-igdss-view/src/main/java/com/fzzy/igds/InoutList.view.xml
@@ -610,6 +610,13 @@ <Property name="iconClass">fa fa-print</Property> <Property name="width">120</Property> </ToolBarButton> <ToolBarButton> <Property name="caption">å¯¼å ¥EXCEL</Property> <Property name="exClassName">btn1</Property> <Property name="iconClass">fa fa-file-excel-o</Property> <Property name="action">uploadExcel</Property> <Property name="width">120</Property> </ToolBarButton> </ToolBar> <DataGrid id="dataGridMain" layoutConstraint="padding:8"> <ClientEvent name="onDataRowClick">view.get("#dataGridMain").set("selection",arg.data);</ClientEvent> @@ -1176,5 +1183,26 @@ </Container> </CustomDropDown> <YearDropDown id="yearDropDown"/> <UploadAction id="uploadExcel"> <ClientEvent name="onFileUploaded">var fileName = arg.returnValue;
 if(fileName){
 $notify("éä»¶ä¸ä¼ æåï¼å¼å§æ§è¡è§£æâ¦â¦");
 view.get("#ajaxAnalysisExcel").set("parameter",fileName).execute(function(result){
 if(result){
 $alert(result);
 }else{
 $alert("å¯¼å ¥å¹¶è§£ææåï¼");
 query();
 }
 });
 }</ClientEvent> <Property name="fileResolver">fileUploadManage#uploadExcel</Property> <Property name="maxFileSize">10MB</Property> <Filters/> </UploadAction> <AjaxAction id="ajaxAnalysisExcel"> <Property name="service">inoutDataPR#analysisExcel</Property> <Property name="executingMessage">æ£å¨æ§è¡è§£æâ¦â¦</Property> </AjaxAction> </View> </ViewConfig> fzzy-igdss-web/src/main/java/com/fzzy/sys/controller/SysIndexController.java
@@ -95,8 +95,7 @@ //夿æ¯å¦æ¾ç¤ºåºåºéæ©å¼¹çª String showDeptList = "Y"; SysDept userDept = iSysDeptService.selectDeptById(user.getDeptId()); if (Constant.DEPT_TYPE_20.equals(userDept.getType())) { if (Constant.USER_TYPE_30.equals(user.getUserType())) { showDeptList = "N"; } mmap.put("showDeptList", showDeptList); fzzy-igdss-web/src/main/resources/templates/index.html
@@ -107,7 +107,7 @@ <!-- <li><a data-toggle="tooltip" data-trigger="hover" data-placement="bottom" title="å¼åææ¡£"--> <!-- href="https://fzzygf-company.feishu.cn/wiki/ZgS5wQuyMi2uDKk9xN6cx8jlnuf" target="_blank"><i class="fa fa-question-circle"></i>--> <!-- ææ¡£</a></li>--> <li><a data-toggle="tooltip" data-trigger="hover" data-placement="bottom" title="大å±" <li id="screenBtn"><a data-toggle="tooltip" data-trigger="hover" data-placement="bottom" title="大å±" href="/index-gateway" id="index-gateway"><i class="fa fa-laptop"></i> 大å±</a></li> <li><a data-toggle="tooltip" data-trigger="hover" data-placement="bottom" title="éå®å±å¹" href="javascript:;" id="lockScreen"><i class="fa fa-lock"></i> éå±</a></li> @@ -304,6 +304,11 @@ } } if(showDeptList === "N"){ //åºåºç¨æ·ï¼éèå¤§å±æé® $("#screenBtn").css('display', 'none'); } /* åå§å¯ç æç¤º */ if ([[${isDefaultModifyPwd}]]) { layer.confirm("æ¨çå¯ç è¿æ¯åå§å¯ç ï¼è¯·ä¿®æ¹å¯ç ï¼", {