15 changed files with 651 additions and 3 deletions
@ -0,0 +1,77 @@ |
|||
package org.nl.wms.pda.ios_manage.controller; |
|||
|
|||
|
|||
import cn.dev33.satoken.annotation.SaIgnore; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.common.logging.annotation.Log; |
|||
import org.nl.wms.pda.ios_manage.service.PdaIosInService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* <p> |
|||
* 手持入库确认 控制层 |
|||
* </p> |
|||
* |
|||
* @author Liuxy |
|||
* @since 2025-06-05 |
|||
*/ |
|||
@RestController |
|||
@RequiredArgsConstructor |
|||
@RequestMapping("/api/pda/iosIn") |
|||
@Slf4j |
|||
public class PdaIosInController { |
|||
|
|||
@Autowired |
|||
private PdaIosInService pdaIosInService; |
|||
|
|||
@PostMapping("/sweepCode") |
|||
@Log("扫码解析") |
|||
@SaIgnore |
|||
public ResponseEntity<Object> sweepCode(@RequestBody JSONObject whereJson) { |
|||
return new ResponseEntity<>(pdaIosInService.sweepCode(whereJson),HttpStatus.OK); |
|||
} |
|||
|
|||
@PostMapping("/groupPlate") |
|||
@Log("组盘") |
|||
@SaIgnore |
|||
public ResponseEntity<Object> groupPlate(@RequestBody JSONObject whereJson) { |
|||
return new ResponseEntity<>(pdaIosInService.groupPlate(whereJson),HttpStatus.OK); |
|||
} |
|||
|
|||
@PostMapping("/getPlateDtl") |
|||
@Log("查询明细") |
|||
@SaIgnore |
|||
public ResponseEntity<Object> getPlateDtl(@RequestBody JSONObject whereJson) { |
|||
return new ResponseEntity<>(pdaIosInService.getPlateDtl(whereJson),HttpStatus.OK); |
|||
} |
|||
|
|||
@PostMapping("/deleteDtl") |
|||
@Log("删除明细") |
|||
@SaIgnore |
|||
public ResponseEntity<Object> deleteDtl(@RequestBody JSONObject whereJson) { |
|||
return new ResponseEntity<>(pdaIosInService.deleteDtl(whereJson),HttpStatus.OK); |
|||
} |
|||
|
|||
@PostMapping("/getSect") |
|||
@Log("获取库区") |
|||
@SaIgnore |
|||
public ResponseEntity<Object> getSect() { |
|||
return new ResponseEntity<>(pdaIosInService.getSect(),HttpStatus.OK); |
|||
} |
|||
|
|||
@PostMapping("/confirmIn") |
|||
@Log("入库确认") |
|||
@SaIgnore |
|||
public ResponseEntity<Object> confirmIn(@RequestBody JSONObject whereJson) { |
|||
return new ResponseEntity<>(pdaIosInService.confirmIn(whereJson),HttpStatus.OK); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,74 @@ |
|||
package org.nl.wms.pda.ios_manage.service; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import org.nl.wms.pda.util.PdaResponse; |
|||
|
|||
/** |
|||
* <p> |
|||
* 手持IOS 服务类 |
|||
* </p> |
|||
* |
|||
* @author Liuxy |
|||
* @since 2025-06-05 |
|||
*/ |
|||
public interface PdaIosInService { |
|||
|
|||
/** |
|||
* |
|||
* @param whereJson { |
|||
* code: 二维码内容 |
|||
* } |
|||
* @return PdaResponse |
|||
*/ |
|||
PdaResponse sweepCode(JSONObject whereJson); |
|||
|
|||
/** |
|||
* 组盘 |
|||
* @param whereJson { |
|||
* storagevehicle_code: 载具编码 |
|||
* group_id: 组盘记录id |
|||
* } |
|||
* @return PdaResponse |
|||
*/ |
|||
PdaResponse groupPlate(JSONObject whereJson); |
|||
|
|||
/** |
|||
* 查询明细 |
|||
* @param whereJson { |
|||
* storagevehicle_code : 载具编码 |
|||
* } |
|||
* @return PdaResponse |
|||
*/ |
|||
PdaResponse getPlateDtl(JSONObject whereJson); |
|||
|
|||
/** |
|||
* 删除明细 |
|||
* @param whereJson { |
|||
* group_id: 组盘标识 |
|||
* material_code: 物料编码 |
|||
* material_name: 物料名称 |
|||
* pcsn: 批次 |
|||
* qty: 数量 |
|||
* qty_unit_name: 单位 |
|||
* } |
|||
* @return PdaResponse |
|||
*/ |
|||
PdaResponse deleteDtl(JSONObject whereJson); |
|||
|
|||
/** |
|||
* 查询库区 |
|||
* @return PdaResponse |
|||
*/ |
|||
PdaResponse getSect(); |
|||
|
|||
/** |
|||
* 入库确认 |
|||
* @param whereJson { |
|||
* storagevehicle_code:载具编码 |
|||
* point_code:点位编码 |
|||
* sect_id:库区 |
|||
* } |
|||
* @return |
|||
*/ |
|||
PdaResponse confirmIn(JSONObject whereJson); |
|||
} |
@ -0,0 +1,348 @@ |
|||
package org.nl.wms.pda.ios_manage.service.impl; |
|||
|
|||
import cn.hutool.core.date.DateUtil; |
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import org.nl.common.exception.BadRequestException; |
|||
import org.nl.common.utils.IdUtil; |
|||
import org.nl.common.utils.SecurityUtils; |
|||
import org.nl.wms.basedata_manage.service.IMdMeMaterialbaseService; |
|||
import org.nl.wms.basedata_manage.service.IMdPbMeasureunitService; |
|||
import org.nl.wms.basedata_manage.service.IMdPbStoragevehicleinfoService; |
|||
import org.nl.wms.basedata_manage.service.ISectattrService; |
|||
import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase; |
|||
import org.nl.wms.basedata_manage.service.dao.MdPbMeasureunit; |
|||
import org.nl.wms.basedata_manage.service.dao.MdPbStoragevehicleinfo; |
|||
import org.nl.wms.basedata_manage.service.dao.Sectattr; |
|||
import org.nl.wms.pda.ios_manage.service.PdaIosInService; |
|||
import org.nl.wms.pda.util.PdaResponse; |
|||
import org.nl.wms.warehouse_management.enums.IOSConstant; |
|||
import org.nl.wms.warehouse_management.enums.IOSEnum; |
|||
import org.nl.wms.warehouse_management.service.IMdPbGroupplateService; |
|||
import org.nl.wms.warehouse_management.service.IRawAssistIStorService; |
|||
import org.nl.wms.warehouse_management.service.dao.GroupPlate; |
|||
import org.nl.wms.warehouse_management.service.dao.IOStorInvDtl; |
|||
import org.nl.wms.warehouse_management.service.dao.mapper.IOStorInvDtlMapper; |
|||
import org.nl.wms.warehouse_management.service.dao.mapper.MdPbGroupplateMapper; |
|||
import org.nl.wms.warehouse_management.service.dto.IOStorInvDisDto; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.*; |
|||
|
|||
/** |
|||
* <p> |
|||
* 手持IOS 实现类 |
|||
* </p> |
|||
* |
|||
* @author Liuxy |
|||
* @since 2025-06-05 |
|||
*/ |
|||
@Service |
|||
public class PdaIosInServiceImpl implements PdaIosInService { |
|||
|
|||
/** |
|||
* 组盘记录mapper |
|||
*/ |
|||
@Autowired |
|||
private MdPbGroupplateMapper mdPbGroupplateMapper; |
|||
|
|||
/** |
|||
* 组盘记录服务 |
|||
*/ |
|||
@Autowired |
|||
private IMdPbGroupplateService iMdPbGroupplateService; |
|||
|
|||
/** |
|||
* 基础物料服务 |
|||
*/ |
|||
@Autowired |
|||
private IMdMeMaterialbaseService iMdMeMaterialbaseService; |
|||
|
|||
/** |
|||
* 计量单位服务 |
|||
*/ |
|||
@Autowired |
|||
private IMdPbMeasureunitService iMdPbMeasureunitService; |
|||
|
|||
/** |
|||
* 载具服务 |
|||
*/ |
|||
@Autowired |
|||
private IMdPbStoragevehicleinfoService iMdPbStoragevehicleinfoService; |
|||
|
|||
/** |
|||
* 库区服务 |
|||
*/ |
|||
@Autowired |
|||
private ISectattrService iSectattrService; |
|||
|
|||
/** |
|||
* 入库服务 |
|||
*/ |
|||
@Autowired |
|||
private IRawAssistIStorService iRawAssistIStorService; |
|||
|
|||
/** |
|||
* 入库明细服务 |
|||
*/ |
|||
@Autowired |
|||
private IOStorInvDtlMapper ioStorInvDtlMapper; |
|||
|
|||
@Override |
|||
@Transactional |
|||
public PdaResponse sweepCode(JSONObject whereJson) { |
|||
// 解析二维码内容:"wl0001##pc050401##1000##kg##dj000001##01"
|
|||
String code = whereJson.getString("code"); |
|||
String[] split = code.split("##"); |
|||
// 物料编码
|
|||
String material_code = split[0]; |
|||
// 批次
|
|||
String pcsn = split[1]; |
|||
// 数量
|
|||
String qty = split[2]; |
|||
// 计量单位
|
|||
String unit_code = split[3]; |
|||
// 单据号
|
|||
String ext_code = split[4]; |
|||
// 业务类型
|
|||
String ext_type = split[5]; |
|||
|
|||
// 校验
|
|||
MdMeMaterialbase materDao = iMdMeMaterialbaseService.getByCode(material_code); |
|||
MdPbMeasureunit unitDao = iMdPbMeasureunitService.getByCode(unit_code); |
|||
GroupPlate groupDao = iMdPbGroupplateService.getOne( |
|||
new QueryWrapper<GroupPlate>().lambda() |
|||
.eq(GroupPlate::getMaterial_id, materDao.getMaterial_id()) |
|||
.eq(GroupPlate::getPcsn, pcsn) |
|||
.eq(GroupPlate::getQty, qty) |
|||
.eq(GroupPlate::getQty_unit_id, unitDao.getMeasure_unit_id()) |
|||
.eq(GroupPlate::getExt_code, ext_code) |
|||
.eq(GroupPlate::getExt_type, ext_type) |
|||
.eq(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("生成")) |
|||
); |
|||
|
|||
if (ObjectUtil.isEmpty(groupDao)) { |
|||
// 插入组盘记录表
|
|||
groupDao = new GroupPlate(); |
|||
groupDao.setGroup_id(IdUtil.getStringId()); |
|||
groupDao.setMaterial_id(materDao.getMaterial_id()); |
|||
groupDao.setPcsn(pcsn); |
|||
groupDao.setQty_unit_id(unitDao.getMeasure_unit_id()); |
|||
groupDao.setQty_unit_name(unitDao.getUnit_name()); |
|||
groupDao.setQty(BigDecimal.valueOf(Double.parseDouble(qty))); |
|||
groupDao.setStatus(IOSEnum.GROUP_PLATE_STATUS.code("生成")); |
|||
groupDao.setExt_code(ext_code); |
|||
groupDao.setExt_type(ext_type); |
|||
groupDao.setCreate_id(SecurityUtils.getCurrentUserId()); |
|||
groupDao.setCreate_name(SecurityUtils.getCurrentUsername()); |
|||
groupDao.setCreate_time(DateUtil.now()); |
|||
iMdPbGroupplateService.save(groupDao); |
|||
} |
|||
|
|||
// 组织返回数据
|
|||
JSONObject result = new JSONObject(); |
|||
result.put("group_id", groupDao.getGroup_id()); |
|||
result.put("material_code", material_code); |
|||
result.put("pcsn", pcsn); |
|||
result.put("qty", qty); |
|||
result.put("qty_unit_name", unitDao.getUnit_name()); |
|||
return PdaResponse.requestParamOk(result); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional |
|||
public PdaResponse groupPlate(JSONObject whereJson) { |
|||
// 校验载具
|
|||
MdPbStoragevehicleinfo vehicleDao = iMdPbStoragevehicleinfoService.getByCode(whereJson.getString("storagevehicle_code")); |
|||
// 校验组盘记录
|
|||
GroupPlate groupDao = iMdPbGroupplateService.getById(whereJson.getString("group_id")); |
|||
if (!groupDao.getStatus().equals(IOSEnum.GROUP_PLATE_STATUS.code("生成"))) { |
|||
throw new BadRequestException("当前组盘记录不为生成状态!【"+whereJson.getString("group_id")+"】"); |
|||
} |
|||
// 校验组盘物料批次是否一样
|
|||
List<GroupPlate> plateDaoList = iMdPbGroupplateService.list( |
|||
new QueryWrapper<GroupPlate>().lambda() |
|||
.eq(GroupPlate::getStoragevehicle_code, whereJson.getString("storagevehicle_code")) |
|||
.eq(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("组盘")) |
|||
); |
|||
if (ObjectUtil.isNotEmpty(plateDaoList)) { |
|||
boolean is_like = plateDaoList.stream() |
|||
.allMatch(row -> row.getMaterial_id().equals(groupDao.getMaterial_id()) && |
|||
row.getPcsn().equals(groupDao.getPcsn()) |
|||
); |
|||
if (!is_like) { |
|||
throw new BadRequestException("当前托盘所绑物料批次与当前组盘物料批次不一致!"); |
|||
} |
|||
} |
|||
|
|||
// 更新数据
|
|||
groupDao.setStoragevehicle_code(vehicleDao.getStoragevehicle_code()); |
|||
groupDao.setStatus(IOSEnum.GROUP_PLATE_STATUS.code("组盘")); |
|||
iMdPbGroupplateService.updateById(groupDao); |
|||
return PdaResponse.requestOk(); |
|||
} |
|||
|
|||
@Override |
|||
public PdaResponse getPlateDtl(JSONObject whereJson) { |
|||
return PdaResponse.requestParamOk(mdPbGroupplateMapper.getDtl(whereJson)); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional |
|||
public PdaResponse deleteDtl(JSONObject whereJson) { |
|||
iMdPbGroupplateService.removeById(whereJson.getString("group_id")); |
|||
return PdaResponse.requestOk(); |
|||
} |
|||
|
|||
@Override |
|||
public PdaResponse getSect() { |
|||
List<Sectattr> sectList = iSectattrService.list( |
|||
new QueryWrapper<Sectattr>().lambda() |
|||
.eq(Sectattr::getIs_delete, IOSConstant.IS_DELETE_NO) |
|||
.eq(Sectattr::getIs_used, IOSConstant.IS_DELETE_YES) |
|||
); |
|||
return PdaResponse.requestParamOk(sectList); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional |
|||
public PdaResponse confirmIn(JSONObject whereJson) { |
|||
// 组织新增数据
|
|||
Map<String, Object> jsonMst = organizeInsertData(whereJson); |
|||
// 调用服务新增数据
|
|||
String iostorinv_id = iRawAssistIStorService.insertDtl(jsonMst); |
|||
// 组织分配数据
|
|||
whereJson.put("iostorinv_id",iostorinv_id); |
|||
Map<String, Object> jsonDtl = organizeDivData(whereJson); |
|||
// 调用分配
|
|||
iRawAssistIStorService.divStruct(jsonDtl); |
|||
// 下发任务
|
|||
sendTask(whereJson); |
|||
return PdaResponse.requestOk(); |
|||
} |
|||
|
|||
/** |
|||
* 组织入库插入数据 |
|||
* @param whereJson { |
|||
* storagevehicle_code:载具编码 |
|||
* point_code:点位编码 |
|||
* sect_id:库区 |
|||
* } |
|||
* @return Map<String, Object> |
|||
*/ |
|||
private Map<String, Object> organizeInsertData(JSONObject whereJson) { |
|||
// 查询组盘明细
|
|||
List<GroupPlate> plateDaoList = iMdPbGroupplateService.list( |
|||
new QueryWrapper<GroupPlate>().lambda() |
|||
.eq(GroupPlate::getStoragevehicle_code, whereJson.getString("storagevehicle_code")) |
|||
.eq(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("组盘")) |
|||
); |
|||
if (ObjectUtil.isEmpty(plateDaoList)) { |
|||
throw new BadRequestException("当前没有可入库的物料!"); |
|||
} |
|||
// 总数量
|
|||
Double total_qty = plateDaoList.stream() |
|||
.map(row -> row.getQty().doubleValue()) |
|||
.reduce(Double::sum).orElse(0.0); |
|||
|
|||
// 查询库区
|
|||
Sectattr sectDao = iSectattrService.getById(whereJson.getString("sect_id")); |
|||
// 组织主表数据
|
|||
Map<String, Object> jsonMst = new HashMap<>(); |
|||
jsonMst.put("stor_id", sectDao.getStor_id()); |
|||
jsonMst.put("bill_status", IOSEnum.BILL_STATUS.code("生成")); |
|||
jsonMst.put("total_qty", total_qty); |
|||
jsonMst.put("detail_count", 1); |
|||
jsonMst.put("bill_type", IOSEnum.BILL_TYPE.code("生产入库")); |
|||
jsonMst.put("biz_date", DateUtil.now()); |
|||
// 组织明细数据
|
|||
ArrayList<HashMap> tableData = new ArrayList<>(); |
|||
HashMap<String, String> dtl = new HashMap<>(); |
|||
GroupPlate plateDao = plateDaoList.get(0); |
|||
dtl.put("storagevehicle_code", plateDao.getStoragevehicle_code()); |
|||
dtl.put("material_id", plateDao.getMaterial_id()); |
|||
dtl.put("pcsn", plateDao.getPcsn()); |
|||
dtl.put("qty_unit_id", plateDao.getQty_unit_id()); |
|||
dtl.put("qty_unit_name", plateDao.getQty_unit_name()); |
|||
dtl.put("qty", String.valueOf(total_qty)); |
|||
MdMeMaterialbase materDao = iMdMeMaterialbaseService.getById(plateDao.getMaterial_id()); |
|||
dtl.put("material_code", materDao.getMaterial_code()); |
|||
dtl.put("material_name", materDao.getMaterial_name()); |
|||
dtl.put("plan_qty", String.valueOf(total_qty)); |
|||
// 调用新增
|
|||
tableData.add(dtl); |
|||
jsonMst.put("tableData",tableData); |
|||
return jsonMst; |
|||
} |
|||
|
|||
/** |
|||
* 组织分配数据 |
|||
* @param whereJson { |
|||
* iostorinv_id |
|||
* sect_id |
|||
* } |
|||
* @return Map<String, Object> |
|||
*/ |
|||
private Map<String, Object> organizeDivData(JSONObject whereJson) { |
|||
// 查询库区
|
|||
Sectattr sectDao = iSectattrService.getById(whereJson.getString("sect_id")); |
|||
// 组织主数据
|
|||
Map<String, Object> jsonMst = new HashMap<>(); |
|||
jsonMst.put("checked", true); |
|||
jsonMst.put("sect_id", sectDao.getSect_id()); |
|||
jsonMst.put("stor_id", sectDao.getStor_id()); |
|||
// 组织明细数据
|
|||
IOStorInvDtl dtlDao = ioStorInvDtlMapper.selectOne( |
|||
new QueryWrapper<IOStorInvDtl>().lambda() |
|||
.eq(IOStorInvDtl::getIostorinv_id, whereJson.getString("iostorinv_id")) |
|||
); |
|||
// 查找分配明细
|
|||
Map<String, Object> map = new HashMap<>(); |
|||
map.put("iostorinvdtl_id",dtlDao.getIostorinvdtl_id()); |
|||
List<IOStorInvDisDto> disDtl = iRawAssistIStorService.getDisDtl(map); |
|||
// 类型转换
|
|||
ArrayList<LinkedHashMap> tableMater = new ArrayList<>(); |
|||
disDtl.forEach(item -> { |
|||
tableMater.add(JSONObject.parseObject(JSONObject.toJSONString(item), LinkedHashMap.class)); |
|||
}); |
|||
jsonMst.put("tableMater", tableMater); |
|||
|
|||
return jsonMst; |
|||
} |
|||
|
|||
/** |
|||
* 下发任务 |
|||
* @param whereJson { |
|||
* storagevehicle_code:载具编码 |
|||
* point_code:点位编码 |
|||
* sect_id:库区 |
|||
* iostorinv_id: id |
|||
* } |
|||
*/ |
|||
private void sendTask(JSONObject whereJson) { |
|||
// 组织主数据
|
|||
Map<String, Object> jsonMst = new HashMap<>(); |
|||
jsonMst.put("point_code", whereJson.getString("point_code")); |
|||
// 组织明细数据
|
|||
IOStorInvDtl dtlDao = ioStorInvDtlMapper.selectOne( |
|||
new QueryWrapper<IOStorInvDtl>().lambda() |
|||
.eq(IOStorInvDtl::getIostorinv_id, whereJson.getString("iostorinv_id")) |
|||
); |
|||
// 查找分配明细
|
|||
Map<String, Object> map = new HashMap<>(); |
|||
map.put("iostorinvdtl_id",dtlDao.getIostorinvdtl_id()); |
|||
List<IOStorInvDisDto> disDtl = iRawAssistIStorService.getDisDtl(map); |
|||
// 类型转换
|
|||
ArrayList<LinkedHashMap> tableMater = new ArrayList<>(); |
|||
disDtl.forEach(item -> { |
|||
tableMater.add(JSONObject.parseObject(JSONObject.toJSONString(item), LinkedHashMap.class)); |
|||
}); |
|||
jsonMst.put("tableMater", tableMater); |
|||
|
|||
iRawAssistIStorService.divPoint(jsonMst); |
|||
} |
|||
} |
@ -0,0 +1,50 @@ |
|||
package org.nl.wms.pda.util; |
|||
|
|||
import lombok.Builder; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* <p> |
|||
* 手持 返回结果 |
|||
* </p> |
|||
* |
|||
* @author Liuxy |
|||
* @since 2025-06-05 |
|||
*/ |
|||
@Data |
|||
@Builder |
|||
public class PdaResponse<T> { |
|||
|
|||
/** |
|||
* 信息 |
|||
*/ |
|||
private String message; |
|||
|
|||
/** |
|||
* 返回数据 |
|||
*/ |
|||
private T data; |
|||
|
|||
/** |
|||
* 不带数据反馈 |
|||
* @return ErpResponse |
|||
*/ |
|||
public static PdaResponse requestOk() { |
|||
return PdaResponse.builder() |
|||
.message("操作成功!") |
|||
.build(); |
|||
} |
|||
|
|||
/** |
|||
* 带数据反馈 |
|||
* @return ErpResponse |
|||
*/ |
|||
public static <T> PdaResponse requestParamOk(T data) { |
|||
return PdaResponse.builder() |
|||
.message("操作成功!") |
|||
.data(data) |
|||
.build(); |
|||
} |
|||
|
|||
} |
|||
|
Loading…
Reference in new issue