add:同步eas平库库存功能;
opt:出入库单据模块
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.nl.wms.basedata_manage.controller;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.base.ResponseData;
|
||||
@@ -8,8 +9,10 @@ import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.wms.basedata_manage.service.IMdPbStoragevehicleextService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;import org.nl.common.base.ResponseData;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -40,4 +43,11 @@ public class StructIvtController {
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page) {
|
||||
return ResponseData.build(iMdPbStoragevehicleextService.queryAll(whereJson, page), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/syncStock")
|
||||
@Log("库存同步")
|
||||
public ResponseEntity<Object> syncStock(@RequestBody JSONObject param) {
|
||||
String warehouseno = param.getString("warehouseno");
|
||||
return ResponseData.build(iMdPbStoragevehicleextService.syncStock(warehouseno), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -36,4 +36,6 @@ public interface IMdPbStoragevehicleextService extends IService<MdPbStoragevehic
|
||||
*/
|
||||
List<MdPbStoragevehicleextDto> queryAll(Map whereJson);
|
||||
|
||||
JSONObject syncStock(String warehouseno);
|
||||
|
||||
}
|
||||
|
||||
@@ -86,4 +86,6 @@ public interface MdPbStoragevehicleextMapper extends BaseMapper<MdPbStoragevehic
|
||||
* @return
|
||||
*/
|
||||
List<MdPbStoragevehicleextDto> queryAvailableInv(@Param("params") Map whereJson);
|
||||
|
||||
List<JSONObject> querySyncByStorCode(@Param("stor_code") String storCode);
|
||||
}
|
||||
|
||||
@@ -332,4 +332,24 @@
|
||||
</where>
|
||||
ORDER BY ext.create_time Desc
|
||||
</select>
|
||||
<select id="querySyncByStorCode" resultType="com.alibaba.fastjson.JSONObject">
|
||||
SELECT
|
||||
ext.group_id,
|
||||
ext.storagevehicle_code,
|
||||
ext.material_code,
|
||||
ext.pcsn,
|
||||
ext.qty,
|
||||
ext.qty_unit_id,
|
||||
ext.qty_unit_name,
|
||||
ext.status,
|
||||
attr.struct_id,
|
||||
attr.struct_code,
|
||||
attr.sect_code
|
||||
FROM
|
||||
md_pb_groupplate ext
|
||||
INNER JOIN st_ivt_structattr attr ON ext.storagevehicle_code = attr.storagevehicle_code
|
||||
WHERE
|
||||
attr.sect_code = #{stor_code}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -1,18 +1,34 @@
|
||||
package org.nl.wms.basedata_manage.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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.IdUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.wms.basedata_manage.service.IMdMeMaterialbaseService;
|
||||
import org.nl.wms.basedata_manage.service.IMdPbStoragevehicleextService;
|
||||
import org.nl.wms.basedata_manage.service.IStructattrService;
|
||||
import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
|
||||
import org.nl.wms.basedata_manage.service.dao.MdPbStoragevehicleext;
|
||||
import org.nl.wms.basedata_manage.service.dao.Structattr;
|
||||
import org.nl.wms.basedata_manage.service.dao.mapper.MdPbStoragevehicleextMapper;
|
||||
import org.nl.wms.basedata_manage.service.dto.MdPbStoragevehicleextDto;
|
||||
import org.nl.wms.ext_manage.api.EasApi;
|
||||
import org.nl.wms.ext_manage.api.request.QueryEasStockRequest;
|
||||
import org.nl.wms.ext_manage.api.response.QueryEasStockResponse;
|
||||
import org.nl.wms.warehouse_manage.enums.IOSEnum;
|
||||
import org.nl.wms.warehouse_manage.service.IMdPbGroupplateService;
|
||||
import org.nl.wms.warehouse_manage.service.dao.GroupPlate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -25,7 +41,14 @@ import java.util.Map;
|
||||
@Service
|
||||
public class MdPbStoragevehicleextServiceImpl extends ServiceImpl<MdPbStoragevehicleextMapper, MdPbStoragevehicleext> implements IMdPbStoragevehicleextService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private EasApi easApi;
|
||||
@Autowired
|
||||
private IMdPbGroupplateService iMdPbGroupplateService;
|
||||
@Autowired
|
||||
private IStructattrService iStructattrService;
|
||||
@Autowired
|
||||
private IMdMeMaterialbaseService iMdMeMaterialbaseService;
|
||||
|
||||
@Override
|
||||
public IPage<JSONObject> queryAll(Map whereJson, PageQuery page) {
|
||||
@@ -38,5 +61,84 @@ public class MdPbStoragevehicleextServiceImpl extends ServiceImpl<MdPbStorageveh
|
||||
return this.baseMapper.queryAll(whereJson);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public JSONObject syncStock(String warehouseno) {
|
||||
Structattr struct = iStructattrService.getOne(
|
||||
new LambdaQueryWrapper<Structattr>()
|
||||
.eq(Structattr::getSect_code, warehouseno)
|
||||
.last("LIMIT 1"));
|
||||
QueryEasStockRequest easRequest = new QueryEasStockRequest();
|
||||
easRequest.setOrgno("01.09.14");
|
||||
easRequest.setWarehouseno(warehouseno);
|
||||
List<QueryEasStockResponse> easStocks = easApi.queryStock(easRequest);
|
||||
|
||||
List<JSONObject> localStocks = this.baseMapper.querySyncByStorCode(warehouseno);
|
||||
|
||||
Map<String, JSONObject> localMap = new HashMap<>();
|
||||
for (JSONObject local : localStocks) {
|
||||
String key = local.getString("material_code") + "_" + local.getString("pcsn");
|
||||
localMap.put(key, local);
|
||||
}
|
||||
|
||||
Set<String> easKeys = new HashSet<>();
|
||||
int updateCount = 0, addCount = 0, deleteCount = 0;
|
||||
|
||||
for (QueryEasStockResponse eas : easStocks) {
|
||||
String key = eas.getMaterialno() + "_" + eas.getLotnumber();
|
||||
easKeys.add(key);
|
||||
|
||||
if (localMap.containsKey(key)) {
|
||||
JSONObject local = localMap.get(key);
|
||||
GroupPlate plate = new GroupPlate();
|
||||
plate.setGroup_id(local.getString("group_id"));
|
||||
plate.setQty(new BigDecimal(eas.getQty()));
|
||||
iMdPbGroupplateService.updateById(plate);
|
||||
updateCount++;
|
||||
} else {
|
||||
GroupPlate plate = new GroupPlate();
|
||||
plate.setGroup_id(IdUtil.getStringId());
|
||||
plate.setStoragevehicle_code(struct.getStoragevehicle_code());
|
||||
plate.setMaterial_code(eas.getMaterialno());
|
||||
plate.setPcsn(Optional.ofNullable(eas.getLotnumber()).filter(s -> !s.isEmpty()).orElse("1"));
|
||||
plate.setQty(new BigDecimal(eas.getQty()));
|
||||
plate.setQty_unit_name(eas.getUnitname());
|
||||
plate.setStatus(IOSEnum.GROUP_PLATE_STATUS.code("入库"));
|
||||
plate.setCreate_time(DateUtil.now());
|
||||
plate.setCreate_id(SecurityUtils.getCurrentUserId());
|
||||
plate.setCreate_name(SecurityUtils.getCurrentUsername());
|
||||
|
||||
MdMeMaterialbase material = iMdMeMaterialbaseService.getOne(
|
||||
new LambdaQueryWrapper<MdMeMaterialbase>()
|
||||
.eq(MdMeMaterialbase::getMaterial_code, eas.getMaterialno()));
|
||||
if (material != null) {
|
||||
plate.setQty_unit_id(material.getQty_unit_id());
|
||||
if (plate.getQty_unit_name() == null) {
|
||||
plate.setQty_unit_name(material.getQty_unit_name());
|
||||
}
|
||||
}
|
||||
|
||||
iMdPbGroupplateService.save(plate);
|
||||
|
||||
addCount++;
|
||||
}
|
||||
}
|
||||
|
||||
for (JSONObject local : localStocks) {
|
||||
String key = local.getString("material_code") + "_" + local.getString("pcsn");
|
||||
if (!easKeys.contains(key)) {
|
||||
iMdPbGroupplateService.removeById(local.getString("group_id"));
|
||||
deleteCount++;
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("updateCount", updateCount);
|
||||
result.put("addCount", addCount);
|
||||
result.put("deleteCount", deleteCount);
|
||||
result.put("easTotal", easStocks.size());
|
||||
result.put("localTotal", localStocks.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -87,10 +87,10 @@ public class ErpUtil {
|
||||
Object result = call.invoke(new Object[]{json});
|
||||
JSONObject resultJson = JSON.parseObject(result.toString());
|
||||
if (resultJson.getBoolean("status") == false){
|
||||
throw new BadRequestException("回传失败:" + resultJson.getString("message"));
|
||||
throw new BadRequestException("EAS接口请求失败失败:" + resultJson.getString("message"));
|
||||
}
|
||||
log.error("Eas回传接口请求成功!");
|
||||
log.error("Eas回传接口invoke调用结果:" + result);
|
||||
log.error("Eas接口请求成功!");
|
||||
log.error("Eas接口invoke调用结果:" + result);
|
||||
return resultJson;
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException("erp审核接口请求失败:" + e.getMessage());
|
||||
|
||||
Reference in New Issue
Block a user