Merge branch 'main' of http://162.14.99.253:3000/10539622/2025-03-JS-SDK-svr
This commit is contained in:
commit
e36036fcf3
@ -0,0 +1,43 @@
|
||||
package com.cim.idm.constants.storage;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
public enum StorageRulesEnums {
|
||||
// S:泗洪-老厂,J:泗洪-胶水,P:泗洪-PET
|
||||
SI_HONG("1020", new String[]{"S", "J", "P"}),
|
||||
// 太仓
|
||||
TAI_CANG("1030", new String[]{"T"}),
|
||||
// 重庆
|
||||
CHONG_QING("1050", new String[]{"C"}),
|
||||
// 东莞
|
||||
DONG_GUAN("1060", new String[]{"D"}),
|
||||
// 越南
|
||||
YUE_NAME("3500", new String[]{"Y"});
|
||||
|
||||
private final String code;
|
||||
private final String[] prefix;
|
||||
|
||||
StorageRulesEnums(String code, String[] prefix) {
|
||||
this.code = code;
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据组织编码获取前缀
|
||||
* @param code 组织编码
|
||||
* @return 前缀
|
||||
*/
|
||||
public static List<String> getPrefix(String code) {
|
||||
for (StorageRulesEnums value : StorageRulesEnums.values()) {
|
||||
if (value.getCode().equals(code)) {
|
||||
return Arrays.asList(value.getPrefix());
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
@ -227,72 +227,4 @@ public class StorageController {
|
||||
List<Map<String,Object>> list = IDMFrameServiceProxy.getSqlTemplate().queryForList(sql, bindMap);
|
||||
return AjaxResult.me().setResultObj(list);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/addStorage", method = RequestMethod.POST)
|
||||
public BaseResponse<Object> addStorage(@RequestBody Map<String, Object> param) {
|
||||
// 获取参数
|
||||
String storageName = (String) param.get("STORAGENAME");
|
||||
String description = (String) param.get("DESCRIPTION");
|
||||
String siteName = (String) param.get("SITENAME");
|
||||
String erpFactory = (String) param.get("ERPFACTORY");
|
||||
// 异常
|
||||
StorageSpecKey storageSpecKey = new StorageSpecKey();
|
||||
storageSpecKey.setStorageName(storageName);
|
||||
storageSpecKey.setSiteName(siteName);
|
||||
com.cim.idm.wmspackage.storage.management.data.StorageSpec storageSpec = null;
|
||||
try {
|
||||
storageSpec = StorageServiceProxy.getStorageSpecService().selectByKey(storageSpecKey);
|
||||
if (Objects.nonNull(storageSpec)) {
|
||||
return RespGenerator.returnError("已存在该货位!");
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
storageSpec = new com.cim.idm.wmspackage.storage.management.data.StorageSpec();
|
||||
// 构建数据
|
||||
storageSpec.setKey(storageSpecKey);
|
||||
storageSpec.setDescription(description);
|
||||
storageSpec.setErpFactory(erpFactory);
|
||||
// 插入数据
|
||||
StorageServiceProxy.getStorageSpecService().insert(storageSpec);
|
||||
return RespGenerator.returnOK(param);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/editStorage", method = RequestMethod.POST)
|
||||
public BaseResponse<Object> editStorage(@RequestBody Map<String, Object> param) {
|
||||
// 获取参数
|
||||
String storageName = (String) param.get("STORAGENAME");
|
||||
String siteName = (String) param.get("SITENAME");
|
||||
String description = (String) param.get("DESCRIPTION");
|
||||
// 获取数据
|
||||
StorageSpecKey storageSpecKey = new StorageSpecKey();
|
||||
storageSpecKey.setStorageName(storageName);
|
||||
storageSpecKey.setSiteName(siteName);
|
||||
com.cim.idm.wmspackage.storage.management.data.StorageSpec storageSpec = null;
|
||||
try {
|
||||
storageSpec = StorageServiceProxy.getStorageSpecService().selectByKey(storageSpecKey);
|
||||
} catch (Exception e) {
|
||||
return RespGenerator.returnError("未找到该货位!");
|
||||
}
|
||||
// 构建数据
|
||||
storageSpec.setDescription(description);
|
||||
// 更新数据
|
||||
StorageServiceProxy.getStorageSpecService().update(storageSpec);
|
||||
return RespGenerator.returnOK(param);
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delStorage", method = RequestMethod.POST)
|
||||
public BaseResponse<Map<String, Object>> delStorage(@RequestBody Map<String, Object> param) {
|
||||
// 获取参数
|
||||
String storageName = (String) param.get("STORAGENAME");
|
||||
String siteName = (String) param.get("SITENAME");
|
||||
// 组建数据
|
||||
StorageSpecKey storageSpec = new StorageSpecKey();
|
||||
storageSpec.setStorageName(storageName);
|
||||
storageSpec.setSiteName(siteName);
|
||||
// 删除数据
|
||||
StorageServiceProxy.getStorageSpecService().delete(storageSpec);
|
||||
return RespGenerator.returnOK(param);
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,19 @@
|
||||
package com.cim.idm.controller;
|
||||
|
||||
import com.cim.idm.exception.GlobalException;
|
||||
import com.cim.idm.model.dto.PageDto;
|
||||
import com.cim.idm.model.dto.WareHouseEditDto;
|
||||
import com.cim.idm.model.dto.storage.StorageAddDto;
|
||||
import com.cim.idm.model.dto.storage.StorageDelDto;
|
||||
import com.cim.idm.model.dto.storage.StorageEditDto;
|
||||
import com.cim.idm.model.dto.storage.StorageSearchDto;
|
||||
import com.cim.idm.service.IWareHouseService;
|
||||
import com.cim.idm.utils.AjaxResult;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
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;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
@RestController
|
||||
@ -31,4 +35,46 @@ public class WareHouseController {
|
||||
return AjaxResult.me().setErrorCode(-1).setMessage("编辑失败");
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping(value = "/page")
|
||||
public AjaxResult page(@RequestBody PageDto in) {
|
||||
return AjaxResult.me().setSuccess(true).setResultObj(wareHouseService.page(in));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/addStorage")
|
||||
public AjaxResult addStorage(@RequestBody StorageAddDto storageAddDto) {
|
||||
// 校验
|
||||
if (Objects.nonNull(wareHouseService.get(storageAddDto.getSiteName(), storageAddDto.getStorageName()))) {
|
||||
throw new GlobalException("已存在该货位!");
|
||||
}
|
||||
// 新增
|
||||
if (wareHouseService.add(storageAddDto) > 0) {
|
||||
return AjaxResult.me().setSuccess(true).setMessage("新增成功");
|
||||
} else {
|
||||
return AjaxResult.me().setErrorCode(-1).setMessage("新增失败");
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping(value = "/editStorage")
|
||||
public AjaxResult editStorage(@RequestBody StorageEditDto storageEditDto) {
|
||||
if (wareHouseService.editStorage(storageEditDto) > 0) {
|
||||
return AjaxResult.me().setSuccess(true).setMessage("编辑成功");
|
||||
} else {
|
||||
return AjaxResult.me().setErrorCode(-1).setMessage("编辑失败");
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping(value = "/delStorage")
|
||||
public AjaxResult delStorage(@RequestBody StorageDelDto storageDelDto) {
|
||||
if (wareHouseService.delStorage(storageDelDto) > 0) {
|
||||
return AjaxResult.me().setSuccess(true).setMessage("删除成功");
|
||||
} else {
|
||||
return AjaxResult.me().setErrorCode(-1).setMessage("删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping(value = "/search")
|
||||
public AjaxResult search(@RequestBody StorageSearchDto storageSearchDto) {
|
||||
return AjaxResult.me().setSuccess(true).setResultObj(wareHouseService.search(storageSearchDto));
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,17 @@
|
||||
package com.cim.idm.dao;
|
||||
|
||||
import com.cim.idm.model.dto.WareHouseEditDto;
|
||||
import com.cim.idm.model.dto.storage.StorageAddDto;
|
||||
import com.cim.idm.model.dto.storage.StorageDelDto;
|
||||
import com.cim.idm.model.dto.storage.StorageEditDto;
|
||||
import com.cim.idm.model.dto.storage.StoragePageDto;
|
||||
import com.cim.idm.model.po.storage.StorageSpec;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Component
|
||||
@Mapper
|
||||
@ -16,4 +23,46 @@ public interface WareHouseDao {
|
||||
* @return 结果
|
||||
*/
|
||||
int edit(@Param("dto") WareHouseEditDto dto);
|
||||
|
||||
/**
|
||||
* 获取采购订单
|
||||
*/
|
||||
List<StorageSpec> page(@Param("dto") StoragePageDto storagePageDto);
|
||||
|
||||
/**
|
||||
* 获取货位
|
||||
* @param siteName 工厂
|
||||
* @param storageName 货位编码
|
||||
* @return 货位
|
||||
*/
|
||||
StorageSpec get(@Param("siteName") String siteName, @Param("storageName") String storageName);
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param storageAddDto 货位
|
||||
* @return 结果
|
||||
*/
|
||||
int add(@Param("storageSpec") StorageAddDto storageAddDto);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param storageEditDto 请求
|
||||
* @return 结果
|
||||
*/
|
||||
int editStorage(@Param("edit") StorageEditDto storageEditDto);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param storageDelDto 请求
|
||||
* @return 结果
|
||||
*/
|
||||
int delStorage(@Param("del") StorageDelDto storageDelDto);
|
||||
|
||||
/**
|
||||
* 检索
|
||||
* @param prefix 前缀
|
||||
* @return 结果
|
||||
*/
|
||||
List<StorageSpec> search(@Param("storageName") String storageName,
|
||||
@Param("prefix") List<String> prefix);
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
package com.cim.idm.model.dto.storage;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class StorageAddDto {
|
||||
|
||||
// 工厂
|
||||
private String siteName;
|
||||
// 编码
|
||||
private String storageName;
|
||||
// 描述
|
||||
private String description;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.cim.idm.model.dto.storage;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class StorageDelDto {
|
||||
|
||||
// 工厂
|
||||
private String siteName;
|
||||
// 编码
|
||||
private String storageName;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.cim.idm.model.dto.storage;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class StorageEditDto {
|
||||
|
||||
// 工厂
|
||||
private String siteName;
|
||||
// 编码
|
||||
private String storageName;
|
||||
// 描述
|
||||
private String description;
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.cim.idm.model.dto.storage;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class StoragePageDto {
|
||||
|
||||
// 货位名称
|
||||
private String storageName;
|
||||
|
||||
// 货位描述
|
||||
private String description;
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.cim.idm.model.dto.storage;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class StorageSearchDto {
|
||||
|
||||
// 编码
|
||||
private String storageName;
|
||||
|
||||
// 组织
|
||||
private String orgNo;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.cim.idm.model.po.storage;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class StorageSpec {
|
||||
|
||||
// 工厂
|
||||
private String siteName;
|
||||
// 编码
|
||||
private String storageName;
|
||||
// 描述
|
||||
private String description;
|
||||
}
|
@ -1,6 +1,15 @@
|
||||
package com.cim.idm.service;
|
||||
|
||||
import com.cim.idm.model.dto.PageDto;
|
||||
import com.cim.idm.model.dto.WareHouseEditDto;
|
||||
import com.cim.idm.model.dto.storage.StorageAddDto;
|
||||
import com.cim.idm.model.dto.storage.StorageDelDto;
|
||||
import com.cim.idm.model.dto.storage.StorageEditDto;
|
||||
import com.cim.idm.model.dto.storage.StorageSearchDto;
|
||||
import com.cim.idm.model.po.storage.StorageSpec;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IWareHouseService {
|
||||
/**
|
||||
@ -9,4 +18,47 @@ public interface IWareHouseService {
|
||||
* @return 结果
|
||||
*/
|
||||
int edit(WareHouseEditDto dto);
|
||||
|
||||
/**
|
||||
* 分页
|
||||
* @param dto 请求
|
||||
* @return 货位
|
||||
*/
|
||||
PageInfo<StorageSpec> page(PageDto dto);
|
||||
|
||||
/**
|
||||
* 获取货位
|
||||
* @param siteName 工厂
|
||||
* @param storageName 货位编码
|
||||
* @return 货位
|
||||
*/
|
||||
StorageSpec get(String siteName, String storageName);
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param storageAddDto 货位
|
||||
* @return 结果
|
||||
*/
|
||||
int add(StorageAddDto storageAddDto);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param storageEditDto 请求
|
||||
* @return 结果
|
||||
*/
|
||||
int editStorage(StorageEditDto storageEditDto);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param storageDelDto 请求
|
||||
* @return 结果
|
||||
*/
|
||||
int delStorage(StorageDelDto storageDelDto);
|
||||
|
||||
/**
|
||||
* 检索
|
||||
* @param storageSearchDto 请求
|
||||
* @return 结果
|
||||
*/
|
||||
List<StorageSpec> search(StorageSearchDto storageSearchDto);
|
||||
}
|
||||
|
@ -1,11 +1,21 @@
|
||||
package com.cim.idm.service.Impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.cim.idm.constants.storage.StorageRulesEnums;
|
||||
import com.cim.idm.dao.WareHouseDao;
|
||||
import com.cim.idm.exception.GlobalException;
|
||||
import com.cim.idm.model.dto.PageDto;
|
||||
import com.cim.idm.model.dto.WareHouseEditDto;
|
||||
import com.cim.idm.model.dto.storage.*;
|
||||
import com.cim.idm.model.po.storage.StorageSpec;
|
||||
import com.cim.idm.service.IWareHouseService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class WareHouseServiceImpl implements IWareHouseService {
|
||||
@ -15,7 +25,47 @@ public class WareHouseServiceImpl implements IWareHouseService {
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int edit(WareHouseEditDto dto) {
|
||||
return wareHouseDao.edit(dto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<StorageSpec> page(PageDto dto) {
|
||||
PageMethod.startPage(dto.getPageNum(), dto.getPageSize());
|
||||
StoragePageDto storagePageDto = JSON.toJavaObject(dto.getParams(), StoragePageDto.class);
|
||||
return new PageInfo<>(wareHouseDao.page(storagePageDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageSpec get(String siteName, String storageName) {
|
||||
return wareHouseDao.get(siteName, storageName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int add(StorageAddDto storageAddDto) {
|
||||
return wareHouseDao.add(storageAddDto);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int editStorage(StorageEditDto storageEditDto) {
|
||||
return wareHouseDao.editStorage(storageEditDto);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int delStorage(StorageDelDto storageDelDto) {
|
||||
return wareHouseDao.delStorage(storageDelDto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StorageSpec> search(StorageSearchDto storageSearchDto) {
|
||||
List<String> prefix = StorageRulesEnums.getPrefix(storageSearchDto.getOrgNo());
|
||||
if (prefix.isEmpty()) {
|
||||
throw new GlobalException("当前组织无法查询数据");
|
||||
}
|
||||
return wareHouseDao.search(storageSearchDto.getStorageName(), prefix);
|
||||
}
|
||||
}
|
||||
|
@ -6,4 +6,53 @@
|
||||
update BS_ERPLOCATION set USE_LOCATION = #{dto.useLocation}, IS_OVEN = #{dto.isOven}
|
||||
where ERPFACTORYNAME = #{dto.erpFactoryName} and ERPLOCATIONNAME = #{dto.erpLocationName}
|
||||
</update>
|
||||
|
||||
<select id="page" resultType="com.cim.idm.model.po.storage.StorageSpec">
|
||||
select SITENAME, STORAGENAME, DESCRIPTION
|
||||
from STORAGESPEC
|
||||
<where>
|
||||
<if test="dto.storageName != null and dto.storageName != ''">
|
||||
AND STORAGENAME LIKE '%'||#{dto.storageName}||'%'
|
||||
</if>
|
||||
<if test="dto.description != null and dto.description != ''">
|
||||
AND DESCRIPTION LIKE '%'||#{dto.description}||'%'
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="get" resultType="com.cim.idm.model.po.storage.StorageSpec">
|
||||
select SITENAME, STORAGENAME, DESCRIPTION
|
||||
from STORAGESPEC
|
||||
where SITENAME = #{siteName}
|
||||
and STORAGENAME = #{storageName}
|
||||
</select>
|
||||
|
||||
<insert id="add">
|
||||
insert into STORAGESPEC(SITENAME, STORAGENAME, DESCRIPTION)
|
||||
values (#{storageSpec.siteName}, #{storageSpec.storageName}, #{storageSpec.description})
|
||||
</insert>
|
||||
|
||||
<update id="editStorage">
|
||||
update STORAGESPEC set DESCRIPTION = #{edit.description}
|
||||
where SITENAME = #{edit.siteName}
|
||||
and STORAGENAME = #{edit.storageName}
|
||||
</update>
|
||||
|
||||
<delete id="delStorage">
|
||||
delete from STORAGESPEC
|
||||
where SITENAME = #{del.siteName}
|
||||
and STORAGENAME = #{del.storageName}
|
||||
</delete>
|
||||
|
||||
<select id="search" resultType="com.cim.idm.model.po.storage.StorageSpec">
|
||||
select SITENAME, STORAGENAME, DESCRIPTION
|
||||
from STORAGESPEC
|
||||
where 1 = 1 AND
|
||||
<foreach item="type" index="index" collection="prefix" open="(" separator="or" close=")">
|
||||
STORAGENAME LIKE #{type}||'%'
|
||||
</foreach>
|
||||
<if test="storageName != null and storageName != ''">
|
||||
AND STORAGENAME LIKE '%'||#{storageName}||'%'
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
Loading…
x
Reference in New Issue
Block a user