|
|
|
@ -22,6 +22,7 @@ import com.chanko.yunxi.mes.module.biz.dal.dataobject.material.MaterialDO;
|
|
|
|
|
import com.chanko.yunxi.mes.module.biz.dal.dataobject.procedure.ProcedureDO;
|
|
|
|
|
import com.chanko.yunxi.mes.module.biz.dal.dataobject.processbom.ProcessBomDO;
|
|
|
|
|
import com.chanko.yunxi.mes.module.biz.dal.dataobject.storage.StorageDO;
|
|
|
|
|
import com.chanko.yunxi.mes.module.biz.dal.dataobject.supplier.SupplierDO;
|
|
|
|
|
import com.chanko.yunxi.mes.module.biz.dal.dataobject.taskreport.TaskReportDO;
|
|
|
|
|
import com.chanko.yunxi.mes.module.biz.dal.dataobject.workshop.WorkshopDO;
|
|
|
|
|
import com.chanko.yunxi.mes.module.biz.dal.mysql.customer.CustomerMapper;
|
|
|
|
@ -257,6 +258,67 @@ public class ChanjetManager {
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void querySupplier() throws ChanjetApiException {
|
|
|
|
|
|
|
|
|
|
String maxTs = null;
|
|
|
|
|
do {
|
|
|
|
|
QueryPartnerReqVO.QueryPartnerParamVO paramVO = new QueryPartnerReqVO.QueryPartnerParamVO(new HashMap<String, String>() {{
|
|
|
|
|
put("Name", "供应商");
|
|
|
|
|
}}, maxTs);
|
|
|
|
|
CommonResult<List<QueryPartnerResVO>> result = chanjetSpi.invokeRetList(QUERY_CUSTOMER, new QueryPartnerReqVO(paramVO), QueryPartnerResVO.class);
|
|
|
|
|
if(!result.isSuccess()){
|
|
|
|
|
throw new RuntimeException(result.getMsg());
|
|
|
|
|
}
|
|
|
|
|
if(CollUtil.isNotEmpty(result.getData())){
|
|
|
|
|
|
|
|
|
|
List<QueryPartnerResVO> dataList = result.getData();
|
|
|
|
|
Map<Long, List<QueryPartnerResVO>> dataGroupById = dataList.stream().collect(Collectors.groupingBy(QueryPartnerResVO::getID));
|
|
|
|
|
|
|
|
|
|
List<SupplierDO> doList = supplierMapper.selectList(new LambdaQueryWrapper<SupplierDO>() {{
|
|
|
|
|
in(SupplierDO::getId, dataGroupById.keySet());
|
|
|
|
|
}});
|
|
|
|
|
Map<Long, List<SupplierDO>> existsDOGroupById = doList.stream().collect(Collectors.groupingBy(SupplierDO::getId));
|
|
|
|
|
|
|
|
|
|
// 取最大 ts
|
|
|
|
|
QueryPartnerResVO maxTsVO = dataList.stream().sorted(Comparator.comparing((d) -> 0 - Long.parseLong(d.getTS().substring(2), 16))).findFirst().get();
|
|
|
|
|
maxTs = maxTsVO.getTS();
|
|
|
|
|
|
|
|
|
|
// 处理
|
|
|
|
|
ArrayList<SupplierDO> insertList = new ArrayList<>(16);
|
|
|
|
|
ArrayList<SupplierDO> updateList = new ArrayList<>(16);
|
|
|
|
|
dataGroupById.forEach((id, voList) -> {
|
|
|
|
|
QueryPartnerResVO vo = voList.get(0);
|
|
|
|
|
List<SupplierDO> existsDOs = existsDOGroupById.get(id);
|
|
|
|
|
|
|
|
|
|
if(CollUtil.isNotEmpty(existsDOs)){
|
|
|
|
|
SupplierDO existsDO = existsDOs.get(0);
|
|
|
|
|
existsDO.setCode(vo.getCode())
|
|
|
|
|
.setBrief(vo.getShorthand())
|
|
|
|
|
.setStatus(!vo.getDisabled() ? ValidStatusEnum.VALID.getCode() : ValidStatusEnum.INVALID.getCode())
|
|
|
|
|
.setName(vo.getName());
|
|
|
|
|
updateList.add(existsDO);
|
|
|
|
|
}else{
|
|
|
|
|
SupplierDO aDO = new SupplierDO();
|
|
|
|
|
aDO.setId(vo.getID())
|
|
|
|
|
.setCode(vo.getCode())
|
|
|
|
|
.setBrief(vo.getShorthand())
|
|
|
|
|
.setStatus(!vo.getDisabled() ? ValidStatusEnum.VALID.getCode() : ValidStatusEnum.INVALID.getCode())
|
|
|
|
|
.setName(vo.getName());
|
|
|
|
|
insertList.add(aDO);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 入库
|
|
|
|
|
if(CollUtil.isNotEmpty(updateList)) supplierMapper.updateBatch(updateList);
|
|
|
|
|
if(CollUtil.isNotEmpty(insertList)) supplierMapper.insertBatch(insertList);
|
|
|
|
|
|
|
|
|
|
if(result.getData().size() < paramVO.getPageSize()){
|
|
|
|
|
maxTs = null;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
maxTs = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}while (maxTs != null);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|