add:出入库回传
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package org.nl.wms.ext.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* WMS调用ERP 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Liuxy
|
||||
* @since 2025-06-03
|
||||
*/
|
||||
public interface WmsToErpService {
|
||||
|
||||
/**
|
||||
* 出入库单据回传
|
||||
* @param whereJson {
|
||||
* data: []
|
||||
* }
|
||||
* @return JSONObject {
|
||||
* status: 200 / !=200
|
||||
* message: 信息
|
||||
* }
|
||||
*/
|
||||
JSONObject uploadErp(JSONObject whereJson);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.nl.wms.ext.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.system.service.param.impl.SysParamServiceImpl;
|
||||
import org.nl.wms.ext.service.WmsToErpService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* WMS调用ERP 实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Liuxy
|
||||
* @since 2025-06-03
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class WmsToErpServiceImpl implements WmsToErpService {
|
||||
|
||||
@Override
|
||||
public JSONObject uploadErp(JSONObject whereJson) {
|
||||
log.info("uploadErp接口输入参数为:-------------------" + whereJson.toString());
|
||||
JSONObject result = new JSONObject();
|
||||
|
||||
String url = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("ERP_URL").getValue();
|
||||
String api = "CamstarApi/MomRollBakeInBound";
|
||||
url = url + api;
|
||||
|
||||
try {
|
||||
String resultMsg = HttpRequest.post(url)
|
||||
.body(String.valueOf(whereJson))
|
||||
.execute().body();
|
||||
result = JSONObject.parseObject(resultMsg);
|
||||
log.info("uploadErp接口输出参数为:-------------------" + result.toString());
|
||||
|
||||
|
||||
Integer status = result.getInteger("status");
|
||||
if (status != HttpStatus.OK.value()) {
|
||||
throw new BadRequestException(result.getString("message"));
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("ERP提示错误:" + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package org.nl.wms.warehouse_management.controller;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.base.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.wms.warehouse_management.service.ReturnService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 出入库回传 控制层
|
||||
* </p>
|
||||
*
|
||||
* @author Liuxy
|
||||
* @since 2025-06-03
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/iosReturn")
|
||||
@Slf4j
|
||||
public class ReturnController {
|
||||
|
||||
@Autowired
|
||||
private ReturnService returnService;
|
||||
|
||||
@GetMapping
|
||||
@Log("查询出入库单")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page) {
|
||||
return new ResponseEntity<>(TableDataInfo.build(returnService.queryAll(whereJson, page)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/upload")
|
||||
@Log("回传")
|
||||
public ResponseEntity<Object> upload(@RequestBody JSONObject whereJson) {
|
||||
returnService.upload(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/disupload")
|
||||
@Log("不回传")
|
||||
public ResponseEntity<Object> disupload(@RequestBody JSONObject whereJson) {
|
||||
returnService.disupload(whereJson);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package org.nl.wms.warehouse_management.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.wms.warehouse_management.service.dao.IOStorInv;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 出入库回传 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Liuxy
|
||||
* @since 2025-06-03
|
||||
*/
|
||||
public interface ReturnService extends IService<IOStorInv> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param whereJson : {查询参数}
|
||||
* @param page : 分页对象
|
||||
* @return 返回结果
|
||||
*/
|
||||
IPage<IOStorInv> queryAll(Map whereJson, PageQuery page);
|
||||
|
||||
/**
|
||||
* 回传
|
||||
* @param whereJson {
|
||||
* rows: []
|
||||
* }
|
||||
*/
|
||||
void upload(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 不回传
|
||||
* @param whereJson {
|
||||
* rows: []
|
||||
* }
|
||||
*/
|
||||
void disupload(JSONObject whereJson);
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
package org.nl.wms.warehouse_management.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.wms.basedata_manage.enums.BaseDataEnum;
|
||||
import org.nl.wms.basedata_manage.service.IMdMeMaterialbaseService;
|
||||
import org.nl.wms.basedata_manage.service.IMdPbMeasureunitService;
|
||||
import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
|
||||
import org.nl.wms.basedata_manage.service.dao.MdPbMeasureunit;
|
||||
import org.nl.wms.ext.service.WmsToErpService;
|
||||
import org.nl.wms.warehouse_management.enums.IOSConstant;
|
||||
import org.nl.wms.warehouse_management.enums.IOSEnum;
|
||||
import org.nl.wms.warehouse_management.service.ReturnService;
|
||||
import org.nl.wms.warehouse_management.service.dao.IOStorInv;
|
||||
import org.nl.wms.warehouse_management.service.dao.IOStorInvDis;
|
||||
import org.nl.wms.warehouse_management.service.dao.mapper.IOStorInvDisMapper;
|
||||
import org.nl.wms.warehouse_management.service.dao.mapper.IOStorInvMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 出入库回传 实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Liuxy
|
||||
* @since 2025-06-03
|
||||
*/
|
||||
@Service
|
||||
public class RetrunServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> implements ReturnService {
|
||||
|
||||
/**
|
||||
* 出入库mapper服务
|
||||
*/
|
||||
@Autowired
|
||||
private IOStorInvDisMapper ioStorInvDisMapper;
|
||||
|
||||
/**
|
||||
* 物料基础服务
|
||||
*/
|
||||
@Autowired
|
||||
private IMdMeMaterialbaseService iMdMeMaterialbaseService;
|
||||
|
||||
/**
|
||||
* 计量单位服务
|
||||
*/
|
||||
@Autowired
|
||||
private IMdPbMeasureunitService iMdPbMeasureunitService;
|
||||
|
||||
/**
|
||||
* WMS调用ERP服务类
|
||||
*/
|
||||
@Autowired
|
||||
private WmsToErpService wmsToErpService;
|
||||
|
||||
@Override
|
||||
public IPage<IOStorInv> queryAll(Map whereJson, PageQuery page) {
|
||||
String stor_id = MapUtil.getStr(whereJson, "stor_id");
|
||||
String io_type = MapUtil.getStr(whereJson, "io_type");
|
||||
String bill_type = MapUtil.getStr(whereJson, "bill_type");
|
||||
String bill_code = MapUtil.getStr(whereJson, "bill_code");
|
||||
String is_upload = MapUtil.getStr(whereJson, "is_upload");
|
||||
String begin_time = MapUtil.getStr(whereJson, "begin_time");
|
||||
String end_time = MapUtil.getStr(whereJson, "end_time");
|
||||
|
||||
LambdaQueryWrapper<IOStorInv> lambda = new QueryWrapper<IOStorInv>().lambda();
|
||||
lambda.eq(ObjectUtil.isNotEmpty(stor_id), IOStorInv::getStor_id, stor_id);
|
||||
lambda.eq(ObjectUtil.isNotEmpty(io_type), IOStorInv::getIo_type, io_type);
|
||||
lambda.eq(ObjectUtil.isNotEmpty(bill_type), IOStorInv::getBill_type, bill_type);
|
||||
lambda.like(ObjectUtil.isNotEmpty(bill_code), IOStorInv::getBill_code, bill_code);
|
||||
lambda.eq(ObjectUtil.isNotEmpty(is_upload), IOStorInv::getIs_upload, is_upload);
|
||||
lambda.ge(ObjectUtil.isNotEmpty(begin_time), IOStorInv::getInput_time, begin_time);
|
||||
lambda.lt(ObjectUtil.isNotEmpty(end_time), IOStorInv::getInput_time, end_time);
|
||||
lambda.eq(IOStorInv::getIs_delete, BaseDataEnum.IS_YES_NOT.code("否"));
|
||||
lambda.eq(IOStorInv::getBill_status, IOSEnum.CHECK_MST_STATUS.code("完成"));
|
||||
lambda.orderByDesc(IOStorInv::getInput_time);
|
||||
return this.baseMapper.selectPage(new Page<>(page.getPage() + 1, page.getSize()),
|
||||
lambda
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upload(JSONObject whereJson) {
|
||||
List<JSONObject> rows = whereJson.getJSONArray("rows").toJavaList(JSONObject.class);
|
||||
// 根据主表id查询所有分配明细
|
||||
List<IOStorInvDis> iosDisList = ioStorInvDisMapper.selectList(
|
||||
new QueryWrapper<IOStorInvDis>().lambda()
|
||||
.in(IOStorInvDis::getIostorinv_id, rows.stream()
|
||||
.map(row -> row.getString("iostorinv_id"))
|
||||
.collect(Collectors.toList())
|
||||
)
|
||||
);
|
||||
// 查询所有物料
|
||||
List<MdMeMaterialbase> materList = iMdMeMaterialbaseService.list(
|
||||
new QueryWrapper<MdMeMaterialbase>().lambda()
|
||||
.in(MdMeMaterialbase::getMaterial_id, iosDisList.stream()
|
||||
.map(IOStorInvDis::getMaterial_id)
|
||||
.distinct()
|
||||
.collect(Collectors.toList())
|
||||
|
||||
)
|
||||
);
|
||||
// 查询所有计量单位
|
||||
List<MdPbMeasureunit> unitList = iMdPbMeasureunitService.list(
|
||||
new QueryWrapper<MdPbMeasureunit>().lambda()
|
||||
.in(MdPbMeasureunit::getMeasure_unit_id, iosDisList.stream()
|
||||
.map(IOStorInvDis::getQty_unit_id)
|
||||
.distinct()
|
||||
.collect(Collectors.toList()))
|
||||
);
|
||||
|
||||
// 需回传数据集合
|
||||
List<JSONObject> paramList = new ArrayList<>();
|
||||
for(IOStorInvDis disDao : iosDisList) {
|
||||
JSONObject param = new JSONObject();
|
||||
// 物料编码
|
||||
MdMeMaterialbase materDao = materList.stream()
|
||||
.filter(row -> row.getMaterial_id().equals(disDao.getMaterial_id()))
|
||||
.findFirst().orElse(null);
|
||||
param.put("mater_code", materDao.getExt_id());
|
||||
// 批次
|
||||
param.put("batch_no", disDao.getPcsn());
|
||||
// 数量
|
||||
param.put("quantity", disDao.getReal_qty());
|
||||
// 计量单位
|
||||
MdPbMeasureunit unitDao = unitList.stream()
|
||||
.filter(row -> row.getMeasure_unit_id().equals(disDao.getQty_unit_id()))
|
||||
.findFirst().orElse(null);
|
||||
param.put("unit_code", unitDao.getExt_id());
|
||||
// 仓库编码
|
||||
JSONObject jsonMst = rows.stream()
|
||||
.filter(row -> row.getString("iostorinv_id").equals(disDao.getIostorinv_id()))
|
||||
.findFirst().orElse(null);
|
||||
param.put("stor_code", jsonMst.getString("stor_code"));
|
||||
// 货位编码
|
||||
param.put("point_code", disDao.getStruct_code());
|
||||
// 载具编码
|
||||
param.put("pallet_code", disDao.getStoragevehicle_code());
|
||||
// 单据号
|
||||
param.put("inv_code", jsonMst.getString("bill_code"));
|
||||
// 业务类型
|
||||
param.put("task_type", jsonMst.getString("bill_type"));
|
||||
paramList.add(param);
|
||||
}
|
||||
JSONObject jsonParam = new JSONObject();
|
||||
jsonParam.put("data", paramList);
|
||||
wmsToErpService.uploadErp(jsonParam);
|
||||
|
||||
// 更新主表
|
||||
this.update(
|
||||
new UpdateWrapper<IOStorInv>().lambda()
|
||||
.in(IOStorInv::getIostorinv_id, rows.stream()
|
||||
.map(row -> row.getString("iostorinv_id"))
|
||||
.collect(Collectors.toList())
|
||||
)
|
||||
.set(IOStorInv::getIs_upload, IOSConstant.IS_DELETE_YES)
|
||||
.set(IOStorInv::getUpdate_optid, SecurityUtils.getCurrentUserId())
|
||||
.set(IOStorInv::getUpdate_optname, SecurityUtils.getCurrentNickName())
|
||||
.set(IOStorInv::getUpdate_time, DateUtil.now())
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void disupload(JSONObject whereJson) {
|
||||
List<JSONObject> rows = whereJson.getJSONArray("rows").toJavaList(JSONObject.class);
|
||||
List<String> idList = rows.stream()
|
||||
.map(row -> row.getString("iostorinv_id"))
|
||||
.collect(Collectors.toList());
|
||||
// 更新
|
||||
this.update(
|
||||
new UpdateWrapper<IOStorInv>().lambda()
|
||||
.in(IOStorInv::getIo_type, idList)
|
||||
.set(IOStorInv::getIs_upload, IOSConstant.IS_DELETE_YES)
|
||||
.set(IOStorInv::getUpdate_optid, SecurityUtils.getCurrentUserId())
|
||||
.set(IOStorInv::getUpdate_optname, SecurityUtils.getCurrentNickName())
|
||||
.set(IOStorInv::getUpdate_time, DateUtil.now())
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,11 @@
|
||||
<included>
|
||||
<springProperty scope="context" name="logPath" source="logging.file.path" defaultValue="logs"/>
|
||||
<property name="LOG_HOME" value="${logPath}"/>
|
||||
<!--<define name="DEVICECODE" class="org.nl.common.logging.DeviceCodeDir"/>-->
|
||||
<!-- 按照每天生成日志文件 -->
|
||||
<appender name="FILE_XGAGV" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<appender name="FILE_WMSTOERP" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<!--日志文件输出的文件名-->
|
||||
<FileNamePattern>${LOG_HOME}/XgAgvDeviceDriver/${DEVICECODE}/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
|
||||
<FileNamePattern>${LOG_HOME}/WmsToErp/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
|
||||
<!--日志文件保留天数-->
|
||||
<maxHistory>15</maxHistory>
|
||||
<!--单个日志最大容量 至少10MB才能看得出来-->
|
||||
@@ -22,13 +21,8 @@
|
||||
</encoder>
|
||||
|
||||
</appender>
|
||||
|
||||
<!-- <logger name="org.nl.start.Init" level="info" additivity="false">
|
||||
<appender-ref ref="FILE3"/>
|
||||
</logger>-->
|
||||
|
||||
<!-- 打印sql -->
|
||||
<logger name="org.nl.system.service.lucene.impl.LuceneExecuteLogServiceImpl" level="info" additivity="false">
|
||||
<appender-ref ref="FILE_XGAGV"/>
|
||||
<logger name="org.nl.wms.ext.service.impl.WmsToErpServiceImpl" level="info" additivity="false">
|
||||
<appender-ref ref="FILE_WMSTOERP"/>
|
||||
</logger>
|
||||
</included>
|
||||
@@ -15,9 +15,7 @@ https://juejin.cn/post/6844903775631572999
|
||||
value="%cyan(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss.SSS}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}) - %blue(%msg%n)"/>
|
||||
<property name="LOG_HOME" value="${logPath}"/>
|
||||
<!--引入默认的一些设置-->
|
||||
<!--<include resource="log/XrToMes.xml"/>
|
||||
<include resource="log/MesToErp.xml"/>-->
|
||||
<include resource="log/XgAgvDeviceDriver.xml"/>
|
||||
<include resource="log/WmsToErp.xml"/>
|
||||
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<!--withJansi 参数改为true-->
|
||||
|
||||
Reference in New Issue
Block a user