【定时任务】获取采购属性信息

This commit is contained in:
10001392 2025-01-22 16:40:50 +08:00
parent 477b249e93
commit 42cfcb449a
5 changed files with 37 additions and 19 deletions

View File

@ -459,7 +459,7 @@ public class MaterialMainApi extends BaseApi {
* @throws Exception
*/
@GetMapping("syncMaterialPurchasePropInfo")
public void syncMaterialPurchasePropInfo() throws Exception {
materialMainService.syncMaterialPurchasePropInfo();
public void syncMaterialPurchasePropInfo(@RequestBody MaterialMainQuery query) throws Exception {
materialMainService.syncMaterialPurchasePropInfo(query);
}
}

View File

@ -167,9 +167,10 @@ public class SaticScheduleTask {
* 只针对物料状态material_state为1:激活 2:禁止采购 3:售后专用
* * 流程状态15已审核 100: 历史正式物料(已审核)
*/
@Scheduled(cron = "0 0 7 * * ?")
// 全量更新几十万条数据太慢暂且注释
// @Scheduled(cron = "0 0 7 * * ?")
// @Scheduled(cron = "0 0/2 * * * ? ") // 测试使用每2分钟
public void syncMaterialPurchasePropInfo() throws Exception {
materialMainService.syncMaterialPurchasePropInfo();
}
// public void syncMaterialPurchasePropInfo() throws Exception {
// materialMainService.syncMaterialPurchasePropInfo(null);
// }
}

View File

@ -82,4 +82,6 @@ public interface MaterialMainMapper extends BaseMapper<MaterialMainEntity> {
List<LanguageTranslationEntity> getKeyLanguage(@Param("languageCode")String languageCode);
void updateBatchTwoYearsUsage(@Param("list") List<MaterialMainEntity> list);
List<Map<String,Object>> getMaterialNoListDataMap(@Param("query") MaterialMainQuery query, @Param("startIndex") Long startIndex, @Param("pageSize")Long pageSize );
}

View File

@ -2986,21 +2986,22 @@ public class MaterialMainService extends ServiceImpl<MaterialMainMapper, Materia
return rlist;
}
public void syncMaterialPurchasePropInfo() {
public void syncMaterialPurchasePropInfo(MaterialMainQuery query) {
log.info("获取采购属性信息开始");
long startTime = System.currentTimeMillis();
MaterialMainQuery query = new MaterialMainQuery();
if (ObjectUtil.isEmpty(query)) {
query = new MaterialMainQuery();
}
// 所有大类的物料
// query.setMaterialStates(Arrays.asList(1, 2, 3));
// query.setFirstMaterialCategoryCode("10");
query.setPage(1L).setPageSize(10000L);
query.setMaterialClass(0); // 接口用途0物料查看
query.setPage(1L).setPageSize(10000L);
int pageCount = this.downExcelGetListPages(query) + 1;
List<MaterialMainAttrEntity> existsList = materialMainAttrMapper.selectList(null);
for (int i = 1; i <= pageCount; i++) {
query.setPage((long) i);
List<Map<String, Object>> result = this.getBaseMapper().getListDataMap(query, (query.getPage() - 1) * query.getPageSize(), query.getPageSize());
List<Map<String, Object>> result = this.getBaseMapper().getMaterialNoListDataMap(query, (query.getPage() - 1) * query.getPageSize(), query.getPageSize());
if (result == null || result.size() <= 0) {
continue;
@ -3019,18 +3020,17 @@ public class MaterialMainService extends ServiceImpl<MaterialMainMapper, Materia
if (CollectionUtil.isEmpty(filterList)) {
continue;
}
this.updateMaterialPropInfo(filterList);
this.updateMaterialPropInfo(filterList, existsList);
}
long endTime = System.currentTimeMillis();
log.info("获取采购属性信息结束耗时ms: {}", (endTime - startTime));
}
private void updateMaterialPropInfo(List<MaterialMainAttrEntity> filterList) {
private void updateMaterialPropInfo(List<MaterialMainAttrEntity> filterList, List<MaterialMainAttrEntity> existsList) {
if (CollUtil.isEmpty(filterList)) {
return;
}
List<MaterialMainAttrEntity> existsList = materialMainAttrMapper.selectList(null);
if (CollUtil.isNotEmpty(existsList)) {
for (MaterialMainAttrEntity materialMainAttrEntity : filterList) {
try {
@ -3038,10 +3038,14 @@ public class MaterialMainService extends ServiceImpl<MaterialMainMapper, Materia
&& item.getFactory().equals(materialMainAttrEntity.getFactory())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(sameList)) {
MaterialMainAttrEntity update = sameList.get(0);
update.setPurchaseType(materialMainAttrEntity.getPurchaseType());
update.setSpecialPurchaseType(materialMainAttrEntity.getSpecialPurchaseType());
update.setPlanDeliveryTime(materialMainAttrEntity.getPlanDeliveryTime());
materialMainAttrMapper.updateById(materialMainAttrEntity);
if (!update.getPurchaseType().equals(materialMainAttrEntity.getPurchaseType())
|| !update.getSpecialPurchaseType().equals(materialMainAttrEntity.getSpecialPurchaseType())
|| update.getPlanDeliveryTime().intValue() != materialMainAttrEntity.getPlanDeliveryTime().intValue()) {
update.setPurchaseType(materialMainAttrEntity.getPurchaseType());
update.setSpecialPurchaseType(materialMainAttrEntity.getSpecialPurchaseType());
update.setPlanDeliveryTime(materialMainAttrEntity.getPlanDeliveryTime());
materialMainAttrMapper.updateById(materialMainAttrEntity);
}
} else {
this.saveMaterialMainAttr(materialMainAttrEntity);
}

View File

@ -573,4 +573,15 @@
WHERE material_no = #{item.materialNo}
</foreach>
</update>
<select id="getMaterialNoListDataMap" resultType="java.util.Map">
SELECT
`row_id` AS rowId,
`material_no` AS materialNo
FROM t_material_main
WHERE 1 = 1
<include refid="get_list_where"/>
order by rowId desc
limit #{startIndex} ,#{pageSize}
</select>
</mapper>