【定时任务】获取采购属性信息
This commit is contained in:
parent
477b249e93
commit
42cfcb449a
|
|
@ -459,7 +459,7 @@ public class MaterialMainApi extends BaseApi {
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@GetMapping("syncMaterialPurchasePropInfo")
|
@GetMapping("syncMaterialPurchasePropInfo")
|
||||||
public void syncMaterialPurchasePropInfo() throws Exception {
|
public void syncMaterialPurchasePropInfo(@RequestBody MaterialMainQuery query) throws Exception {
|
||||||
materialMainService.syncMaterialPurchasePropInfo();
|
materialMainService.syncMaterialPurchasePropInfo(query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -167,9 +167,10 @@ public class SaticScheduleTask {
|
||||||
* 只针对物料状态material_state为1:激活 2:禁止采购 3:售后专用
|
* 只针对物料状态material_state为1:激活 2:禁止采购 3:售后专用
|
||||||
* * 流程状态:15:已审核 100: 历史正式物料(已审核)
|
* * 流程状态:15:已审核 100: 历史正式物料(已审核)
|
||||||
*/
|
*/
|
||||||
@Scheduled(cron = "0 0 7 * * ?")
|
// 全量更新几十万条数据太慢,暂且注释
|
||||||
|
// @Scheduled(cron = "0 0 7 * * ?")
|
||||||
// @Scheduled(cron = "0 0/2 * * * ? ") // 测试使用,每2分钟
|
// @Scheduled(cron = "0 0/2 * * * ? ") // 测试使用,每2分钟
|
||||||
public void syncMaterialPurchasePropInfo() throws Exception {
|
// public void syncMaterialPurchasePropInfo() throws Exception {
|
||||||
materialMainService.syncMaterialPurchasePropInfo();
|
// materialMainService.syncMaterialPurchasePropInfo(null);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,4 +82,6 @@ public interface MaterialMainMapper extends BaseMapper<MaterialMainEntity> {
|
||||||
List<LanguageTranslationEntity> getKeyLanguage(@Param("languageCode")String languageCode);
|
List<LanguageTranslationEntity> getKeyLanguage(@Param("languageCode")String languageCode);
|
||||||
|
|
||||||
void updateBatchTwoYearsUsage(@Param("list") List<MaterialMainEntity> list);
|
void updateBatchTwoYearsUsage(@Param("list") List<MaterialMainEntity> list);
|
||||||
|
|
||||||
|
List<Map<String,Object>> getMaterialNoListDataMap(@Param("query") MaterialMainQuery query, @Param("startIndex") Long startIndex, @Param("pageSize")Long pageSize );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2986,21 +2986,22 @@ public class MaterialMainService extends ServiceImpl<MaterialMainMapper, Materia
|
||||||
return rlist;
|
return rlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void syncMaterialPurchasePropInfo() {
|
public void syncMaterialPurchasePropInfo(MaterialMainQuery query) {
|
||||||
log.info("获取采购属性信息开始");
|
log.info("获取采购属性信息开始");
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
MaterialMainQuery query = new MaterialMainQuery();
|
if (ObjectUtil.isEmpty(query)) {
|
||||||
|
query = new MaterialMainQuery();
|
||||||
|
}
|
||||||
// 所有大类的物料
|
// 所有大类的物料
|
||||||
// query.setMaterialStates(Arrays.asList(1, 2, 3));
|
// query.setMaterialStates(Arrays.asList(1, 2, 3));
|
||||||
// query.setFirstMaterialCategoryCode("10");
|
// query.setFirstMaterialCategoryCode("10");
|
||||||
query.setPage(1L).setPageSize(10000L);
|
|
||||||
query.setMaterialClass(0); // 接口用途:0:物料查看
|
query.setMaterialClass(0); // 接口用途:0:物料查看
|
||||||
|
query.setPage(1L).setPageSize(10000L);
|
||||||
int pageCount = this.downExcelGetListPages(query) + 1;
|
int pageCount = this.downExcelGetListPages(query) + 1;
|
||||||
|
List<MaterialMainAttrEntity> existsList = materialMainAttrMapper.selectList(null);
|
||||||
for (int i = 1; i <= pageCount; i++) {
|
for (int i = 1; i <= pageCount; i++) {
|
||||||
query.setPage((long) 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) {
|
if (result == null || result.size() <= 0) {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -3019,18 +3020,17 @@ public class MaterialMainService extends ServiceImpl<MaterialMainMapper, Materia
|
||||||
if (CollectionUtil.isEmpty(filterList)) {
|
if (CollectionUtil.isEmpty(filterList)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
this.updateMaterialPropInfo(filterList);
|
this.updateMaterialPropInfo(filterList, existsList);
|
||||||
}
|
}
|
||||||
long endTime = System.currentTimeMillis();
|
long endTime = System.currentTimeMillis();
|
||||||
log.info("获取采购属性信息结束,耗时(ms): {}", (endTime - startTime));
|
log.info("获取采购属性信息结束,耗时(ms): {}", (endTime - startTime));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateMaterialPropInfo(List<MaterialMainAttrEntity> filterList) {
|
private void updateMaterialPropInfo(List<MaterialMainAttrEntity> filterList, List<MaterialMainAttrEntity> existsList) {
|
||||||
if (CollUtil.isEmpty(filterList)) {
|
if (CollUtil.isEmpty(filterList)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<MaterialMainAttrEntity> existsList = materialMainAttrMapper.selectList(null);
|
|
||||||
if (CollUtil.isNotEmpty(existsList)) {
|
if (CollUtil.isNotEmpty(existsList)) {
|
||||||
for (MaterialMainAttrEntity materialMainAttrEntity : filterList) {
|
for (MaterialMainAttrEntity materialMainAttrEntity : filterList) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -3038,10 +3038,14 @@ public class MaterialMainService extends ServiceImpl<MaterialMainMapper, Materia
|
||||||
&& item.getFactory().equals(materialMainAttrEntity.getFactory())).collect(Collectors.toList());
|
&& item.getFactory().equals(materialMainAttrEntity.getFactory())).collect(Collectors.toList());
|
||||||
if (CollUtil.isNotEmpty(sameList)) {
|
if (CollUtil.isNotEmpty(sameList)) {
|
||||||
MaterialMainAttrEntity update = sameList.get(0);
|
MaterialMainAttrEntity update = sameList.get(0);
|
||||||
update.setPurchaseType(materialMainAttrEntity.getPurchaseType());
|
if (!update.getPurchaseType().equals(materialMainAttrEntity.getPurchaseType())
|
||||||
update.setSpecialPurchaseType(materialMainAttrEntity.getSpecialPurchaseType());
|
|| !update.getSpecialPurchaseType().equals(materialMainAttrEntity.getSpecialPurchaseType())
|
||||||
update.setPlanDeliveryTime(materialMainAttrEntity.getPlanDeliveryTime());
|
|| update.getPlanDeliveryTime().intValue() != materialMainAttrEntity.getPlanDeliveryTime().intValue()) {
|
||||||
materialMainAttrMapper.updateById(materialMainAttrEntity);
|
update.setPurchaseType(materialMainAttrEntity.getPurchaseType());
|
||||||
|
update.setSpecialPurchaseType(materialMainAttrEntity.getSpecialPurchaseType());
|
||||||
|
update.setPlanDeliveryTime(materialMainAttrEntity.getPlanDeliveryTime());
|
||||||
|
materialMainAttrMapper.updateById(materialMainAttrEntity);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.saveMaterialMainAttr(materialMainAttrEntity);
|
this.saveMaterialMainAttr(materialMainAttrEntity);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -573,4 +573,15 @@
|
||||||
WHERE material_no = #{item.materialNo}
|
WHERE material_no = #{item.materialNo}
|
||||||
</foreach>
|
</foreach>
|
||||||
</update>
|
</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>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue