erp根据工厂、物料查询生产版本
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
package com.zt.plat.module.erp.api;
|
package com.zt.plat.module.erp.api;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
|
import com.zt.plat.module.erp.api.dto.ErpProductiveVersionReqDTO;
|
||||||
import com.zt.plat.module.erp.api.dto.ErpQueryReqDTO;
|
import com.zt.plat.module.erp.api.dto.ErpQueryReqDTO;
|
||||||
import com.zt.plat.module.erp.api.dto.ErpSubmitReqDTO;
|
import com.zt.plat.module.erp.api.dto.ErpSubmitReqDTO;
|
||||||
import com.zt.plat.module.erp.enums.ApiConstants;
|
import com.zt.plat.module.erp.enums.ApiConstants;
|
||||||
@@ -10,6 +12,7 @@ import org.springframework.cloud.openfeign.FeignClient;
|
|||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -28,4 +31,7 @@ public interface ErpExternalApi {
|
|||||||
@Operation(summary = "erp数据查询")
|
@Operation(summary = "erp数据查询")
|
||||||
HashMap<String, Object> queryDataToErp(@Valid @RequestBody ErpQueryReqDTO reqDTO);
|
HashMap<String, Object> queryDataToErp(@Valid @RequestBody ErpQueryReqDTO reqDTO);
|
||||||
|
|
||||||
|
@GetMapping(PREFIX + "/queryProductiveVersion")
|
||||||
|
@Operation(summary = "生产版本数据查询")
|
||||||
|
CommonResult<String> getErpProductiveVersionByFM(@Valid @RequestBody ErpProductiveVersionReqDTO reqDTO);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.zt.plat.module.erp.api.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Schema(description = "RPC 服务 - 查询 ERP DTO")
|
||||||
|
@Data
|
||||||
|
public class ErpProductiveVersionReqDTO {
|
||||||
|
|
||||||
|
@Schema(description = "工厂编码")
|
||||||
|
@NotNull(message = "工厂编码不能为空")
|
||||||
|
private String factoryNumber;
|
||||||
|
@Schema(description = "物料编码")
|
||||||
|
@NotNull(message = "物料编码不能为空")
|
||||||
|
private String materialNumber;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,15 +1,22 @@
|
|||||||
package com.zt.plat.module.erp.api;
|
package com.zt.plat.module.erp.api;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
|
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||||
|
import com.zt.plat.module.erp.api.dto.ErpProductiveVersionReqDTO;
|
||||||
import com.zt.plat.module.erp.api.dto.ErpQueryReqDTO;
|
import com.zt.plat.module.erp.api.dto.ErpQueryReqDTO;
|
||||||
import com.zt.plat.module.erp.api.dto.ErpSubmitReqDTO;
|
import com.zt.plat.module.erp.api.dto.ErpSubmitReqDTO;
|
||||||
|
import com.zt.plat.module.erp.service.erp.ErpProductiveVersionService;
|
||||||
import com.zt.plat.module.erp.utils.ErpConfig;
|
import com.zt.plat.module.erp.utils.ErpConfig;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ERP Api 实现类
|
* ERP Api 实现类
|
||||||
*
|
*
|
||||||
@@ -22,6 +29,8 @@ public class ErpExternalApiImpl implements ErpExternalApi {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ErpConfig erpConfig;
|
private ErpConfig erpConfig;
|
||||||
|
@Resource
|
||||||
|
private ErpProductiveVersionService erpProductiveVersionService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HashMap<String, String> submitDataToErp(ErpSubmitReqDTO reqDTO) {
|
public HashMap<String, String> submitDataToErp(ErpSubmitReqDTO reqDTO) {
|
||||||
@@ -34,4 +43,10 @@ public class ErpExternalApiImpl implements ErpExternalApi {
|
|||||||
Map<String, Object> req = new HashMap<>();
|
Map<String, Object> req = new HashMap<>();
|
||||||
return erpConfig.fetchDataFromERP(funcnr, req);
|
return erpConfig.fetchDataFromERP(funcnr, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<String> getErpProductiveVersionByFM(ErpProductiveVersionReqDTO reqDTO) {
|
||||||
|
String productiveVersionNumber = erpProductiveVersionService.getErpProductiveVersionByFM(reqDTO);
|
||||||
|
return success(productiveVersionNumber);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,4 +109,11 @@ public class ErpProductiveVersionController {
|
|||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PutMapping("/isEnable")
|
||||||
|
@Operation(summary = "启用ERP生产版本,相同工厂、物料,只能启用一个")
|
||||||
|
@PreAuthorize("@ss.hasPermission('sply:erp-productive-version:update')")
|
||||||
|
public CommonResult<Boolean> enableErpProductiveVersion(@Valid @RequestBody ErpProductiveVersionSaveReqVO updateReqVO) {
|
||||||
|
erpProductiveVersionService.enableErpProductiveVersion(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -29,4 +29,6 @@ public class ErpProductiveVersionPageReqVO extends PageParam {
|
|||||||
@Schema(description = "组计数器", example = "15610")
|
@Schema(description = "组计数器", example = "15610")
|
||||||
private Long groupCount;
|
private Long groupCount;
|
||||||
|
|
||||||
|
@Schema(description = "是否启用")
|
||||||
|
private String isEnable;
|
||||||
}
|
}
|
||||||
@@ -42,4 +42,7 @@ public class ErpProductiveVersionRespVO {
|
|||||||
@ExcelProperty("组计数器")
|
@ExcelProperty("组计数器")
|
||||||
private Long groupCount;
|
private Long groupCount;
|
||||||
|
|
||||||
|
@Schema(description = "是否启用")
|
||||||
|
private String isEnable;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.zt.plat.module.erp.controller.admin.erp.vo;
|
package com.zt.plat.module.erp.controller.admin.erp.vo;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
@@ -38,4 +39,7 @@ public class ErpProductiveVersionSaveReqVO {
|
|||||||
@NotNull(message = "组计数器不能为空")
|
@NotNull(message = "组计数器不能为空")
|
||||||
private Long groupCount;
|
private Long groupCount;
|
||||||
|
|
||||||
|
@Schema(description = "是否启用")
|
||||||
|
private String isEnable;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -63,4 +63,7 @@ public class ErpProductiveVersionDO {
|
|||||||
@TableField("GRP_CNT")
|
@TableField("GRP_CNT")
|
||||||
private Long groupCount;
|
private Long groupCount;
|
||||||
|
|
||||||
|
@TableField("IS_ENB")
|
||||||
|
private String isEnable;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,9 +3,11 @@ package com.zt.plat.module.erp.dal.mysql.erp;
|
|||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import com.zt.plat.module.erp.api.dto.ErpProductiveVersionReqDTO;
|
||||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpProductiveVersionPageReqVO;
|
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpProductiveVersionPageReqVO;
|
||||||
import com.zt.plat.module.erp.dal.dataobject.erp.ErpProductiveVersionDO;
|
import com.zt.plat.module.erp.dal.dataobject.erp.ErpProductiveVersionDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ERP生产版本 Mapper
|
* ERP生产版本 Mapper
|
||||||
@@ -27,4 +29,13 @@ public interface ErpProductiveVersionMapper extends BaseMapperX<ErpProductiveVer
|
|||||||
.orderByDesc(ErpProductiveVersionDO::getId));
|
.orderByDesc(ErpProductiveVersionDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void enableErpProductiveVersion(@Param("factoryNumber") String factoryNumber,@Param("materialNumber") String materialNumber);
|
||||||
|
|
||||||
|
default String getErpProductiveVersionByFM(ErpProductiveVersionReqDTO reqDTO){
|
||||||
|
return selectOne(new LambdaQueryWrapperX<ErpProductiveVersionDO>()
|
||||||
|
.eq(ErpProductiveVersionDO::getFactoryNumber, reqDTO.getFactoryNumber())
|
||||||
|
.eq(ErpProductiveVersionDO::getMaterialNumber, reqDTO.getMaterialNumber())
|
||||||
|
.eq(ErpProductiveVersionDO::getIsEnable, 1)
|
||||||
|
.last("LIMIT 1")).getProductiveVersionNumber();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
@@ -149,11 +149,12 @@ public class ErpProcessDetailServiceImpl implements ErpProcessDetailService {
|
|||||||
new LambdaQueryWrapperX<ErpProcessDetailDO>()
|
new LambdaQueryWrapperX<ErpProcessDetailDO>()
|
||||||
.in(ErpProcessDetailDO::getProcessId, result.toInsert.stream().map(ErpProcessDetailDO::getProcessId).distinct().collect(Collectors.toList()))
|
.in(ErpProcessDetailDO::getProcessId, result.toInsert.stream().map(ErpProcessDetailDO::getProcessId).distinct().collect(Collectors.toList()))
|
||||||
.in(ErpProcessDetailDO::getProcessingNumber, result.toInsert.stream().map(ErpProcessDetailDO::getProcessingNumber).distinct().collect(Collectors.toList()))
|
.in(ErpProcessDetailDO::getProcessingNumber, result.toInsert.stream().map(ErpProcessDetailDO::getProcessingNumber).distinct().collect(Collectors.toList()))
|
||||||
|
.in(ErpProcessDetailDO::getProcessingName, result.toInsert.stream().map(ErpProcessDetailDO::getProcessingName).distinct().collect(Collectors.toList()))
|
||||||
.in(ErpProcessDetailDO::getWorkCenterNumber, result.toInsert.stream().map(ErpProcessDetailDO::getWorkCenterNumber).distinct().collect(Collectors.toList()))
|
.in(ErpProcessDetailDO::getWorkCenterNumber, result.toInsert.stream().map(ErpProcessDetailDO::getWorkCenterNumber).distinct().collect(Collectors.toList()))
|
||||||
);
|
);
|
||||||
Map<String, Long> numberIdMap = insertedRecords.stream()
|
Map<String, Long> numberIdMap = insertedRecords.stream()
|
||||||
.collect(Collectors.toMap(
|
.collect(Collectors.toMap(
|
||||||
asset -> asset.getProcessId() + "-" + asset.getProcessingNumber() + "-" + asset.getWorkCenterNumber(),
|
asset -> asset.getProcessId() + "-" + asset.getProcessingNumber() + "-" + asset.getProcessingName() + "-" + asset.getWorkCenterNumber(),
|
||||||
ErpProcessDetailDO::getId, (existing, replacement) -> replacement));
|
ErpProcessDetailDO::getId, (existing, replacement) -> replacement));
|
||||||
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
|
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
|
||||||
}
|
}
|
||||||
@@ -188,7 +189,7 @@ public class ErpProcessDetailServiceImpl implements ErpProcessDetailService {
|
|||||||
List<ErpProcessDetailDO> assets = erpProcessDetailMapper.selectList(new LambdaQueryWrapperX<ErpProcessDetailDO>());
|
List<ErpProcessDetailDO> assets = erpProcessDetailMapper.selectList(new LambdaQueryWrapperX<ErpProcessDetailDO>());
|
||||||
Map<String, Long> existingNumbers = new HashMap<>();
|
Map<String, Long> existingNumbers = new HashMap<>();
|
||||||
for (ErpProcessDetailDO asset : assets) {
|
for (ErpProcessDetailDO asset : assets) {
|
||||||
String mapKey = asset.getProcessId() + "-" + asset.getProcessingNumber()+ "-" + asset.getWorkCenterNumber();
|
String mapKey = asset.getProcessId() + "-" + asset.getProcessingNumber()+ "-" + asset.getProcessingName()+ "-" + asset.getWorkCenterNumber();
|
||||||
existingNumbers.put(mapKey, asset.getId());
|
existingNumbers.put(mapKey, asset.getId());
|
||||||
}
|
}
|
||||||
myRedisConfig.addRedisCacheMap(key, existingNumbers);
|
myRedisConfig.addRedisCacheMap(key, existingNumbers);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.zt.plat.module.erp.service.erp;
|
package com.zt.plat.module.erp.service.erp;
|
||||||
|
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
|
import com.zt.plat.module.erp.api.dto.ErpProductiveVersionReqDTO;
|
||||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpProductiveVersionPageReqVO;
|
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpProductiveVersionPageReqVO;
|
||||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpProductiveVersionRespVO;
|
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpProductiveVersionRespVO;
|
||||||
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpProductiveVersionSaveReqVO;
|
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpProductiveVersionSaveReqVO;
|
||||||
@@ -62,4 +63,8 @@ public interface ErpProductiveVersionService {
|
|||||||
PageResult<ErpProductiveVersionDO> getErpProductiveVersionPage(ErpProductiveVersionPageReqVO pageReqVO);
|
PageResult<ErpProductiveVersionDO> getErpProductiveVersionPage(ErpProductiveVersionPageReqVO pageReqVO);
|
||||||
|
|
||||||
void callErpRfcInterface();
|
void callErpRfcInterface();
|
||||||
|
|
||||||
|
void enableErpProductiveVersion(ErpProductiveVersionSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
String getErpProductiveVersionByFM(ErpProductiveVersionReqDTO reqDTO);
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ import com.xxl.job.core.handler.annotation.XxlJob;
|
|||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import com.zt.plat.module.erp.api.dto.ErpProductiveVersionReqDTO;
|
||||||
import com.zt.plat.module.erp.utils.ErpConfig;
|
import com.zt.plat.module.erp.utils.ErpConfig;
|
||||||
import com.zt.plat.module.erp.utils.MyRedisConfig;
|
import com.zt.plat.module.erp.utils.MyRedisConfig;
|
||||||
import com.zt.plat.module.erp.enums.OftenEnum;
|
import com.zt.plat.module.erp.enums.OftenEnum;
|
||||||
@@ -104,6 +105,22 @@ public class ErpProductiveVersionServiceImpl implements ErpProductiveVersionServ
|
|||||||
return erpProductiveVersionMapper.selectPage(pageReqVO);
|
return erpProductiveVersionMapper.selectPage(pageReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enableErpProductiveVersion(ErpProductiveVersionSaveReqVO updateReqVO) {
|
||||||
|
|
||||||
|
validateErpProductiveVersionExists(updateReqVO.getId());
|
||||||
|
erpProductiveVersionMapper.enableErpProductiveVersion(updateReqVO.getFactoryNumber(), updateReqVO.getMaterialNumber());
|
||||||
|
// 更新
|
||||||
|
ErpProductiveVersionDO updateObj = BeanUtils.toBean(updateReqVO, ErpProductiveVersionDO.class);
|
||||||
|
erpProductiveVersionMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getErpProductiveVersionByFM(ErpProductiveVersionReqDTO reqDTO) {
|
||||||
|
return erpProductiveVersionMapper.getErpProductiveVersionByFM(reqDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
@XxlJob("getErpProductiveVersionTask")
|
@XxlJob("getErpProductiveVersionTask")
|
||||||
|
|||||||
@@ -9,4 +9,10 @@
|
|||||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<update id="enableErpProductiveVersion">
|
||||||
|
UPDATE sply_erp_pdtv_ver
|
||||||
|
SET IS_ENB = 1
|
||||||
|
WHERE FACT_NUM = #{factoryNumber}
|
||||||
|
AND MTRL_NUM = #{materialNumber}
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user