| | |
| | | Plant p = new Plant();
|
| | | p.setName(plantDTO.getName());
|
| | | p.setGridSetting(plantDTO.getGridSetting());
|
| | | |
| | |
|
| | | plantMapper.insert(p);
|
| | | |
| | | Long plantId = p.getId();
|
| | |
|
| | | List<Integer> machineIds = this.parseMachineIdInGrid(plantDTO.getGridSetting());
|
| | | |
| | | for(Integer mid:machineIds ) {
|
| | | List<Long> machineIds = this.parseMachineIdInGrid(plantDTO.getGridSetting());
|
| | | for(Long mid:machineIds ) {
|
| | | Machine m = machineMapper.selectById(mid);
|
| | | if(m != null) {
|
| | | m.setPlantId(plantId);
|
| | |
| | |
|
| | | }
|
| | |
|
| | | public List<Integer> parseMachineIdInGrid(String gridSetting){
|
| | | List<Integer> macineIds = new ArrayList<>();
|
| | | /**
|
| | | * 解析出地图中包括的设备id
|
| | | * @param gridSetting
|
| | | * @return
|
| | | */
|
| | | public List<Long> parseMachineIdInGrid(String gridSetting){
|
| | | List<Long> macineIds = new ArrayList<>();
|
| | | try {
|
| | |
|
| | | JSONArray arr1 = JSONArray.parseArray(gridSetting);
|
| | |
| | | for(int j=0;j<arr2.size();j++) {
|
| | | node = arr2.getJSONObject(j);
|
| | | if(node.containsKey("id")) {
|
| | | macineIds.add(node.getInteger("id"));
|
| | | macineIds.add(node.getLong("id"));
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | String oriGridSetting = p.getGridSetting();
|
| | |
|
| | | //清空原有的machine的plantId
|
| | | List<Integer> oriMachineIds = this.parseMachineIdInGrid(oriGridSetting);
|
| | | for(Integer mid:oriMachineIds ) {
|
| | | List<Long> oriMachineIds = this.parseMachineIdInGrid(oriGridSetting);
|
| | | for(Long mid:oriMachineIds ) {
|
| | | Machine m = machineMapper.selectById(mid);
|
| | | if(m != null) {
|
| | | m.setPlantId(null);
|
| | |
| | | }
|
| | |
|
| | | //新配置的机床,更新plantId
|
| | | List<Integer> machineIds = this.parseMachineIdInGrid(plantDTO.getGridSetting());
|
| | | List<Long> machineIds = this.parseMachineIdInGrid(plantDTO.getGridSetting());
|
| | |
|
| | | Long plantId = plantDTO.getId();
|
| | | for(Integer mid:machineIds ) {
|
| | | for(Long mid : machineIds) {
|
| | | Machine m = machineMapper.selectById(mid);
|
| | | if(m != null) {
|
| | | m.setPlantId(plantId);
|