设备档案

This commit is contained in:
zds
2022-07-04 00:58:04 +08:00
parent 97c59ccb56
commit a34ddd9924
9 changed files with 2155 additions and 0 deletions

View File

@@ -0,0 +1,122 @@
package org.nl.wms.basedata.em.rest;
import cn.hutool.core.util.ObjectUtil;
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.domain.LocalStorage;
import org.nl.exception.BadRequestException;
import org.nl.service.LocalStorageService;
import org.nl.utils.SecurityUtils;
import org.nl.wms.basedata.em.service.EquipmentfileService;
import org.nl.wms.pdm.service.WorkOrdereService;
import org.nl.wql.core.bean.WQLObject;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.Map;
@RestController
@RequiredArgsConstructor
@Api(tags = "设备档案管理")
@RequestMapping("/api/equipmentfile")
@Slf4j
public class EquipmentfileController {
private final EquipmentfileService equipmentfileService;
private final LocalStorageService localStorageService;
@GetMapping
@Log("查询工令")
@ApiOperation("查询工令")
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page){
return new ResponseEntity<>(equipmentfileService.queryAll(whereJson,page),HttpStatus.OK);
}
@PostMapping
@Log("新增工令")
@ApiOperation("新增工令")
public ResponseEntity<Object> create(@RequestBody JSONObject json){
equipmentfileService.create(json);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@PutMapping
@Log("修改工令")
@ApiOperation("修改工令")
public ResponseEntity<Object> update(@RequestBody JSONObject whereJson){
equipmentfileService.update(whereJson);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@Log("删除工令")
@ApiOperation("删除工令")
@DeleteMapping
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
equipmentfileService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("提交")
@ApiOperation("提交")
@PostMapping("/submit")
public ResponseEntity<Object> submit(@RequestBody JSONObject whereJson) {
equipmentfileService.submit(whereJson);
return new ResponseEntity<>(HttpStatus.OK);
}
@GetMapping("/queryivt1")
@Log("查询成型剂")
@ApiOperation("查询工令")
public ResponseEntity<Object> queryivt1(@RequestParam Map whereJson){
return new ResponseEntity<>(equipmentfileService.queryAll1(whereJson),HttpStatus.OK);
}
@GetMapping("/queryivt2")
@Log("查询成型剂")
@ApiOperation("查询工令")
public ResponseEntity<Object> queryivt2(@RequestParam Map whereJson){
return new ResponseEntity<>(equipmentfileService.queryAll2(whereJson),HttpStatus.OK);
}
@GetMapping("/queryivt3")
@Log("查询成型剂")
@ApiOperation("查询工令")
public ResponseEntity<Object> queryivt3(@RequestParam Map whereJson){
return new ResponseEntity<>(equipmentfileService.queryAll3(whereJson),HttpStatus.OK);
}
@GetMapping("/queryBomList")
@Log("查询成型剂")
@ApiOperation("查询工令")
public ResponseEntity<Object> queryBomList(@RequestParam Map whereJson){
return new ResponseEntity<>(equipmentfileService.queryBomList(whereJson),HttpStatus.OK);
}
@PostMapping({"/pictures/{inspection_id}"})
@ApiOperation("质保书上传")
public ResponseEntity<Object> upload(@RequestParam MultipartFile file, @PathVariable String inspection_id) {
LocalStorage localStorage = this.localStorageService.create((String) null, file);
JSONObject mstObj = WQLObject.getWQLObject("EM_BI_EquipmentFile").query("devicerecord_id = '" + inspection_id + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(mstObj)) throw new BadRequestException("未找到相关设备档案!");
Long currentUserId = SecurityUtils.getCurrentUserId();
//更新存储表的来源标识
JSONObject param = new JSONObject();
param.put("source_bill_id", inspection_id);
param.put("source_bill_code", mstObj.getString("devicerecord_code"));
param.put("source_bill_table", "EM_BI_EquipmentFile");
param.put("source_bill_table_pk", "devicerecord_id");
param.put("is_delete", "0");
param.put("create_id", currentUserId);
param.put("create_name", SecurityUtils.getNickName());
WQLObject storateTab = WQLObject.getWQLObject("tool_local_storage");
storateTab.update(param, "storage_id = '" + localStorage.getId() + "'");
return new ResponseEntity(localStorage, HttpStatus.OK);
}
}

View File

@@ -0,0 +1,67 @@
package org.nl.wms.basedata.em.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.data.domain.Pageable;
import java.util.Map;
public interface EquipmentfileService {
/**
* 查询数据分页
* @param whereJson 条件
* @param page 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(Map whereJson, Pageable page);
/**
* 创建
* @param json /
*/
void create(JSONObject json);
/**
* 编辑
* @param whereJson /
*/
void update(JSONObject whereJson);
/**
* 多选删除
* @param ids /
*/
void deleteAll(Long[] ids);
/**
* 提交
* @param whereJson /
*/
void submit(JSONObject whereJson);
/**
* 查询数据分页
* @param whereJson 条件
* @return Map<String,Object>
*/
JSONArray queryAll1(Map whereJson);
/**
* 查询数据分页
* @param whereJson 条件
* @return Map<String,Object>
*/
JSONArray queryAll2(Map whereJson);
/**
* 查询数据分页
* @param whereJson 条件
* @return Map<String,Object>
*/
JSONArray queryAll3(Map whereJson);
/**
* 查询数据分页
* @param whereJson 条件
* @return Map<String,Object>
*/
JSONArray queryBomList(Map whereJson);
}

View File

@@ -0,0 +1,255 @@
package org.nl.wms.basedata.em.service.impl;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
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 lombok.extern.slf4j.Slf4j;
import org.nl.exception.BadRequestException;
import org.nl.modules.security.service.dto.JwtUserDto;
import org.nl.modules.system.util.CodeUtil;
import org.nl.utils.SecurityUtils;
import org.nl.wms.basedata.em.service.EquipmentfileService;
import org.nl.wms.basedata.master.constant.MaterOptTypeEnum;
import org.nl.wms.pdm.service.WorkOrdereService;
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 org.springframework.transaction.annotation.Transactional;
import java.util.*;
@Service
@RequiredArgsConstructor
@Slf4j
public class EquipmentfileServiceImpl implements EquipmentfileService {
@Override
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
HashMap<String, String> map = new HashMap<>(whereJson);
map.put("flag", "1");
String device_code = map.get("device_code");
if (StrUtil.isNotEmpty(device_code)) {
map.put("device_code", "%" + device_code + "%");
}
String manufacturer = map.get("manufacturer");
if (StrUtil.isNotEmpty(manufacturer)) {
map.put("manufacturer", "%" + manufacturer + "%");
}
String begin_time = map.get("begin_time");
if (StrUtil.isNotEmpty(begin_time)) {
map.put("begin_time", begin_time.substring(0,10)+" 00:00:00");
}
String end_time = map.get("end_time");
if (StrUtil.isNotEmpty(end_time)) {
map.put("end_time", end_time.substring(0,10)+" 23:59:59");
}
JSONObject json = WQL.getWO("QEM_EQUIPMENTFILE01").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "equipmentfile.devicerecord_code");
return json;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(JSONObject json) {
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getNickName();
String now = DateUtil.now();
JwtUserDto currentUser = (JwtUserDto) SecurityUtils.getCurrentUser();
Long deptId = currentUser.getDeptId();
WQLObject mstTab = WQLObject.getWQLObject("EM_BI_EquipmentFile"); // 工艺路线主表
WQLObject EM_BI_DeviceLifeCycle = WQLObject.getWQLObject("EM_BI_DeviceLifeCycle"); // 工艺路线主表
// 插入主表
String devicerecord_id = IdUtil.getSnowflake(1, 1).nextId()+"";
json.put("devicerecord_id", devicerecord_id);
String devicerecord_code = CodeUtil.getNewCode("EM_EF_CODE");
json.put("devicerecord_code", devicerecord_code);
json.put("is_delete", "0");
json.put("create_id", currentUserId);
json.put("create_name", nickName);
json.put("create_time", now);
mstTab.insert(json);
JSONObject jo = new JSONObject();
jo.put("devicechangedtl_id", IdUtil.getSnowflake(1, 1).nextId());
jo.put("devicerecord_id", devicerecord_id);
jo.put("changetype", "00");
jo.put("change_reason", "生成");
jo.put("change_id", currentUserId);
jo.put("change_name", nickName);
jo.put("change_time", now);
jo.put("create_id", currentUserId);
jo.put("create_name", nickName);
jo.put("create_time", now);
EM_BI_DeviceLifeCycle.insert(jo);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(JSONObject whereJson) {
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getNickName();
String now = DateUtil.now();
JwtUserDto currentUser = (JwtUserDto) SecurityUtils.getCurrentUser();
Long deptId = currentUser.getDeptId();
WQLObject mstTab = WQLObject.getWQLObject("EM_BI_EquipmentFile"); // 工艺路线主表
WQLObject EM_BI_DeviceLifeCycle = WQLObject.getWQLObject("EM_BI_DeviceLifeCycle"); // 工艺路线主表
whereJson.put("update_optid", currentUserId);
whereJson.put("update_optname", nickName);
whereJson.put("update_time", now);
mstTab.update(whereJson);
JSONObject jo = new JSONObject();
jo.put("devicechangedtl_id", IdUtil.getSnowflake(1, 1).nextId());
jo.put("devicerecord_id", whereJson.getString("devicerecord_id"));
jo.put("changetype", "00");
jo.put("change_reason", "生成");
jo.put("change_id", currentUserId);
jo.put("change_name", nickName);
jo.put("change_time", now);
jo.put("create_id", currentUserId);
jo.put("create_name", nickName);
jo.put("create_time", now);
EM_BI_DeviceLifeCycle.insert(jo);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteAll(Long[] ids) {
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getNickName();
String now = DateUtil.now();
WQLObject wo = WQLObject.getWQLObject("EM_BI_EquipmentFile");
for (Long devicerecord_id : ids) {
JSONObject param = new JSONObject();
param.put("devicerecord_id", String.valueOf(devicerecord_id));
param.put("is_delete", "1");
param.put("update_optid", currentUserId);
param.put("update_optname", nickName);
param.put("update_time", now);
wo.update(param);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void submit(JSONObject json) {
Long currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getNickName();
String now = DateUtil.now();
WQLObject mstTab = WQLObject.getWQLObject("EM_BI_EquipmentFile"); // 工艺路线主表
WQLObject EM_BI_DeviceLifeCycle = WQLObject.getWQLObject("EM_BI_DeviceLifeCycle"); // 工艺路线主表
String status = json.getString("status");
JSONArray ja = json.getJSONArray("rows");
for (int i = 0; i < ja.size(); i++) {
JSONObject jo = ja.getJSONObject(i);
JSONObject jsonMst = mstTab.query("devicerecord_id ='" + jo.getString("devicerecord_id") + "' and is_delete = '0'").uniqueResult(0);
if (jsonMst == null) {
throw new BadRequestException(jo.getString("devicerecord_code") + "当前记录状态异常,操作失败!");
}
String nowStatus = jsonMst.getString("status");
HashMap<String, String> map = new HashMap<>();
if ("10".equals(status)) {//启用
if (StrUtil.isEmpty(jsonMst.getString("device_bom_id"))) {
throw new BadRequestException("设备BOM不能为空");
}
if (StrUtil.isEmpty(jsonMst.getString("use_deptid"))) {
throw new BadRequestException("使用部门不能为空!");
}
if (StrUtil.isEmpty(jsonMst.getString("use_groupid"))) {
throw new BadRequestException("使用班组不能为空!");
}
if (StrUtil.isEmpty(jsonMst.getString("user_name"))) {
throw new BadRequestException("使用人不能为空!");
}
map.put("status", "10");
JSONObject jo2 = new JSONObject();
jo2.put("devicechangedtl_id", IdUtil.getSnowflake(1, 1).nextId());
jo2.put("devicerecord_id", jsonMst.getString("devicerecord_id"));
jo2.put("changetype", "10");
jo2.put("change_reason", "启用");
jo2.put("change_id", currentUserId);
jo2.put("change_name", nickName);
jo2.put("change_time", now);
jo2.put("create_id", currentUserId);
jo2.put("create_name", nickName);
jo2.put("create_time", now);
EM_BI_DeviceLifeCycle.insert(jo);
} else if ("11".equals(status)) {//禁用
map.put("status", "11");
JSONObject jo2 = new JSONObject();
jo2.put("devicechangedtl_id", IdUtil.getSnowflake(1, 1).nextId());
jo2.put("devicerecord_id", jsonMst.getString("devicerecord_id"));
jo2.put("changetype", "11");
jo2.put("change_reason", "停用");
jo2.put("change_id", currentUserId);
jo2.put("change_name", nickName);
jo2.put("change_time", now);
jo2.put("create_id", currentUserId);
jo2.put("create_name", nickName);
jo2.put("create_time", now);
EM_BI_DeviceLifeCycle.insert(jo);
}
map.put("update_optid", currentUserId + "");
map.put("update_optname", nickName);
map.put("update_time", now);
mstTab.update(map, "workorder_id ='" + jo.getString("workorder_id") + "'");
}
}
@Override
public JSONArray queryAll1(Map whereJson) {
String devicerecord_id = (String) whereJson.get("devicerecord_id");
WQLObject EM_BI_DeviceLifeCycle = WQLObject.getWQLObject("EM_BI_DeviceLifeCycle"); // 工艺路线主表
JSONArray ja = EM_BI_DeviceLifeCycle.query("devicerecord_id='"+devicerecord_id+"'").getResultJSONArray(0);
return ja;
}
@Override
public JSONArray queryAll2(Map whereJson) {
HashMap<String, String> map = new HashMap<>(whereJson);
map.put("flag", "2");
String devicerecord_id = map.get("devicerecord_id");
if (StrUtil.isEmpty(devicerecord_id)) {
return new JSONArray();
}
map.put("devicerecord_id", devicerecord_id);
JSONArray ja = WQL.getWO("QEM_EQUIPMENTFILE01")
.addParamMap(map).process().getResultJSONArray(0);
return ja;
}
@Override
public JSONArray queryAll3(Map whereJson) {
HashMap<String, String> map = new HashMap<>(whereJson);
map.put("flag", "3");
String devicerecord_id = map.get("devicerecord_id");
if (StrUtil.isEmpty(devicerecord_id)) {
return new JSONArray();
}
map.put("devicerecord_id", devicerecord_id);
JSONArray ja = WQL.getWO("QEM_EQUIPMENTFILE01")
.addParamMap(map).process().getResultJSONArray(0);
return ja;
}
@Override
public JSONArray queryBomList(Map whereJson) {
WQLObject EM_BI_DeviceBOM = WQLObject.getWQLObject("EM_BI_DeviceBOM"); // 工艺路线主表
JSONArray ja = EM_BI_DeviceBOM.query("is_delete='0' and is_used='1'").getResultJSONArray(0);
return ja;
}
}

View File

@@ -0,0 +1,131 @@
[交易说明]
交易名: 工艺路线分页查询
所属模块:
功能简述:
版权所有:
表引用:
版本经历:
[数据库]
--指定数据库为空采用默认值默认为db.properties中列出的第一个库
[IO定义]
#################################################
## 表字段对应输入参数
#################################################
输入.flag TYPEAS s_string
输入.use_deptid TYPEAS s_string
输入.material_type_id TYPEAS s_string
输入.device_code TYPEAS s_string
输入.status TYPEAS s_string
输入.end_time TYPEAS s_string
输入.begin_time TYPEAS s_string
输入.manufacturer TYPEAS s_string
输入.device_type TYPEAS s_string
输入.workprocedure_id TYPEAS s_string
输入.is_produceuse TYPEAS s_string
输入.devicerecord_id TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
[临时变量]
--所有中间过程变量均可在此处定义
[业务过程]
##########################################
# 1、输入输出检查 #
##########################################
##########################################
# 2、主过程前处理 #
##########################################
##########################################
# 3、业务主过程 #
##########################################
IF 输入.flag = "1"
PAGEQUERY
SELECT
equipmentfile.*,
classstandard.class_name AS material_type_name,
dept1.name AS use_deptname,
dept2.name AS belong_deptname
FROM
em_bi_equipmentfile equipmentfile
LEFT JOIN md_pb_classstandard classstandard ON classstandard.class_id = equipmentfile.material_type_id
LEFT JOIN sys_dept dept1 ON dept1.dept_id = equipmentfile.use_deptid
LEFT JOIN sys_dept dept2 ON dept2.dept_id = equipmentfile.belong_deptid
WHERE
equipmentfile.is_delete = '0'
OPTION 输入.is_produceuse <> ""
equipmentfile.is_produceuse = 输入.is_produceuse
ENDOPTION
OPTION 输入.status <> ""
equipmentfile.status = 输入.status
ENDOPTION
OPTION 输入.use_deptid <> ""
equipmentfile.use_deptid = 输入.use_deptid
ENDOPTION
OPTION 输入.device_type <> ""
equipmentfile.device_type = 输入.device_type
ENDOPTION
OPTION 输入.material_type_id <> ""
equipmentfile.material_type_id = 输入.material_type_id
ENDOPTION
OPTION 输入.device_code <> ""
(equipmentfile.device_code like 输入.device_code or equipmentfile.device_name like 输入.device_code)
ENDOPTION
OPTION 输入.manufacturer <> ""
equipmentfile.manufacturer like 输入.manufacturer
ENDOPTION
OPTION 输入.begin_time <> ""
equipmentfile.beginuse_date >= 输入.begin_time
ENDOPTION
OPTION 输入.end_time <> ""
equipmentfile.beginuse_date <= 输入.end_time
ENDOPTION
ENDSELECT
ENDPAGEQUERY
ENDIF
IF 输入.flag = "2"
QUERY
SELECT
bomdtl.*,
materialbase.material_code,
materialbase.material_name,
classstandard.class_code,
classstandard.class_name
FROM
EM_BI_EquipmentSpareBOM bomdtl
left join md_me_materialbase materialbase on materialbase.material_id = bomdtl.material_id
left join md_pb_classstandard classstandard on materialbase.material_type_id = classstandard.class_id
OPTION 输入.devicerecord_id <> ""
bomdtl.devicerecord_id = 输入.devicerecord_id
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "3"
QUERY
SELECT
local_storage.*
FROM
tool_local_storage local_storage
where local_storage.is_delete = '0'
OPTION 输入.devicerecord_id <> ""
local_storage.source_bill_id = 输入.devicerecord_id
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF