czt
2026-01-20 b00dd93dedca0c151a760fff48191b92ac572545
优化调整,及数据导入提交1
已添加1个文件
已修改4个文件
577 ■■■■■ 文件已修改
fzzy-igdss-core/src/main/java/com/fzzy/igds/service/ExportService.java 354 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fzzy-igdss-view/src/main/java/com/fzzy/igds/InoutDataPR.java 185 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fzzy-igdss-view/src/main/java/com/fzzy/igds/InoutList.view.xml 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fzzy-igdss-web/src/main/java/com/fzzy/sys/controller/SysIndexController.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fzzy-igdss-web/src/main/resources/templates/index.html 7 ●●●● 补丁 | 查看 | 原始文档 | 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(&quot;#dataGridMain&quot;).set(&quot;selection&quot;,arg.data);</ClientEvent>
@@ -1176,5 +1183,26 @@
      </Container>
    </CustomDropDown>
    <YearDropDown id="yearDropDown"/>
    <UploadAction id="uploadExcel">
      <ClientEvent name="onFileUploaded">var fileName = arg.returnValue;&#xD;
if(fileName){&#xD;
    $notify(&quot;附件上传成功,开始执行解析……&quot;);&#xD;
    view.get(&quot;#ajaxAnalysisExcel&quot;).set(&quot;parameter&quot;,fileName).execute(function(result){&#xD;
        if(result){&#xD;
            $alert(result);&#xD;
        }else{&#xD;
            $alert(&quot;导入并解析成功!&quot;);&#xD;
            query();&#xD;
        }&#xD;
    });&#xD;
}</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("您的密码还是初始密码,请修改密码!", {