设备运行记录
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
|
||||
package org.nl.wms.sb.run.rest;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.sb.run.service.DevicerunrecordService;
|
||||
import org.nl.wms.sb.run.service.dto.DevicerunrecordDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.annotation.Log;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
* @date 2022-06-27
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "运行记录填报管理")
|
||||
@RequestMapping("/api/devicerunrecord")
|
||||
@Slf4j
|
||||
public class DevicerunrecordController {
|
||||
|
||||
private final DevicerunrecordService devicerunrecordService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询运行记录填报")
|
||||
@ApiOperation("查询运行记录填报")
|
||||
//@PreAuthorize("@el.check('devicerunrecord:list')")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
|
||||
return new ResponseEntity<>(devicerunrecordService.queryAll(whereJson, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增运行记录填报")
|
||||
@ApiOperation("新增运行记录填报")
|
||||
//@PreAuthorize("@el.check('devicerunrecord:add')")
|
||||
public ResponseEntity<Object> create(@RequestBody JSONObject whereJson) {
|
||||
devicerunrecordService.create(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改运行记录填报")
|
||||
@ApiOperation("修改运行记录填报")
|
||||
//@PreAuthorize("@el.check('devicerunrecord:edit')")
|
||||
public ResponseEntity<Object> update(@RequestBody JSONObject whereJson) {
|
||||
devicerunrecordService.update(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除运行记录填报")
|
||||
@ApiOperation("删除运行记录填报")
|
||||
//@PreAuthorize("@el.check('devicerunrecord:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
|
||||
devicerunrecordService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
|
||||
package org.nl.wms.sb.run.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.sb.run.service.dto.DevicerunrecordDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
* @description 服务接口
|
||||
* @date 2022-06-27
|
||||
**/
|
||||
public interface DevicerunrecordService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
*
|
||||
* @param whereJson 条件
|
||||
* @param page 分页参数
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> queryAll(Map whereJson, Pageable page);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
*
|
||||
* @param whereJson 条件参数
|
||||
* @return List<DevicerunrecordDto>
|
||||
*/
|
||||
List<DevicerunrecordDto> queryAll(Map whereJson);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param runrecord_id ID
|
||||
* @return Devicerunrecord
|
||||
*/
|
||||
DevicerunrecordDto findById(Long runrecord_id);
|
||||
|
||||
/**
|
||||
* 根据编码查询
|
||||
*
|
||||
* @param code code
|
||||
* @return Devicerunrecord
|
||||
*/
|
||||
DevicerunrecordDto findByCode(String code);
|
||||
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param whereJson /
|
||||
*/
|
||||
void create(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param whereJson /
|
||||
*/
|
||||
void update(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Long[] ids);
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package org.nl.wms.sb.run.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
* @description /
|
||||
* @date 2022-06-27
|
||||
**/
|
||||
@Data
|
||||
public class DevicerunrecordDto implements Serializable {
|
||||
|
||||
/** 记录标识 */
|
||||
/**
|
||||
* 防止精度丢失
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long runrecord_id;
|
||||
|
||||
/**
|
||||
* 设备档案标识
|
||||
*/
|
||||
private Long devicerecord_id;
|
||||
|
||||
/**
|
||||
* 填报日期
|
||||
*/
|
||||
private String run_date;
|
||||
|
||||
/**
|
||||
* 工作时间(分钟)
|
||||
*/
|
||||
private BigDecimal run_times;
|
||||
|
||||
/**
|
||||
* 准备时间(分钟)
|
||||
*/
|
||||
private BigDecimal prepare_times;
|
||||
|
||||
/**
|
||||
* 故障时间(分钟)
|
||||
*/
|
||||
private BigDecimal error_times;
|
||||
|
||||
/**
|
||||
* 工装调整时间(分钟)
|
||||
*/
|
||||
private BigDecimal adjust_times;
|
||||
|
||||
/**
|
||||
* 生产总量
|
||||
*/
|
||||
private BigDecimal product_qty;
|
||||
|
||||
/**
|
||||
* 不合格数
|
||||
*/
|
||||
private BigDecimal nok_qty;
|
||||
|
||||
/**
|
||||
* OEE指标
|
||||
*/
|
||||
private BigDecimal oee_value;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private Long create_id;
|
||||
|
||||
/**
|
||||
* 创建人姓名
|
||||
*/
|
||||
private String create_name;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String create_time;
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
|
||||
package org.nl.wms.sb.run.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.exception.BadRequestException;
|
||||
import org.nl.wms.basedata.master.service.ClassstandardService;
|
||||
import org.nl.wms.sb.run.service.DevicerunrecordService;
|
||||
import org.nl.wms.sb.run.service.dto.DevicerunrecordDto;
|
||||
import org.nl.wql.WQL;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.utils.SecurityUtils;
|
||||
import org.nl.wql.core.bean.ResultBean;
|
||||
import org.nl.wql.core.bean.WQLObject;
|
||||
import org.nl.wql.util.WqlUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
* @description 服务实现
|
||||
* @date 2022-06-27
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class DevicerunrecordServiceImpl implements DevicerunrecordService {
|
||||
private final ClassstandardService classstandardService;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
||||
String material_type_id = MapUtil.getStr(whereJson, "material_type_id");
|
||||
String class_idStr = MapUtil.getStr(whereJson, "class_idStr");
|
||||
String begin_time = MapUtil.getStr(whereJson, "begin_time");
|
||||
String end_time = MapUtil.getStr(whereJson, "end_time");
|
||||
String device_code = MapUtil.getStr(whereJson, "device_code");
|
||||
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("flag", "1");
|
||||
map.put("begin_time", begin_time);
|
||||
map.put("end_time", end_time);
|
||||
if (ObjectUtil.isNotEmpty(device_code)) map.put("device_code","%"+device_code+"%");
|
||||
//处理物料当前节点的所有子节点
|
||||
if (!StrUtil.isEmpty(material_type_id)) {
|
||||
map.put("material_type_id", material_type_id);
|
||||
String classIds = classstandardService.getChildIdStr(material_type_id);
|
||||
map.put("classIds", classIds);
|
||||
} else if (ObjectUtil.isNotEmpty(class_idStr)) {
|
||||
String classIds = classstandardService.getAllChildIdStr(class_idStr);
|
||||
map.put("classIds", classIds);
|
||||
}
|
||||
JSONObject json = WQL.getWO("EM_DEVICERUNRECORD001").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "run.create_time DESC");
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DevicerunrecordDto> queryAll(Map whereJson) {
|
||||
WQLObject wo = WQLObject.getWQLObject("em_bi_devicerunrecord");
|
||||
JSONArray arr = wo.query().getResultJSONArray(0);
|
||||
if (ObjectUtil.isNotEmpty(arr)) return arr.toJavaList(DevicerunrecordDto.class);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DevicerunrecordDto findById(Long runrecord_id) {
|
||||
WQLObject wo = WQLObject.getWQLObject("em_bi_devicerunrecord");
|
||||
JSONObject json = wo.query("runrecord_id = '" + runrecord_id + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)) {
|
||||
return json.toJavaObject(DevicerunrecordDto.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DevicerunrecordDto findByCode(String code) {
|
||||
WQLObject wo = WQLObject.getWQLObject("em_bi_devicerunrecord");
|
||||
JSONObject json = wo.query("code ='" + code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)) {
|
||||
return json.toJavaObject(DevicerunrecordDto.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(JSONObject whereJson) {
|
||||
WQLObject tab = WQLObject.getWQLObject("EM_BI_DeviceRunRecord");
|
||||
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
String devicerecord_id = whereJson.getString("devicerecord_id");
|
||||
String run_date = whereJson.getString("run_date");
|
||||
|
||||
JSONObject jsonMst = tab.query("devicerecord_id = '" + devicerecord_id + "' and run_date = '" + run_date + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(jsonMst)) throw new BadRequestException("填报信息已存在");
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("runrecord_id", IdUtil.getSnowflake(1,1).nextId());
|
||||
json.put("devicerecord_id", whereJson.get("devicerecord_id"));
|
||||
json.put("run_date", whereJson.getString("run_date"));
|
||||
json.put("run_times", whereJson.get("run_times"));
|
||||
json.put("prepare_times", whereJson.get("prepare_times"));
|
||||
json.put("error_times", whereJson.get("error_times"));
|
||||
json.put("adjust_times", whereJson.get("adjust_times"));
|
||||
json.put("product_qty", whereJson.get("product_qty"));
|
||||
json.put("nok_qty", whereJson.get("nok_qty"));
|
||||
json.put("oee_value", 0.0);
|
||||
json.put("remark", whereJson.getString("remark"));
|
||||
json.put("create_id", currentUserId);
|
||||
json.put("create_name", nickName);
|
||||
json.put("create_time", now);
|
||||
tab.insert(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(JSONObject whereJson) {
|
||||
WQLObject tab = WQLObject.getWQLObject("EM_BI_DeviceRunRecord");
|
||||
|
||||
JSONObject json = tab.query("runrecord_id = '" + whereJson.getString("runrecord_id") + "'").uniqueResult(0);
|
||||
json.put("run_date", whereJson.getString("run_date"));
|
||||
json.put("run_times", whereJson.get("run_times"));
|
||||
json.put("prepare_times", whereJson.get("prepare_times"));
|
||||
json.put("error_times", whereJson.get("error_times"));
|
||||
json.put("adjust_times", whereJson.get("adjust_times"));
|
||||
json.put("product_qty", whereJson.get("product_qty"));
|
||||
json.put("nok_qty", whereJson.get("nok_qty"));
|
||||
json.put("oee_value", 0);
|
||||
json.put("remark", whereJson.getString("remark"));
|
||||
tab.update(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(Long[] ids) {
|
||||
WQLObject wo = WQLObject.getWQLObject("em_bi_devicerunrecord");
|
||||
for (Long runrecord_id : ids) {
|
||||
wo.delete("runrecord_id = '"+runrecord_id+"'");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
[交易说明]
|
||||
交易名: 运行记录填报分页查询
|
||||
所属模块:
|
||||
功能简述:
|
||||
版权所有:
|
||||
表引用:
|
||||
版本经历:
|
||||
|
||||
[数据库]
|
||||
--指定数据库,为空采用默认值,默认为db.properties中列出的第一个库
|
||||
|
||||
[IO定义]
|
||||
#################################################
|
||||
## 表字段对应输入参数
|
||||
#################################################
|
||||
输入.flag TYPEAS s_string
|
||||
输入.classIds TYPEAS f_string
|
||||
输入.device_code TYPEAS s_string
|
||||
输入.begin_time TYPEAS s_string
|
||||
输入.end_time TYPEAS s_string
|
||||
|
||||
|
||||
[临时表]
|
||||
--这边列出来的临时表就会在运行期动态创建
|
||||
|
||||
[临时变量]
|
||||
--所有中间过程变量均可在此处定义
|
||||
|
||||
[业务过程]
|
||||
|
||||
##########################################
|
||||
# 1、输入输出检查 #
|
||||
##########################################
|
||||
|
||||
|
||||
##########################################
|
||||
# 2、主过程前处理 #
|
||||
##########################################
|
||||
|
||||
|
||||
##########################################
|
||||
# 3、业务主过程 #
|
||||
##########################################
|
||||
|
||||
IF 输入.flag = "1"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
run.*,
|
||||
class.class_name,
|
||||
file.device_code,
|
||||
file.device_name
|
||||
FROM
|
||||
EM_BI_DeviceRunRecord run
|
||||
LEFT JOIN EM_BI_EquipmentFile file ON file.devicerecord_id = run.devicerecord_id
|
||||
LEFT JOIN md_pb_classstandard class ON file.material_type_id = class.class_id
|
||||
WHERE
|
||||
file.is_delete = '0'
|
||||
|
||||
OPTION 输入.device_code <> ""
|
||||
(file.device_code like 输入.device_code or
|
||||
file.device_name like 输入.device_code)
|
||||
ENDOPTION
|
||||
|
||||
OPTION 输入.classIds <> ""
|
||||
class.class_id in 输入.classIds
|
||||
ENDOPTION
|
||||
|
||||
OPTION 输入.begin_time <> ""
|
||||
run.run_date >= 输入.begin_time
|
||||
ENDOPTION
|
||||
|
||||
OPTION 输入.end_time <> ""
|
||||
run.run_date <= 输入.end_time
|
||||
ENDOPTION
|
||||
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user