From 10e199f950f5c74b25e446433ceb51cffe675be4 Mon Sep 17 00:00:00 2001 From: Fixiaobai <fixiaobai@163.com> Date: 星期一, 30 十月 2023 09:57:07 +0800 Subject: [PATCH] Changes --- mes-common/src/main/java/com/chinaztt/mes/common/config/TransactionConfig.java | 11 + mes-basic/src/main/java/com/chinaztt/mes/basic/service/PartService.java | 3 mes-technology/src/main/java/com/chinaztt/mes/technology/controller/DocumentController.java | 9 mes-basic/src/main/java/com/chinaztt/mes/basic/util/JDBCUtil.java | 48 ++++++++ mes-web/src/main/java/com/chinaztt/mes/App.java | 2 mes-web/src/main/resources/bootstrap.yml | 1 mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/RoutingServiceImpl.java | 5 mes-basic/src/main/java/com/chinaztt/mes/basic/controller/PartController.java | 17 ++ mes-basic/src/main/java/com/chinaztt/mes/basic/util/TransactionUtils.java | 44 +++++++ mes-technology/src/main/java/com/chinaztt/mes/technology/feign/MesFileApi.java | 20 +++ mes-technology/src/main/java/com/chinaztt/mes/technology/service/DocumentService.java | 5 mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/DocumentServiceImpl.java | 101 ++++++++++++---- mes-basic/src/main/java/com/chinaztt/mes/basic/service/impl/PartServiceImpl.java | 34 ++++- mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/StructureServiceImpl.java | 6 14 files changed, 254 insertions(+), 52 deletions(-) diff --git a/mes-basic/src/main/java/com/chinaztt/mes/basic/controller/PartController.java b/mes-basic/src/main/java/com/chinaztt/mes/basic/controller/PartController.java index 37b623f..603c3c3 100644 --- a/mes-basic/src/main/java/com/chinaztt/mes/basic/controller/PartController.java +++ b/mes-basic/src/main/java/com/chinaztt/mes/basic/controller/PartController.java @@ -25,6 +25,7 @@ import com.chinaztt.mes.basic.excel.PartData; import com.chinaztt.mes.basic.excel.PartUploadListener; import com.chinaztt.mes.basic.service.PartService; +import com.chinaztt.mes.common.util.JsonUtil; import com.chinaztt.mes.common.wrapper.QueryWrapperUtil; import com.chinaztt.ztt.admin.api.entity.SysDictItem; import com.chinaztt.ztt.admin.api.feign.RemoteDictService; @@ -42,7 +43,6 @@ import org.springframework.web.multipart.MultipartFile; import java.io.IOException; -import java.util.Date; import java.util.List; @@ -74,6 +74,9 @@ @GetMapping("/page") @PreAuthorize("@pms.hasPermission('basic_part_view')") public R getPartPage(Page page, Part part, Long bomId) { + //System.out.println(bomId); + //System.out.println(part); + System.out.println(JsonUtil.jsonToString(page)); return R.ok(partService.getPartPage(page, QueryWrapperUtil.gen(part), bomId)); } /** @@ -91,11 +94,19 @@ partService.syncPart(); return R.ok(); } + + //@InitBinder + //protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { + // //System.out.println(request.getParameter("date")); + // DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + // CustomDateEditor editor = new CustomDateEditor(df, true);//true琛ㄧず鍏佽涓虹┖锛宖alse鍙嶄箣 + // binder.registerCustomEditor(Date.class, editor); + //} + @ApiOperation(value = "鍚屾Ifs", notes = "鍚屾Ifs") @PostMapping("/syncNewIfs") //@XxlJob("syncPart") - public R syncNewIfs(Date date) { - System.out.println(date); + public R syncNewIfs(String date) { String key = "syncPart_lock"+ SecurityUtils.getUser().getId(); if (redisTemplate.hasKey(key)) { throw new RuntimeException("鏈夊悓姝ヤ换鍔℃鍦ㄥ鐞�"); diff --git a/mes-basic/src/main/java/com/chinaztt/mes/basic/service/PartService.java b/mes-basic/src/main/java/com/chinaztt/mes/basic/service/PartService.java index 30b53d9..106baa5 100644 --- a/mes-basic/src/main/java/com/chinaztt/mes/basic/service/PartService.java +++ b/mes-basic/src/main/java/com/chinaztt/mes/basic/service/PartService.java @@ -26,7 +26,6 @@ import com.chinaztt.mes.basic.excel.PartData; import com.chinaztt.ztt.common.core.util.R; -import java.util.Date; import java.util.List; /** @@ -131,5 +130,5 @@ void syncPart(); - Long syncNewIfs(Date date); + Long syncNewIfs(String date); } diff --git a/mes-basic/src/main/java/com/chinaztt/mes/basic/service/impl/PartServiceImpl.java b/mes-basic/src/main/java/com/chinaztt/mes/basic/service/impl/PartServiceImpl.java index 62a1689..e6ad84e 100644 --- a/mes-basic/src/main/java/com/chinaztt/mes/basic/service/impl/PartServiceImpl.java +++ b/mes-basic/src/main/java/com/chinaztt/mes/basic/service/impl/PartServiceImpl.java @@ -17,7 +17,6 @@ package com.chinaztt.mes.basic.service.impl; import cn.hutool.core.collection.CollectionUtil; -import cn.hutool.core.date.DateUtil; import cn.hutool.http.HttpRequest; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -33,6 +32,7 @@ import com.chinaztt.mes.basic.service.PartService; import com.chinaztt.mes.basic.util.DictUtils; import com.chinaztt.mes.basic.util.PartUtils; +import com.chinaztt.mes.basic.util.TransactionUtils; import com.chinaztt.mes.common.util.JsonUtil; import com.chinaztt.ztt.common.core.util.R; import com.chinaztt.ztt.common.security.util.SecurityUtils; @@ -54,11 +54,15 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; +import org.springframework.transaction.TransactionDefinition; +import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; import java.io.IOException; import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.PreparedStatement; import java.util.*; /** @@ -77,7 +81,9 @@ private DiscoveryClient discoveryClient; private Environment environment; private RedisTemplate redisTemplate; + private TransactionUtils transactionUtils; ; + @Override public void importPartExcel(List<PartData> list) { @@ -369,9 +375,10 @@ } - @Transactional(rollbackFor = Exception.class) @Override - public Long syncNewIfs(Date date) { + @Transactional(rollbackFor = Exception.class) + public Long syncNewIfs(String date) { + TransactionStatus transaction = transactionUtils.begin(TransactionDefinition.ISOLATION_READ_COMMITTED); Map<String, String> dicmattype = dictUtils.getDicKey("material_type"); Map<String, String> dicunit = dictUtils.getDicKey("unit"); String key = "syncPart_lock" + SecurityUtils.getUser().getId(); @@ -379,16 +386,26 @@ throw new RuntimeException("鏈夊悓姝ヤ换鍔℃鍦ㄥ鐞�"); } redisTemplate.opsForValue().set(key, 1, 1000 * 3600); - Map<String, Object>map=new HashMap<>(); - map.put("MODIFY_DATE", DateUtil.format(date,"yyyy-MM-dd")); List<Part>partList=new ArrayList<Part>(); + Connection conn =null; + PreparedStatement pstmt =null; try { + String url =""; + //鍒ゆ柇鏃ユ湡鏈夊惁 + if (Objects.isNull(date)){ + url = "http://192.168.20.47:8008/PurchService.ashx?contract=KJZS&contractKey=4ttDeLKNsZuhstjtROMcRE1USNFXKdFYE7lQ2p1m5Bo=&procedureName=QUERY_INVENTORY_PART_INFO_STD&userId=7632&inAttr={}"; + }else { + Map<String, Object>map=new HashMap<>(); + map.put("MODIFY_DATE", date); + url = "http://192.168.20.47:8008/PurchService.ashx?contract=KJZS&contractKey=4ttDeLKNsZuhstjtROMcRE1USNFXKdFYE7lQ2p1m5Bo=&procedureName=QUERY_INVENTORY_PART_INFO_STD&userId=7632&inAttr="+new ObjectMapper().writeValueAsString(map); + } log.info("寮�濮嬫墽琛屽悓姝�==========銆�"); - String url = "http://192.168.20.47:8008/PurchService.ashx?contract=ZTKJ&contractKey=4ttDeLKNsZuhstjtROMcRE1USNFXKdFYE7lQ2p1m5Bo=&procedureName=QUERY_INVENTORY_PART_INFO_STD&userId=7632&inAttr="+new ObjectMapper().writeValueAsString(map); String body = HttpRequest.get(url).execute().body(); log.info("鎵ц鍚屾缁撴潫===========銆�"); Map<String, Object> mapResult = JsonUtil.jsonToPojo(body, Map.class); List<Map<String, Object>> data = JsonUtil.jsonToPojo(JsonUtil.jsonToString(mapResult.get("INVENTORY_PART_INFO")), List.class); + System.out.println(data.size()); + //data.forEach(System.out::println); List<String>no=new ArrayList<String>(); data.forEach(l->{ Part part = new Part(); @@ -418,8 +435,8 @@ List<Part> selectList = baseMapper.selectList(queryWrapper); //System.out.println(baseMapper.selectList(queryWrapper)); partList.removeIf(mainObj -> selectList.stream().anyMatch(subObj -> subObj.getPartNo().equals(mainObj.getPartNo()))); - //System.out.println(partList); - partList.forEach(l -> { + System.out.println("杩囨护闀垮害=============================銆�"+partList.size()); + partList.forEach(l->{ baseMapper.insert(l); }); } @@ -427,6 +444,7 @@ e.printStackTrace(); throw new RuntimeException(e.getMessage()); } finally { + //JDBCUtil.close(pstmt,conn); redisTemplate.delete(key); } return (long) partList.size(); diff --git a/mes-basic/src/main/java/com/chinaztt/mes/basic/util/JDBCUtil.java b/mes-basic/src/main/java/com/chinaztt/mes/basic/util/JDBCUtil.java new file mode 100644 index 0000000..c428fdb --- /dev/null +++ b/mes-basic/src/main/java/com/chinaztt/mes/basic/util/JDBCUtil.java @@ -0,0 +1,48 @@ +package com.chinaztt.mes.basic.util; + +import java.sql.*; + +/** + * @Author 寮犲 + * @Date 2023/10/26 + */ +public class JDBCUtil { + private static String url; + private static String user; + private static String password; + private static String driver; + + static { + try { + url = "jdbc:postgresql://127.0.0.1:5432/postgres"; + user = "postgres"; + password = "root2022"; + driver = "org.postgresql.Driver"; + } catch (Exception e) { + e.getMessage(); + } + + } + + public static Connection getConn() throws Exception { + Connection connection = DriverManager.getConnection(url, user, password); + + return connection; + } + + public static void close(PreparedStatement preparedStatement, + Connection connection) { + + try { + if (preparedStatement != null) { + preparedStatement.close(); + } + if (connection != null) { + connection.close(); + } + } catch (SQLException e) { + throw new RuntimeException(); + } + } + +} diff --git a/mes-basic/src/main/java/com/chinaztt/mes/basic/util/TransactionUtils.java b/mes-basic/src/main/java/com/chinaztt/mes/basic/util/TransactionUtils.java new file mode 100644 index 0000000..8c1f551 --- /dev/null +++ b/mes-basic/src/main/java/com/chinaztt/mes/basic/util/TransactionUtils.java @@ -0,0 +1,44 @@ +package com.chinaztt.mes.basic.util; + +import org.springframework.jdbc.datasource.DataSourceTransactionManager; +import org.springframework.stereotype.Component; +import org.springframework.transaction.TransactionDefinition; +import org.springframework.transaction.TransactionStatus; +import org.springframework.transaction.support.DefaultTransactionDefinition; + +import javax.annotation.Resource; + +/** + * @Author 寮犲 + * @Date 2023/10/26 + */ +@Component +public class TransactionUtils { + + @Resource + private DataSourceTransactionManager transactionManager; + + //寮�鍚簨鍔�,浼犲叆闅旂绾у埆 + public TransactionStatus begin(int isolationLevel) { + DefaultTransactionDefinition def = new DefaultTransactionDefinition(); + // 浜嬬墿闅旂绾у埆锛屽紑鍚柊浜嬪姟 TransactionDefinition.ISOLATION_READ_COMMITTED + def.setIsolationLevel(isolationLevel); + // 浜嬪姟浼犳挱琛屼负 + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); + //榛樿浜嬪姟 + TransactionStatus transaction = transactionManager.getTransaction(def); + //灏嗘嬁鍒扮殑浜嬪姟杩斿洖杩涘幓锛屾墠鑳芥彁浜ゃ�� + return transaction; + } + + //鎻愪氦浜嬪姟 + public void commit(TransactionStatus transaction) { + //鎻愪氦浜嬪姟 + transactionManager.commit(transaction); + } + + //鍥炴粴浜嬪姟 + public void rollback(TransactionStatus transaction) { + transactionManager.rollback(transaction); + } +} \ No newline at end of file diff --git a/mes-common/src/main/java/com/chinaztt/mes/common/config/TransactionConfig.java b/mes-common/src/main/java/com/chinaztt/mes/common/config/TransactionConfig.java new file mode 100644 index 0000000..9eecfa1 --- /dev/null +++ b/mes-common/src/main/java/com/chinaztt/mes/common/config/TransactionConfig.java @@ -0,0 +1,11 @@ +package com.chinaztt.mes.common.config; + +import org.springframework.context.annotation.Configuration; + +/** + * @Author 寮犲 + * @Date 2023/10/26 + */ +@Configuration +public class TransactionConfig { +} diff --git a/mes-technology/src/main/java/com/chinaztt/mes/technology/controller/DocumentController.java b/mes-technology/src/main/java/com/chinaztt/mes/technology/controller/DocumentController.java index 827347c..81d2a43 100644 --- a/mes-technology/src/main/java/com/chinaztt/mes/technology/controller/DocumentController.java +++ b/mes-technology/src/main/java/com/chinaztt/mes/technology/controller/DocumentController.java @@ -37,7 +37,6 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -258,7 +257,7 @@ * @return */ @PostMapping("/uploadJgt") - public R uploadJgt(@RequestParam("file") List<MultipartFile> file, @RequestParam("documentId") Long documentId) { + public R uploadJgt(@RequestParam("file") MultipartFile file, @RequestParam("documentId") Long documentId) { return documentService.uploadJgt(file, documentId); } @@ -301,9 +300,9 @@ * @param fileName * @param response */ - @Inner(false) - @GetMapping("/file/{fileName}") - public void file(@PathVariable String fileName, HttpServletResponse response) { + @Inner(value = false) + @GetMapping("/file") + public void file(@RequestParam("fileName") String fileName, HttpServletResponse response) { documentService.getFile(fileName, response); } diff --git a/mes-technology/src/main/java/com/chinaztt/mes/technology/feign/MesFileApi.java b/mes-technology/src/main/java/com/chinaztt/mes/technology/feign/MesFileApi.java new file mode 100644 index 0000000..d48b228 --- /dev/null +++ b/mes-technology/src/main/java/com/chinaztt/mes/technology/feign/MesFileApi.java @@ -0,0 +1,20 @@ +package com.chinaztt.mes.technology.feign; + +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; + +/** + * @Author 寮犲 + * @Date 2023/10/27 + */ +@FeignClient(value = "mes-file",path = "/mes-file") +public interface MesFileApi { + + @PostMapping(value = "/uploadFile",consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = {MediaType.APPLICATION_JSON_VALUE}) + String uploadFile(MultipartFile file); + +} diff --git a/mes-technology/src/main/java/com/chinaztt/mes/technology/service/DocumentService.java b/mes-technology/src/main/java/com/chinaztt/mes/technology/service/DocumentService.java index f8c4294..9a384ab 100644 --- a/mes-technology/src/main/java/com/chinaztt/mes/technology/service/DocumentService.java +++ b/mes-technology/src/main/java/com/chinaztt/mes/technology/service/DocumentService.java @@ -23,7 +23,6 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.chinaztt.mes.quality.dto.TestStandardDTO; import com.chinaztt.mes.quality.entity.TestStandard; -import com.chinaztt.mes.technology.dto.DocTestStandardDTO; import com.chinaztt.mes.technology.dto.DocumentDTO; import com.chinaztt.mes.technology.dto.DocumentMaterialCostDTO; import com.chinaztt.mes.technology.dto.JoinDocumentTestStandardDTO; @@ -34,8 +33,6 @@ import com.chinaztt.mes.technology.excel.DocumentTestStandardData; import com.chinaztt.mes.technology.state.document.constant.DocumentStates; import com.chinaztt.ztt.common.core.util.R; -import com.sun.org.apache.xpath.internal.operations.Bool; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; @@ -134,7 +131,7 @@ * @param documentId * @return */ - R uploadJgt(List<MultipartFile> file, Long documentId); + R uploadJgt(MultipartFile file, Long documentId); /** * 涓婁紶娴佺▼鍥炬枃浠� diff --git a/mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/DocumentServiceImpl.java b/mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/DocumentServiceImpl.java index a9a9068..67c46ad 100644 --- a/mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/DocumentServiceImpl.java +++ b/mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/DocumentServiceImpl.java @@ -17,6 +17,7 @@ package com.chinaztt.mes.technology.service.impl; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.BooleanUtil; @@ -53,6 +54,7 @@ import com.chinaztt.mes.technology.entity.*; import com.chinaztt.mes.technology.excel.DocumentTestStandardData; import com.chinaztt.mes.technology.excel.MaterialCostData; +import com.chinaztt.mes.technology.feign.MesFileApi; import com.chinaztt.mes.technology.mapper.*; import com.chinaztt.mes.technology.service.DocumentJgtService; import com.chinaztt.mes.technology.service.DocumentService; @@ -72,13 +74,13 @@ import lombok.extern.slf4j.Slf4j; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; import java.math.BigDecimal; import java.net.URLEncoder; import java.time.LocalDateTime; @@ -127,6 +129,13 @@ private DocumentJgtMapper documentJgtMapper; private DocumentJgtService documentJgtService; private DocumentSamplingRuleMapper documentSamplingRuleMapper; + + @Autowired + private MesFileApi mesFileApi; + + private static final String locationImg="D:/file/img"; + + private static final String file_img_url = "http://127.0.0.1:6066/Image/img"; /** * @Author: Hans @@ -600,23 +609,61 @@ @SneakyThrows @Override - public R uploadJgt(List<MultipartFile> file, Long documentId) { - List<DocumentJgt> list = new ArrayList<>(); - for (MultipartFile multipartFile:file) { - String fileName = IdUtil.simpleUUID() + StrUtil.DOT + FileUtil.extName(multipartFile.getOriginalFilename()); - minioTemplate.putObject(OSS_BUCKET, fileName, multipartFile.getInputStream()); - DocumentJgt jgt = new DocumentJgt(); - jgt.setFileName(fileName); - jgt.setDocumentId(documentId); - list.add(jgt); - } - //宸ヨ壓涓昏〃鏇存柊鏃堕棿锛屾洿鏂颁汉 - Document document = new Document(); - document.setId(documentId); - baseMapper.updateById(doUpdateRealUser(document)); - documentJgtService.saveBatch(list); - List<String> fileNameList = list.stream().map(a -> a.getFileName()).collect(Collectors.toList()); - return R.ok(org.apache.commons.lang3.StringUtils.join(fileNameList,",")); + public R uploadJgt(MultipartFile file, Long documentId) { + String requestUrl=""; + String fileName = IdUtil.simpleUUID() + StrUtil.DOT + FileUtil.extName(file.getOriginalFilename()); + //minioTemplate.putObject(OSS_BUCKET, fileName, multipartFile.getInputStream()); + //鍒涘缓鏂囦欢澶� + String timeForder= DateUtil.format(DateUtil.date(),"yyyy/MM/dd"); + String forder=locationImg+"/"+OSS_BUCKET+"/"+timeForder; + File filePath = new File(forder); + if(!filePath.exists()){ + filePath.mkdirs(); + } + //鍚堝苟鏂囦欢 + RandomAccessFile raFile = null; + BufferedInputStream inputStream=null; + try{ + File dirFile = new File(forder, fileName); + //浠ヨ鍐欑殑鏂瑰紡鎵撳紑鐩爣鏂囦欢 + raFile = new RandomAccessFile(dirFile, "rw"); + raFile.seek(raFile.length()); + inputStream = new BufferedInputStream(file.getInputStream()); + byte[] buf = new byte[1024]; + int length = 0; + while ((length = inputStream.read(buf)) != -1) { + raFile.write(buf, 0, length); + } + requestUrl=OSS_BUCKET+"/"+timeForder+"/"+fileName; + }catch(Exception e){ + e.printStackTrace(); + }finally{ + try { + if (inputStream != null) { + inputStream.close(); + } + if (raFile != null) { + raFile.close(); + } + }catch(Exception ignored){ + + } + } + String url = requestUrl; + QueryWrapper<DocumentJgt>queryWrapper=new QueryWrapper<>(); + queryWrapper.lambda().eq(DocumentJgt::getDocumentId,documentId); + DocumentJgt documentJgt = documentJgtMapper.selectOne(queryWrapper); + if(Objects.nonNull(documentJgt)){ + UpdateWrapper<DocumentJgt>updateWrapper=new UpdateWrapper<>(); + updateWrapper.lambda().eq(DocumentJgt::getDocumentId,documentId).set(DocumentJgt::getFileName,locationImg+"/"+url); + documentJgtMapper.update(null,updateWrapper); + }else { + DocumentJgt jgt=new DocumentJgt(); + jgt.setDocumentId(documentId); + jgt.setFileName(locationImg+"/"+url); + documentJgtMapper.insert(jgt); + } + return R.ok(locationImg+"/"+url); } @SneakyThrows @@ -668,7 +715,7 @@ @Override public void getFile(String fileName, HttpServletResponse response) { - try (InputStream inputStream = minioTemplate.getObject(OSS_BUCKET, fileName)) { + try (InputStream inputStream = new FileInputStream(fileName)) { response.setContentType("application/octet-stream; charset=UTF-8"); IoUtil.copy(inputStream, response.getOutputStream()); } catch (Exception e) { @@ -792,11 +839,15 @@ if (CollectionUtil.isEmpty(routings)) { throw new RuntimeException("淇濆瓨澶辫触锛岄浂浠讹細" + document.getPartNo() + "鏃犲伐鑹鸿矾绾�"); } - Routing routing = routings.get(0); - joinDocumentBomRouting.setRoutingId(routing.getId()); - joinDocumentBomRouting.setBomId(routing.getBomId()); - joinDocumentBomRoutingMapper.insertAndGetId(joinDocumentBomRouting); - // 娣诲姞妫�娴嬫爣鍑� + Routing routing = routings.get(0); + joinDocumentBomRouting.setRoutingId(routing.getId()); + joinDocumentBomRouting.setBomId(routing.getBomId()); + Routing routing1 = routingMapper.selectById(joinDocumentBomRouting.getRoutingId()); + if(Objects.equals(routing1.getState(),RoutingStateStringValues.DRAFT)){ + throw new RuntimeException("宸ヨ壓璺嚎鐘舵�佹湭閫氳繃锛�"); + } + joinDocumentBomRoutingMapper.insertAndGetId(joinDocumentBomRouting); + // 娣诲姞妫�娴嬫爣鍑� addDocTestStandard(joinDocumentBomRouting); // 璁剧疆瀛愯妭鐐规暟鎹� addBomRoutingPartByBomId(joinDocumentBomRouting.getId(), routing.getBomId(), diff --git a/mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/RoutingServiceImpl.java b/mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/RoutingServiceImpl.java index 532d7c0..a83cb8b 100644 --- a/mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/RoutingServiceImpl.java +++ b/mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/RoutingServiceImpl.java @@ -46,6 +46,7 @@ import com.chinaztt.mes.technology.excel.RoutingExcelData; import com.chinaztt.mes.technology.mapper.*; import com.chinaztt.mes.technology.service.RoutingService; +import com.chinaztt.mes.technology.state.bom.constant.BomStateStringValues; import com.chinaztt.mes.technology.state.routing.RoutingStateMachineConfig; import com.chinaztt.mes.technology.state.routing.constant.RoutingEvents; import com.chinaztt.mes.technology.state.routing.constant.RoutingStateStringValues; @@ -168,6 +169,10 @@ if (noCount > 0) { throw new RuntimeException("缂栧彿閲嶅"); } + Bom bom = bomMapper.selectById(routingDTO.getBomId()); + if(Objects.equals(BomStateStringValues.DRAFT,bom.getState())){ + throw new RuntimeException("BOM鐘舵�佹湭閫氳繃锛�"); + } //涓昏〃涓�愰浂浠跺彿銆戙�併�愬伐鑹虹増鏈�戙�併�愭浛浠c�戝�肩殑缁勫悎椤诲敮涓�銆� noCount = baseMapper.selectCount(Wrappers.<Routing>lambdaQuery().eq(Routing::getPartId, routingDTO.getPartId()) .eq(Routing::getBomTypeDb, routingDTO.getBomTypeDb()) diff --git a/mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/StructureServiceImpl.java b/mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/StructureServiceImpl.java index 281daf7..9acf37a 100644 --- a/mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/StructureServiceImpl.java +++ b/mes-technology/src/main/java/com/chinaztt/mes/technology/service/impl/StructureServiceImpl.java @@ -386,9 +386,9 @@ structure.setIfsSync(false); resetMaster(structure); baseMapper.updateById(structure); - // 瀵规帴ifs - List<StructureDTO> structureDTOS = structureMapper.getStructureDtoByIds(Arrays.asList(structure.getId())); - structureIfsSyncByDto(structureDTOS); + //// 瀵规帴ifs + //List<StructureDTO> structureDTOS = structureMapper.getStructureDtoByIds(Arrays.asList(structure.getId())); + //structureIfsSyncByDto(structureDTOS); return R.ok(); } diff --git a/mes-web/src/main/java/com/chinaztt/mes/App.java b/mes-web/src/main/java/com/chinaztt/mes/App.java index 87401c3..7ae4f54 100644 --- a/mes-web/src/main/java/com/chinaztt/mes/App.java +++ b/mes-web/src/main/java/com/chinaztt/mes/App.java @@ -16,7 +16,7 @@ @EnableZttSwagger2 @SpringCloudApplication @EnableDiscoveryClient -@EnableZttFeignClients(basePackages = {"com.chinaztt.ztt", "com.chinaztt.ifs", "com.chinaztt.inspect"}) +@EnableZttFeignClients(basePackages = {"com.chinaztt.**"}) @EnableZttResourceServer @EnableZttXxlJob public class App { diff --git a/mes-web/src/main/resources/bootstrap.yml b/mes-web/src/main/resources/bootstrap.yml index 7d0d312..f8f31c8 100644 --- a/mes-web/src/main/resources/bootstrap.yml +++ b/mes-web/src/main/resources/bootstrap.yml @@ -38,7 +38,6 @@ log-impl: org.apache.ibatis.logging.stdout.StdOutImpl - #erpBase: http://localhost:7071/zbgj ## 鍚屾鍚堝悓 #erpUrl: ${erpBase}/syncList -- Gitblit v1.9.3