whycxzp
1 天以前 aa52854f0a413e153efeea76a952dcf66d76c94a
设备器件excel导入
2个文件已修改
32 ■■■■■ 已修改文件
src/main/java/com/whyc/service/DeviceSpareService.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/util/CommonUtil.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/DeviceSpareService.java
@@ -1,5 +1,6 @@
package com.whyc.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -271,9 +272,36 @@
                String picUrl = File.separator + filePath.substring(filePath.indexOf(split));
                spare.setPictureUrl(picUrl);
            }
        }
        //新增列表
        List<DeviceSpare> spareListNew = new ArrayList<>();
        //更新列表
        List<DeviceSpare> spareListUpdate = new ArrayList<>();
        //查询库中的所有设备器件
        List<DeviceSpare> deviceSpareListInDB = mapper.selectList((Wrapper<DeviceSpare>) CommonUtil.nullObject);
        for (DeviceSpare spare : spareList){
            for (DeviceSpare spareInDB : deviceSpareListInDB){
                if (spare.getName().equals(spareInDB.getName())
                        && spare.getModel().equals(spareInDB.getModel())
                        && spare.getVersion().equals(spareInDB.getVersion())
                        && spare.getBrand().equals(spareInDB.getBrand())
                        && spare.getType().equals(spareInDB.getType())
                        && spare.getSupplier().equals(spareInDB.getSupplier())
                ){
                    spare.setId(spareInDB.getId());
                    spare.setQuantity(spareInDB.getQuantity()+spare.getQuantity());
                    if (spare.getPictureUrl() != null && spareInDB.getPictureUrl()!=null){
                        spare.setPictureUrl(spareInDB.getPictureUrl()+","+spare.getPictureUrl());
                    }
                    spareListUpdate.add(spare);
                }else{
                    spareListNew.add(spare);
                }
            }
        }
        //更新TODO
        //addBatch(spareList);
src/main/java/com/whyc/util/CommonUtil.java
@@ -3,6 +3,7 @@
import com.whyc.constant.YamlProperties;
import com.whyc.pojo.db_user.User;
import com.whyc.service.UserLogService;
import org.apache.poi.ss.formula.functions.T;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
@@ -20,6 +21,7 @@
@Component
public class CommonUtil {
    public static Object nullObject = null;
    private static UserLogService userLogService;
    @Autowired