设备报废

This commit is contained in:
2022-06-28 11:13:36 +08:00
parent 4b908ac5da
commit 95df973501
6 changed files with 602 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
package org.nl.wms.sb.run.rest;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.annotation.Log;
import org.nl.wms.sb.run.service.DeviceScrapService;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* @author Liuxy
* @date 2022-06-27
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "设备报废")
@RequestMapping("/api/devicescrap")
@Slf4j
public class DeviceScrapController {
private final DeviceScrapService deviceScrapService;
@GetMapping
@Log("查询设备报废")
@ApiOperation("查询设备报废")
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
return new ResponseEntity<>(deviceScrapService.queryAll(whereJson, page), HttpStatus.OK);
}
@PostMapping("/scrap")
@Log("报废")
@ApiOperation("报废")
public ResponseEntity<Object> scrap(@RequestBody JSONObject whereJson) {
deviceScrapService.scrap(whereJson);
return new ResponseEntity<>(HttpStatus.OK);
}
}

View File

@@ -0,0 +1,30 @@
package org.nl.wms.sb.run.service;
import com.alibaba.fastjson.JSONObject;
import org.springframework.data.domain.Pageable;
import java.util.Map;
/**
* @author Liuxy
* @description 服务接口
* @date 2022-06-27
**/
public interface DeviceScrapService {
/**
* 查询数据分页
*
* @param whereJson 条件
* @param page 分页参数
* @return Map<String, Object>
*/
Map<String, Object> queryAll(Map whereJson, Pageable page);
/**
* 报废
* @param whereJson 参数
*/
void scrap(JSONObject whereJson);
}

View File

@@ -0,0 +1,101 @@
package org.nl.wms.sb.run.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.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.utils.SecurityUtils;
import org.nl.wms.basedata.master.service.ClassstandardService;
import org.nl.wms.sb.run.service.DeviceScrapService;
import org.nl.wql.WQL;
import org.nl.wql.core.bean.WQLObject;
import org.nl.wql.util.WqlUtil;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* @author Liuxy
* @description 服务实现
* @date 2022-06-27
**/
@Service
@RequiredArgsConstructor
@Slf4j
public class DeviceScrapServiceImpl implements DeviceScrapService {
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");
String manufacturer = MapUtil.getStr(whereJson, "manufacturer");
String supplier_code = MapUtil.getStr(whereJson, "supplier_code");
HashMap<String, String> map = new HashMap<>();
map.put("flag", "1");
map.put("begin_time", begin_time);
map.put("end_time", end_time);
map.put("device_type", MapUtil.getStr(whereJson, "device_type"));
map.put("status", MapUtil.getStr(whereJson, "status"));
map.put("is_produceuse", MapUtil.getStr(whereJson, "is_produceuse"));
if (ObjectUtil.isNotEmpty(device_code)) map.put("device_code","%"+device_code+"%");
if (ObjectUtil.isNotEmpty(manufacturer)) map.put("manufacturer","%"+manufacturer+"%");
if (ObjectUtil.isNotEmpty(supplier_code)) map.put("supplier_code","%"+supplier_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_DEVICESCRAP001").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "file.update_time DESC");
return json;
}
@Override
public void scrap(JSONObject whereJson) {
String devicerecord_id = whereJson.getString("devicerecord_id");
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getNickName();
WQLObject fileTab = WQLObject.getWQLObject("EM_BI_EquipmentFile");
WQLObject lifeTab = WQLObject.getWQLObject("EM_BI_DeviceLifeCycle");
// 更新设备档案表状态为报废
JSONObject json = fileTab.query("devicerecord_id ='" + devicerecord_id + "' and is_delete = '0'").uniqueResult(0);
if (ObjectUtil.isEmpty(json)) throw new BootstrapMethodError("档案已被删除");
json.put("status", "90");
json.put("update_optid", currentUserId);
json.put("update_optname", nickName);
json.put("update_time", DateUtil.now());
fileTab.update(json);
// 插入设备生命周期表
JSONObject jsonLife = new JSONObject();
jsonLife.put("devicechangedtl_id", IdUtil.getSnowflake(1,1).nextId());
jsonLife.put("devicerecord_id",json.get("devicerecord_id"));
jsonLife.put("changetype","40");
jsonLife.put("change_id",currentUserId);
jsonLife.put("change_name",nickName);
jsonLife.put("change_time",DateUtil.now());
jsonLife.put("create_id",currentUserId);
jsonLife.put("create_name",nickName);
jsonLife.put("create_time",DateUtil.now());
lifeTab.insert(jsonLife);
}
}

View File

@@ -0,0 +1,113 @@
[交易说明]
交易名: 设备报废分页查询
所属模块:
功能简述:
版权所有:
表引用:
版本经历:
[数据库]
--指定数据库为空采用默认值默认为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
输入.manufacturer TYPEAS s_string
输入.supplier_code TYPEAS s_string
输入.device_type TYPEAS s_string
输入.status TYPEAS s_string
输入.is_produceuse TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
[临时变量]
--所有中间过程变量均可在此处定义
[业务过程]
##########################################
# 1、输入输出检查 #
##########################################
##########################################
# 2、主过程前处理 #
##########################################
##########################################
# 3、业务主过程 #
##########################################
IF 输入.flag = "1"
PAGEQUERY
SELECT
file.*,
class.class_name,
dept1.name AS use_groupid_name,
dept2.name AS use_deptid_name,
work.workprocedure_name,
info.is_active,
info.is_delete AS device_is_delete
FROM
EM_BI_EquipmentFile file
LEFT JOIN em_bi_deviceinfo info ON file.device_code = info.device_code
LEFT JOIN md_pb_classstandard class ON file.material_type_id = class.class_id
LEFT JOIN sys_dept dept1 ON file.use_groupid = dept1.dept_id
LEFT JOIN sys_dept dept2 ON file.use_deptid = dept2.dept_id
LEFT JOIN pdm_bi_workprocedure work ON file.workprocedure_id = work.workprocedure_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 <> ""
file.beginuse_date >= 输入.begin_time
ENDOPTION
OPTION 输入.end_time <> ""
file.beginuse_date <= 输入.end_time
ENDOPTION
OPTION 输入.manufacturer <> ""
file.manufacturer like 输入.manufacturer
ENDOPTION
OPTION 输入.device_type <> ""
file.device_type = 输入.device_type
ENDOPTION
OPTION 输入.status <> ""
file.status = 输入.status
ENDOPTION
OPTION 输入.is_produceuse <> ""
file.is_produceuse = 输入.is_produceuse
ENDOPTION
OPTION 输入.supplier_code <> ""
(file.supplier_code like 输入.supplier_code or
file.supplier_name like 输入.supplier_code)
ENDOPTION
ENDSELECT
ENDPAGEQUERY
ENDIF