| | |
| | | import cn.hutool.core.util.IdUtil; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.aps.common.core.constant.SecurityConstants; |
| | | import com.aps.common.core.utils.DateUtils; |
| | | import com.aps.common.core.utils.StringUtils; |
| | |
| | | import com.aps.job.mapper.ApsWorkOrderJobLogMapper; |
| | | import com.aps.job.service.IApsBomHeaderJobService; |
| | | import com.aps.system.api.RemoteCoreService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.http.HttpEntity; |
| | |
| | | * @date 2025-05-08 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class ApsBomHeaderJobServiceImpl implements IApsBomHeaderJobService |
| | | { |
| | | @Autowired |
| | |
| | | jobLog.setResult("header:"+headerList.size() + " line:"+lineList.size()); |
| | | jobLog.setCreateBy(batchNum); |
| | | jobLogMapper.insertApsWorkOrderJobLog(jobLog); |
| | | log.info("BOM同步:"+ JSON.toJSONString(jobLog)); |
| | | |
| | | pageIndex++; |
| | | }else{ |
| | | break; |
| | |
| | | jobLog.setResult("error"); |
| | | jobLog.setCreateBy(batchNum); |
| | | jobLogMapper.insertApsWorkOrderJobLog(jobLog); |
| | | log.info("BOM同步:"+ JSON.toJSONString(jobLog)); |
| | | break; |
| | | } |
| | | } |
| | |
| | | jobLog.setResult("error"); |
| | | jobLog.setCreateBy(batchNum); |
| | | jobLogMapper.insertApsWorkOrderJobLog(jobLog); |
| | | log.info("BOM同步异常信息:"+ JSON.toJSONString(jobLog)); |
| | | return false; |
| | | } |
| | | return true; |
| | |
| | | @Override |
| | | public boolean syncBomDataJob(Integer pageIndex, Integer pageSize, String orgCode, String itemCodeList){ |
| | | try { |
| | | log.info("全量同步BOM数据定时任务开始"); |
| | | log.info(" DELETE FROM aps_bom_header_job"); |
| | | apsBomHeaderJobMapper.deleteApsBomHeaderJob(); |
| | | log.info(" DELETE FROM aps_bom_line_job"); |
| | | apsBomLineJobMapper.deleteApsBomLineJob(); |
| | | boolean res = syncBomData(pageIndex, pageSize, orgCode, itemCodeList); |
| | | if(!res){ |
| | | return false; |
| | | } |
| | | log.info("将BOM同步到Redis"); |
| | | remoteCoreService.setBomDataToRedis(SecurityConstants.INNER); |
| | | log.info("deleteApsBomHeader"); |
| | | apsBomHeaderJobMapper.deleteApsBomHeader(); |
| | | log.info("deleteApsBomLine"); |
| | | apsBomLineJobMapper.deleteApsBomLine(); |
| | | log.info("insertIntoApsBomHeader"); |
| | | apsBomHeaderJobMapper.insertIntoApsBomHeader(); |
| | | log.info("insertIntoApsBomLine"); |
| | | apsBomLineJobMapper.insertIntoApsBomLine(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |