车车 před 11 měsíci
rodič
revize
599d4c7836

+ 189 - 0
ktg-framework/src/main/java/com/ktg/framework/websocket/WebSocketJobTicket.java

@@ -0,0 +1,189 @@
+package com.ktg.framework.websocket;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import javax.websocket.*;
+import javax.websocket.server.PathParam;
+import javax.websocket.server.ServerEndpoint;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArraySet;
+
+@Component
+@ServerEndpoint("/websocket/jobTicket/{code}")
+@Slf4j
+public class WebSocketJobTicket {
+    private Session session;
+    private String code;
+    // 静态变量,用来记录当前在线连接数。应该把它设计成线程安全的。
+    private static int onlineCount = 0;
+    private static CopyOnWriteArraySet<WebSocketJobTicket> webSocketSet = new CopyOnWriteArraySet<>();
+    //concurrent包的线程安全set,用来存放每个客户端对应的MyWebSocket对象
+    private static ConcurrentHashMap<String, WebSocketJobTicket> webSocketMap2 = new ConcurrentHashMap();
+
+    // 为了保存在线用户信息,在方法中新建一个list存储一下【实际项目依据复杂度,可以存储到数据库或者缓存】
+    private final static List<Session> SESSIONS = Collections.synchronizedList(new ArrayList<>());
+    private Thread heartbeatThread;
+
+    /**
+     * 建立连接
+     *
+     * @param session
+     * @param code
+     */
+    @OnOpen
+    public void onOpen(Session session, @PathParam("code") String code) {
+        this.session = session;
+        this.code = code;
+        webSocketSet.add(this);
+        SESSIONS.add(session);
+        if (webSocketMap2.containsKey(code)) {
+            webSocketMap2.remove(code);
+            webSocketMap2.put(code, this);
+        } else {
+            webSocketMap2.put(code, this);
+            addOnlineCount();
+        }
+        // 心跳机制
+        heartbeatThread = new Thread(() -> {
+            try {
+                sendHeartbeats(session, code);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        });
+        heartbeatThread.start();
+        log.info("[连接ID:{}] 建立连接, 当前连接数:{}", this.code, webSocketMap2.size());
+        log.info("线程序号{}, 当前存活线程数{}", heartbeatThread.getId(), Thread.activeCount());
+
+    }
+
+    private void sendHeartbeats(Session session, String code) throws IOException {
+        int heartbeatInterval = 60000; // 60 seconds
+        while (true) {
+            try {
+                Thread.sleep(heartbeatInterval);
+                session.getBasicRemote().sendText("heartbeat");
+            } catch (InterruptedException | IOException e) {
+                break;
+            }
+        }
+    }
+
+    /**
+     * 断开连接
+     */
+    @OnClose
+    public void onClose() {
+        webSocketSet.remove(this);
+        if (webSocketMap2.containsKey(code)) {
+            webSocketMap2.remove(code);
+            subOnlineCount();
+        }
+        // 关闭当前线程
+        if (heartbeatThread != null && heartbeatThread.isAlive()) {
+            log.info("关闭线程序号{}, 当前存活线程数{}", heartbeatThread.getId(), Thread.activeCount());
+            heartbeatThread.interrupt(); // Interrupt the heartbeat thread
+            try {
+                heartbeatThread.join(); // Wait for the thread to finish
+            } catch (InterruptedException e) {
+                log.error("Error joining heartbeat thread for connection ID: {}", code, e);
+                log.info("关闭线程序号{}, 当前存活线程数{}", Thread.currentThread().getId(), Thread.activeCount());
+                Thread.currentThread().interrupt(); // Restore the interruption status
+            }
+        }
+        log.info("[连接ID:{}] 断开连接, 当前连接数:{}", code, webSocketMap2.size());
+    }
+
+    /**
+     * 发送错误
+     *
+     * @param session
+     * @param error
+     */
+    @OnError
+    public void onError(Session session, Throwable error) {
+        log.info("[连接ID:{}] 错误原因:{}", this.code, error.getMessage());
+        error.printStackTrace();
+        // 发生错误时,关闭连接
+        // conn.close(500, "连接出错");
+    }
+
+    /**
+     * 收到消息
+     *
+     * @param message
+     */
+    @OnMessage
+    public void onMessage(String message) {
+        // log.info("【websocket消息】收到客户端发来的消息:{}", message);
+        log.info("[连接ID:{}] 收到消息:{}", this.code, message);
+    }
+
+    /**
+     * 发送消息
+     *
+     * @param message
+     * @param code
+     */
+    public void sendMessage(String code, String message) {
+        WebSocketJobTicket webSocketIots = webSocketMap2.get(code);
+        log.info("【websocket消息】推送消息, webSocketServer={}", webSocketIots);
+        if (webSocketIots != null) {
+            log.info("【websocket消息】推送消息, message={}", message);
+            try {
+                webSocketIots.session.getBasicRemote().sendText(message);
+            } catch (Exception e) {
+                e.printStackTrace();
+                log.error("[连接ID:{}] 发送消息失败, 消息:{}", this.code, message, e);
+            }
+        }
+    }
+
+    /**
+     * 群发消息
+     *
+     * @param message
+     */
+    public static void sendMassMessage(String message) {
+        try {
+            for (Session session : SESSIONS) {
+                if (session.isOpen()) {
+                    session.getBasicRemote().sendText(message);
+                    log.info("[连接ID:{}] 发送消息:{}", session.getRequestParameterMap().get("code"), message);
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 获取当前连接数
+     *
+     * @return
+     */
+    public static synchronized int getOnlineCount() {
+        return onlineCount;
+    }
+
+    /**
+     * 当前连接数加一
+     */
+    public static synchronized void addOnlineCount() {
+        WebSocketJobTicket.onlineCount++;
+    }
+
+    /**
+     * 当前连接数减一
+     */
+    public static synchronized void subOnlineCount() {
+        WebSocketJobTicket.onlineCount--;
+    }
+
+}
+

+ 1 - 1
ktg-iscs/src/main/java/com/ktg/iscs/controller/HardwareApiController.java

@@ -75,7 +75,7 @@ public class HardwareApiController extends BaseController
     @ApiOperation("取出辅件时更新数据")
     @Log(title = "取出辅件时更新数据", businessType = BusinessType.UPDATE)
     @PostMapping("/updateLocksetTake")
-    public CommonResult<Boolean> updateLocksetTake(@RequestBody @Parameter(name = "list", description = "修改数据类,放到body") LTParamDTO dto)
+    public CommonResult<Boolean> updateLocksetTake(@RequestBody @Parameter(name = "dto", description = "修改数据类,放到body") LTParamDTO dto)
     {
         return CommonResult.success(hardwareApiService.updateLocksetTake(dto.getList()));
     }

+ 1 - 0
ktg-iscs/src/main/java/com/ktg/iscs/controller/IsKeyController.java

@@ -122,4 +122,5 @@ public class IsKeyController extends BaseController
     {
         return CommonResult.success(isKeyService.deleteIsKeyByKeyIds(keyIds) != 0);
     }
+
 }

+ 26 - 0
ktg-iscs/src/main/java/com/ktg/iscs/controller/IsMaterialsController.java

@@ -3,12 +3,14 @@ package com.ktg.iscs.controller;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ktg.common.annotation.Log;
 import com.ktg.common.core.controller.BaseController;
+import com.ktg.common.core.domain.AjaxResult;
 import com.ktg.common.enums.BusinessType;
 import com.ktg.common.pojo.CommonResult;
 import com.ktg.common.utils.poi.ExcelUtil;
 import com.ktg.iscs.domain.IsMaterials;
 import com.ktg.iscs.domain.dto.materials.LoanMaterialDTO;
 import com.ktg.iscs.domain.dto.materials.MaterialsPageDTO;
+import com.ktg.iscs.domain.vo.materials.ImportMaterialsVO;
 import com.ktg.iscs.domain.vo.materials.MaterialsPageVO;
 import com.ktg.iscs.service.IIsMaterialsService;
 import io.swagger.annotations.Api;
@@ -16,7 +18,9 @@ import io.swagger.annotations.ApiOperation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.Parameters;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
 import java.util.List;
@@ -122,4 +126,26 @@ public class IsMaterialsController extends BaseController
     {
         return CommonResult.success(isMaterialsService.deleteIsMaterialsByMaterialsIds(materialsIds) != 0);
     }
+
+    @ApiOperation("导入模板-物资")
+    @Log(title = "导入模板-物资")
+    @PostMapping("/importTemplate")
+    public void importTemplate(HttpServletResponse response)
+    {
+        ExcelUtil<ImportMaterialsVO> util = new ExcelUtil<>(ImportMaterialsVO.class);
+        util.importTemplateExcel(response, "物资数据");
+    }
+
+    @ApiOperation("导入-物资")
+    @Log(title = "导入-物资", businessType = BusinessType.IMPORT)
+    @PreAuthorize("@ss.hasPermi('iscs:materials:import')")
+    @PostMapping("/importMaterials")
+    public AjaxResult importMaterials(MultipartFile file, boolean updateSupport) throws Exception
+    {
+        ExcelUtil<ImportMaterialsVO> util = new ExcelUtil<>(ImportMaterialsVO.class);
+        List<ImportMaterialsVO> itemList = util.importExcel(file.getInputStream());
+        String operName = getUsername();
+        String message = isMaterialsService.importMaterials(itemList, updateSupport, operName);
+        return AjaxResult.success(message);
+    }
 }

+ 2 - 3
ktg-iscs/src/main/java/com/ktg/iscs/domain/IsMaterials.java

@@ -39,11 +39,9 @@ public class IsMaterials extends BaseBean
     private Long materialsTypeId;
 
     @ApiModelProperty(value = "区域ID")
-    @Excel(name = "区域ID")
     private Long workareaId;
 
     @ApiModelProperty(value = "物资柜ID")
-    @Excel(name = "物资柜ID")
     private Long materialsCabinetId;
 
     @ApiModelProperty(value = "可用寿命")
@@ -74,6 +72,7 @@ public class IsMaterials extends BaseBean
     private String loanState;
 
     @ApiModelProperty(value = "物资RFID")
-    private Long materialsRfid;
+    @Excel(name = "物资RFID")
+    private String materialsRfid;
 
 }

+ 65 - 0
ktg-iscs/src/main/java/com/ktg/iscs/domain/vo/materials/ImportMaterialsVO.java

@@ -0,0 +1,65 @@
+package com.ktg.iscs.domain.vo.materials;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ktg.common.annotation.Excel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 物资对象 is_materials
+ *
+ * @author cgj
+ * @date 2024-11-08
+ */
+@Data
+public class ImportMaterialsVO
+{
+
+    @ApiModelProperty(value = "物资编号")
+    @Excel(name = "物资编号")
+    private String materialsCode;
+
+    @ApiModelProperty(value = "物资名称")
+    @Excel(name = "物资名称")
+    private String materialsName;
+
+    @ApiModelProperty(value = "物资类型ID")
+    private Long materialsTypeId;
+
+    @Excel(name = "物资类型名称")
+    private String materialsTypeName;
+
+    @ApiModelProperty(value = "区域ID")
+    private Long workareaId;
+
+    @ApiModelProperty(value = "物资柜ID")
+    private Long materialsCabinetId;
+
+    @ApiModelProperty(value = "可用寿命")
+    @Excel(name = "可用寿命")
+    private String serviceLife;
+
+    @ApiModelProperty(value = "剩余寿命")
+    @Excel(name = "剩余寿命")
+    private String availableLife;
+
+    @ApiModelProperty(value = "可用次数")
+    @Excel(name = "可用次数")
+    private Long serviceTimes;
+
+    @ApiModelProperty(value = "剩余次数")
+    @Excel(name = "剩余次数")
+    private Long availableTimes;
+
+    @ApiModelProperty(value = "启用时间")
+    @JsonFormat(timezone="GMT+8", pattern = "yyyy-MM-dd")
+    @Excel(name = "启用时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date startTime;
+
+    @ApiModelProperty(value = "物资RFID")
+    @Excel(name = "物资RFID")
+    private String materialsRfid;
+
+}

+ 4 - 1
ktg-iscs/src/main/java/com/ktg/iscs/service/IIsMaterialsService.java

@@ -3,8 +3,9 @@ package com.ktg.iscs.service;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ktg.iscs.domain.IsMaterials;
-import com.ktg.iscs.domain.dto.materials.MaterialsPageDTO;
 import com.ktg.iscs.domain.dto.materials.LoanMaterialDTO;
+import com.ktg.iscs.domain.dto.materials.MaterialsPageDTO;
+import com.ktg.iscs.domain.vo.materials.ImportMaterialsVO;
 import com.ktg.iscs.domain.vo.materials.MaterialsPageVO;
 
 import java.util.List;
@@ -72,4 +73,6 @@ public interface IIsMaterialsService extends IService<IsMaterials>
     Page<MaterialsPageVO> getIsMaterialsPage(Page<IsMaterials> page, MaterialsPageDTO dto);
 
     Boolean updateIsMaterialById(LoanMaterialDTO dto);
+
+    String importMaterials(List<ImportMaterialsVO> itemList, boolean updateSupport, String operName);
 }

+ 148 - 9
ktg-iscs/src/main/java/com/ktg/iscs/service/impl/IsMaterialsServiceImpl.java

@@ -5,16 +5,22 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ktg.common.core.text.Convert;
+import com.ktg.common.exception.ServiceException;
 import com.ktg.common.utils.DateUtils;
+import com.ktg.common.utils.bean.BeanUtils;
 import com.ktg.iscs.domain.IsMaterials;
+import com.ktg.iscs.domain.IsMaterialsType;
 import com.ktg.iscs.domain.dto.materials.LoanMaterialDTO;
 import com.ktg.iscs.domain.dto.materials.MaterialsPageDTO;
 import com.ktg.iscs.domain.dto.materialsLoan.AddLoanDTO;
 import com.ktg.iscs.domain.dto.materialsLoan.ReturnLoanDTO;
+import com.ktg.iscs.domain.vo.materials.ImportMaterialsVO;
 import com.ktg.iscs.domain.vo.materials.MaterialsPageVO;
 import com.ktg.iscs.mapper.IsMaterialsMapper;
 import com.ktg.iscs.service.IIsMaterialsLoanService;
 import com.ktg.iscs.service.IIsMaterialsService;
+import com.ktg.iscs.service.IIsMaterialsTypeService;
+import com.ktg.system.strategy.AutoCodeUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -35,6 +41,10 @@ public class IsMaterialsServiceImpl extends ServiceImpl<IsMaterialsMapper, IsMat
     private IsMaterialsMapper isMaterialsMapper;
     @Autowired
     private IIsMaterialsLoanService iIsMaterialsLoanService;
+    @Autowired
+    private AutoCodeUtil autoCodeUtil;
+    @Autowired
+    private IIsMaterialsTypeService iIsMaterialsTypeService;
 
     /**
      * 查询物资
@@ -67,8 +77,7 @@ public class IsMaterialsServiceImpl extends ServiceImpl<IsMaterialsMapper, IsMat
     @Override
     public int insertIsMaterials(IsMaterials isMaterials) {
         // 1.检查物资编码有没有被使用
-        List<IsMaterials> list = list(Wrappers.<IsMaterials>lambdaQuery()
-                .eq(IsMaterials::getMaterialsCode, isMaterials.getMaterialsCode()));
+        List<IsMaterials> list = list(Wrappers.<IsMaterials>lambdaQuery().eq(IsMaterials::getMaterialsCode, isMaterials.getMaterialsCode()));
         Assert.isFalse(!list.isEmpty(), "该物资编码已被使用!");
         isMaterials.setCreateTime(DateUtils.getNowDate());
         return isMaterialsMapper.insertIsMaterials(isMaterials);
@@ -83,9 +92,7 @@ public class IsMaterialsServiceImpl extends ServiceImpl<IsMaterialsMapper, IsMat
     @Override
     public int updateIsMaterials(IsMaterials isMaterials) {
         // 1.检查物资编码有没有被使用
-        List<IsMaterials> list = list(Wrappers.<IsMaterials>lambdaQuery()
-                .eq(IsMaterials::getMaterialsCode, isMaterials.getMaterialsCode())
-                .ne(IsMaterials::getMaterialsId, isMaterials.getMaterialsId()));
+        List<IsMaterials> list = list(Wrappers.<IsMaterials>lambdaQuery().eq(IsMaterials::getMaterialsCode, isMaterials.getMaterialsCode()).ne(IsMaterials::getMaterialsId, isMaterials.getMaterialsId()));
         Assert.isFalse(!list.isEmpty(), "该物资编码已被使用!");
         isMaterials.setUpdateTime(DateUtils.getNowDate());
         return isMaterialsMapper.updateIsMaterials(isMaterials);
@@ -127,10 +134,7 @@ public class IsMaterialsServiceImpl extends ServiceImpl<IsMaterialsMapper, IsMat
         Assert.notNull(dto.getMaterialsId(), "请告诉我需要借出/归还的物资!");
         Assert.isFalse(StringUtils.isBlank(dto.getLoanState()), "请告诉我是借出还是归还!");
         // 2.开始更新物资状态
-        update(Wrappers.<IsMaterials>lambdaUpdate()
-                .eq(IsMaterials::getMaterialsId, dto.getMaterialsId())
-                .set(IsMaterials::getLoanState, dto.getLoanState())
-                .set(IsMaterials::getUpdateTime, new Date()));
+        update(Wrappers.<IsMaterials>lambdaUpdate().eq(IsMaterials::getMaterialsId, dto.getMaterialsId()).set(IsMaterials::getLoanState, dto.getLoanState()).set(IsMaterials::getUpdateTime, new Date()));
         // 3.物资信息
         IsMaterials materials = getById(dto.getMaterialsId());
         Assert.notNull(materials, "该物资不存在!");
@@ -152,4 +156,139 @@ public class IsMaterialsServiceImpl extends ServiceImpl<IsMaterialsMapper, IsMat
         return true;
     }
 
+    @Transactional
+    @Override
+    public String importMaterials(List<ImportMaterialsVO> itemList, boolean updateSupport, String operName) {
+        Assert.notNull(itemList, "导入物料产品数据不能为空!");
+        int successNum = 0;
+        int failureNum = 0;
+        StringBuilder successMsg = new StringBuilder();
+        StringBuilder failureMsg = new StringBuilder();
+        for (ImportMaterialsVO materials : itemList) {
+            // 0.定义一个boolean,记录当前这条数据有没有问题
+            boolean result = true;
+            // 0.1定义一个物资类型id
+            Long materialsTypeId = null;
+
+            // 1.---------------物资如果没有编号,自动生成物资编号--------------------
+            if (StringUtils.isBlank(materials.getMaterialsCode())) {
+                String ruleCode = "MATERIALS_CODE";
+                materials.setMaterialsCode(autoCodeUtil.genSerialCode(ruleCode, null));
+            }
+            // 1.1检查物资的编号是否可用
+            List<IsMaterials> materialsCodeList = list(Wrappers.<IsMaterials>lambdaQuery().eq(IsMaterials::getMaterialsCode, materials.getMaterialsCode()));
+            if (!materialsCodeList.isEmpty()) {
+                result = false;
+                failureMsg.append("<br/>" + failureNum + "、物资编号 " + materials.getMaterialsCode() + " 已被使用");
+            }
+
+            // 2.-----------------检查物资名称不能为空-------------------------------
+            if (StringUtils.isBlank(materials.getMaterialsName())) {
+                result = false;
+                failureMsg.append("<br/>" + failureNum + "、物资名称 " + materials.getMaterialsName() + " 不能为空");
+            }
+            // 3.-----------------检查物资类型不能为空-------------------------------
+            if (StringUtils.isNotBlank(materials.getMaterialsTypeName())) {
+                // 3.1检查物资类型是否在我们的系统中
+                List<IsMaterialsType> materialsTypelist = iIsMaterialsTypeService.list(Wrappers.<IsMaterialsType>lambdaQuery()
+                        .eq(IsMaterialsType::getMaterialsTypeName, materials.getMaterialsTypeName()));
+                if (materialsTypelist.isEmpty()) {
+                    result = false;
+                    failureMsg.append("<br/>" + failureNum + "、物资分类 " + materials.getMaterialsName() + " 系统中无该物资类型");
+                } else {
+                    materialsTypeId = materialsTypelist.get(0).getMaterialsTypeId();
+                }
+            } else {
+                result = false;
+                failureMsg.append("<br/>" + failureNum + "、物资分类 " + materials.getMaterialsName() + " 不能为空");
+            }
+            // 4.---------------------检查rfid是否填写------------------------------
+            if (StringUtils.isNotBlank(materials.getMaterialsRfid())) {
+                // 4.1检查rfid是否被使用
+                List<IsMaterials> materialslist = list(Wrappers.<IsMaterials>lambdaQuery()
+                        .eq(IsMaterials::getMaterialsRfid, materials.getMaterialsRfid()));
+                if (!materialslist.isEmpty()) {
+                    result = false;
+                    failureMsg.append("<br/>" + failureNum + "、物资RFID " + materials.getMaterialsRfid() + " 已被使用");
+                }
+            } else {
+                result = false;
+                failureMsg.append("<br/>" + failureNum + "、物资RFID " + materials.getMaterialsName() + " 不能为空");
+            }
+
+            // 开始做最后的插入操作
+            if (result) {
+                successNum++;
+                IsMaterials bean = BeanUtils.toBean(materials, IsMaterials.class);
+                bean.setMaterialsTypeId(materialsTypeId);
+                insertIsMaterials(bean);
+            } else {
+                failureNum++;
+            }
+
+        }
+        // 总结
+        if (failureNum > 0) {
+            failureMsg.insert(0, "导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
+            throw new ServiceException(failureMsg.toString());
+        } else {
+            successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条");
+        }
+        /*for (IsMaterials item : itemList) {
+            try {
+                // 物料分类是否正确
+                if (com.ktg.common.utils.StringUtils.isNotNull(item.getItemTypeName())) {
+                    List<ItemType> types = itemTypeMapper.selectItemTypeByName(item.getItemTypeName());
+                    if (!CollectionUtils.isEmpty(types)) {
+                        item.setItemTypeId(types.get(0).getItemTypeId());
+                        item.setItemTypeCode(types.get(0).getItemTypeCode());
+                        item.setItemTypeName(types.get(0).getItemTypeName());
+                        item.setItemOrProduct(types.get(0).getItemOrProduct());
+
+                        item.setSafeStockFlag(UserConstants.NO);
+                        item.setEnableFlag(UserConstants.YES);
+                        item.setHighValue(UserConstants.NO);
+
+                        //是否存在
+                        MdItem v = mdItemMapper.checkItemCodeUnique(item);
+                        if (com.ktg.common.utils.StringUtils.isNull(v)) {
+                            BeanValidators.validateWithException(validator, item);
+                            String itemCode = autoCodeUtil.genSerialCode(UserConstants.ITEM_CODE, "");
+                            item.setItemCode(itemCode);
+                            this.insertMdItem(item);
+                            barCodeUtil.generateBarCode(UserConstants.BARCODE_TYPE_ITEM, item.getItemId(), item.getItemCode(), item.getItemName());
+                            successNum++;
+                        } else if (isUpdateSupport) {
+                            BeanValidators.validateWithException(validator, item);
+                            item.setUpdateBy(operName);
+                            item.setItemId(v.getItemId());
+                            this.updateMdItem(item);
+                            successNum++;
+                        } else {
+                            failureNum++;
+                            failureMsg.append("<br/>" + failureNum + "、物料/产品 " + item.getItemName() + " 已存在");
+                        }
+                    } else {
+                        failureNum++;
+                        failureMsg.append("<br/>" + failureNum + "、物料/产品 " + item.getItemName() + " 请填写正确的分类");
+                    }
+                } else {
+                    failureNum++;
+                    failureMsg.append("<br/>" + failureNum + "、物料/产品 " + item.getItemName() + " 请填写分类");
+                }
+            } catch (Exception e) {
+                failureNum++;
+                String msg = "<br/>" + failureNum + "、物料/产品 " + item.getItemName() + " 导入失败:";
+                failureMsg.append(msg + e.getMessage());
+            }
+        }
+        if (failureNum > 0) {
+            failureMsg.insert(0, "导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
+            throw new ServiceException(failureMsg.toString());
+        } else {
+            successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条");
+        }*/
+        return successMsg.toString();
+    }
+
 }