| | |
| | | for(KingDeeUtilType kingDeeUtilType : KingDeeUtilType.values()) { |
| | | InFormIdParam inFormIdParam = new InFormIdParam(); |
| | | DocType docType = docTypeService.selectOne(new EntityWrapper<DocType>().eq("doc_name", kingDeeUtilType.desc)); |
| | | if (Cools.isEmpty(docType)){ |
| | | docType = docTypeService.selectOrAdd(kingDeeUtilType.desc, kingDeeUtilType.pakIn.equals(1)); |
| | | } |
| | | inFormIdParam.setFormId(kingDeeUtilType.formId); |
| | | inFormIdParam.setLimit(100); |
| | | inFormIdParam.setStartRow("0"); |
| | |
| | | jsonObject.put("StartRow", inFormIdParam.getStartRow()); |
| | | //物料档案查询 |
| | | if(inFormIdParam.getFormId().equals("BD_MATERIAL")){ |
| | | Tag tag = tagService.selectById(20); |
| | | //最新时间 |
| | | Date time=tag.getCreateTime(); |
| | | Tag tag = tagService.selectByName("全部", 1); |
| | | //物料状态 FUseOrgId .FNumber |
| | | FDocumentStatus="C"; |
| | | jsonObject.put("FilterString", "FCreateDate>'"+sdf.format(time)+"' and FDocumentStatus='"+FDocumentStatus+"' and FUseOrgId .FNumber='201'"); |
| | | jsonObject.put("FilterString", "FCreateDate>'"+sdf.format(tag.getUpdateTime())+"' and FDocumentStatus='"+FDocumentStatus+"' and FUseOrgId .FNumber='201'"); |
| | | jsonObject.put("FieldKeys", "FName,FNumber,FCreateDate,FSpecification,FDocumentStatus"); |
| | | // FName : 物料名称 ; |
| | | // FNumber :物料编号; |
| | |
| | | if(data.size()<=0) continue; |
| | | if (data.getJSONArray(0).get(0).toString().length()>=20) continue; |
| | | if (kingDeeUtilType.formId.equals("BD_MATERIAL")) {//物料档案 |
| | | Tag tag = tagService.selectByName("全部", 1); |
| | | for (int j = 0; j < data.size(); j++) { |
| | | JSONArray jsonArray = data.getJSONArray(j); |
| | | //对美国时间进行转换 |
| | | Date date = KingDeeUtil.KingDeeDate(jsonArray.get(2).toString()); |
| | | //生成商品档案 |
| | | //商品编号 |
| | | Mat mat = matService.selectByMatnr(jsonArray.get(1).toString()); |
| | | if (mat == null) { |
| | | mat = new Mat(); |
| | | Tag tag = new Tag(); |
| | | mat.setMatnr(jsonArray.get(1).toString()); |
| | | mat.setMaktx(jsonArray.get(0).toString()); |
| | | mat.setSpecs(jsonArray.get(3).toString());//规格 |
| | | mat.setTagId(20L); |
| | | //对美国时间进行转换 |
| | | Date date = KingDeeUtil.KingDeeDate(jsonArray.get(2).toString()); |
| | | mat.setTagId(tag.getId()); |
| | | mat.setCreateTime(date);//商品创建时间 |
| | | mat.setUpdateTime(new Date()); |
| | | mat.setStatus(1); |
| | | //最新抓取商品时间 |
| | | tag.setCreateTime(date); |
| | | tagService.update(tag, new EntityWrapper<Tag>().eq("id", 20)); |
| | | if (!matService.insert(mat)) { |
| | | throw new CoolException("服务器内部错误,请联系管理员"); |
| | | // throw new CoolException("服务器内部错误,请联系管理员"); |
| | | log.info("同步新物料出错!!!参数:[{}]、[{}]",mat,jsonArray); |
| | | } else { |
| | | log.info("同步新物料[商品编号:{}]", mat.getMatnr()); |
| | | } |
| | | }else { |
| | | log.info("同步新物料[商品编号:{}],商品编号重复!!!", mat.getMatnr()); |
| | | } |
| | | tag.setUpdateTime(date); |
| | | } |
| | | tagService.updateById(tag); |
| | | } else { |
| | | for (int j = 0; j < data.size(); j++) { |
| | | JSONArray jsonArray = data.getJSONArray(j); |