设备管理
This commit is contained in:
@@ -2,12 +2,11 @@
|
||||
package org.nl.wms.pdm.rest;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.common.anno.Log;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.anno.Log;
|
||||
import org.nl.wms.pdm.service.DeviceService;
|
||||
import org.nl.wms.pdm.service.dto.DeviceDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -19,9 +18,9 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author geng by
|
||||
* @date 2022-05-25
|
||||
**/
|
||||
* @author lyd
|
||||
* @date 2023-03-15
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "生产设备管理")
|
||||
@@ -61,7 +60,7 @@ public class DeviceController {
|
||||
@ApiOperation("删除生产设备")
|
||||
//@PreAuthorize("@el.check('device:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
|
||||
public ResponseEntity<Object> delete(@RequestBody String[] ids) {
|
||||
deviceService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
@@ -74,46 +73,4 @@ public class DeviceController {
|
||||
return new ResponseEntity<>(deviceService.getWorkprocedure(),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/getItemByDevice")
|
||||
@Log("获取设备下的项点")
|
||||
@ApiOperation("获取设备下的项点")
|
||||
//@PreAuthorize("@el.check('device:list')")
|
||||
public ResponseEntity<Object> getItemByDevice(@RequestBody JSONObject param){
|
||||
return new ResponseEntity<>(deviceService.getItemByDevice(param),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/savaDeviceItem")
|
||||
@Log("保存设备项点")
|
||||
@ApiOperation("保存设备项点")
|
||||
//@PreAuthorize("@el.check('device:list')")
|
||||
public ResponseEntity<Object> savaDeviceItem(@RequestBody JSONObject param){
|
||||
deviceService.savaDeviceItem(param);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/getItemByDeviceId")
|
||||
@Log("动态获取表格列")
|
||||
@ApiOperation("动态获取表格列")
|
||||
//@PreAuthorize("@el.check('dcBaseDevice:list')")
|
||||
public ResponseEntity<Object> getItemByDeviceId(@RequestBody JSONObject param){
|
||||
return new ResponseEntity<>(deviceService.getItemByDeviceId(param),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/copyAdd")
|
||||
@Log("复制新增")
|
||||
@ApiOperation("复制新增")
|
||||
//@PreAuthorize("@el.check('dcBaseDevice:list')")
|
||||
public ResponseEntity<Object> copyAdd(@RequestBody JSONObject param){
|
||||
deviceService.copyAdd(param);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/queryById/{device_id}")
|
||||
@Log("查询生产设备")
|
||||
@ApiOperation("查询生产设备")
|
||||
//@PreAuthorize("@el.check('device:list')")
|
||||
public ResponseEntity<Object> queryById(@PathVariable("device_id") String device_id){
|
||||
return new ResponseEntity<>(deviceService.queryById(device_id),HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,82 +2,71 @@
|
||||
package org.nl.wms.pdm.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.pdm.service.dto.DeviceDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @description 服务接口
|
||||
* @author geng by
|
||||
* @date 2022-05-25
|
||||
**/
|
||||
* @description 服务接口
|
||||
* @author lyd
|
||||
* @date 2023-03-15
|
||||
**/
|
||||
public interface DeviceService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param whereJson 条件
|
||||
* @param page 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
* 查询数据分页
|
||||
* @param whereJson 条件
|
||||
* @param page 分页参数
|
||||
* @return Map<String,Object>
|
||||
*/
|
||||
Map<String,Object> queryAll(Map whereJson, Pageable page);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param whereJson 条件参数
|
||||
* @return List<DeviceDto>
|
||||
*/
|
||||
* 查询所有数据不分页
|
||||
* @param whereJson 条件参数
|
||||
* @return List<DeviceDto>
|
||||
*/
|
||||
List<DeviceDto> queryAll(Map whereJson);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param device_id ID
|
||||
* @param device_code ID
|
||||
* @return Device
|
||||
*/
|
||||
DeviceDto findById(Long device_id);
|
||||
DeviceDto findById(String device_code);
|
||||
|
||||
/**
|
||||
* 根据编码查询
|
||||
* @param code code
|
||||
* @return Device
|
||||
*/
|
||||
* 根据编码查询
|
||||
* @param code code
|
||||
* @return Device
|
||||
*/
|
||||
DeviceDto findByCode(String code);
|
||||
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param dto /
|
||||
*/
|
||||
* 创建
|
||||
* @param dto /
|
||||
*/
|
||||
void create(DeviceDto dto);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param dto /
|
||||
*/
|
||||
* 编辑
|
||||
* @param dto /
|
||||
*/
|
||||
void update(DeviceDto dto);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Long[] ids);
|
||||
|
||||
JSONArray getWorkprocedure();
|
||||
|
||||
JSONArray getItemByDevice(JSONObject param);
|
||||
|
||||
void savaDeviceItem(JSONObject param);
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(String[] ids);
|
||||
|
||||
/**
|
||||
* 查询设备类型
|
||||
* @param param
|
||||
* 获取工序的下拉框
|
||||
* @return
|
||||
*/
|
||||
Map<String,Object> getItemByDeviceId(JSONObject param);
|
||||
|
||||
void copyAdd(JSONObject param);
|
||||
|
||||
DeviceDto queryById(String device_id);
|
||||
JSONArray getWorkprocedure();
|
||||
}
|
||||
|
||||
@@ -1,73 +1,87 @@
|
||||
package org.nl.wms.pdm.service.dto;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @description /
|
||||
* @author geng by
|
||||
* @date 2022-05-25
|
||||
**/
|
||||
* @description /
|
||||
* @author lyd
|
||||
* @date 2023-03-15
|
||||
**/
|
||||
@Data
|
||||
public class DeviceDto implements Serializable {
|
||||
|
||||
/** 设备标识 */
|
||||
/** 防止精度丢失 */
|
||||
@JsonSerialize(using= ToStringSerializer.class)
|
||||
private Long device_id;
|
||||
/** 设备编码 */
|
||||
private String device_code;
|
||||
|
||||
/** 设备编码 */
|
||||
private String device_code;
|
||||
/** 设备名称 */
|
||||
private String device_name;
|
||||
|
||||
/** 设备名称 */
|
||||
private String device_name;
|
||||
/** 生产区域 */
|
||||
private String product_area;
|
||||
|
||||
/** 设备型号 */
|
||||
private String device_model;
|
||||
|
||||
/** 工序标识 */
|
||||
private Long workprocedure_id;
|
||||
|
||||
/** 外部编码 */
|
||||
private String extend_code;
|
||||
|
||||
/** 设备档案标识 */
|
||||
private Long devicebill_id;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** 是否启用 */
|
||||
private String is_active;
|
||||
|
||||
/** 创建人 */
|
||||
private String create_id;
|
||||
|
||||
/** 创建人姓名 */
|
||||
private String create_name;
|
||||
|
||||
/** 创建时间 */
|
||||
private String create_time;
|
||||
|
||||
/** 是否删除 */
|
||||
private String is_delete;
|
||||
/** 工序标识 */
|
||||
private Long workprocedure_id;
|
||||
|
||||
/** 外部编码 */
|
||||
private String ext_code;
|
||||
|
||||
/** 物料标识 */
|
||||
private Long material_id;
|
||||
|
||||
/** 生产班次工单标识 */
|
||||
private Long produceorder_id;
|
||||
/** 工单编号 */
|
||||
private String workorder_code;
|
||||
|
||||
/** 生产班次工单编号 */
|
||||
private String produceorder_code;
|
||||
/** 设备编码2 */
|
||||
private String device_code2;
|
||||
|
||||
/** 设备产能 */
|
||||
private BigDecimal productivity;
|
||||
/** 设备来料仓上限数 */
|
||||
private BigDecimal inupperlimit_qty;
|
||||
|
||||
/** 设备来料仓下限数 */
|
||||
private BigDecimal inlowerlimit_qty;
|
||||
|
||||
/** 设备产品仓上限数 */
|
||||
private BigDecimal outupperlimit_qty;
|
||||
|
||||
/** 设备产品仓下限数 */
|
||||
private BigDecimal outlowerlimit_qty;
|
||||
|
||||
/** 设备初始来料仓数 */
|
||||
private BigDecimal deviceinitinstor_qty;
|
||||
|
||||
/** 设备实时来料仓数 */
|
||||
private BigDecimal deviceinstor_qty;
|
||||
|
||||
/** 设备实时产品仓数 */
|
||||
private BigDecimal deviceoutstor_qty;
|
||||
|
||||
/** 是否人工 */
|
||||
private String is_artificial;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** 创建人 */
|
||||
private String create_id;
|
||||
|
||||
/** 创建人 */
|
||||
private String create_name;
|
||||
|
||||
/** 创建时间 */
|
||||
private String create_time;
|
||||
|
||||
/** 修改人 */
|
||||
private String update_id;
|
||||
|
||||
/** 修改人 */
|
||||
private String update_name;
|
||||
|
||||
/** 修改时间 */
|
||||
private String update_time;
|
||||
|
||||
/** 是否删除 */
|
||||
private String is_delete;
|
||||
}
|
||||
|
||||
@@ -3,36 +3,32 @@ package org.nl.wms.pdm.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.common.anno.Log;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.ResultBean;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.nl.wms.pdm.service.DeviceService;
|
||||
import org.nl.wms.pdm.service.dto.DeviceDto;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author geng by
|
||||
* @description 服务实现
|
||||
* @date 2022-05-25
|
||||
* @author lyd
|
||||
* @date 2023-03-15
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@@ -40,60 +36,17 @@ import java.util.Map;
|
||||
public class DeviceServiceImpl implements DeviceService {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
||||
String workprocedure_id = MapUtil.getStr(whereJson, "workprocedure_id");
|
||||
String search = MapUtil.getStr(whereJson, "search");
|
||||
JSONObject map2 = new JSONObject();
|
||||
map2.put("flag", "3");
|
||||
map2.put("workprocedure_id", workprocedure_id);
|
||||
if (!StrUtil.isEmpty(search)) {
|
||||
map2.put("search", "%" + search + "%");
|
||||
}
|
||||
//根据工序获取设备信息
|
||||
JSONObject json = WQL.getWO("PDM_BI_DEVICE01").addParamMap(map2).pageQuery(WqlUtil.getHttpContext(page), "device.create_time desc");
|
||||
JSONArray jsonArray = json.getJSONArray("content");
|
||||
JSONArray newContent = new JSONArray();
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
JSONObject map = new JSONObject();
|
||||
String device_id = jsonObject.getString("device_id");
|
||||
map.put("flag", "4");
|
||||
map.put("device_id", device_id);
|
||||
//获取设备所拥有的项点信息
|
||||
JSONArray itemArray = WQL.getWO("PDM_BI_DEVICE01").addParamMap(map).process().getResultJSONArray(0);
|
||||
JSONObject newMap = new JSONObject();
|
||||
newMap.put("device_id", jsonObject.getString("device_id"));
|
||||
newMap.put("device_code", jsonObject.getString("device_code"));
|
||||
newMap.put("device_name", jsonObject.getString("device_name"));
|
||||
newMap.put("device_model", jsonObject.getString("device_model"));
|
||||
newMap.put("productivity", jsonObject.getString("productivity"));
|
||||
newMap.put("workprocedure_id", jsonObject.getString("workprocedure_id"));
|
||||
newMap.put("extend_code", jsonObject.getString("extend_code"));
|
||||
newMap.put("devicebill_id", jsonObject.getString("devicebill_id"));
|
||||
newMap.put("remark", jsonObject.getString("remark"));
|
||||
newMap.put("is_active", jsonObject.getString("is_active"));
|
||||
newMap.put("is_delete", jsonObject.getString("is_delete"));
|
||||
//循环每个设备的项点信息,将项点所对应的键设为项点编码,对应动态表格的prop
|
||||
for (int j = 0; j < itemArray.size(); j++) {
|
||||
JSONObject itemObject = itemArray.getJSONObject(j);
|
||||
if (itemObject.getString("data_type").equals("01")){
|
||||
if (itemObject.getString("item_value").equals("0")){
|
||||
newMap.put(itemObject.getString("item_code"), "否");
|
||||
}else {
|
||||
newMap.put(itemObject.getString("item_code"), "是");
|
||||
}
|
||||
}else {
|
||||
newMap.put(itemObject.getString("item_code"), itemObject.getString("item_value"));
|
||||
}
|
||||
}
|
||||
newContent.add(newMap);
|
||||
}
|
||||
json.put("content", newContent);
|
||||
return json;
|
||||
public Map<String,Object> queryAll(Map whereJson, Pageable page){
|
||||
Map param = new HashMap();
|
||||
param.put("flag", "1");
|
||||
param.put("search", whereJson.get("search"));
|
||||
param.put("workprocedure_id", whereJson.get("workprocedure_id"));
|
||||
JSONObject jsonObject = WQL.getWO("QUERY_DEVICE").addParamMap(param).pageQuery(WqlUtil.getHttpContext(page), "device_code asc");
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceDto> queryAll(Map whereJson) {
|
||||
public List<DeviceDto> queryAll(Map whereJson){
|
||||
WQLObject wo = WQLObject.getWQLObject("pdm_bi_device");
|
||||
JSONArray arr = wo.query().getResultJSONArray(0);
|
||||
if (ObjectUtil.isNotEmpty(arr)) return arr.toJavaList(DeviceDto.class);
|
||||
@@ -101,21 +54,21 @@ public class DeviceServiceImpl implements DeviceService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDto findById(Long device_id) {
|
||||
public DeviceDto findById(String device_code) {
|
||||
WQLObject wo = WQLObject.getWQLObject("pdm_bi_device");
|
||||
JSONObject json = wo.query("device_id = '" + device_id + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)) {
|
||||
return json.toJavaObject(DeviceDto.class);
|
||||
JSONObject json = wo.query("device_code = '" + device_code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)){
|
||||
return json.toJavaObject( DeviceDto.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDto findByCode(String code) {
|
||||
public DeviceDto findByCode(String code) {
|
||||
WQLObject wo = WQLObject.getWQLObject("pdm_bi_device");
|
||||
JSONObject json = wo.query("device_code ='" + code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)) {
|
||||
return json.toJavaObject(DeviceDto.class);
|
||||
JSONObject json = wo.query("code ='" + code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)){
|
||||
return json.toJavaObject( DeviceDto.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -126,13 +79,11 @@ public class DeviceServiceImpl implements DeviceService {
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
|
||||
//编码唯一性校验
|
||||
String device_code = dto.getDevice_code();
|
||||
DeviceDto byCode = this.findByCode(device_code);
|
||||
if (ObjectUtil.isNotEmpty(byCode)) throw new BadRequestException("编码已存在!");
|
||||
dto.setDevice_id(IdUtil.getSnowflake(1, 1).nextId());
|
||||
dto.setCreate_id(currentUserId);
|
||||
dto.setCreate_name(nickName);
|
||||
dto.setUpdate_id(currentUserId);
|
||||
dto.setUpdate_name(nickName);
|
||||
dto.setUpdate_time(DateUtil.now());
|
||||
dto.setCreate_time(DateUtil.now());
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("pdm_bi_device");
|
||||
@@ -143,12 +94,19 @@ public class DeviceServiceImpl implements DeviceService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(DeviceDto dto) {
|
||||
DeviceDto entity = this.findById(dto.getDevice_id());
|
||||
DeviceDto entity = this.findById(dto.getDevice_code());
|
||||
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
|
||||
//编码唯一性校验
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
|
||||
|
||||
dto.setUpdate_time(DateUtil.now());
|
||||
dto.setUpdate_id(currentUserId);
|
||||
dto.setUpdate_name(nickName);
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("pdm_bi_device");
|
||||
String where = "is_delete = '0' and device_code = '" + dto.getDevice_code() + "' and device_id != '" + dto.getDevice_id() + "'";
|
||||
String where = "is_delete = '0' and device_code = '" + dto.getDevice_code() + "'";
|
||||
|
||||
JSONObject jsonObject = wo.query(where).uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(jsonObject)) {
|
||||
@@ -162,16 +120,23 @@ public class DeviceServiceImpl implements DeviceService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(Long[] ids) {
|
||||
public void deleteAll(String[] ids) {
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("pdm_bi_device");
|
||||
WQLObject wo_value = WQLObject.getWQLObject("PDM_BI_DeviceItemValue");
|
||||
for (Long device_id : ids) {
|
||||
wo.delete("device_id = '" + device_id + "'");
|
||||
wo_value.delete("device_id = '" + device_id + "'");
|
||||
for (String device_code: ids) {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("device_code", String.valueOf(device_code));
|
||||
param.put("is_delete", "1");
|
||||
param.put("update_optid", currentUserId);
|
||||
param.put("update_optname", nickName);
|
||||
param.put("update_time", DateUtil.now());
|
||||
wo.update(param);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JSONArray getWorkprocedure() {
|
||||
WQLObject wo = WQLObject.getWQLObject("pdm_bi_workprocedure");
|
||||
@@ -179,107 +144,4 @@ public class DeviceServiceImpl implements DeviceService {
|
||||
return resultJSONArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray getItemByDevice(JSONObject param) {
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("flag", "1");
|
||||
map.put("device_id", param.getString("device_id"));
|
||||
final JSONArray resultJSONArray = WQL.getWO("PDM_BI_DEVICE01").addParamMap(map).addParamMap(map).process().getResultJSONArray(0);
|
||||
return resultJSONArray;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void savaDeviceItem(JSONObject param) {
|
||||
WQLObject wo = WQLObject.getWQLObject("PDM_BI_DeviceItemValue");
|
||||
final JSONObject row = param.getJSONObject("row");
|
||||
final JSONArray rows = param.getJSONArray("rows");
|
||||
final String device_id = row.getString("device_id");
|
||||
wo.delete("device_id = '" + device_id + "'");
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
final JSONObject jsonObject = rows.getJSONObject(i);
|
||||
final String item_id = jsonObject.getString("item_id");
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("deviceitem_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||
map.put("device_id", device_id);
|
||||
map.put("item_id", item_id);
|
||||
map.put("item_value", jsonObject.getString("item_value"));
|
||||
map.put("order_seq", i + 1);
|
||||
wo.insert(map);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getItemByDeviceId(JSONObject param) {
|
||||
//动态获取设备类型下对应的项点信息
|
||||
String workprocedure_id = param.getString("workprocedure_id");
|
||||
String search = param.getString("search");
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("flag", "2");
|
||||
map.put("workprocedure_id", workprocedure_id);
|
||||
if (StrUtil.isNotEmpty(search)) {
|
||||
map.put("search", "%" + search + "%");
|
||||
}
|
||||
final JSONArray jsonArray = WQL.getWO("PDM_BI_DEVICE01").addParamMap(map).process().getResultJSONArray(0);
|
||||
JSONArray newArray = new JSONArray();
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
||||
String item_name = jsonObject.getString("item_name");
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("label", item_name);
|
||||
//将表格prop设置为项点编码
|
||||
json.put("prop", jsonObject.getString("item_code"));
|
||||
json.put("show", true);
|
||||
if (item_name.length() >= 6) {
|
||||
json.put("width", "150");
|
||||
}
|
||||
newArray.add(json);
|
||||
}
|
||||
JSONObject resultMap = new JSONObject();
|
||||
resultMap.put("newArray", newArray);
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void copyAdd(JSONObject param) {
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("PDM_BI_Device");
|
||||
WQLObject wo_value = WQLObject.getWQLObject("PDM_BI_DeviceItemValue");
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
|
||||
String device_id = IdUtil.getSnowflake(1, 1).nextId() + "";
|
||||
JSONObject row = param.getJSONObject("row");
|
||||
//编码唯一性校验
|
||||
String device_code = row.getString("device_code");
|
||||
DeviceDto byCode = this.findByCode(device_code);
|
||||
if (ObjectUtil.isNotEmpty(byCode)) throw new BadRequestException("编码已存在!");
|
||||
|
||||
row.put("device_id", device_id);
|
||||
row.put("create_id", currentUserId);
|
||||
row.put("create_name", nickName);
|
||||
row.put("create_time", DateUtil.now());
|
||||
wo.insert(row);
|
||||
JSONArray rows = param.getJSONArray("rows");
|
||||
if (rows.size() > 0) {
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
JSONObject jsonObject = rows.getJSONObject(i);
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("deviceitem_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||
map.put("device_id", device_id);
|
||||
map.put("item_id", jsonObject.getString("item_id"));
|
||||
map.put("item_value", jsonObject.getString("default_value"));
|
||||
map.put("order_seq", i + 1);
|
||||
wo_value.insert(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDto queryById(String device_id) {
|
||||
DeviceDto deviceDto = this.findById(Long.parseLong(device_id));
|
||||
return deviceDto;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
[交易说明]
|
||||
交易名: 设备查询
|
||||
所属模块:
|
||||
功能简述:
|
||||
版权所有:
|
||||
表引用:
|
||||
版本经历:
|
||||
|
||||
[数据库]
|
||||
--指定数据库,为空采用默认值,默认为db.properties中列出的第一个库
|
||||
|
||||
[IO定义]
|
||||
#################################################
|
||||
## 表字段对应输入参数
|
||||
#################################################
|
||||
输入.flag TYPEAS s_string
|
||||
输入.search TYPEAS s_string
|
||||
输入.workprocedure_id TYPEAS s_string
|
||||
|
||||
|
||||
[临时表]
|
||||
--这边列出来的临时表就会在运行期动态创建
|
||||
|
||||
[临时变量]
|
||||
--所有中间过程变量均可在此处定义
|
||||
|
||||
[业务过程]
|
||||
|
||||
##########################################
|
||||
# 1、输入输出检查 #
|
||||
##########################################
|
||||
|
||||
|
||||
##########################################
|
||||
# 2、主过程前处理 #
|
||||
##########################################
|
||||
|
||||
|
||||
##########################################
|
||||
# 3、业务主过程 #
|
||||
##########################################
|
||||
|
||||
IF 输入.flag = "1"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
PDM_BI_Device device
|
||||
WHERE
|
||||
1 = 1
|
||||
OPTION 输入.search <> ""
|
||||
(device.device_code like "%" 输入.search "%" or
|
||||
device.device_name like "%" 输入.search "%")
|
||||
ENDOPTION
|
||||
OPTION 输入.workprocedure_id <> ""
|
||||
(device.workprocedure_id = 输入.workprocedure_id)
|
||||
ENDOPTION
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user