载具维护
This commit is contained in:
@@ -1,85 +0,0 @@
|
||||
|
||||
package org.nl.wms.basedata.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.modules.logging.annotation.Log;
|
||||
import org.nl.wms.basedata.service.StoragevehicleinfoService;
|
||||
import org.nl.wms.basedata.service.dto.VehicleDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
* @date 2021-12-09
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "载具管理")
|
||||
@RequestMapping("/api/storagevehicleinfo")
|
||||
@Slf4j
|
||||
public class StoragevehicleinfoController {
|
||||
|
||||
private final StoragevehicleinfoService storagevehicleinfoService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询载具")
|
||||
@ApiOperation("查询载具")
|
||||
//@SaCheckPermission("mdPbStoragevehicleinfo:list")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page){
|
||||
return new ResponseEntity<>(storagevehicleinfoService.queryAll(whereJson,page),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增载具")
|
||||
@ApiOperation("新增载具")
|
||||
//@SaCheckPermission("mdPbStoragevehicleinfo:add")
|
||||
public ResponseEntity<Object> create(@RequestBody Map map){
|
||||
return new ResponseEntity<>(storagevehicleinfoService.create(map),HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改载具")
|
||||
@ApiOperation("修改载具")
|
||||
//@SaCheckPermission("mdPbStoragevehicleinfo:edit")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody VehicleDto dto){
|
||||
storagevehicleinfoService.update(dto);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除载具")
|
||||
@ApiOperation("删除载具")
|
||||
//@SaCheckPermission("mdPbStoragevehicleinfo:del")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
|
||||
storagevehicleinfoService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PutMapping("/changeActive")
|
||||
@Log("修改点位启用状态")
|
||||
@ApiOperation("修改点位启用状态")
|
||||
//@SaCheckPermission("store:edit")
|
||||
public ResponseEntity<Object> changeActive(@RequestBody JSONObject json) {
|
||||
storagevehicleinfoService.changeActive(json);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@GetMapping("/getVehicle/{code}")
|
||||
@Log("获取起始载具号")
|
||||
@ApiOperation("获取起始载具号")
|
||||
//@SaCheckPermission("store:edit")
|
||||
public ResponseEntity<Object> getVehicle(@PathVariable String code) {
|
||||
JSONObject json = storagevehicleinfoService.getVehicle(code);
|
||||
return new ResponseEntity<>(json,HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
|
||||
package org.nl.wms.basedata.rest;
|
||||
|
||||
|
||||
import org.nl.wms.basedata.service.VehicleService;
|
||||
import org.nl.wms.basedata.service.dto.VehicleDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.modules.logging.annotation.Log;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
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 lyd
|
||||
* @date 2022-10-18
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "载具维护管理")
|
||||
@RequestMapping("/api/vehicle")
|
||||
@Slf4j
|
||||
public class VehicleController {
|
||||
|
||||
private final VehicleService vehicleService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询载具维护")
|
||||
@ApiOperation("查询载具维护")
|
||||
//@SaCheckPermission("@el.check('vehicle:list')")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page){
|
||||
return new ResponseEntity<>(vehicleService.queryAll(whereJson,page),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增载具维护")
|
||||
@ApiOperation("新增载具维护")
|
||||
//@SaCheckPermission("@el.check('vehicle:add')")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody VehicleDto dto){
|
||||
vehicleService.create(dto);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改载具维护")
|
||||
@ApiOperation("修改载具维护")
|
||||
//@SaCheckPermission("@el.check('vehicle:edit')")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody VehicleDto dto){
|
||||
vehicleService.update(dto);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除载具维护")
|
||||
@ApiOperation("删除载具维护")
|
||||
//@SaCheckPermission("@el.check('vehicle:del')")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
|
||||
vehicleService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,19 @@
|
||||
|
||||
package org.nl.wms.basedata.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.basedata.service.dto.VehicleDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @description 服务接口
|
||||
* @author ldjun
|
||||
* @date 2021-12-09
|
||||
* @author lyd
|
||||
* @date 2022-10-18
|
||||
**/
|
||||
public interface StoragevehicleinfoService {
|
||||
public interface VehicleService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
@@ -27,30 +26,30 @@ public interface StoragevehicleinfoService {
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param whereJson 条件参数
|
||||
* @return List<StoragevehicleinfoDto>
|
||||
* @return List<VehicleDto>
|
||||
*/
|
||||
List<VehicleDto> queryAll(Map whereJson);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param storagevehicle_id ID
|
||||
* @return MdPbStoragevehicleinfo
|
||||
*/
|
||||
VehicleDto findById(Long storagevehicle_id);
|
||||
* 根据ID查询
|
||||
* @param vehicle_id ID
|
||||
* @return Vehicle
|
||||
*/
|
||||
VehicleDto findById(Long vehicle_id);
|
||||
|
||||
/**
|
||||
* 根据编码查询
|
||||
* @param code code
|
||||
* @return MdPbStoragevehicleinfo
|
||||
* @return Vehicle
|
||||
*/
|
||||
VehicleDto findByCode(String code);
|
||||
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param map /
|
||||
* @param dto /
|
||||
*/
|
||||
JSONArray create(Map map);
|
||||
void create(VehicleDto dto);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
@@ -63,16 +62,4 @@ public interface StoragevehicleinfoService {
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Long[] ids);
|
||||
|
||||
/**
|
||||
* 多修改启用状态
|
||||
* @param json /
|
||||
*/
|
||||
void changeActive(JSONObject json);
|
||||
|
||||
/**
|
||||
* 获取起始载具号
|
||||
* @param code /
|
||||
*/
|
||||
JSONObject getVehicle(String code);
|
||||
}
|
||||
@@ -1,61 +1,75 @@
|
||||
package org.nl.wms.basedata.service.dto;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
|
||||
/**
|
||||
* @description /
|
||||
* @author ldjun
|
||||
* @date 2021-12-09
|
||||
* @author lyd
|
||||
* @date 2022-10-18
|
||||
**/
|
||||
@Data
|
||||
public class VehicleDto implements Serializable {
|
||||
|
||||
/** 防止精度丢失 */
|
||||
@JsonSerialize(using= ToStringSerializer.class)
|
||||
private Long storagevehicle_id;
|
||||
/** 载具标识 */
|
||||
/** 防止精度丢失 */
|
||||
@JsonSerialize(using= ToStringSerializer.class)
|
||||
private Long vehicle_id;
|
||||
|
||||
private String vehicle_code;
|
||||
/** 载具编码 */
|
||||
private String vehicle_code;
|
||||
|
||||
private String vehicle_name;
|
||||
/** 载具名称 */
|
||||
private String vehicle_name;
|
||||
|
||||
private String one_code;
|
||||
/** 一维码 */
|
||||
private String one_code;
|
||||
|
||||
private String two_code;
|
||||
/** 二维码 */
|
||||
private String two_code;
|
||||
|
||||
private String rfid_code;
|
||||
/** RFID编码 */
|
||||
private String rfid_code;
|
||||
|
||||
private Long create_id;
|
||||
/** 载具类型 */
|
||||
private String vehicle_type;
|
||||
|
||||
private String create_name;
|
||||
/** 载具宽度 */
|
||||
private BigDecimal vehicle_width;
|
||||
|
||||
private String create_time;
|
||||
/** 载具长度 */
|
||||
private BigDecimal vehicle_long;
|
||||
|
||||
private Long update_optid;
|
||||
/** 载具高度 */
|
||||
private BigDecimal vehicle_height;
|
||||
|
||||
private String update_optname;
|
||||
/** 载具超仓位类型 */
|
||||
private String overstruct_type;
|
||||
|
||||
private String update_time;
|
||||
/** 占仓位数 */
|
||||
private BigDecimal occupystruct_qty;
|
||||
|
||||
private String is_delete;
|
||||
/** 外部标识 */
|
||||
private String ext_id;
|
||||
|
||||
private String is_used;
|
||||
/** 创建人 */
|
||||
private Long create_id;
|
||||
|
||||
private String storagevehicle_type;
|
||||
/** 创建人 */
|
||||
private String create_name;
|
||||
|
||||
private BigDecimal vehicle_width;
|
||||
/** 创建时间 */
|
||||
private String create_time;
|
||||
|
||||
private BigDecimal vehicle_long;
|
||||
/** 修改人 */
|
||||
private Long update_optid;
|
||||
|
||||
private BigDecimal vehicle_height;
|
||||
/** 修改人 */
|
||||
private String update_optname;
|
||||
|
||||
private String overstruct_type;
|
||||
|
||||
private BigDecimal occupystruct_qty;
|
||||
|
||||
private String ext_id;
|
||||
/** 修改时间 */
|
||||
private String update_time;
|
||||
}
|
||||
|
||||
@@ -1,218 +0,0 @@
|
||||
|
||||
package org.nl.wms.basedata.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.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.common.utils.SecurityUtils;
|
||||
import org.nl.modules.system.service.impl.GenCodeServiceImpl;
|
||||
import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import org.nl.wms.basedata.service.StoragevehicleinfoService;
|
||||
import org.nl.wms.basedata.service.dto.VehicleDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ldjun
|
||||
* @description 服务实现
|
||||
* @date 2021-12-09
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class StoragevehicleinfoServiceImpl implements StoragevehicleinfoService {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
||||
WQLObject taskTab = WQLObject.getWQLObject("sch_base_task");
|
||||
|
||||
String ehicle_code_begin = (String) whereJson.get("ehicle_code_begin");
|
||||
String ehicle_code_end = (String) whereJson.get("ehicle_code_end");
|
||||
String storagevehicle_type = (String) whereJson.get("storagevehicle_type");
|
||||
|
||||
HashMap<String, Object> map = new HashMap();
|
||||
map.put("ehicle_code_begin", ehicle_code_begin);
|
||||
map.put("ehicle_code_end", ehicle_code_end);
|
||||
map.put("storagevehicle_type", storagevehicle_type);
|
||||
map.put("flag", "1");
|
||||
JSONObject json = WQL.getWO("QMD_PB_STORAGEVEHICLEINFO").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "s.ehicle_code ASC");
|
||||
JSONArray content = json.getJSONArray("content");
|
||||
for (int i = 0; i < content.size(); i++) {
|
||||
JSONObject jsonObject = content.getJSONObject(i);
|
||||
JSONObject jsonTask = taskTab.query("vehicle_code = '" + jsonObject.getString("ehicle_code") + "' and task_status <> '99' and is_delete = '0'").uniqueResult(0);
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VehicleDto> queryAll(Map whereJson) {
|
||||
WQLObject wo = WQLObject.getWQLObject("md_pb_storagevehicleinfo");
|
||||
JSONArray arr = wo.query().getResultJSONArray(0);
|
||||
List<VehicleDto> list = arr.toJavaList(VehicleDto.class);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VehicleDto findById(Long storagevehicle_id) {
|
||||
WQLObject wo = WQLObject.getWQLObject("md_pb_storagevehicleinfo");
|
||||
JSONObject json = wo.query("storagevehicle_id =" + storagevehicle_id + "").uniqueResult(0);
|
||||
final VehicleDto obj = json.toJavaObject(VehicleDto.class);
|
||||
return obj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VehicleDto findByCode(String code) {
|
||||
WQLObject wo = WQLObject.getWQLObject("md_pb_storagevehicleinfo");
|
||||
JSONObject json = wo.query("ehicle_code ='" + code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(json)){
|
||||
throw new BadRequestException("请输入正确的载具号!");
|
||||
}
|
||||
final VehicleDto obj = json.toJavaObject(VehicleDto.class);
|
||||
return obj;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public JSONArray create(Map map) {
|
||||
WQLObject wo = WQLObject.getWQLObject("md_pb_storagevehicleinfo");
|
||||
JSONObject jsonObject = wo.query("ehicle_code = '" + map.get("ehicle_code") + "' and is_delete = '0'").uniqueResult(0);
|
||||
if (!ObjectUtil.isEmpty(jsonObject)) {
|
||||
throw new BadRequestException("此载具已存在");
|
||||
}
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
String storagevehicle_type = (String) map.get("storagevehicle_type");
|
||||
String code = "";
|
||||
switch (storagevehicle_type) {
|
||||
case "00":
|
||||
code = "VEHICCLE_CODE_MTP";
|
||||
break;
|
||||
case "01":
|
||||
code = "VEHICCLE_CODE_TTP";
|
||||
break;
|
||||
}
|
||||
JSONArray resultCodeArr = new JSONArray();
|
||||
int num = MapUtil.getInt(map, "num");
|
||||
for (int i = 0; i < num; i++) {
|
||||
VehicleDto dto = new VehicleDto();
|
||||
dto.setStoragevehicle_id(IdUtil.getSnowflake(1, 1).nextId());
|
||||
dto.setVehicle_code(CodeUtil.getNewCode(code));
|
||||
dto.setCreate_id(currentUserId);
|
||||
dto.setVehicle_name(dto.getVehicle_code());
|
||||
dto.setCreate_name(nickName);
|
||||
dto.setUpdate_optid(currentUserId);
|
||||
dto.setUpdate_optname(nickName);
|
||||
dto.setUpdate_time(now);
|
||||
dto.setCreate_time(now);
|
||||
dto.setStoragevehicle_type((String) map.get("storagevehicle_type"));
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
|
||||
wo.insert(json);
|
||||
resultCodeArr.add(dto.getVehicle_code());
|
||||
}
|
||||
return resultCodeArr;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(VehicleDto dto) {
|
||||
WQLObject wo = WQLObject.getWQLObject("md_pb_storagevehicleinfo");
|
||||
JSONObject jsonObject = wo.query("ehicle_code = '" + dto.getVehicle_code() + "' and is_delete = '0'").uniqueResult(0);
|
||||
if (!ObjectUtil.isEmpty(jsonObject)) {
|
||||
throw new BadRequestException("此载具已存在");
|
||||
}
|
||||
VehicleDto entity = this.findById(dto.getStoragevehicle_id());
|
||||
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
|
||||
String now = DateUtil.now();
|
||||
dto.setUpdate_time(now);
|
||||
dto.setUpdate_optid(currentUserId);
|
||||
dto.setUpdate_optname(nickName);
|
||||
|
||||
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.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("md_pb_storagevehicleinfo");
|
||||
for (Long storagevehicle_id : ids) {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("storagevehicle_id", String.valueOf(storagevehicle_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 changeActive(JSONObject json) {
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
String is_used = "1";
|
||||
if (StrUtil.equals("1", json.getString("is_used"))) {
|
||||
is_used = "0";
|
||||
}
|
||||
json.put("is_used", is_used);
|
||||
json.put("update_optid", currentUserId);
|
||||
json.put("update_optname", nickName);
|
||||
json.put("update_time", now);
|
||||
WQLObject.getWQLObject("md_pb_storagevehicleinfo").update(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public JSONObject getVehicle(String code) {
|
||||
String term = "";
|
||||
switch (code) {
|
||||
case "00":
|
||||
term = "VEHICCLE_CODE_MTP";
|
||||
break;
|
||||
case "01":
|
||||
term = "VEHICCLE_CODE_TTP";
|
||||
break;
|
||||
}
|
||||
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("code", term);
|
||||
map.put("flag", "0");
|
||||
GenCodeServiceImpl genCodeService = new GenCodeServiceImpl();
|
||||
String value = genCodeService.codeDemo(map);
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("value", value);
|
||||
return json;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
|
||||
package org.nl.wms.basedata.service.impl;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.wms.basedata.service.VehicleService;
|
||||
import org.nl.wms.basedata.service.dto.VehicleDto;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
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.modules.common.utils.SecurityUtils;
|
||||
import org.nl.modules.wql.core.bean.ResultBean;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.WqlUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
|
||||
/**
|
||||
* @description 服务实现
|
||||
* @author lyd
|
||||
* @date 2022-10-18
|
||||
**/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class VehicleServiceImpl implements VehicleService {
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(Map whereJson, Pageable page){
|
||||
WQLObject wo = WQLObject.getWQLObject("md_pb_vehicle");
|
||||
ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "1=1", "update_time desc");
|
||||
final JSONObject json = rb.pageResult();
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VehicleDto> queryAll(Map whereJson){
|
||||
WQLObject wo = WQLObject.getWQLObject("md_pb_vehicle");
|
||||
JSONArray arr = wo.query().getResultJSONArray(0);
|
||||
if (ObjectUtil.isNotEmpty(arr)) return arr.toJavaList(VehicleDto.class);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VehicleDto findById(Long vehicle_id) {
|
||||
WQLObject wo = WQLObject.getWQLObject("md_pb_vehicle");
|
||||
JSONObject json = wo.query("vehicle_id = '" + vehicle_id + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)){
|
||||
return json.toJavaObject( VehicleDto.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VehicleDto findByCode(String code) {
|
||||
WQLObject wo = WQLObject.getWQLObject("md_pb_vehicle");
|
||||
JSONObject json = wo.query("code ='" + code + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)){
|
||||
return json.toJavaObject( VehicleDto.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(VehicleDto dto) {
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
dto.setVehicle_id(IdUtil.getSnowflake(1, 1).nextId());
|
||||
dto.setVehicle_name(dto.getVehicle_name());
|
||||
dto.setCreate_id(currentUserId);
|
||||
dto.setCreate_name(nickName);
|
||||
dto.setUpdate_optid(currentUserId);
|
||||
dto.setUpdate_optname(nickName);
|
||||
dto.setUpdate_time(now);
|
||||
dto.setCreate_time(now);
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("md_pb_vehicle");
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
|
||||
wo.insert(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(VehicleDto dto) {
|
||||
VehicleDto entity = this.findById(dto.getVehicle_id());
|
||||
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
|
||||
String now = DateUtil.now();
|
||||
dto.setUpdate_time(now);
|
||||
dto.setUpdate_optid(currentUserId);
|
||||
dto.setUpdate_optname(nickName);
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("md_pb_vehicle");
|
||||
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.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
WQLObject wo = WQLObject.getWQLObject("md_pb_vehicle");
|
||||
for (Long vehicle_id: ids) {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("vehicle_id", String.valueOf(vehicle_id));
|
||||
param.put("is_delete", "1");
|
||||
param.put("update_optid", currentUserId);
|
||||
param.put("update_optname", nickName);
|
||||
param.put("update_time", now);
|
||||
wo.update(param);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import org.nl.modules.common.utils.SecurityUtils;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.nl.wms.basedata.service.StoragevehicleinfoService;
|
||||
import org.nl.wms.basedata.service.VehicleService;
|
||||
import org.nl.wms.basedata.service.dto.VehicleDto;
|
||||
import org.nl.wms.pda.emptyandqty.service.EmptyAndQtyService;
|
||||
|
||||
@@ -29,12 +29,12 @@ public class EmptyAndQtyServiceImpl implements EmptyAndQtyService {
|
||||
String qty = whereJson.getString("qty");
|
||||
|
||||
WQLObject vqTab = WQLObject.getWQLObject("PDM_BI_vehicleQty");
|
||||
VehicleDto byCode = SpringContextHolder.getBean(StoragevehicleinfoService.class).findByCode(vehicle_code);
|
||||
VehicleDto byCode = SpringContextHolder.getBean(VehicleService.class).findByCode(vehicle_code);
|
||||
|
||||
// 插入记录
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("vehicleqty_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||
json.put("vehicle_id", byCode.getStoragevehicle_id());
|
||||
json.put("vehicle_id", byCode.getVehicle_id());
|
||||
json.put("vehicle_code", vehicle_code);
|
||||
json.put("qty", qty);
|
||||
json.put("create_id", SecurityUtils.getCurrentUserId());
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.nl.wms.basedata.service.StoragevehicleinfoService;
|
||||
import org.nl.wms.basedata.service.VehicleService;
|
||||
import org.nl.wms.basedata.service.dto.VehicleDto;
|
||||
import org.nl.wms.pdm.service.DeviceService;
|
||||
import org.nl.wms.pdm.service.dto.DeviceDto;
|
||||
@@ -239,9 +239,9 @@ public class SendEmpVehicleTask extends AbstractAcsTask {
|
||||
// 如果说明是货梯业务:则判断载具号是否为空
|
||||
if (ObjectUtil.isEmpty(vehicle_code)) throw new BadRequestException("起点点位错误");
|
||||
// 根据载具号找对应的载具类型
|
||||
VehicleDto vehicleDto = SpringContextHolder.getBean(StoragevehicleinfoService.class).findByCode(vehicle_code);
|
||||
VehicleDto vehicleDto = SpringContextHolder.getBean(VehicleService.class).findByCode(vehicle_code);
|
||||
if (ObjectUtil.isEmpty(vehicleDto)) throw new BadRequestException("载具不存在");
|
||||
vehicle_type = vehicleDto.getStoragevehicle_type();
|
||||
vehicle_type = vehicleDto.getVehicle_type();
|
||||
} else {
|
||||
// 不为空说明不是货梯业务:则根据工单找到对应类型
|
||||
JSONObject jsonOrder = orderTab.query("device_id = '" + deviceDto.getDevice_id() + "' and order_status = '02' and is_delete = '0'").uniqueResult(0);
|
||||
|
||||
Reference in New Issue
Block a user