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