This commit is contained in:
2022-06-27 20:25:27 +08:00
10 changed files with 1096 additions and 5 deletions

View File

@@ -0,0 +1,184 @@
package org.nl.wms.sb.auToTask;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.security.service.dto.JwtUserDto;
import org.nl.modules.system.util.CodeUtil;
import org.nl.utils.SecurityUtils;
import org.nl.wql.core.bean.WQLObject;
import org.springframework.stereotype.Component;
/**
* 自动创建维修单
* @author Liuxy
* @date 2022-06-27
**/
@Slf4j
@Component
@RequiredArgsConstructor
public class AutoCreateRepair {
public void run() {
WQLObject fileTab = WQLObject.getWQLObject("EM_BI_EquipmentFile"); // 档案表
WQLObject planMstTab = WQLObject.getWQLObject("EM_BI_DeviceRepairPlanMst"); // 设备维修计划主表
WQLObject repairMstTab = WQLObject.getWQLObject("EM_BI_DeviceRepairMst"); // 设备维修单主表
// 1.查询 设备档案表 中状态为正常10、闲置11、故障20、维修30、保养40状态的设备
JSONArray fileArr = fileTab.query("status in (10,11,20,30,40)").getResultJSONArray(0);
// 2.根据查询出来的记录 查询 设备维修计划表 中启用状态 = 启用的记录
for (int i = 0; i < fileArr.size(); i++) {
JSONObject json = fileArr.getJSONObject(i);
String devicerecord_id = json.getString("devicerecord_id");
JSONObject jsonPlanMst = planMstTab.query("devicerecord_id = '" + devicerecord_id + "' and is_active = '1'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonPlanMst)) {
// 2.1 判断维修计划表中:实际开始时间、实际结束时间 为空
String real_start_date = jsonPlanMst.getString("real_start_date");
String real_end_date = jsonPlanMst.getString("real_end_date");
// 2.2 根据源单号为维修计划id查询 维修单 --条件未删除、未审核
JSONObject jsonRepairMst = repairMstTab.query("source_bill_id = '" + jsonPlanMst.getString("repair_plan_id") + "' and is_delete = '0' and invstatus != '99'").uniqueResult(0);
if (ObjectUtil.isEmpty(real_start_date) && ObjectUtil.isEmpty(real_end_date)) {
if (ObjectUtil.isEmpty(jsonRepairMst)) {
// 2.3 判断周期
String maintenancecycle = jsonPlanMst.getString("maintenancecycle");
String plan_start_date = jsonPlanMst.getString("plan_start_date").replace("-", "");
String today = DateUtil.today().replace("-", "");
// 准备参数
JSONObject param = new JSONObject();
param.put("devicerecord_id",jsonPlanMst.getString("devicerecord_id"));
param.put("maintenancecycle","01");
param.put("plan_start_date",jsonPlanMst.getString("plan_start_date"));
param.put("source_bill_id",jsonPlanMst.getString("repair_plan_id"));
param.put("source_bill_code",jsonPlanMst.getString("repair_plan_code"));
// 计算 当前日期 - 维修计划日期 后的天数
String num = String.valueOf(NumberUtil.sub(today, plan_start_date));
// 周期为年 :当前日期-维修计划开始时间 <= 15 天时,新增维修单
if (StrUtil.equals(maintenancecycle,"01")) {
if (Integer.parseInt(num) <= 15) {
this.createRepair(param);
}
// 周期为季度 :当前日期-维修计划开始时间 <= 10 天时,新增维修单
} else if (StrUtil.equals(maintenancecycle,"02")) {
if (Integer.parseInt(num) <= 10) {
this.createRepair(param);
}
// 周期为月 :当前日期-维修计划开始时间 <= 7 天时,新增维修单
} else if (StrUtil.equals(maintenancecycle,"03")) {
if (Integer.parseInt(num) <= 7) {
this.createRepair(param);
}
// 周期为周 :当前日期-维修计划开始时间 <= 3 天时,新增维修单
} else if (StrUtil.equals(maintenancecycle,"04")) {
if (Integer.parseInt(num) <= 3) {
this.createRepair(param);
}
}
}
} else {
// 3 如果保养实际开始时间 和 保养实际结束时间不为空 并且查不到对应单据
if (ObjectUtil.isEmpty(jsonRepairMst)) {
// 取维修实际结束日期:用当前日期 - 维修实际结束日期
String maintenancecycle = jsonPlanMst.getString("maintenancecycle");
String rep_real_end_date = jsonPlanMst.getString("real_end_date").replace("-", "");
String today = DateUtil.today().replace("-", "");
// 准备参数
JSONObject param = new JSONObject();
param.put("devicerecord_id",jsonPlanMst.getString("devicerecord_id"));
param.put("maintenancecycle","01");
param.put("plan_start_date",jsonPlanMst.getString("plan_start_date"));
param.put("source_bill_id",jsonPlanMst.getString("repair_plan_id"));
param.put("source_bill_code",jsonPlanMst.getString("repair_plan_code"));
// 计算 当前日期 - 维修实际结束 后的天数
String num = String.valueOf(NumberUtil.sub(today, rep_real_end_date));
// 周期为年 :当前日期-维修实际结束 <= 15 天时,新增维修单
if (StrUtil.equals(maintenancecycle,"01")) {
if (Integer.parseInt(num) <= 15) {
this.createRepair(param);
}
// 周期为季度 :当前日期-维修实际结束 <= 10 天时,新增维修单
} else if (StrUtil.equals(maintenancecycle,"02")) {
if (Integer.parseInt(num) <= 10) {
this.createRepair(param);
}
// 周期为月 :当前日期-维修实际结束 <= 7 天时,新增维修单
} else if (StrUtil.equals(maintenancecycle,"03")) {
if (Integer.parseInt(num) <= 7) {
this.createRepair(param);
}
// 周期为周 :当前日期-维修实际结束 <= 3 天时,新增维修单
} else if (StrUtil.equals(maintenancecycle,"04")) {
if (Integer.parseInt(num) <= 3) {
this.createRepair(param);
}
}
}
}
}
}
}
/**
* 创建维修单共用方法
* json: {
* 设备档案标识devicerecord_id,
* 单据类型maintenancecycle,
* 计划开始日期plan_start_date,
* 来源单据标识source_bill_id,
* 来源单据编码source_bill_code,
* }
*/
public void createRepair(JSONObject json) {
Long currentUserId = 1L;
String nickName = "管理员";
Long deptId = 1L;
WQLObject repaiMstTab = WQLObject.getWQLObject("EM_BI_DeviceRepairMst"); // 设备维修单主表
WQLObject repaiDtlTab = WQLObject.getWQLObject("EM_BI_DeviceRepairDtl"); // 设备维修单主明细表
WQLObject planDtlTab = WQLObject.getWQLObject("EM_BI_DeviceRepairPlanDtl"); // 设备维修计划明细表
JSONArray planDtlArr = planDtlTab.query("repair_plan_id = '" + json.getString("source_bill_id") + "'").getResultJSONArray(0);
// 维修单主表
JSONObject jsonRepaiMst = new JSONObject();
jsonRepaiMst.put("repair_id", IdUtil.getSnowflake(1,1).nextId());
jsonRepaiMst.put("repair_code", CodeUtil.getNewCode("REPAIR_CODE"));
jsonRepaiMst.put("devicerecord_id",json.get("devicerecord_id"));
jsonRepaiMst.put("maintenancecycle",json.getString("maintenancecycle"));
jsonRepaiMst.put("invstatus","01");
jsonRepaiMst.put("fault_level","01");
jsonRepaiMst.put("plan_start_date",json.getString("plan_start_date"));
jsonRepaiMst.put("detail_count",planDtlArr.size());
jsonRepaiMst.put("source_bill_id",json.get("source_bill_id"));
jsonRepaiMst.put("source_bill_type","WXJH");
jsonRepaiMst.put("source_bill_code",json.getString("source_bill_code"));
jsonRepaiMst.put("input_optid",currentUserId);
jsonRepaiMst.put("input_optname",nickName);
jsonRepaiMst.put("input_time", DateUtil.now());
jsonRepaiMst.put("sysdeptid", deptId);
jsonRepaiMst.put("syscompanyid", deptId);
repaiMstTab.insert(jsonRepaiMst);
// 维修单明细表
for (int i = 0; i < planDtlArr.size(); i++) {
JSONObject jsonObject = planDtlArr.getJSONObject(i);
JSONObject jsonMainDtl = new JSONObject();
jsonMainDtl.put("repair_dtl_id", IdUtil.getSnowflake(1,1).nextId());
jsonMainDtl.put("repair_id", jsonRepaiMst.get("repair_id"));
jsonMainDtl.put("repair_item_id", jsonObject.get("repair_item_id"));
repaiDtlTab.insert(jsonMainDtl);
}
}
}

View File

@@ -1,14 +1,172 @@
package org.nl.wms.sb.auToTask;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.security.service.dto.JwtUserDto;
import org.nl.modules.system.util.CodeUtil;
import org.nl.utils.SecurityUtils;
import org.nl.wql.core.bean.WQLObject;
import org.springframework.stereotype.Component;
/**
* 自动创建保养单
* @author Liuxy
* @date 2022-06-27
**/
@Slf4j
@Component
@RequiredArgsConstructor
public class AutoCreateUpkeep {
public void run () {
// 1.查询 设备档案表 中状态为正常10、闲置11、故障20、维修30、保养40状态的设备
// 2.根据查询出来的记录 查询 设备保养计划表 中启用状态 = 启用的记录
// 3.
public void run() {
WQLObject fileTab = WQLObject.getWQLObject("EM_BI_EquipmentFile"); // 档案表
WQLObject planMstTab = WQLObject.getWQLObject("EM_BI_DeviceMaintenancePlanMst"); // 设备保养计划主表
WQLObject mainMstTab = WQLObject.getWQLObject("EM_BI_DeviceMaintenanceMst"); // 设备保养单主表
// 1.查询 设备档案表 中状态为正常10、闲置11、故障20、维修30、保养40状态的设备
JSONArray fileArr = fileTab.query("status in (10,11,20,30,40)").getResultJSONArray(0);
// 2.根据查询出来的记录 查询 设备保养计划表 中启用状态 = 启用的记录
for (int i = 0; i < fileArr.size(); i++) {
JSONObject json = fileArr.getJSONObject(i);
String devicerecord_id = json.getString("devicerecord_id");
JSONObject jsonPlanMst = planMstTab.query("devicerecord_id = '" + devicerecord_id + "' and is_active = '1'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonPlanMst)) {
// 2.1 判断保养计划表中:实际开始时间、实际结束时间 为空
String real_start_date = jsonPlanMst.getString("real_start_date");
String real_end_date = jsonPlanMst.getString("real_end_date");
// 2.2 根据源单号为保养计划id查询 保养单 --条件未删除、未审核
JSONObject jsonMainMst = mainMstTab.query("source_bill_id = '" + jsonPlanMst.getString("maint_plan_id") + "' and is_delete = '0' and invstatus != '99'").uniqueResult(0);
if (ObjectUtil.isEmpty(real_start_date) && ObjectUtil.isEmpty(real_end_date)) {
if (ObjectUtil.isEmpty(jsonMainMst)) {
// 2.3 判断周期
String maintenancecycle = jsonPlanMst.getString("maintenancecycle");
String plan_start_date = jsonPlanMst.getString("plan_start_date").replace("-", "");
String today = DateUtil.today().replace("-", "");
// 准备参数
JSONObject param = new JSONObject();
param.put("devicerecord_id",jsonPlanMst.getString("devicerecord_id"));
param.put("maintenancecycle","01");
param.put("plan_start_date",jsonPlanMst.getString("plan_start_date"));
param.put("source_bill_id",jsonPlanMst.getString("maint_plan_id"));
param.put("source_bill_code",jsonPlanMst.getString("maint_plan_code"));
// 计算 当前日期 - 保养计划日期 后的天数
String num = String.valueOf(NumberUtil.sub(today, plan_start_date));
// 周期为年 :当前日期-保养计划日期 <= 15 天时,新增保养单
if (StrUtil.equals(maintenancecycle,"01")) {
if (Integer.parseInt(num) <= 15) {
this.createMain(param);
}
// 周期为月 :当前日期-保养计划日期 <= 7 天时,新增保养单
} else if (StrUtil.equals(maintenancecycle,"02")) {
if (Integer.parseInt(num) <= 7) {
this.createMain(param);
}
// 周期为周 :当前日期-保养计划日期 <= 3 天时,新增保养单
} else if (StrUtil.equals(maintenancecycle,"03")) {
if (Integer.parseInt(num) <= 3) {
this.createMain(param);
}
}
}
} else {
// 3 如果保养实际开始时间 和 保养实际结束时间不为空 并且查不到对应单据
if (ObjectUtil.isEmpty(jsonMainMst)) {
// 取保养实际结束日期:用当前日期 - 保养实际结束日期
String maintenancecycle = jsonPlanMst.getString("maintenancecycle");
String rep_real_end_date = jsonPlanMst.getString("real_end_date").replace("-", "");
String today = DateUtil.today().replace("-", "");
// 准备参数
JSONObject param = new JSONObject();
param.put("devicerecord_id",jsonPlanMst.getString("devicerecord_id"));
param.put("maintenancecycle","01");
param.put("plan_start_date",jsonPlanMst.getString("plan_start_date"));
param.put("source_bill_id",jsonPlanMst.getString("maint_plan_id"));
param.put("source_bill_code",jsonPlanMst.getString("maint_plan_code"));
// 计算 当前日期 - 保养实际结束 后的天数
String num = String.valueOf(NumberUtil.sub(today, rep_real_end_date));
// 周期为年 :当前日期-保养实际结束 <= 15 天时,新增保养单
if (StrUtil.equals(maintenancecycle,"01")) {
if (Integer.parseInt(num) <= 15) {
this.createMain(param);
}
// 周期为月 :当前日期-保养实际结束 <= 7 天时,新增保养单
} else if (StrUtil.equals(maintenancecycle,"02")) {
if (Integer.parseInt(num) <= 7) {
this.createMain(param);
}
// 周期为周 :当前日期-保养实际结束 <= 3 天时,新增保养单
} else if (StrUtil.equals(maintenancecycle,"03")) {
if (Integer.parseInt(num) <= 3) {
this.createMain(param);
}
}
}
}
}
}
}
/**
* 创建保养单共用方法
* json: {
* 设备档案标识devicerecord_id,
* 单据类型maintenancecycle,
* 计划开始日期plan_start_date,
* 来源单据标识source_bill_id,
* 来源单据编码source_bill_code,
* }
*/
public void createMain(JSONObject json) {
Long currentUserId = 1L;
String nickName = "管理员";
Long deptId = 1L;
WQLObject mainMstTab = WQLObject.getWQLObject("EM_BI_DeviceMaintenanceMst"); // 设备保养单主表
WQLObject mainDtlTab = WQLObject.getWQLObject("EM_BI_DeviceMaintenanceDtl"); // 设备保养单主明细表
WQLObject planDtlTab = WQLObject.getWQLObject("EM_BI_DeviceMaintenancePlanDtl"); // 设备保养计划明细表
JSONArray planDtlArr = planDtlTab.query("maint_plan_id = '" + json.getString("source_bill_id") + "'").getResultJSONArray(0);
// 保养单主表
JSONObject jsonMainMst = new JSONObject();
jsonMainMst.put("maint_id", IdUtil.getSnowflake(1,1).nextId());
jsonMainMst.put("maint_code", CodeUtil.getNewCode("MAINT_CODE"));
jsonMainMst.put("devicerecord_id",json.get("devicerecord_id"));
jsonMainMst.put("maintenancecycle",json.getString("maintenancecycle"));
jsonMainMst.put("invstatus","01");
jsonMainMst.put("plan_start_date",json.getString("plan_start_date"));
jsonMainMst.put("detail_count",planDtlArr.size());
jsonMainMst.put("source_bill_id",json.get("source_bill_id"));
jsonMainMst.put("source_bill_type","BYJH");
jsonMainMst.put("source_bill_code",json.getString("source_bill_code"));
jsonMainMst.put("input_optid",currentUserId);
jsonMainMst.put("input_optname",nickName);
jsonMainMst.put("input_time", DateUtil.now());
jsonMainMst.put("sysdeptid", deptId);
jsonMainMst.put("syscompanyid", deptId);
mainMstTab.insert(jsonMainMst);
// 保养单明细表
for (int i = 0; i < planDtlArr.size(); i++) {
JSONObject jsonObject = planDtlArr.getJSONObject(i);
JSONObject jsonMainDtl = new JSONObject();
jsonMainDtl.put("maint_dtl_id", IdUtil.getSnowflake(1,1).nextId());
jsonMainDtl.put("maint_id", jsonMainMst.get("maint_id"));
jsonMainDtl.put("device_item_id", jsonObject.get("maint_item_id"));
mainDtlTab.insert(jsonMainDtl);
}
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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+"'");
}
}
}

View File

@@ -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