erp根据工厂、物料查询生产版本

This commit is contained in:
liss
2025-10-22 10:30:46 +08:00
parent 8e85e47a1d
commit 3ced883117
13 changed files with 102 additions and 2 deletions

View File

@@ -1,15 +1,22 @@
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.ErpSubmitReqDTO;
import com.zt.plat.module.erp.service.erp.ErpProductiveVersionService;
import com.zt.plat.module.erp.utils.ErpConfig;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
import static com.zt.plat.framework.common.pojo.CommonResult.success;
/**
* ERP Api 实现类
*
@@ -22,6 +29,8 @@ public class ErpExternalApiImpl implements ErpExternalApi {
@Resource
private ErpConfig erpConfig;
@Resource
private ErpProductiveVersionService erpProductiveVersionService;
@Override
public HashMap<String, String> submitDataToErp(ErpSubmitReqDTO reqDTO) {
@@ -34,4 +43,10 @@ public class ErpExternalApiImpl implements ErpExternalApi {
Map<String, Object> req = new HashMap<>();
return erpConfig.fetchDataFromERP(funcnr, req);
}
@Override
public CommonResult<String> getErpProductiveVersionByFM(ErpProductiveVersionReqDTO reqDTO) {
String productiveVersionNumber = erpProductiveVersionService.getErpProductiveVersionByFM(reqDTO);
return success(productiveVersionNumber);
}
}

View File

@@ -109,4 +109,11 @@ public class ErpProductiveVersionController {
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);
}
}

View File

@@ -29,4 +29,6 @@ public class ErpProductiveVersionPageReqVO extends PageParam {
@Schema(description = "组计数器", example = "15610")
private Long groupCount;
@Schema(description = "是否启用")
private String isEnable;
}

View File

@@ -42,4 +42,7 @@ public class ErpProductiveVersionRespVO {
@ExcelProperty("组计数器")
private Long groupCount;
@Schema(description = "是否启用")
private String isEnable;
}

View File

@@ -1,5 +1,6 @@
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 jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
@@ -38,4 +39,7 @@ public class ErpProductiveVersionSaveReqVO {
@NotNull(message = "组计数器不能为空")
private Long groupCount;
@Schema(description = "是否启用")
private String isEnable;
}

View File

@@ -63,4 +63,7 @@ public class ErpProductiveVersionDO {
@TableField("GRP_CNT")
private Long groupCount;
@TableField("IS_ENB")
private String isEnable;
}

View File

@@ -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.mybatis.core.mapper.BaseMapperX;
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.dal.dataobject.erp.ErpProductiveVersionDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* ERP生产版本 Mapper
@@ -27,4 +29,13 @@ public interface ErpProductiveVersionMapper extends BaseMapperX<ErpProductiveVer
.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();
};
}

View File

@@ -149,11 +149,12 @@ public class ErpProcessDetailServiceImpl implements ErpProcessDetailService {
new LambdaQueryWrapperX<ErpProcessDetailDO>()
.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::getProcessingName, result.toInsert.stream().map(ErpProcessDetailDO::getProcessingName).distinct().collect(Collectors.toList()))
.in(ErpProcessDetailDO::getWorkCenterNumber, result.toInsert.stream().map(ErpProcessDetailDO::getWorkCenterNumber).distinct().collect(Collectors.toList()))
);
Map<String, Long> numberIdMap = insertedRecords.stream()
.collect(Collectors.toMap(
asset -> asset.getProcessId() + "-" + asset.getProcessingNumber() + "-" + asset.getWorkCenterNumber(),
asset -> asset.getProcessId() + "-" + asset.getProcessingNumber() + "-" + asset.getProcessingName() + "-" + asset.getWorkCenterNumber(),
ErpProcessDetailDO::getId, (existing, replacement) -> replacement));
myRedisConfig.addRedisCacheMap(result.key, numberIdMap);
}
@@ -188,7 +189,7 @@ public class ErpProcessDetailServiceImpl implements ErpProcessDetailService {
List<ErpProcessDetailDO> assets = erpProcessDetailMapper.selectList(new LambdaQueryWrapperX<ErpProcessDetailDO>());
Map<String, Long> existingNumbers = new HashMap<>();
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());
}
myRedisConfig.addRedisCacheMap(key, existingNumbers);

View File

@@ -1,6 +1,7 @@
package com.zt.plat.module.erp.service.erp;
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.ErpProductiveVersionRespVO;
import com.zt.plat.module.erp.controller.admin.erp.vo.ErpProductiveVersionSaveReqVO;
@@ -62,4 +63,8 @@ public interface ErpProductiveVersionService {
PageResult<ErpProductiveVersionDO> getErpProductiveVersionPage(ErpProductiveVersionPageReqVO pageReqVO);
void callErpRfcInterface();
void enableErpProductiveVersion(ErpProductiveVersionSaveReqVO updateReqVO);
String getErpProductiveVersionByFM(ErpProductiveVersionReqDTO reqDTO);
}

View File

@@ -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.util.object.BeanUtils;
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.MyRedisConfig;
import com.zt.plat.module.erp.enums.OftenEnum;
@@ -104,6 +105,22 @@ public class ErpProductiveVersionServiceImpl implements ErpProductiveVersionServ
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
@Transactional
@XxlJob("getErpProductiveVersionTask")

View File

@@ -9,4 +9,10 @@
文档可见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>