mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/service/lsv2/Lsv2Client.java
@@ -12,7 +12,9 @@ import com.qianwen.mdc.utils.Lsv2Util; import com.qianwen.mdc.utils.MdcException; /** * Lsv2åè®®çæ°æ®éé客æ·ç«¯ï¼ç¨äºHeidenhainç³»ç»ãLSV-2ç¨äºä»ç¶ä½¿ç¨16使»çº¿çè®¾å¤ */ public class Lsv2Client { private Shell shell; @@ -27,6 +29,8 @@ private boolean connected; private final Logger logger; private final String activeXClsid = "{F9EE051D-C65D-4480-8E35-76F10FAB15C6}"; public Lsv2Client(String ipAddr) { this.connected = false; @@ -43,7 +47,7 @@ this.shell = new Shell(display, 1264); this.shell.setLayout(null); this.oleFrame = new OleFrame((Composite)this.shell, 0); this.oleControlSite = new OleControlSite((Composite)this.oleFrame, 0, "{F9EE051D-C65D-4480-8E35-76F10FAB15C6}"); this.oleControlSite = new OleControlSite((Composite)this.oleFrame, 0, activeXClsid); this.oleAutomation = new OleAutomation((OleClientSite)this.oleControlSite); this.oleControlSite.doVerb(-3); }); mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/utils/Lsv2Util.java
@@ -1,152 +1,121 @@ /* */ package com.qianwen.mdc.utils; /* */ /* */ import org.eclipse.swt.ole.win32.OleAutomation; /* */ import org.eclipse.swt.ole.win32.Variant; /* */ /* */ /* */ /* */ public class Lsv2Util /* */ { /* */ public static final String lsv2Ctrl3ProgId = "{F9EE051D-C65D-4480-8E35-76F10FAB15C6}"; /* */ /* */ private static Variant execute(OleAutomation oleAutomation, String methodName) { /* 13 */ return execute(oleAutomation, methodName, null); /* */ } /* */ /* */ private static Variant execute(OleAutomation oleAutomation, String methodName, Variant[] args) { /* 17 */ int mid = getID(oleAutomation, methodName); /* */ /* 19 */ return execute(oleAutomation, mid, args); /* */ } /* */ private static Variant execute(OleAutomation oleAutomation, int mid, Variant[] args) { /* */ Variant rtnv; /* 23 */ if (mid < 0) { /* 24 */ return null; /* */ } /* */ /* */ /* 28 */ if (args == null) { /* 29 */ rtnv = oleAutomation.invoke(mid); /* */ } else { /* 31 */ rtnv = oleAutomation.invoke(mid, args); /* */ } /* */ /* 34 */ return rtnv; /* */ } /* */ /* */ private static int getID(OleAutomation oleAutomation, String name) { /* */ try { /* 39 */ int[] ids = oleAutomation.getIDsOfNames(new String[] { name }); /* 40 */ if (ids == null) { /* 41 */ return -1; /* */ } /* */ /* 44 */ return ids[0]; /* 45 */ } catch (RuntimeException e) { /* 46 */ e.printStackTrace(); /* */ /* */ /* 49 */ return -1; /* */ } /* */ } /* */ public static String getLastError(OleAutomation oleAutomation) { /* 53 */ String methodName = "LastError"; /* */ /* 55 */ return execute(oleAutomation, methodName).getString(); /* */ } /* */ /* */ public static String getLastErrorString(OleAutomation oleAutomation) { /* 59 */ String methodName = "LastErrorString"; /* */ /* 61 */ return execute(oleAutomation, methodName).getString(); /* */ } /* */ /* */ public static boolean connect(OleAutomation oleAutomation) { /* 65 */ String methodName = "Connect"; /* */ /* 67 */ return execute(oleAutomation, methodName).getBoolean(); /* */ } /* */ /* */ public static boolean testConnection(OleAutomation oleAutomation) { /* 71 */ String methodName = "TestConnection"; /* 72 */ Variant[] args = { new Variant(2) }; /* */ /* 74 */ return execute(oleAutomation, methodName, args).getBoolean(); /* */ } /* */ /* */ public static boolean disConnect(OleAutomation oleAutomation) { /* 78 */ String methodName = "DisConnect"; /* */ /* 80 */ return execute(oleAutomation, methodName).getBoolean(); /* */ } /* */ /* */ public static boolean reConnect(OleAutomation oleAutomation) { /* 84 */ String methodName = "ReConnect"; /* */ /* 86 */ return execute(oleAutomation, methodName).getBoolean(); /* */ } /* */ /* */ public static void setMedium(OleAutomation oleAutomation, int medium) { /* 90 */ String methodName = "Medium"; /* 91 */ Variant[] args = { new Variant(medium) }; /* */ /* 93 */ execute(oleAutomation, methodName, args); /* */ } /* */ /* */ public static void setIPAddress(OleAutomation oleAutomation, String ipAddress) { /* 97 */ String methodName = "IPAddress"; /* 98 */ Variant[] args = { new Variant(ipAddress) }; /* */ /* 100 */ execute(oleAutomation, methodName, args); /* */ } /* */ /* */ public static void setPort(OleAutomation oleAutomation) { /* 104 */ String methodName = "Port"; /* */ /* 106 */ execute(oleAutomation, methodName); /* */ } /* */ /* */ public static void setTransferMode(OleAutomation oleAutomation, Integer mode) { /* 110 */ String methodName = "TransferMode"; /* 111 */ Variant[] args = { new Variant(mode.intValue()) }; /* */ /* 113 */ execute(oleAutomation, methodName, args); /* */ } /* */ /* */ public static void setHostFunction(OleAutomation oleAutomation, Boolean hostFunction) { /* 117 */ String methodName = "HostFunction"; /* 118 */ Variant[] args = { new Variant(hostFunction.booleanValue()) }; /* */ /* 120 */ execute(oleAutomation, methodName, args); /* */ } /* */ /* */ public static String getVersionTNC(OleAutomation oleAutomation) { /* 124 */ String methodName = "VersionTNC"; /* */ /* 126 */ return execute(oleAutomation, methodName).getString(); /* */ } /* */ /* */ /* */ /* */ public static String getProgramName(OleAutomation oleAutomation) { /* 132 */ String methodName = "ReceiveDNCInfo"; /* 133 */ short type = 3; /* 134 */ int InfoPara = 0; /* 135 */ Variant[] args = { new Variant(type), new Variant(InfoPara) }; /* */ /* 137 */ return execute(oleAutomation, methodName, args).getString(); /* */ } /* */ /* */ public static String receiveMemBlock(OleAutomation oleAutomation, short type, short address, short count) { /* 141 */ String methodName = "ReceiveMemBlock"; /* 142 */ Variant[] args = { new Variant(type), new Variant(address), new Variant(count) }; /* */ /* 144 */ return execute(oleAutomation, methodName, args).getString(); /* */ } /* */ } package com.qianwen.mdc.utils; /* Location: D:\yangys\mdm\è代ç \mdcplugin\mdc-plugin-0.0.1-SNAPSHOT-å é¤lib.jar!\BOOT-INF\classes\cn\net\hx\md\\utils\Lsv2Util.class * Java compiler version: 8 (52.0) * JD-Core Version: 1.1.3 */ import org.eclipse.swt.ole.win32.OleAutomation; import org.eclipse.swt.ole.win32.Variant; public class Lsv2Util { public static final String lsv2Ctrl3ProgId = "{F9EE051D-C65D-4480-8E35-76F10FAB15C6}"; private static Variant execute(OleAutomation oleAutomation, String methodName) { return execute(oleAutomation, methodName, null); } private static Variant execute(OleAutomation oleAutomation, String methodName, Variant[] args) { int mid = getID(oleAutomation, methodName); return execute(oleAutomation, mid, args); } private static Variant execute(OleAutomation oleAutomation, int mid, Variant[] args) { Variant rtnv; if (mid < 0) return null; if (args == null) { rtnv = oleAutomation.invoke(mid); } else { rtnv = oleAutomation.invoke(mid, args); } return rtnv; } private static int getID(OleAutomation oleAutomation, String name) { try { int[] ids = oleAutomation.getIDsOfNames(new String[] { name }); if (ids == null) return -1; return ids[0]; } catch (RuntimeException e) { e.printStackTrace(); return -1; } } public static String getLastError(OleAutomation oleAutomation) { String methodName = "LastError"; return execute(oleAutomation, methodName).getString(); } public static String getLastErrorString(OleAutomation oleAutomation) { String methodName = "LastErrorString"; return execute(oleAutomation, methodName).getString(); } public static boolean connect(OleAutomation oleAutomation) { String methodName = "Connect"; return execute(oleAutomation, methodName).getBoolean(); } public static boolean testConnection(OleAutomation oleAutomation) { String methodName = "TestConnection"; Variant[] args = { new Variant(2) }; return execute(oleAutomation, methodName, args).getBoolean(); } public static boolean disConnect(OleAutomation oleAutomation) { String methodName = "DisConnect"; return execute(oleAutomation, methodName).getBoolean(); } public static boolean reConnect(OleAutomation oleAutomation) { String methodName = "ReConnect"; return execute(oleAutomation, methodName).getBoolean(); } public static void setMedium(OleAutomation oleAutomation, int medium) { String methodName = "Medium"; Variant[] args = { new Variant(medium) }; execute(oleAutomation, methodName, args); } public static void setIPAddress(OleAutomation oleAutomation, String ipAddress) { String methodName = "IPAddress"; Variant[] args = { new Variant(ipAddress) }; execute(oleAutomation, methodName, args); } public static void setPort(OleAutomation oleAutomation) { String methodName = "Port"; execute(oleAutomation, methodName); } public static void setTransferMode(OleAutomation oleAutomation, Integer mode) { String methodName = "TransferMode"; Variant[] args = { new Variant(mode.intValue()) }; execute(oleAutomation, methodName, args); } public static void setHostFunction(OleAutomation oleAutomation, Boolean hostFunction) { String methodName = "HostFunction"; Variant[] args = { new Variant(hostFunction.booleanValue()) }; execute(oleAutomation, methodName, args); } public static String getVersionTNC(OleAutomation oleAutomation) { String methodName = "VersionTNC"; return execute(oleAutomation, methodName).getString(); } public static String getProgramName(OleAutomation oleAutomation) { String methodName = "ReceiveDNCInfo"; short type = 3; int InfoPara = 0; Variant[] args = { new Variant(type), new Variant(InfoPara) }; return execute(oleAutomation, methodName, args).getString(); } public static String receiveMemBlock(OleAutomation oleAutomation, short type, short address, short count) { String methodName = "ReceiveMemBlock"; Variant[] args = { new Variant(type), new Variant(address), new Variant(count) }; return execute(oleAutomation, methodName, args).getString(); } } mdc-parent/mdc-collect/src/test/java/com/qianwen/mdc/service/lsv2/Lsv2ClientTest.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,59 @@ package com.qianwen.mdc.service.lsv2; import org.eclipse.swt.ole.win32.OleAutomation; import org.eclipse.swt.ole.win32.OleClientSite; import org.eclipse.swt.ole.win32.OleControlSite; import org.eclipse.swt.ole.win32.OleFrame; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.junit.jupiter.api.Test; import com.qianwen.mdc.utils.Lsv2Util; public class Lsv2ClientTest { private Shell shell; private OleFrame oleFrame; private OleControlSite oleControlSite; private OleAutomation oleAutomation; @Test public void create() { Display display = Display.getDefault(); if (!display.isDisposed()) display.syncExec(() -> { this.shell = new Shell(display, 1264); this.shell.setLayout(null); this.oleFrame = new OleFrame((Composite) this.shell, 0); this.oleControlSite = new OleControlSite((Composite) this.oleFrame, 0, "{F9EE051D-C65D-4480-8E35-76F10FAB15C6}"); this.oleAutomation = new OleAutomation((OleClientSite) this.oleControlSite); this.oleControlSite.doVerb(-3); }); Lsv2Util.setMedium(this.oleAutomation, 1); Lsv2Util.setIPAddress(this.oleAutomation, "192.168.1.12"); Lsv2Util.setHostFunction(this.oleAutomation, Boolean.valueOf(false)); boolean connected = Lsv2Util.connect(this.oleAutomation); System.out.println(connected); boolean b = Lsv2Util.testConnection(oleAutomation); System.out.println(b); //readNCState short type = 0; short address = 4176; short count = 1; String state = Lsv2Util.receiveMemBlock(this.oleAutomation, type, address, count); System.out.println(state); //readVersionTNC String versionTNC =Lsv2Util.getVersionTNC(this.oleAutomation); System.out.println(versionTNC); } } mdc-parent/mdc-show/pom.xml
@@ -44,6 +44,12 @@ <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <exclusions> <exclusion> <groupId>com.zaxxer</groupId> <artifactId>HikariCP</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/controller/machine/MachineEditController.java
@@ -19,8 +19,8 @@ import com.qianwen.mdc.common.OpResult; import com.qianwen.mdc.dto.IdsDTO; import com.qianwen.mdc.dto.MachineProtocolDTO; import com.qianwen.mdc.dto.WorkshopDTO; import com.qianwen.mdc.dto.machine.MachineDTO; import com.qianwen.mdc.dto.workshop.WorkshopDTO; import com.qianwen.mdc.service.machine.MachineEditService; import com.qianwen.mdc.service.workshop.WorkshopService; mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/controller/plant/PlantEditController.java
ÎļþÃû´Ó mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/controller/PlantEditController.java ÐÞ¸Ä @@ -1,6 +1,4 @@ package com.qianwen.mdc.controller; import java.util.List; package com.qianwen.mdc.controller.plant; import javax.servlet.http.HttpServletRequest; @@ -9,7 +7,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; @@ -17,10 +14,9 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import com.alibaba.fastjson.JSONObject; import com.qianwen.mdc.common.OpResult; import com.qianwen.mdc.dto.IdsDTO; import com.qianwen.mdc.dto.PlantDTO; import com.qianwen.mdc.dto.plant.PlantDTO; import com.qianwen.mdc.service.plant.PlantService; import com.qianwen.mdc.vallidate.AddGroup; import com.qianwen.mdc.vallidate.UpdateGroup; @@ -93,20 +89,5 @@ } } /** * å ¨é¨è½¦é´å表 * @param request * @return */ @GetMapping(value = "/list") public OpResult<List<PlantDTO>> list() { try { return OpResult.success(plantService.list()); }catch(Exception ex) { logger.error("æ¥è¯¢åæ¿å表失败",ex); return OpResult.fail(ex.getMessage()); } } } mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/controller/plant/PlantQueryController.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,67 @@ package com.qianwen.mdc.controller.plant; import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.qianwen.mdc.common.OpResult; import com.qianwen.mdc.dto.plant.PlantDTO; import com.qianwen.mdc.dto.plant.PlantQueryDTO; import com.qianwen.mdc.service.plant.PlantQueryService; import com.qianwen.mdc.service.sysaccount.AccountTokenService; /** * è®¾å¤æ¥è¯¢æ§å¶å¨ */ @RestController @CrossOrigin @RequestMapping(value = "/plant") public class PlantQueryController { @Autowired private AccountTokenService accountTokenService; @Autowired private PlantQueryService queryService; public static final Logger logger = LoggerFactory.getLogger(PlantQueryController.class); /** * å ¨é¨è½¦é´å表 * @param request * @return */ //@GetMapping(value = "/list") @Deprecated public OpResult<List<PlantDTO>> list() { try { return OpResult.success(queryService.list()); }catch(Exception ex) { logger.error("æ¥è¯¢åæ¿å表失败",ex); return OpResult.fail(ex.getMessage()); } } @PostMapping(value = "/pageQuery") public OpResult<Page<PlantDTO>> pageQuery(@RequestBody PlantQueryDTO dto) { try { return OpResult.success(queryService.pageQuery(dto)); }catch(Exception e) { logger.error("æºåºå页æ¥è¯¢å¼å¸¸",e); return OpResult.fail(e.getMessage()); } } } mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/controller/workshop/SectionController.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,78 @@ package com.qianwen.mdc.controller.workshop; import java.util.List; import javax.validation.groups.Default; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.qianwen.mdc.common.OpResult; import com.qianwen.mdc.dto.SectionDTO; import com.qianwen.mdc.service.section.SectionService; /** * @author y_ys79 * å·¥æ®µæ°æ®ç»´æ¤æ§å¶å¨ */ @RestController @CrossOrigin @RequestMapping(value = "/section") public class SectionController { @Autowired private SectionService sectionService; public static final Logger logger = LoggerFactory.getLogger(SectionController.class); @PostMapping(value = "/create") public OpResult<Void> create(@RequestHeader(value = "mdc-token", defaultValue = "") String token, @Validated(value = {Default.class}) @RequestBody SectionDTO sectionDTO) { try { sectionService.save(sectionDTO); }catch(Exception ex) { logger.error("æ°å¢è½¦é´å¤±è´¥",ex); return OpResult.fail(ex.getMessage()); } return OpResult.success(); } @PostMapping(value = "/modify") public OpResult<Void> modify(@RequestHeader(value = "mdc-token", defaultValue = "") String token, @Validated(value = {Default.class}) @RequestBody SectionDTO sectionDTO) { try { sectionService.modify(sectionDTO); }catch(Exception ex) { logger.error("æ°å¢è½¦é´å¤±è´¥",ex); return OpResult.fail(ex.getMessage()); } return OpResult.success(); } @GetMapping(value = "/listByWorkshop") public OpResult<List<SectionDTO>> listByWorkshop(@RequestHeader(value = "mdc-token", defaultValue = "") String token, Long workshopId) { try { OpResult.success(sectionService.listByWorkshopId(workshopId)); }catch(Exception ex) { logger.error("æ¥è¯¢è½¦é´ä¸å±å·¥æ®µå¤±è´¥",ex); return OpResult.fail(ex.getMessage()); } return OpResult.success(); } } mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/controller/workshop/WorkshopEditController.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,66 @@ package com.qianwen.mdc.controller.workshop; import javax.validation.groups.Default; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.qianwen.mdc.common.OpResult; import com.qianwen.mdc.dto.workshop.WorkshopDTO; import com.qianwen.mdc.service.workshop.WorkshopEditService; import com.qianwen.mdc.service.workshop.WorkshopService; /** * @author y_ys79 * 车é´ä¿®æ¹æ§å¶å¨ */ @RestController @CrossOrigin @RequestMapping(value = "/workshop") public class WorkshopEditController { @Autowired private WorkshopEditService editService; @Autowired private WorkshopService workshopService; public static final Logger logger = LoggerFactory.getLogger(WorkshopEditController.class); @PostMapping(value = "/create") public OpResult<Void> create(@RequestHeader(value = "mdc-token", defaultValue = "") String token, @Validated(value = {Default.class}) @RequestBody WorkshopDTO workshopDTO) { try { editService.save(workshopDTO); }catch(Exception ex) { logger.error("æ°å¢è½¦é´å¤±è´¥",ex); return OpResult.fail(ex.getMessage()); } return OpResult.success(); } @PostMapping(value = "/modify") public OpResult<Void> modify(@RequestHeader(value = "mdc-token", defaultValue = "") String token, @Validated(value = {Default.class}) @RequestBody WorkshopDTO workshopDTO) { try { editService.modify(workshopDTO); }catch(Exception ex) { logger.error("æ°å¢è½¦é´å¤±è´¥",ex); return OpResult.fail(ex.getMessage()); } return OpResult.success(); } } mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/controller/workshop/WorkshopQueryController.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,47 @@ package com.qianwen.mdc.controller.workshop; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.qianwen.mdc.common.OpResult; import com.qianwen.mdc.dto.workshop.WorkshopFullDTO; import com.qianwen.mdc.dto.workshop.WorkshopQueryDTO; import com.qianwen.mdc.service.sysaccount.AccountTokenService; import com.qianwen.mdc.service.workshop.WorkshopService; /** * è½¦é´æ¥è¯¢æ§å¶å¨ */ @RestController @CrossOrigin @RequestMapping(value = "/workshop") public class WorkshopQueryController { @Autowired private AccountTokenService accountTokenService; @Autowired private WorkshopService workshopService; public static final Logger logger = LoggerFactory.getLogger(WorkshopQueryController.class); @PostMapping(value = "/pageQuery") public OpResult<Page<WorkshopFullDTO>> pageQuery(@RequestBody WorkshopQueryDTO dto) { try { return OpResult.success(workshopService.pageQuery(dto)); }catch(Exception e) { logger.error("车é´å页æ¥è¯¢å¼å¸¸",e); return OpResult.fail(e.getMessage()); } } } mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/domain/Section.java
@@ -14,7 +14,7 @@ * primary key */ @TableId(type=IdType.ASSIGN_ID) private Integer id; private Long id; /** * section name @@ -25,7 +25,7 @@ * workshop id */ //@Column(name = "workshop_id") private Integer workshopId; private Long workshopId; private static final long serialVersionUID = 1L; @@ -34,7 +34,7 @@ * * @return id - primary key */ public Integer getId() { public Long getId() { return id; } @@ -43,7 +43,7 @@ * * @param id primary key */ public void setId(Integer id) { public void setId(Long id) { this.id = id; } @@ -70,7 +70,7 @@ * * @return workshop_id - workshop id */ public Integer getWorkshopId() { public Long getWorkshopId() { return workshopId; } @@ -79,7 +79,7 @@ * * @param workshopId workshop id */ public void setWorkshopId(Integer workshopId) { public void setWorkshopId(Long workshopId) { this.workshopId = workshopId; } mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/domain/workshop/Workshop.java
@@ -13,7 +13,7 @@ * primary key */ @TableId(type=IdType.ASSIGN_ID) private Integer id; private Long id; /** * workshop name @@ -27,7 +27,7 @@ * * @return id - primary key */ public Integer getId() { public Long getId() { return id; } @@ -36,7 +36,7 @@ * * @param id primary key */ public void setId(Integer id) { public void setId(Long id) { this.id = id; } mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/domain/workshop/WorkshopAssembler.java
@@ -6,7 +6,7 @@ import com.qianwen.mdc.domain.Section; import com.qianwen.mdc.dto.SectionDTO; import com.qianwen.mdc.dto.WorkshopDTO; import com.qianwen.mdc.dto.workshop.WorkshopDTO; /** * è´è´£ç±»çç»è£ 转æ¢å·¥ä½ mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/dto/SectionDTO.java
@@ -11,18 +11,18 @@ */ private static final long serialVersionUID = -2006517821720524176L; private Integer id; private Long id; private String name; private Integer workshopId; private Long workshopId; public Integer getId() { public Long getId() { return id; } public void setId(Integer id) { public void setId(Long id) { this.id = id; } @@ -36,12 +36,12 @@ } public Integer getWorkshopId() { public Long getWorkshopId() { return workshopId; } public void setWorkshopId(Integer workshopId) { public void setWorkshopId(Long workshopId) { this.workshopId = workshopId; } mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/dto/plant/PlantDTO.java
ÎļþÃû´Ó mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/dto/PlantDTO.java ÐÞ¸Ä @@ -1,4 +1,4 @@ package com.qianwen.mdc.dto; package com.qianwen.mdc.dto.plant; import java.io.Serializable; @@ -24,6 +24,11 @@ @NotBlank(message = "åæ¿è®¾ç½®ä¸è½ä¸ºç©º", groups = {AddGroup.class, UpdateGroup.class}) private String gridSetting; /** * è®¾å¤æ°é */ private Integer machineCount; public Long getId() { return id; } @@ -53,5 +58,15 @@ } public Integer getMachineCount() { return machineCount; } public void setMachineCount(Integer machineCount) { this.machineCount = machineCount; } } mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/dto/plant/PlantQueryDTO.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,19 @@ package com.qianwen.mdc.dto.plant; import com.qianwen.mdc.dto.BasePageDTO; /** * åæ¿æ¥è¯¢æ°æ®ä¼ è¾å¯¹è±¡ */ public class PlantQueryDTO extends BasePageDTO{ private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } } mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/dto/workshop/WorkshopDTO.java
ÎļþÃû´Ó mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/dto/WorkshopDTO.java ÐÞ¸Ä @@ -1,7 +1,9 @@ package com.qianwen.mdc.dto; package com.qianwen.mdc.dto.workshop; import java.io.Serializable; import java.util.List; import com.qianwen.mdc.dto.SectionDTO; /** * è½¦é´æ°æ®ä¼ è¾å¯¹è±¡ */ @@ -12,18 +14,18 @@ */ private static final long serialVersionUID = -2006517821720524176L; private Integer id; private Long id; private String name; private List<SectionDTO> sections; public Integer getId() { public Long getId() { return id; } public void setId(Integer id) { public void setId(Long id) { this.id = id; } mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/dto/workshop/WorkshopFullDTO.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,63 @@ package com.qianwen.mdc.dto.workshop; import java.io.Serializable; import java.util.List; import com.qianwen.mdc.dto.SectionDTO; /** * è½¦é´æ°æ®ä¼ è¾å¯¹è±¡ */ public class WorkshopFullDTO implements Serializable { /** * */ private static final long serialVersionUID = -2006517821720524176L; private Long id; private String name; private List<SectionDTO> sections; private String sectionNames; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public List<SectionDTO> getSections() { return sections; } public void setSections(List<SectionDTO> sections) { this.sections = sections; } public String getSectionNames() { return sectionNames; } public void setSectionNames(String sectionNames) { this.sectionNames = sectionNames; } } mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/dto/workshop/WorkshopQueryDTO.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,38 @@ package com.qianwen.mdc.dto.workshop; import com.qianwen.mdc.dto.BasePageDTO; /** * 设å¤ç±»å"æ°æ® */ public class WorkshopQueryDTO extends BasePageDTO{ /* * ç±»ååç§° */ private String name; /* * å 餿 è®° 0:æªå é¤ï¼1:å·²å é¤ */ private int deleteFlag; public String getName() { return name; } public void setName(String name) { this.name = name; } public int getDeleteFlag() { return deleteFlag; } public void setDeleteFlag(int deleteFlag) { this.deleteFlag = deleteFlag; } } mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/mapper/PlantMapper.java
@@ -1,8 +1,19 @@ package com.qianwen.mdc.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.qianwen.mdc.domain.plant.Plant; import com.qianwen.mdc.dto.plant.PlantDTO; import com.qianwen.mdc.dto.plant.PlantQueryDTO; public interface PlantMapper extends BaseMapper<Plant> { /** * å页æ¥è¯¢ * @param rowPage * @param dto * @return */ Page<PlantDTO> queryPage(Page<PlantDTO> rowPage, PlantQueryDTO dto); } mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/mapper/SectionMapper.java
@@ -11,5 +11,5 @@ * @param workshopId 车é´id * @return */ List<Section> queryByWorkshopId(Integer workshopId); List<Section> queryByWorkshopId(Long workshopId); } mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/mapper/WorkshopMapper.java
@@ -1,7 +1,20 @@ package com.qianwen.mdc.mapper; import com.qianwen.mdc.domain.workshop.Workshop; import org.apache.ibatis.annotations.Param; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.qianwen.mdc.domain.workshop.Workshop; import com.qianwen.mdc.dto.workshop.WorkshopFullDTO; import com.qianwen.mdc.dto.workshop.WorkshopQueryDTO; public interface WorkshopMapper extends BaseMapper<Workshop> { /** * å页æ¥è¯¢è½¦é´ * @param rowPage * @param dto * @return */ Page<WorkshopFullDTO> queryPage(Page<WorkshopFullDTO> rowPage,@Param("dto")WorkshopQueryDTO dto); } mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/service/plant/PlantQueryService.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,65 @@ package com.qianwen.mdc.service.plant; import java.util.List; import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.qianwen.mdc.domain.plant.Plant; import com.qianwen.mdc.dto.plant.PlantDTO; import com.qianwen.mdc.dto.plant.PlantQueryDTO; import com.qianwen.mdc.mapper.PlantMapper; /** * @author y_ys79 * åæ¿å°å¾æ¥è¯¢æå¡ */ @Service public class PlantQueryService { @Autowired private PlantMapper plantMapper; @Autowired private PlantService plantService; /** * ææåæ¿å表 * @return */ @Transactional(readOnly=true) public List<PlantDTO> list() { List<Plant> plist = plantMapper.selectList(null); return plist.stream().map(p -> { PlantDTO dto = new PlantDTO(); dto.setId(p.getId()); dto.setName(p.getName()); dto.setGridSetting(p.getGridSetting()); return dto; }).collect(Collectors.toList()); } /** * åæ¿å页æ¥è¯¢ * @param dto * @return */ @Transactional(readOnly=true) public Page<PlantDTO> pageQuery(PlantQueryDTO dto) { Page<PlantDTO> rowPage = new Page<>(dto.finalPageNo(),dto.finalPageSize()); rowPage = plantMapper.queryPage(rowPage, dto); List<PlantDTO> list = rowPage.getRecords(); //è§£ææºåºä¸ªæ° for(PlantDTO p: list) { p.setMachineCount(plantService.parseMachineIdInGrid(p.getGridSetting()).size()); } return rowPage; } } mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/service/plant/PlantService.java
@@ -1,12 +1,9 @@ package com.qianwen.mdc.service.plant; import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; import org.apache.commons.io.FileUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -17,7 +14,7 @@ import com.alibaba.fastjson.JSONObject; import com.qianwen.mdc.domain.Machine; import com.qianwen.mdc.domain.plant.Plant; import com.qianwen.mdc.dto.PlantDTO; import com.qianwen.mdc.dto.plant.PlantDTO; import com.qianwen.mdc.mapper.MachineMapper; import com.qianwen.mdc.mapper.PlantMapper; @@ -61,7 +58,7 @@ } List<Integer> parseMachineIdInGrid(String gridSetting){ public List<Integer> parseMachineIdInGrid(String gridSetting){ List<Integer> macineIds = new ArrayList<>(); try { @@ -124,24 +121,7 @@ plantMapper.updateById(p); } /** * ææåæ¿å表 * @return */ @Transactional(readOnly=true) public List<PlantDTO> list() { List<Plant> plist = plantMapper.selectList(null); return plist.stream().map(p -> { PlantDTO dto = new PlantDTO(); dto.setId(p.getId()); dto.setName(p.getName()); dto.setGridSetting(p.getGridSetting()); return dto; }).collect(Collectors.toList()); } /** * å é¤åæ¿ mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/service/section/SectionService.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,52 @@ package com.qianwen.mdc.service.section; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; import java.util.stream.Collectors; import com.qianwen.mdc.domain.Section; import com.qianwen.mdc.dto.SectionDTO; import com.qianwen.mdc.mapper.SectionMapper; /** * @author y_ys79 * 工段æå¡ï¼æä¾å¢å æ¹æ¥å ¨é¨æä½ï¼é»è¾æ¯è¾ç®åï¼ */ @Service public class SectionService { @Autowired private SectionMapper sectionMapper; @Transactional public void save(SectionDTO sectionDTO) { Section sec = new Section(); sec.setName(sectionDTO.getName()); sec.setWorkshopId(sectionDTO.getWorkshopId()); sectionMapper.insert(sec); } @Transactional public void modify(SectionDTO sectionDTO) { Section sec = sectionMapper.selectById(sectionDTO.getId()); sec.setName(sectionDTO.getName()); sectionMapper.updateById(sec); } @Transactional(readOnly=true) public List<SectionDTO> listByWorkshopId(Long workshopId) { List<Section> list = sectionMapper.queryByWorkshopId(workshopId); return list.stream().map(s -> { SectionDTO dto = new SectionDTO(); BeanUtils.copyProperties(s, dto); return dto; }).collect(Collectors.toList()); } } mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/service/workshop/WorkshopEditService.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,46 @@ package com.qianwen.mdc.service.workshop; import java.util.List; import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.qianwen.mdc.domain.Section; import com.qianwen.mdc.domain.workshop.Workshop; import com.qianwen.mdc.domain.workshop.WorkshopAssembler; import com.qianwen.mdc.dto.workshop.WorkshopDTO; import com.qianwen.mdc.mapper.SectionMapper; import com.qianwen.mdc.mapper.WorkshopMapper; /** * @author y_ys79 * è½¦é´æå¡ï¼æä¾å¢å æ¹æ¥å ¨é¨æä½ï¼é»è¾æ¯è¾ç®åï¼ */ @Service public class WorkshopEditService { @Autowired private WorkshopMapper workshopMapper; @Autowired private SectionMapper sectionMapper; @Transactional public void save(WorkshopDTO workshopDTO) { Workshop ws = new Workshop(); ws.setName(workshopDTO.getName()); workshopMapper.insert(ws); } @Transactional public void modify(WorkshopDTO workshopDTO) { Workshop ws = workshopMapper.selectById(workshopDTO.getId()); ws.setName(workshopDTO.getName()); workshopMapper.updateById(ws); } } mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/service/workshop/WorkshopService.java
@@ -1,19 +1,22 @@ package com.qianwen.mdc.service.workshop; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; import org.apache.tomcat.util.buf.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.qianwen.mdc.domain.Machine; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.qianwen.mdc.domain.Section; import com.qianwen.mdc.domain.workshop.Workshop; import com.qianwen.mdc.domain.workshop.WorkshopAssembler; import com.qianwen.mdc.dto.WorkshopDTO; import com.qianwen.mdc.dto.machine.MachineDTO; import com.qianwen.mdc.mapper.MachineMapper; import com.qianwen.mdc.dto.workshop.WorkshopDTO; import com.qianwen.mdc.dto.workshop.WorkshopFullDTO; import com.qianwen.mdc.dto.workshop.WorkshopQueryDTO; import com.qianwen.mdc.mapper.SectionMapper; import com.qianwen.mdc.mapper.WorkshopMapper; @@ -27,29 +30,15 @@ private WorkshopMapper workshopMapper; @Autowired private SectionMapper sectionMapper; @Transactional public void save(WorkshopDTO workshopDTO) { Workshop ws = new Workshop(); ws.setName(workshopDTO.getName()); workshopMapper.insert(ws); } @Transactional public void modify(WorkshopDTO workshopDTO) { Workshop ws = workshopMapper.selectById(workshopDTO.getId()); ws.setName(workshopDTO.getName()); workshopMapper.updateById(ws); } /** * è·å车é´å表ï¼é带车é´ä¸çå·¥æ®µæ°æ® * @return */ @Transactional(readOnly=true) public List<WorkshopDTO> listWithSections() { List<Workshop> list = workshopMapper.selectList(null); List<Workshop> list = workshopMapper.selectList(Wrappers.emptyWrapper()); return list.stream().map(ws -> { List<Section> sectionList = sectionMapper.queryByWorkshopId(ws.getId()); WorkshopDTO wsDTO = WorkshopAssembler.toDTO(ws,sectionList); @@ -57,4 +46,22 @@ return wsDTO; }).collect(Collectors.toList()); } @Transactional(readOnly=true) public Page<WorkshopFullDTO> pageQuery(WorkshopQueryDTO dto) { Page<WorkshopFullDTO> rowPage = new Page<>(dto.finalPageNo(),dto.finalPageSize()); rowPage = workshopMapper.queryPage(rowPage, dto); rowPage.getRecords().forEach((ws) -> { List<Section> sectionList = sectionMapper.queryByWorkshopId(ws.getId()); List<String> nameList = new ArrayList<>(); for(Section s : sectionList) { nameList.add(s.getName()); } ws.setSectionNames(StringUtils.join(nameList,',')); }); return rowPage; } } mdc-parent/mdc-showdb-mysql/src/main/resources/mapper/PlantMapper.xml
@@ -7,4 +7,17 @@ <result column="name" jdbcType="VARCHAR" property="name" /> <result column="grid_setting" jdbcType="VARCHAR" property="gridSetting" /> </resultMap> <select id="queryPage" resultType="com.qianwen.mdc.dto.plant.PlantDTO"> select id,name,grid_setting gridSetting from plant <where> <if test="dto.name != null and dto.name != ''"> <bind name="name" value="'%' + dto.name + '%'" /> and name like #{name} </if> </where> order by id </select> </mapper> mdc-parent/mdc-showdb-mysql/src/main/resources/mapper/WorkshopMapper.xml
@@ -8,4 +8,17 @@ <id column="id" jdbcType="INTEGER" property="id" /> <result column="name" jdbcType="VARCHAR" property="name" /> </resultMap> <select id="queryPage" resultType="com.qianwen.mdc.dto.workshop.WorkshopFullDTO"> select id,name from workshop <where> <if test="dto.name != null and dto.name != ''"> <bind name="name" value="'%' + dto.name + '%'" /> and name like #{name} </if> </where> order by id </select> </mapper>