组盘
This commit is contained in:
@@ -71,4 +71,11 @@ public class VehicleController {
|
||||
JSONObject json = mdPbVehicleService.getVehicle(code);
|
||||
return new ResponseEntity<>(json,HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/getVehicleByType")
|
||||
@Log("选择载具")
|
||||
@ApiOperation("选择载具")
|
||||
public ResponseEntity<Object> getVehicleByType(@RequestParam Map whereJson, Pageable page) {
|
||||
return new ResponseEntity<>(mdPbVehicleService.getVehicleByType(whereJson,page),HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,4 +68,11 @@ public interface VehicleService {
|
||||
*/
|
||||
JSONObject getVehicle(String code);
|
||||
|
||||
/**
|
||||
* 组盘信息选择载具查询
|
||||
* @param whereJson
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
Map<String,Object> getVehicleByType(Map whereJson, Pageable page);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.nl.wms.database.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;
|
||||
@@ -11,6 +12,7 @@ import org.nl.modules.system.util.CodeUtil;
|
||||
import org.nl.wms.database.service.VehicleService;
|
||||
import org.nl.wms.database.service.dto.VehicleDto;
|
||||
import org.nl.wql.WQL;
|
||||
import org.nl.wql.core.bean.ResultBean;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -241,5 +243,19 @@ public class MdPbVehicleServiceImpl implements VehicleService {
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getVehicleByType(Map whereJson, Pageable page) {
|
||||
String where = "";
|
||||
WQLObject wo = WQLObject.getWQLObject("md_pb_vehicle");
|
||||
String search = MapUtil.getStr(whereJson, "search");
|
||||
if (!StrUtil.isEmpty(search)) {
|
||||
where = " AND (vehicle_code like '%" + search + "%' OR vehicle_name like '%" + search + "%' ) ";
|
||||
}
|
||||
ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "is_delete= '0' " + where + " AND vehicle_type = '02'" , "update_time desc");
|
||||
final JSONObject json = rb.pageResult();
|
||||
if (json.isEmpty()) return null; // 空值定义
|
||||
return json;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package org.nl.wms.st.buss.rest;
|
||||
|
||||
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.database.service.dto.MaterialDto;
|
||||
import org.nl.wms.st.buss.service.VehicleGroupService;
|
||||
import org.nl.wms.st.buss.service.dto.VehicleGrouplDto;
|
||||
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: lyd
|
||||
* @Description:
|
||||
* @Date: 2022-07-07 10:33
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "组盘管理")
|
||||
@RequestMapping("/api/stBussVehicleGroup")
|
||||
@Slf4j
|
||||
public class VehicleGroupController {
|
||||
|
||||
private final VehicleGroupService vehicleGroupService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询组盘")
|
||||
@ApiOperation("查询组盘")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page){
|
||||
return new ResponseEntity<>(vehicleGroupService.queryAll(whereJson,page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增组盘")
|
||||
@ApiOperation("新增组盘")
|
||||
//@PreAuthorize("@el.check('mdMeMaterial:add')")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody VehicleGrouplDto dto){
|
||||
log.info("dto:{}",dto);
|
||||
System.out.println(dto.toString());
|
||||
vehicleGroupService.create(dto);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改组盘")
|
||||
@ApiOperation("修改组盘")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody VehicleGrouplDto dto){
|
||||
vehicleGroupService.update(dto);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("删除组盘")
|
||||
@ApiOperation("删除组盘")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestBody Long[] ids) {
|
||||
vehicleGroupService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package org.nl.wms.st.buss.service;
|
||||
|
||||
import org.nl.wms.database.service.dto.MaterialDto;
|
||||
import org.nl.wms.st.buss.service.dto.VehicleGrouplDto;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description: 组盘信息服务接口
|
||||
* @Date: 2022-07-07 10:35
|
||||
*/
|
||||
public interface VehicleGroupService {
|
||||
/**
|
||||
* 添加组盘信息
|
||||
* @param dto
|
||||
*/
|
||||
void create(VehicleGrouplDto dto);
|
||||
|
||||
/**
|
||||
* 分页获取组盘数据
|
||||
* @param whereJson
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> queryAll(Map whereJson, Pageable page);
|
||||
|
||||
/**
|
||||
* 修改组盘数据
|
||||
* @param dto
|
||||
*/
|
||||
void update(VehicleGrouplDto dto);
|
||||
|
||||
/**
|
||||
* 根据id查找对象
|
||||
* @param group_id
|
||||
* @return
|
||||
*/
|
||||
VehicleGrouplDto findById(Long group_id);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param ids
|
||||
*/
|
||||
void deleteAll(Long[] ids);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package org.nl.wms.st.buss.service.dto;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description:
|
||||
* @Date: 2022-07-07 10:37
|
||||
*/
|
||||
@Data
|
||||
public class VehicleGrouplDto implements Serializable {
|
||||
/**
|
||||
* 防止精度丢失
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long group_id;
|
||||
|
||||
/**
|
||||
* 载具编码
|
||||
*/
|
||||
private String vehicle_code;
|
||||
|
||||
/**
|
||||
* 物料id
|
||||
*/
|
||||
private Long material_id;
|
||||
|
||||
/**
|
||||
* 物料编码
|
||||
*/
|
||||
private String material_code;
|
||||
|
||||
/**
|
||||
* 物料名
|
||||
*/
|
||||
private String material_name;
|
||||
|
||||
/**
|
||||
* 批次
|
||||
*/
|
||||
private String pcsn;
|
||||
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
private BigDecimal qty;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private Long create_id;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String create_name;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String create_time;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package org.nl.wms.st.buss.service.impl;
|
||||
|
||||
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.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.exception.BadRequestException;
|
||||
import org.nl.utils.SecurityUtils;
|
||||
import org.nl.wms.database.service.dto.MaterialDto;
|
||||
import org.nl.wms.st.buss.service.VehicleGroupService;
|
||||
import org.nl.wms.st.buss.service.dto.VehicleGrouplDto;
|
||||
import org.nl.wql.core.bean.ResultBean;
|
||||
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.Map;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description: 组盘管理实现类
|
||||
* @Date: 2022-07-07 10:35
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class VehicleGroupServiceImpl implements VehicleGroupService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(VehicleGrouplDto dto) {
|
||||
//获取当前用户信息以及时间
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getNickName();
|
||||
String now = DateUtil.now();
|
||||
|
||||
//赋值准备参数
|
||||
dto.setCreate_id(currentUserId);
|
||||
dto.setCreate_name(nickName);
|
||||
dto.setCreate_time(now);
|
||||
dto.setGroup_id(IdUtil.getSnowflake(1, 1).nextId());
|
||||
//获取表对象
|
||||
WQLObject st_buss_vehiclegroup = WQLObject.getWQLObject("st_buss_vehiclegroup");
|
||||
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(dto));
|
||||
st_buss_vehiclegroup.insert(jsonObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
||||
WQLObject wo = WQLObject.getWQLObject("st_buss_vehiclegroup");
|
||||
String name = (String) whereJson.get("name");
|
||||
String sql = "1=1";
|
||||
if (StrUtil.isNotEmpty(name)) {
|
||||
sql = " (vehicle_code like '%"+name+"%')";
|
||||
}
|
||||
ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), sql + " and is_delete='0'", "create_time desc");
|
||||
final JSONObject json = rb.pageResult();
|
||||
log.info("json:{}",json);
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(VehicleGrouplDto dto) {
|
||||
System.out.println(dto);
|
||||
//判断你是否存在
|
||||
VehicleGrouplDto vg = this.findById(dto.getGroup_id());
|
||||
if (vg == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
WQLObject wo = WQLObject.getWQLObject("st_buss_vehiclegroup");
|
||||
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
|
||||
wo.update(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VehicleGrouplDto findById(Long group_id) {
|
||||
WQLObject wo = WQLObject.getWQLObject("st_buss_vehiclegroup");
|
||||
JSONObject json = wo.query("group_id = '" + group_id + "' and is_delete='0'").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(json)) {
|
||||
return json.toJavaObject(VehicleGrouplDto.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(Long[] ids) {
|
||||
WQLObject wo = WQLObject.getWQLObject("st_buss_vehiclegroup");
|
||||
for (Long group_id : ids) {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("group_id", String.valueOf(group_id));
|
||||
param.put("is_delete", "1");
|
||||
wo.update(param);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user