| | |
| | | })
|
| | | }
|
| | |
|
| | | export function UpdateTask(types,shelfrack) {
|
| | | export function UpdateTask(types,glassid,shelfrack) {
|
| | | return request({
|
| | | url: '/home/UpdateTask?types=' + types + '&shelfrack='+shelfrack,
|
| | | url: '/home/UpdateTask?types=' + types + '&glassid='+glassid+'&shelfrack='+shelfrack,
|
| | | method: 'get',
|
| | | data :""
|
| | | })
|
| | |
| | | <el-table-column prop="lengthWidth" label="Length and width"></el-table-column>
|
| | | <el-table-column prop="coating" label="coating"></el-table-column>
|
| | | <el-table-column label="Operate">
|
| | | <el-button type="primary" style="padding: 4px 10px;font-size: 12px;" @click="endtask(0)">end
|
| | | <template slot-scope='scope'>
|
| | | <el-button type="primary" style="padding: 4px 10px;font-size: 12px;"
|
| | | @click="endtask(0, scope.row.glassId, scope.row.cell)">end
|
| | | task</el-button>
|
| | | </template>
|
| | | </el-table-column>
|
| | | </el-table>
|
| | | <el-table :data="this.tasklist2" border style="width: 100%">
|
| | |
| | | <el-table-column prop="lengthWidth" label="Length and width"></el-table-column>
|
| | | <el-table-column prop="coating" label="coating"></el-table-column>
|
| | | <el-table-column label="Operate">
|
| | | <el-button type="primary" style="padding: 4px 10px;font-size: 12px;" @click="endtask(1)">end
|
| | | <template slot-scope='scope'>
|
| | | <el-button type="primary" style="padding: 4px 10px;font-size: 12px;"
|
| | | @click="endtask(1, scope.row.glassId, scope.row.cell)">end
|
| | | task</el-button>
|
| | | </template>
|
| | | </el-table-column>
|
| | | </el-table>
|
| | | </div>
|
| | |
| | | <el-table-column prop="endTime" label="endTime"></el-table-column>
|
| | | </el-table>
|
| | | </el-dialog>
|
| | | <el-dialog :visible.sync="dialogFormVisible3" title="Ordering Information">
|
| | | <el-dialog :visible.sync="dialogFormVisible3" title="Cage Details">
|
| | | <el-table :data="this.cageinfo" border style="width: 100%;height: 700px;overflow: auto;">
|
| | | <el-table-column :width="150" prop="cage" label="the grille number"></el-table-column>
|
| | | <el-table-column prop="cell" label="cell"></el-table-column>
|
| | |
| | | url: "../../img/bigcar01.png",
|
| | | car1: 150,
|
| | | car2: 242,
|
| | | incell: "",
|
| | | outcell: "",
|
| | | cageinfo: [],
|
| | | cage: 0
|
| | | };
|
| | |
| | | this.car1 = 150 + 24.6 * obj.params[0][0];
|
| | | this.car2 = 242 + 24.6 * obj.params[0][1];
|
| | | }
|
| | |
|
| | | this.tableData = obj.tableData[0];
|
| | | this.cagelist1 = obj.cagelist1[0];
|
| | | this.cagelist2 = obj.cagelist2[0];
|
| | |
| | | this.cagelist4 = obj.cagelist4[0];
|
| | | this.tasklist1 = obj.tasklist1[0];
|
| | | this.tasklist2 = obj.tasklist2[0];
|
| | | if (this.tasklist1.length > 0) {
|
| | | this.incell = this.tasklist1[0]['cell'];
|
| | | }
|
| | | if (this.tasklist1.length > 0) {
|
| | | this.outcell = this.tasklist2[0]['cell'];
|
| | | }
|
| | | this.alarm = obj.alarmmg[0];
|
| | |
|
| | | SelectCageInfo(this.cage).then(res => {
|
| | |
| | | if (res.data.message2 == 200) {
|
| | | this.$message.success("Operation successful");
|
| | | this.cancal();
|
| | | } else {
|
| | | } else if(res.data.message2 == 500) {
|
| | | this.$message.success("There are currently tasks");
|
| | | }
|
| | | else if(res.data.message2 == 300) {
|
| | | this.$message.success("There is no such grid");
|
| | | }
|
| | | else if(res.data.message2 == 400) {
|
| | | this.$message.success("There is no such grid");
|
| | | }
|
| | | });
|
| | | }
|
| | |
| | | this.dialogFormVisible1 = false;
|
| | | this.form1 = {};
|
| | | },
|
| | | endtask(type) {
|
| | | if (type == 0) {
|
| | | UpdateTask(type, this.incell).then(res => {
|
| | | endtask(type, glassid, cell) {
|
| | | UpdateTask(type, glassid, cell).then(res => {
|
| | | if (res.data.message3 == 200) {
|
| | | this.$message.success("Operation successful");
|
| | | }
|
| | | });
|
| | | } else {
|
| | | UpdateTask(type, this.outcell).then(res => {
|
| | | if (res.data.message3 == 200) {
|
| | | this.$message.success("Operation successful");
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | },
|
| | | showcageinfo(cage) {
|
| | | this.cage = cage;
|
| | |
| | | package com.example.springboot.component; |
| | | |
| | | import java.sql.SQLException; |
| | | import java.util.List; |
| | | import com.example.springboot.service.SpianService; |
| | | import com.example.springboot.mapper.AlarmMapper; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import com.example.springboot.service.JdbcConnections; |
| | | import com.example.springboot.service.SpianService; |
| | | import com.example.springboot.entity.Glass; |
| | | import com.example.springboot.mapper.AlarmMapper; |
| | | |
| | | public class PlcHold extends Thread { |
| | | |
| | | private AlarmMapper alarmMapper; |
| | | |
| | | @Autowired |
| | | private JdbcConnections jdbcConnections; |
| | | |
| | | private SpianService spianService; |
| | | |
| | | |
| | | @Override |
| | | public void run() { |
| | |
| | | |
| | | Thread.sleep(500); |
| | | } catch (InterruptedException e) { |
| | | // TODO Auto-generated catch block |
| | | //\\ TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | spianService = WebSocketServer.applicationContext.getBean(SpianService.class); |
| | | //spianService.selectout("112"); |
| | | |
| | | jdbcConnections = WebSocketServer.applicationContext.getBean(JdbcConnections.class); |
| | | try { |
| | | Glass glass=jdbcConnections.selectGlass(112); |
| | | //System.out.println(glass.getOrderId()); |
| | | } catch (SQLException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | //判断进片请求 |
| | | List<Short> datas1List=S7control.getinstance().ReadWord("DB106.24", 1); |
| | |
| | | List<Short> datas1ListID=S7control.getinstance().ReadWord("DB106.26", 13); |
| | | //获取玻璃id |
| | | for(Short list1:datas1ListID){ |
| | | |
| | | spianService.selectAll((short)list1); |
| | | } |
| | | } |
| | |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | |
| | | import com.example.springboot.entity.StorageCage; |
| | | import com.example.springboot.entity.alarmmg; |
| | | import com.example.springboot.mapper.HomeMapper; |
| | |
| | | public void run() { |
| | | while (this != null) { |
| | | try { |
| | | Thread.sleep(5000); |
| | | Thread.sleep(10000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | |
| | | //注入mapper |
| | |
| | | jsonObject.append("alarmmg", alarmmg); |
| | | //读去Plc进片车与出片车位置W |
| | | List<String> addressList = new ArrayList<String>(); |
| | | addressList.add("DB105.DBW0"); |
| | | addressList.add("DB105.DBW12"); |
| | | addressList.add("DB106.0"); |
| | | addressList.add("DB106.12"); |
| | | List<Short> paramlist = S7control.getinstance().ReadWord(addressList); |
| | | //将集合转为数组 |
| | | |
| | | // List<Short> paramlists = new ArrayList<Short>(); |
| | | // short para1 = 1; |
| | | // short para2 = 2; |
| | | // paramlists.add(para1); |
| | | // paramlists.add(para2); |
| | | // System.out.println(paramlists); |
| | | |
| | | if(paramlist!=null){ |
| | | Short[] paramlists = paramlist.toArray(new Short[0]); |
| | | jsonObject.append("params", paramlists); |
| | | // Short[] paramlists = paramlist.toArray(new Short[0]); |
| | | jsonObject.append("params", paramlist); |
| | | } |
| | | // jsonObject.append("params", new short[] { 30, 40, }); |
| | | WebSocketServer sendwServer = WebSocketServer.sessionMap.get("Home"); |
| | |
| | | if (taskno > 0) { |
| | | map.put("message2", "500"); |
| | | } else { |
| | | map.put("message2", "200"); |
| | | // 调用伍上片函数 |
| | | spianService.selectAll(glassid); |
| | | short results= spianService.selectAll(glassid); |
| | | if(results==200){ |
| | | map.put("message2", "200"); |
| | | }else if(results==300){ |
| | | map.put("message2", "300"); |
| | | }else if(results==400){ |
| | | map.put("message2", "400"); |
| | | } |
| | | } |
| | | return Result.success(map); |
| | | } |
| | | |
| | | @GetMapping("/UpdateTask") |
| | | public Result UpdateTask(Integer types, Integer shelfrack) { |
| | | public Result UpdateTask(Integer types, Integer shelfrack, Integer glassid) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | homeMapper.UpdateTask(types, shelfrack); |
| | | if (types == 0) { |
| | | homeMapper.UpdateCageTask1(shelfrack); |
| | | homeMapper.UpdateCageTask1(shelfrack,glassid); |
| | | } else { |
| | | homeMapper.UpdateCageTask2(shelfrack); |
| | | homeMapper.UpdateCageTask2(shelfrack,glassid); |
| | | } |
| | | map.put("message3", "200"); |
| | | return Result.success(map); |
| | |
| | | List<StorageCage> selectinout(@Param("task_type") Integer task_type); |
| | | |
| | | // 查询是否存在此订单 |
| | | @Select("select count(*) from storage_cage where order_id=#{orderid} and state=0") |
| | | @Select("select count(*) from storage_cage where order_id=#{orderid} and state=1") |
| | | short SelectOrder(@Param("orderid") String orderid); |
| | | |
| | | // @Insert("insert into order_out(orderid) values('#{orderid}')") |
| | | @Insert("INSERT INTO `canadames`.`order_out`( `orderid`,`mod_time`) VALUES ( #{orderid},now())") |
| | | @Insert("INSERT INTO `canadames`.`order_out`( `order_id`,`state`) VALUES ( #{orderid},0)") |
| | | void InsertOrder(String orderid); |
| | | |
| | | // 停止按当前订单出片 |
| | |
| | | void UpdateTask(@Param("task_type") Integer task_type, @Param("shelf_rack") Integer shelf_rack); |
| | | |
| | | // 手动完成进片任务修改笼子数据 |
| | | @Update("update storage_cage set state=1 where cell=#{cell} and state=2") |
| | | void UpdateCageTask1(@Param("cell") Integer cell); |
| | | @Update("update storage_cage set state=1 where cell=#{cell} and glass_id=#{glassid} and state=2") |
| | | void UpdateCageTask1(@Param("cell") Integer cell,@Param("glassid") Integer glassid); |
| | | |
| | | // 手动完成出片任务修改笼子数据 |
| | | @Update("update storage_cage set state=0,glass_id=null,order_id=null,glasswidth=null,glassheight=null,coating=null where cell=#{cell} and state=2") |
| | | void UpdateCageTask2(@Param("cell") Integer cell); |
| | | @Update("update storage_cage set state=0,glass_id=null,order_id=null,glasswidth=null,glassheight=null,coating=null where cell=#{cell} and glass_id=#{glassid} and state=3") |
| | | void UpdateCageTask2(@Param("cell") Integer cell,@Param("glassid") Integer glassid); |
| | | |
| | | //获取报警信息 |
| | | @Select("select id,content,timeon as timeons,endTime from alarmmg where endTime is null") |
| | |
| | | |
| | | //@Select("(select*from storage_cage as a where a.state=0 and cage%2=0 ORDER BY id LIMIT 1)union (select a.* from storage_cage a inner join (select cage,if(shu2=1,shu3,shu5) as gezi from ( select cage, count(case when state1=1 and state2=0 then cell else null end)as shu1, count(case when state1=0 then cell else null end) as shu2, min(case when state1=1 and state2=0 then cell else null end) as shu3, min(case when state1=0 then cell else null end) as shu4, min(case when state1=0 or state2=0 then cell else null end) as shu5 from (select *,max(state) as state1,min(state) as state2 from storage_cage group by cage,cell) as a where cage%2!=0 GROUP BY cage HAVING shu2>1 or (shu2=1 and shu1>0) ) as sss limit 1)as b on a.cage=b.cage and a.cell=b.gezi and a.state=0 order by tier limit 1) ORDER BY id LIMIT 1;") |
| | | //获取订单号排序的空订单笼子 |
| | | @Select("select cage,COUNT(if(order_id=#{glassid},order_id,null))as orderid from storage_cage where (order_id=#{glassid} or ''='') GROUP BY cage ORDER BY orderid desc; ") |
| | | List<StorageCage> selectAll(Short glassid); |
| | | @Select("select cage,COUNT(if(order_id=#{orderids},order_id,null))as orderid from storage_cage where (order_id=#{orderids} or ''='') GROUP BY cage ORDER BY orderid desc; ") |
| | | List<StorageCage> selectAll(Short orderids); |
| | | |
| | | //判断该笼子是否有合适宽度空格 |
| | | @Select("select cage,cell,tier,id,ROUND(id/2)as prcId from storage_cage where cage=#{cage1} and state=0 and width>=#{width} ORDER BY cell,tier LIMIT 1") |
| | |
| | | @Select("select cage,cell,tier,glasswidth,ROUND(id/2)as prcId,id from storage_cage as a where a.order_id=#{orderId} and state=1 order by cage desc,tier desc,cell desc LIMIT 1") |
| | | StorageCage selectOut(String orderId); |
| | | //按玻璃ID出片任务查询 |
| | | @Select("select cage,cell,tier,glasswidth,ROUND(id/2)as prcId,id from storage_cage as a where a.order_id=#{orderId} and state=1 order by cage desc,tier desc,cell desc LIMIT 1") |
| | | @Select("select cage,cell,tier,glasswidth,ROUND(id/2)as prcId,id from storage_cage as a where a.glass_id=#{glassid} and state=1 order by cage desc,tier desc,cell desc LIMIT 1") |
| | | StorageCage selectOut2(String glassid); |
| | | |
| | | //判断出片为1时,是否可直接出片 |
New file |
| | |
| | | package com.example.springboot.service; |
| | | |
| | | import java.sql.Connection; |
| | | import java.sql.DriverManager; |
| | | import java.sql.PreparedStatement; |
| | | import java.sql.ResultSet; |
| | | import java.sql.SQLException; |
| | | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import com.example.springboot.entity.Glass; |
| | | @Component |
| | | public class JdbcConnections { |
| | | /** |
| | | * 数据库连接参数 |
| | | * driver,url,username,password |
| | | */ |
| | | private static final String DRIVER = "com.mysql.jdbc.Driver"; |
| | | private static final String URL = "jdbc:mysql://localhost:3306/canadames"; |
| | | private static final String USERNAME = "root"; |
| | | private static final String PASSWORD = "beibo.123/"; |
| | | |
| | | private static Connection conn = null; |
| | | private static PreparedStatement ps = null; |
| | | private static ResultSet rs = null; |
| | | |
| | | public Glass selectGlass(int glassid) throws SQLException { |
| | | conn = getConn(); |
| | | Glass glass=new Glass(); |
| | | String sql = "select orderid from glass where glassid=?"; |
| | | ps = conn.prepareStatement(sql); |
| | | ps.setInt(1, glassid); |
| | | rs= ps.executeQuery(); |
| | | while (rs.next()) { |
| | | glass.setOrderId(rs.getShort("orderid")); |
| | | } |
| | | |
| | | return glass; |
| | | } |
| | | /** |
| | | * 1. 加载驱动 |
| | | * 2. 获取连接 conn |
| | | * 3. 创建语句 ps |
| | | * 4. 执行语句 rs |
| | | * 5. 处理结果 |
| | | * 6. 回收资源 |
| | | * |
| | | * 实现CRUD |
| | | * 更新: |
| | | * 1增加 |
| | | * 2删除 |
| | | * 3修改 |
| | | * 查询: |
| | | * 1. 查一个,一个对象 |
| | | * 2. 查一组,做成一个对象列表,查全部 |
| | | */ |
| | | public static Connection getConn() throws SQLException { |
| | | Connection conn = null; |
| | | conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/canadames?serverTimezone=GMT%2B8&characterEncoding=utf-8", "root", "beibo.123/"); |
| | | return conn; |
| | | } |
| | | |
| | | static { |
| | | try { |
| | | Class.forName(DRIVER); |
| | | } catch (ClassNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | |
| | | import com.example.springboot.common.Result; |
| | | import com.example.springboot.component.S7control; |
| | |
| | | public class SpianService { |
| | | @Autowired |
| | | private SpianMapper spianMapper; |
| | | @GetMapping("/all2") |
| | | |
| | | // @GetMapping("/all2") |
| | | public Result selectout(String orderid){ |
| | | //定义PRC数据传送数组 |
| | | List<String> adddresslist=new ArrayList<>(); |
| | |
| | | datas.add((short)1); |
| | | S7control.getinstance().WriteWord(adddresslist, datas); |
| | | return Result.success(datas); |
| | | } |
| | | else{ |
| | | } else { |
| | | //获取格子的玻璃数量 |
| | | int state= spianMapper.selectGlassState(cage,cell); |
| | | //判断内片是否需要调拨 |
| | | if(state==0){ |
| | | spianMapper.UpdataGlassCage("", "", glasswidth, cage, cell, tier, 0); |
| | | datas.add((short) prcid); |
| | | datas.add((short) 1000); |
| | | datas.add((short) 1); |
| | | datas.add((short) 1); |
| | | S7control.getinstance().WriteWord(adddresslist, datas); |
| | | return Result.success("状态为0,直接出片"); |
| | | }else{ |
| | | //玻璃需要调拨时,判断属于哪个半区的笼子 |
| | |
| | | |
| | | } |
| | | |
| | | @GetMapping("/all") |
| | | // @GetMapping("/all") |
| | | //进片任务,传订单id |
| | | //按订单优先进片 |
| | | public Result selectAll(Short glassid){ |
| | | //return spianMapper.selectAll(); |
| | | public Short selectAll(Short glassid) { |
| | | |
| | | int cage1; |
| | | int cells; |
| | | int ids; |
| | |
| | | int prctier; |
| | | |
| | | Glass glasslist=spianMapper.selectGlass(glassid); |
| | | if (glasslist == null) { |
| | | return (300); |
| | | } |
| | | double widths=glasslist.getWidth(); |
| | | Short orderids=glasslist.getOrderId(); |
| | | |
| | |
| | | |
| | | //String orderid="A001"; |
| | | //获取订单相关度最高的笼子排序 |
| | | List<StorageCage> storageCage=spianMapper.selectAll(glassid); |
| | | List<StorageCage> storageCage = spianMapper.selectAll(orderids); |
| | | if(storageCage==null){ |
| | | return Result.success(storageCage); |
| | | return (400); |
| | | } |
| | | for (StorageCage storageCage2 : storageCage) { |
| | | //保存订单优先顺序笼子号 |
| | |
| | | int cages=spianMapper.selectCage(cage1); |
| | | //判断选中笼子是否有合适宽度空格 |
| | | StorageCage cages1=spianMapper.selectCage1(cage1,widths); |
| | | if (cages1 != null) { |
| | | ids=cages1.getId();//数据库ID |
| | | tiers=cages1.getTier();//内外片 |
| | | cells=cages1.getCell();//格子号 |
| | |
| | | datas.add((short)prcid); |
| | | datas.add((short)prctier); |
| | | datas.add((short)1); |
| | | S7control.getinstance().WriteWord(adddresslist, datas); |
| | | //数据库修改笼子表新增一条玻璃 |
| | | |
| | | spianMapper.UpdataAddCage(orderids, glassid, widths, cage1, cells, ids, 1); |
| | | return Result.success(cages1); |
| | | S7control.getinstance().WriteWord(adddresslist, datas); |
| | | |
| | | return (200); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | return Result.success("不可进片"); |
| | | return (300); |
| | | |
| | | } |
| | | |
| | | @GetMapping("/all2") |
| | | // @GetMapping("/all2") |
| | | public Result selectout2(String glassid){ |
| | | //定义PRC数据传送数组 |
| | | List<String> adddresslist=new ArrayList<>(); |
| | |
| | | datas.add((short)1); |
| | | S7control.getinstance().WriteWord(adddresslist, datas); |
| | | return Result.success(datas); |
| | | } |
| | | else{ |
| | | } else { |
| | | //获取格子的玻璃数量 |
| | | int state= spianMapper.selectGlassState(cage,cell); |
| | | //判断内片是否需要调拨 |
| | |
| | | |
| | | } |
| | | |
| | | /*** 修改用户* @throws SQLException */ |
| | | // public static int updateUser(Glass user) throws SQLException {conn = |
| | | // getConn(); |
| | | // String sql = "update t_user set name=?,gender=?,age=?,score=?"+ " where |
| | | // id=?";ps = conn.prepareStatement(sql); |
| | | // ps.setString(1, user.getName());ps.setString(2, user.getGender()); |
| | | // ps.setInt(3, user.getAge());ps.setDouble(4, user.getScore());ps.setInt(5, |
| | | // user.getId());return ps.executeUpdate();} |
| | | // /*** 增加用户* @throws SQLException */ |
| | | // public static int insertUser(User user) throws SQLException { |
| | | // conn = getConn(); |
| | | // String sql = "insert into t_user(name,gender,age,score)"+ " values(?,?,?,?)"; |
| | | // ps = conn.prepareStatement(sql);ps.setString(1, |
| | | // user.getName());ps.setString(2, user.getGender()); |
| | | // ps.setInt(3, user.getAge());ps.setDouble(4, user.getScore());return |
| | | // ps.executeUpdate(); |
| | | // } |
| | | |
| | | } |