春风项目四线(合箱线、总装线)
yyt
2024-06-29 c9745dfbbd9f64b1b84574446ab93f32a76896fe
提交 | 用户 | 时间
2df134 1 package com.jcdm.main.da.tileMatchRules.controller;
J 2
3 import java.util.List;
5030f3 4 import java.util.stream.Collectors;
dd4482 5 import javax.annotation.Resource;
2df134 6 import javax.servlet.http.HttpServletResponse;
5030f3 7
Y 8 import cn.hutool.core.collection.CollUtil;
9 import com.jcdm.main.da.paramCollection.domain.DaParamCollection;
10 import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService;
dd4482 11 import com.jcdm.main.da.tileMatchCollection.domain.DaTileMatchCollection;
Y 12 import com.jcdm.main.da.tileMatchCollection.service.IDaTileMatchCollectionService;
5030f3 13 import com.jcdm.main.da.tileMatchMiddleware.domain.DaTileMatchMiddleware;
c9745d 14 import com.kangaroohy.milo.model.ReadWriteEntity;
2df134 15 import org.springframework.security.access.prepost.PreAuthorize;
J 16 import org.springframework.beans.factory.annotation.Autowired;
17 import org.springframework.web.bind.annotation.GetMapping;
18 import org.springframework.web.bind.annotation.PostMapping;
19 import org.springframework.web.bind.annotation.PutMapping;
20 import org.springframework.web.bind.annotation.DeleteMapping;
21 import org.springframework.web.bind.annotation.PathVariable;
22 import org.springframework.web.bind.annotation.RequestBody;
23 import org.springframework.web.bind.annotation.RequestMapping;
24 import org.springframework.web.bind.annotation.RestController;
25 import com.jcdm.common.annotation.Log;
26 import com.jcdm.common.core.controller.BaseController;
27 import com.jcdm.common.core.domain.AjaxResult;
28 import com.jcdm.common.enums.BusinessType;
29 import com.jcdm.main.da.tileMatchRules.domain.DaTileMatchRules;
30 import com.jcdm.main.da.tileMatchRules.service.IDaTileMatchRulesService;
31 import com.jcdm.common.utils.poi.ExcelUtil;
32 import com.jcdm.common.core.page.TableDataInfo;
33
5030f3 34 import static com.jcdm.main.plcserver.sub.OPCUaSubscription.miloService;
Y 35
2df134 36 /**
J 37  * 配瓦规则Controller
38  * 
39  * @author jiang
40  * @date 2024-01-24
41  */
42 @RestController
43 @RequestMapping("/da/tileMatchRules")
44 public class DaTileMatchRulesController extends BaseController
45 {
46     @Autowired
47     private IDaTileMatchRulesService daTileMatchRulesService;
5030f3 48
Y 49     @Autowired
50     public IDaParamCollectionService daParamCollectionService;
dd4482 51     @Resource
Y 52     private IDaTileMatchCollectionService daTileMatchCollectionService;
2df134 53
J 54     /**
1c7036 55      * 查询配瓦规则列表()
2df134 56      */
J 57     @PreAuthorize("@ss.hasPermi('da:tileMatchRules:list')")
58     @GetMapping("/list")
59     public TableDataInfo list(DaTileMatchRules daTileMatchRules)
60     {
61         startPage();
62         List<DaTileMatchRules> list = daTileMatchRulesService.selectDaTileMatchRulesList(daTileMatchRules);
63         return getDataTable(list);
64     }
65
66     /**
1c7036 67      *  曲轴配瓦
Y 68      */
69     @PreAuthorize("@ss.hasPermi('da:tileMatchRules:list')")
70     @GetMapping("/list2")
71     public TableDataInfo list2(DaTileMatchRules daTileMatchRules)
72     {
73         startPage();
74         List<DaTileMatchRules> list = daTileMatchRulesService.selectDaTileMatchRulesList(daTileMatchRules);
75         return getDataTable(list);
76     }
77
78     /**
79      *  连杆配瓦
80      */
81     @PreAuthorize("@ss.hasPermi('da:tileMatchRules:list')")
82     @GetMapping("/list4")
83     public TableDataInfo list4(DaTileMatchRules daTileMatchRules)
84     {
85         startPage();
86         List<DaTileMatchRules> list = daTileMatchRulesService.selectDaTileMatchRulesList(daTileMatchRules);
87         return getDataTable(list);
88     }
89
90     /**
91      * 平衡轴配瓦
92      */
93     @PreAuthorize("@ss.hasPermi('da:tileMatchRules:list')")
94     @GetMapping("/list3")
95     public TableDataInfo list3(DaTileMatchRules daTileMatchRules)
96     {
97         startPage();
98         List<DaTileMatchRules> list = daTileMatchRulesService.selectDaTileMatchRulesList(daTileMatchRules);
99         return getDataTable(list);
100     }
101
102     /**
2df134 103      * 导出配瓦规则列表
J 104      */
105     @PreAuthorize("@ss.hasPermi('da:tileMatchRules:export')")
106     @Log(title = "配瓦规则", businessType = BusinessType.EXPORT)
107     @PostMapping("/export")
108     public void export(HttpServletResponse response, DaTileMatchRules daTileMatchRules)
109     {
110         List<DaTileMatchRules> list = daTileMatchRulesService.selectDaTileMatchRulesList(daTileMatchRules);
111         ExcelUtil<DaTileMatchRules> util = new ExcelUtil<DaTileMatchRules>(DaTileMatchRules.class);
112         util.exportExcel(response, list, "配瓦规则数据");
113     }
114
115     /**
116      * 获取配瓦规则详细信息
117      */
118     @PreAuthorize("@ss.hasPermi('da:tileMatchRules:query')")
119     @GetMapping(value = "/{id}")
120     public AjaxResult getInfo(@PathVariable("id") Long id)
121     {
122         return success(daTileMatchRulesService.selectDaTileMatchRulesById(id));
123     }
124
125     /**
126      * 新增配瓦规则
127      */
128     @PreAuthorize("@ss.hasPermi('da:tileMatchRules:add')")
129     @Log(title = "配瓦规则", businessType = BusinessType.INSERT)
130     @PostMapping
131     public AjaxResult add(@RequestBody DaTileMatchRules daTileMatchRules)
132     {
133         return toAjax(daTileMatchRulesService.insertDaTileMatchRules(daTileMatchRules));
134     }
135
136     /**
137      * 修改配瓦规则
138      */
139     @PreAuthorize("@ss.hasPermi('da:tileMatchRules:edit')")
140     @Log(title = "配瓦规则", businessType = BusinessType.UPDATE)
141     @PutMapping
142     public AjaxResult edit(@RequestBody DaTileMatchRules daTileMatchRules)
143     {
144         return toAjax(daTileMatchRulesService.updateDaTileMatchRules(daTileMatchRules));
145     }
146
147     /**
148      * 删除配瓦规则
149      */
150     @PreAuthorize("@ss.hasPermi('da:tileMatchRules:remove')")
151     @Log(title = "配瓦规则", businessType = BusinessType.DELETE)
152     @DeleteMapping("/{ids}")
153     public AjaxResult remove(@PathVariable Long[] ids)
154     {
155         return toAjax(daTileMatchRulesService.deleteDaTileMatchRulesByIds(ids));
156     }
5030f3 157
Y 158     @PreAuthorize("@ss.hasPermi('da:tileMatchRules:query')")
159     @GetMapping(value = "/barcode")
160     public String setBarcode(String barcode,String locationCode) {
161         String XT="";
162         try {
163             //Object SNCodeObject = miloService.readFromOpcUa("CFL4HX."+locationCode+".Code1").getValue();
164             Object SNCodeObject = miloService.readFromOpcUa("CFL4HX.HOP040.Code1").getValue();
165             if (null == SNCodeObject){
166                 //SNCodeObject = miloService.readFromOpcUa("CFL4HX."+locationCode+ ".Code").getValue();
167                 SNCodeObject = miloService.readFromOpcUa("CFL4HX.HOP040.Code").getValue();
168             }
169             if (null != SNCodeObject){
170                 String SNCode = SNCodeObject.toString();
171
172                 //插入数据
173                 DaParamCollection saveData = new DaParamCollection();
174                 saveData.setSfcCode(SNCode);
175                 saveData.setParamValue(barcode);
176                 saveData.setLocationCode(locationCode);
dd4482 177                 saveData.setParamCode("PHZ");
Y 178                 saveData.setParamName("平衡轴");
5030f3 179                 daParamCollectionService.insertDaParamCollection(saveData);
Y 180
dd4482 181                 DaTileMatchCollection MatchCollection = new DaTileMatchCollection();
Y 182                 MatchCollection.setSfcCode(SNCode);
183                 MatchCollection.setParamValue(barcode);
184                 MatchCollection.setLocationCode(locationCode);
185                 MatchCollection.setParamCode("PHZ");
186                 MatchCollection.setParamName("平衡轴");
187                 daTileMatchCollectionService.insertDaTileMatchCollection(MatchCollection);
188
5030f3 189                 DaParamCollection ParamCollection = new DaParamCollection();
Y 190                 ParamCollection.setSfcCode(SNCode);
191                 List<DaParamCollection> DaParamCollectionlist=daParamCollectionService.selectDaParamCollectionList(ParamCollection);
192                 List<DaParamCollection> XTParamCollection = DaParamCollectionlist.stream().filter(x -> "箱体".equals(x.getParamName())).collect(Collectors.toList());
193                 if (CollUtil.isNotEmpty(XTParamCollection)){
194                     DaParamCollection lastOne = XTParamCollection.get(0);
195                     XT = lastOne.getParamValue();
196                 }
c9745d 197
Y 198                 ReadWriteEntity entity6 = new ReadWriteEntity("CFL4HX.HOP040.Partcode", "1");
199                 miloService.writeToOpcByte(entity6);
5030f3 200             }
Y 201         } catch (Exception e) {
202             throw new RuntimeException(e);
203         }
204         return XT;
205     }
2df134 206 }