пре 5 година
родитељ
комит
5099053b50

+ 3 - 5
cloud-model/src/main/java/com/hssx/cloudmodel/controller/PartController.java

@@ -6,6 +6,7 @@ import com.hssx.cloudmodel.entity.vo.UserVO;
 import com.hssx.cloudmodel.service.PartService;
 import com.hssx.cloudmodel.util.HttpRespMsg;
 import io.swagger.annotations.ApiOperation;
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.xssf.usermodel.XSSFCell;
 import org.apache.poi.xssf.usermodel.XSSFRow;
@@ -21,10 +22,7 @@ import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
+import java.io.*;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
@@ -53,7 +51,7 @@ public class PartController {
     @ResponseBody
     public HttpRespMsg importAppLogin(
             @RequestParam(value = "file", required = false) MultipartFile file,
-            UserVO userVO) {
+            UserVO userVO) throws IOException, InvalidFormatException {
         HttpRespMsg msg = new HttpRespMsg();
         msg = partService.importPartExcel(file, userVO);
         return msg;

+ 3 - 1
cloud-model/src/main/java/com/hssx/cloudmodel/service/PartService.java

@@ -4,9 +4,11 @@ import com.hssx.cloudmodel.entity.Part;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.hssx.cloudmodel.entity.vo.UserVO;
 import com.hssx.cloudmodel.util.HttpRespMsg;
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 
 /**
  * <p>
@@ -18,7 +20,7 @@ import javax.servlet.http.HttpServletResponse;
  */
 public interface PartService extends IService<Part> {
 
-    HttpRespMsg importPartExcel(MultipartFile file, UserVO userVO);
+    HttpRespMsg importPartExcel(MultipartFile file, UserVO userVO) throws IOException, InvalidFormatException;
 
     HttpRespMsg add(Part part, UserVO userVO);
 

+ 1 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/MouldFileServiceImpl.java

@@ -153,6 +153,7 @@ public class MouldFileServiceImpl extends ServiceImpl<MouldFileMapper, MouldFile
                     dynamics.setMouldId(userVO.getMouldId());
                     dynamics.setBelongType(blongType);
                     mouldOperationDynamicsMapper.insert(dynamics);
+                    //添加消息通知记录
                 }
                 msg.data = projectFile;
             }

+ 11 - 11
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/PartServiceImpl.java

@@ -13,6 +13,7 @@ import com.hssx.cloudmodel.mapper.UserMapper;
 import com.hssx.cloudmodel.service.PartService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.hssx.cloudmodel.util.HttpRespMsg;
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.xssf.usermodel.XSSFCell;
 import org.apache.poi.xssf.usermodel.XSSFRow;
@@ -24,10 +25,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
+import java.io.*;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
@@ -50,12 +48,12 @@ public class PartServiceImpl extends ServiceImpl<PartMapper, Part> implements Pa
     @Resource
     MouldMapper mouldMapper;
     @Override
-    public HttpRespMsg importPartExcel(MultipartFile file, UserVO userVO) {
+    public HttpRespMsg importPartExcel(MultipartFile file, UserVO userVO) throws IOException, InvalidFormatException {
         HttpRespMsg msg = new HttpRespMsg();
         User user = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl", userVO.getToken()));
         if(user != null){
             List<Part> parts = partMapper.selectList(new QueryWrapper<Part>().eq("mould_id",userVO.getMouldId()));
-            try {
+//            try {
                 File f = null;
                 if ("".equals(file) || file.getSize() <= 0) {
                     file = null;
@@ -72,12 +70,14 @@ public class PartServiceImpl extends ServiceImpl<PartMapper, Part> implements Pa
                 XSSFWorkbook wookbook = new XSSFWorkbook(f);
                 XSSFSheet sheet = wookbook.getSheetAt(0);
                 int s = sheet.getLastRowNum();
+            System.out.println("s==========>"+s);
                 // 遍历当前sheet中的所有行,第一行是数据对应的字段,不是数据,
                 // 故从第二行开始遍历拿数据(如果有标题的话,则从第三行开始拿数据)
                 for (int j = 1; j < sheet.getLastRowNum() + 1; j++) {
                     XSSFRow row = sheet.getRow(j);
                     //新建零件
                     Part part = new Part();
+                    part.setMouldId(mould.getId());
                     // 遍历所有的列,下面的10是excle表格里共有10列即对应了10个字段
                     for (int y = 0; y < 2; y++) {
                         XSSFCell cell = row.getCell(y);
@@ -113,11 +113,11 @@ public class PartServiceImpl extends ServiceImpl<PartMapper, Part> implements Pa
                     part.setCreator(user.getUsername());
                     partMapper.insert(part);
                 }
-            } catch (Exception e) {
-                log.error(e.getMessage(), e);
-                msg.setError(e.getMessage());
-                return msg;
-            }
+//            } catch (Exception e) {
+//                log.error(e.getMessage(), e);
+//                msg.setError(e.getMessage());
+//                return msg;
+//            }
         }else{
             msg.setError("用户不存在或者未登录");
         }

+ 1 - 0
cloud-model/src/main/resources/application-prod.properties

@@ -3,6 +3,7 @@
 server.port=9099
 server.servlet.context-path=/
 server.tomcat.uri-encoding=UTF-8
+server.tomcat.max-http-post-size=-1
 # ####################################################################################################
 # thymeleaf ÅäÖÃ
 spring.thymeleaf.cache=false

+ 1 - 0
cloud-model/src/main/resources/application.properties

@@ -3,6 +3,7 @@
 server.port=8099
 server.servlet.context-path=/
 server.tomcat.uri-encoding=UTF-8
+server.tomcat.max-http-post-size=-1
 # ####################################################################################################
 # thymeleaf ÅäÖÃ
 spring.thymeleaf.cache=false

+ 11 - 7
cloud-model/src/main/resources/mapper/MouldMapper.xml

@@ -78,7 +78,7 @@
         tbm.id id,tbm.model_no model_no, tbm.model_name model_name,tbm.initial_modulus initial_modulus,tbm.rfid rfid,tbm.creator_id creator_id,tbm.equipment_id equipment_id,
         tbmp.end_time endTime,tbm.state state,tbp.project_name projectName,tbc.company_name companyName,tbco.company_name produceCompany,
         tbp.manager mangerName,tbm.factory_name factory_name,tbm.area area,tbmp.hill_number hillNumber,tbm.oc_cycle oc_cycle,tbp.manager_id managerId,
-        tbmp.equipment_no equipmentNo,tbm.setting_life setting_life,tbp.owner_company_name ownerCompanyName,tbm.run_times run_times
+        tbmp.equipment_no equipmentNo,tbm.setting_life setting_life,tbcom.company_name ownerCompanyName,tbm.run_times run_times
         from
         tb_mould tbm
         left join
@@ -96,6 +96,10 @@
         tb_company tbco
         on
         tbco.id = tbm.produce_company_id
+        left join
+        tb_company tbcom
+        on
+        tbcom.id = tbm.company_id
         <where>
             <if test="userVO.parentId != 0">
                 tbm.company_id = #{userVO.companyId}
@@ -116,7 +120,7 @@
         tbm.id id,tbm.model_no model_no, tbm.model_name model_name,tbm.initial_modulus initial_modulus,tbm.rfid rfid,tbp.manager_id managerId,tbm.equipment_id equipment_id,
         tbmp.end_time endTime,tbm.state state,tbp.project_name projectName,tbc.company_name companyName,tbco.company_name produceCompany,
         tbp.manager mangerName,tbm.factory_name factory_name,tbm.area area,tbmp.hill_number hillNumber,tbm.oc_cycle oc_cycle,tbm.creator_id creator_id,
-        tbmp.equipment_no equipmentNo,tbm.setting_life setting_life,tbp.owner_company_name ownerCompanyName,tbm.run_times run_times
+        tbmp.equipment_no equipmentNo,tbm.setting_life setting_life,tbcom.company_name ownerCompanyName,tbm.run_times run_times
         from
         tb_mould tbm
         left join
@@ -131,10 +135,6 @@
         tb_company tbc
         on
         tbc.id = tbm.company_id
-        left join
-        tb_company tbco
-        on
-        tbco.id = tbm.produce_company_id
         <where>
             <if test="userVO.searchType == 0 and userVO.keyName != '' and userVO.keyName != null">
                 AND tbm.model_no like concat('%',#{userVO.keyName},'%')
@@ -155,7 +155,7 @@
         tbm.project_id project_id, tbm.setting_life setting_life, tbm.area area,tbm.equipment_id equipment_id,
         tbm.id id,tbm.model_no model_no, tbm.model_name,tbm.initial_modulus initial_modulus,tbp.manager_id managerId,
         tbmp.end_time endTime,tbm.state state,tbp.project_name projectName,tbco.company_name produceCompany,tbm.creator_id creator_id,
-        tbp.manager mangerName,tbm.factory_name factory_name,tbm.area area,tbm.rfid rfid,tbm.oc_cycle oc_cycle,
+        tbp.manager mangerName,tbm.factory_name factory_name,tbm.area area,tbm.rfid rfid,tbm.oc_cycle oc_cycle,tbc.company_name companyName,
         tbmp.equipment_no equipmentNo,tbmp.hill_number hillNumber,tbm.setting_life setting_life,tbm.run_times run_times
         from
         tb_mould tbm
@@ -170,6 +170,10 @@
         tb_company tbco
         on
         tbco.id = tbm.produce_company_id
+        left join
+        tb_company tbc
+        on
+        tbc.id = tbm.company_id
         where
         tbm.id = #{mouldVO.id}
     </select>