Merge branch 'master' of http://121.40.234.130:8899/root/wuHanXinRui
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.nl.pda.st.out.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.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
@@ -408,6 +409,8 @@ public class HandPFOutIvtServiceImpl implements HandPFOutIvtService {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> confirmOutStore2(Map<String, String> jsonObject) {
|
||||
String input_optid = MapUtil.getStr(jsonObject, "input_optid");
|
||||
String input_optname = MapUtil.getStr(jsonObject, "input_optid");
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
UserDto userDto = userService.findById(currentUserId);
|
||||
// 仓位属性表【ST_IVT_StructAttr】
|
||||
@@ -550,8 +553,8 @@ public class HandPFOutIvtServiceImpl implements HandPFOutIvtService {
|
||||
invrow.put("detail_count", 1);
|
||||
invrow.put("bill_status", "99");
|
||||
invrow.put("create_mode", "02");
|
||||
invrow.put("input_optid", currentUserId);
|
||||
invrow.put("input_optname", userDto.getNickName());
|
||||
invrow.put("input_optid", input_optid);
|
||||
invrow.put("input_optname", input_optname);
|
||||
invrow.put("input_time", now);
|
||||
invrow.put("update_optid", currentUserId);
|
||||
invrow.put("update_optname", userDto.getNickName());
|
||||
@@ -559,8 +562,8 @@ public class HandPFOutIvtServiceImpl implements HandPFOutIvtService {
|
||||
invrow.put("dis_optid", currentUserId);
|
||||
invrow.put("dis_optname", userDto.getNickName());
|
||||
invrow.put("dis_time", now);
|
||||
invrow.put("confirm_optid", currentUserId);
|
||||
invrow.put("confirm_optname", userDto.getNickName());
|
||||
invrow.put("confirm_optid", input_optid);
|
||||
invrow.put("confirm_optname", input_optname);
|
||||
invrow.put("confirm_time", now);
|
||||
invrow.put("sysdeptid", userDto.getDept().getId());
|
||||
invrow.put("syscompanyid", userDto.getDept().getId());
|
||||
|
||||
@@ -553,6 +553,8 @@ public class FlourworkServiceImpl implements FlourworkService {
|
||||
}
|
||||
map.put("bucketunique", jsonFormDtlJob.getString("bucketunique"));
|
||||
map.put("out_qty", jsonFormDtlJob.getString("outconfirm_qty"));
|
||||
map.put("input_optid", jsonFormDtlJob.getString("create_id"));
|
||||
map.put("input_optname", jsonFormDtlJob.getString("create_name"));
|
||||
handPFOutIvtService.confirmOutStore2(map);
|
||||
} else {
|
||||
// 2.如果不是
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
|
||||
package org.nl.wms.sb.stat.rest;
|
||||
|
||||
|
||||
import org.nl.wms.sb.stat.service.DevicesparepartivtService;
|
||||
import org.nl.wms.sb.stat.service.dto.DevicesparepartivtDto;
|
||||
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.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
* @date 2022-06-28
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "备件库存查询管理")
|
||||
@RequestMapping("/api/devicesparepartivt")
|
||||
@Slf4j
|
||||
public class DevicesparepartivtController {
|
||||
|
||||
private final DevicesparepartivtService devicesparepartivtService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询备件库存查询")
|
||||
@ApiOperation("查询备件库存查询")
|
||||
//@PreAuthorize("@el.check('devicesparepartivt:list')")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
|
||||
return new ResponseEntity<>(devicesparepartivtService.queryAll(whereJson, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增备件库存查询")
|
||||
@ApiOperation("新增备件库存查询")
|
||||
//@PreAuthorize("@el.check('devicesparepartivt:add')")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody DevicesparepartivtDto dto) {
|
||||
devicesparepartivtService.create(dto);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改备件库存查询")
|
||||
@ApiOperation("修改备件库存查询")
|
||||
//@PreAuthorize("@el.check('devicesparepartivt:edit')")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody DevicesparepartivtDto dto) {
|
||||
devicesparepartivtService.update(dto);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除备件库存查询")
|
||||
@ApiOperation("删除备件库存查询")
|
||||
//@PreAuthorize("@el.check('devicesparepartivt:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
|
||||
devicesparepartivtService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
public void download(HttpServletResponse response, @RequestParam Map whereJson) throws IOException {
|
||||
devicesparepartivtService.download(whereJson, response);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
|
||||
package org.nl.wms.sb.stat.service;
|
||||
|
||||
import org.nl.wms.sb.stat.service.dto.DevicesparepartivtDto;
|
||||
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-28
|
||||
**/
|
||||
public interface DevicesparepartivtService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
*
|
||||
* @param whereJson 条件
|
||||
* @param page 分页参数
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> queryAll(Map whereJson, Pageable page);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
*
|
||||
* @param whereJson 条件参数
|
||||
* @return List<DevicesparepartivtDto>
|
||||
*/
|
||||
List<DevicesparepartivtDto> queryAll(Map whereJson);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param stockrecord_id ID
|
||||
* @return Devicesparepartivt
|
||||
*/
|
||||
DevicesparepartivtDto findById(Long stockrecord_id);
|
||||
|
||||
/**
|
||||
* 根据编码查询
|
||||
*
|
||||
* @param code code
|
||||
* @return Devicesparepartivt
|
||||
*/
|
||||
DevicesparepartivtDto findByCode(String code);
|
||||
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param dto /
|
||||
*/
|
||||
void create(DevicesparepartivtDto dto);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param dto /
|
||||
*/
|
||||
void update(DevicesparepartivtDto dto);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Long[] ids);
|
||||
|
||||
void download(Map whereJson, HttpServletResponse response) throws IOException;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package org.nl.wms.sb.stat.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;
|
||||
|
||||
/**
|
||||
* @description /
|
||||
* @author Liuxy
|
||||
* @date 2022-06-28
|
||||
**/
|
||||
@Data
|
||||
public class DevicesparepartivtDto implements Serializable {
|
||||
|
||||
/** 库存记录标识 */
|
||||
/** 防止精度丢失 */
|
||||
@JsonSerialize(using= ToStringSerializer.class)
|
||||
private Long stockrecord_id;
|
||||
|
||||
/** 备件唯一标识 */
|
||||
private String sparepart_only_id;
|
||||
|
||||
/** 物料标识 */
|
||||
private Long material_id;
|
||||
|
||||
/** 批次 */
|
||||
private String pcsn;
|
||||
|
||||
/** 仓库标识 */
|
||||
private Long stor_id;
|
||||
|
||||
/** 仓库名称 */
|
||||
private String stor_name;
|
||||
|
||||
/** 仓位标识 */
|
||||
private Long struct_id;
|
||||
|
||||
/** 仓位编码 */
|
||||
private String struct_code;
|
||||
|
||||
/** 仓位名称 */
|
||||
private String struct_name;
|
||||
|
||||
/** 库存数 */
|
||||
private BigDecimal ivt_qty;
|
||||
|
||||
/** 数量计量单位标识 */
|
||||
private Long qty_unit_id;
|
||||
|
||||
/** 数量计量单位名称 */
|
||||
private String qty_unit_name;
|
||||
|
||||
/** 入库时间 */
|
||||
private String instorage_time;
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
|
||||
package org.nl.wms.sb.stat.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.utils.FileUtil;
|
||||
import org.nl.wms.sb.stat.service.DevicesparepartivtService;
|
||||
import org.nl.wms.sb.stat.service.dto.DevicesparepartivtDto;
|
||||
import org.nl.wql.WQL;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
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;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author Liuxy
|
||||
* @description 服务实现
|
||||
* @date 2022-06-28
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class DevicesparepartivtServiceImpl implements DevicesparepartivtService {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
||||
String material_code = MapUtil.getStr(whereJson, "material_code");
|
||||
String is_all = MapUtil.getStr(whereJson, "is_all");
|
||||
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
if (ObjectUtil.isEmpty(is_all) || StrUtil.equals(is_all, "0")) {
|
||||
map.put("flag", "1");
|
||||
} else {
|
||||
map.put("flag", "2");
|
||||
}
|
||||
map.put("stor_id", MapUtil.getStr(whereJson,"stor_id"));
|
||||
map.put("sect_id", MapUtil.getStr(whereJson,"sect_id"));
|
||||
if (ObjectUtil.isNotEmpty(material_code)) map.put("material_code", "%"+material_code+"%");
|
||||
JSONObject json = WQL.getWO("EM_DEVICEIVT001").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "ivt.material_id DESC");
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DevicesparepartivtDto> queryAll(Map whereJson) {
|
||||
WQLObject wo = WQLObject.getWQLObject("em_bi_devicesparepartivt");
|
||||
JSONArray arr = wo.query().getResultJSONArray(0);
|
||||
if (ObjectUtil.isNotEmpty(arr)) return arr.toJavaList(DevicesparepartivtDto.class);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DevicesparepartivtDto findById(Long stockrecord_id) {
|
||||
WQLObject wo = WQLObject.getWQLObject("em_bi_devicesparepartivt");
|
||||
JSONObject json = wo.query("stockrecord_id = '" + stockrecord_id + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)) {
|
||||
return json.toJavaObject(DevicesparepartivtDto.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DevicesparepartivtDto findByCode(String code) {
|
||||
WQLObject wo = WQLObject.getWQLObject("em_bi_devicesparepartivt");
|
||||
JSONObject json = wo.query("code ='" + code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)) {
|
||||
return json.toJavaObject(DevicesparepartivtDto.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(DevicesparepartivtDto dto) {
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
dto.setStockrecord_id(IdUtil.getSnowflake(1, 1).nextId());
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("em_bi_devicesparepartivt");
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
|
||||
wo.insert(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(DevicesparepartivtDto dto) {
|
||||
DevicesparepartivtDto entity = this.findById(dto.getStockrecord_id());
|
||||
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getNickName();
|
||||
|
||||
String now = DateUtil.now();
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("em_bi_devicesparepartivt");
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
|
||||
wo.update(json);
|
||||
}
|
||||
|
||||
@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_devicesparepartivt");
|
||||
for (Long stockrecord_id : ids) {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("stockrecord_id", String.valueOf(stockrecord_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
|
||||
public void download(Map whereJson, HttpServletResponse response) throws IOException {
|
||||
String material_code = MapUtil.getStr(whereJson, "material_code");
|
||||
String is_all = MapUtil.getStr(whereJson, "is_all");
|
||||
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
if (ObjectUtil.isEmpty(is_all) || StrUtil.equals(is_all, "0")) {
|
||||
map.put("flag", "1");
|
||||
} else {
|
||||
map.put("flag", "2");
|
||||
}
|
||||
map.put("stor_id", MapUtil.getStr(whereJson,"stor_id"));
|
||||
map.put("sect_id", MapUtil.getStr(whereJson,"sect_id"));
|
||||
if (ObjectUtil.isNotEmpty(material_code)) map.put("material_code", "%"+material_code+"%");
|
||||
JSONArray rows = WQL.getWO("EM_DEVICEIVT001").addParamMap(map).process().getResultJSONArray(0);
|
||||
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
JSONObject jo = rows.getJSONObject(i);
|
||||
Map<String, Object> dtl_map = new LinkedHashMap<>();
|
||||
dtl_map.put("库区编码", jo.getString("sect_code"));
|
||||
dtl_map.put("库区名称", jo.getString("sect_name"));
|
||||
dtl_map.put("物料编码", jo.getString("material_code"));
|
||||
dtl_map.put("物料名称", jo.getString("material_name"));
|
||||
dtl_map.put("型号", jo.getString("material_model"));
|
||||
dtl_map.put("技术规格", jo.getString("material_spec"));
|
||||
dtl_map.put("批次", jo.getString("pcsn"));
|
||||
dtl_map.put("库存数", jo.getString("ivt_qty"));
|
||||
dtl_map.put("单位", jo.getString("qty_unit_name"));
|
||||
dtl_map.put("入库时间", jo.getString("instorage_time"));
|
||||
list.add(dtl_map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
[交易说明]
|
||||
交易名: 备件库存分页查询
|
||||
所属模块:
|
||||
功能简述:
|
||||
版权所有:
|
||||
表引用:
|
||||
版本经历:
|
||||
|
||||
[数据库]
|
||||
--指定数据库,为空采用默认值,默认为db.properties中列出的第一个库
|
||||
|
||||
[IO定义]
|
||||
#################################################
|
||||
## 表字段对应输入参数
|
||||
#################################################
|
||||
输入.flag TYPEAS s_string
|
||||
输入.stor_id TYPEAS s_string
|
||||
输入.sect_id TYPEAS s_string
|
||||
输入.material_code TYPEAS s_string
|
||||
|
||||
|
||||
[临时表]
|
||||
--这边列出来的临时表就会在运行期动态创建
|
||||
|
||||
[临时变量]
|
||||
--所有中间过程变量均可在此处定义
|
||||
|
||||
[业务过程]
|
||||
|
||||
##########################################
|
||||
# 1、输入输出检查 #
|
||||
##########################################
|
||||
|
||||
|
||||
##########################################
|
||||
# 2、主过程前处理 #
|
||||
##########################################
|
||||
|
||||
|
||||
##########################################
|
||||
# 3、业务主过程 #
|
||||
##########################################
|
||||
|
||||
IF 输入.flag = "1"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
MAX(struct.sect_code) AS sect_code,
|
||||
MAX(struct.sect_name) AS sect_name,
|
||||
me.material_code,
|
||||
me.material_name,
|
||||
me.material_spec,
|
||||
me.material_model,
|
||||
ivt.pcsn,
|
||||
sum(ivt.ivt_qty) AS ivt_qty,
|
||||
MAX(ivt.qty_unit_name) AS qty_unit_name,
|
||||
MAX(ivt.instorage_time) AS instorage_time
|
||||
FROM
|
||||
EM_BI_DeviceSparePartIvt ivt
|
||||
LEFT JOIN ST_IVT_StructAttr struct ON ivt.struct_id = struct.struct_id
|
||||
LEFT JOIN MD_ME_MaterialBase me ON me.material_id = ivt.material_id
|
||||
WHERE 1=1
|
||||
OPTION 输入.stor_id <> ""
|
||||
struct.stor_id = 输入.stor_id
|
||||
ENDOPTION
|
||||
OPTION 输入.sect_id <> ""
|
||||
struct.sect_id = 输入.sect_id
|
||||
ENDOPTION
|
||||
|
||||
OPTION 输入.material_code <> ""
|
||||
(me.material_name like 输入.material_code or
|
||||
me.material_code like 输入.material_code)
|
||||
ENDOPTION
|
||||
|
||||
group by ivt.material_id,ivt.pcsn
|
||||
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
|
||||
IF 输入.flag = "2"
|
||||
PAGEQUERY
|
||||
SELECT
|
||||
struct.sect_code,
|
||||
struct.sect_name,
|
||||
me.material_code,
|
||||
me.material_name,
|
||||
me.material_spec,
|
||||
me.material_model,
|
||||
ivt.*
|
||||
FROM
|
||||
EM_BI_DeviceSparePartIvt ivt
|
||||
LEFT JOIN ST_IVT_StructAttr struct ON ivt.struct_id = struct.struct_id
|
||||
LEFT JOIN MD_ME_MaterialBase me ON me.material_id = ivt.material_id
|
||||
WHERE 1=1
|
||||
OPTION 输入.stor_id <> ""
|
||||
struct.stor_id = 输入.stor_id
|
||||
ENDOPTION
|
||||
OPTION 输入.sect_id <> ""
|
||||
struct.sect_id = 输入.sect_id
|
||||
ENDOPTION
|
||||
|
||||
OPTION 输入.material_code <> ""
|
||||
(me.material_name like 输入.material_code or
|
||||
me.material_code like 输入.material_code)
|
||||
ENDOPTION
|
||||
|
||||
ENDSELECT
|
||||
ENDPAGEQUERY
|
||||
ENDIF
|
||||
Reference in New Issue
Block a user