diff --git a/op-modules/op-open/src/main/java/com/op/open/mapper/OpenMapper.java b/op-modules/op-open/src/main/java/com/op/open/mapper/OpenMapper.java index df9c304c..e8d52529 100644 --- a/op-modules/op-open/src/main/java/com/op/open/mapper/OpenMapper.java +++ b/op-modules/op-open/src/main/java/com/op/open/mapper/OpenMapper.java @@ -5,10 +5,7 @@ import com.op.system.api.domain.SysSapLog; import com.op.system.api.domain.device.DeviceRepairOrder; import com.op.system.api.domain.device.EquEquipmentDTO; import com.op.system.api.domain.dto.WCSDTO; -import com.op.system.api.domain.mes.MesReportWorkConsumeDTO; -import com.op.system.api.domain.mes.MesReportWorkDTO; -import com.op.system.api.domain.mes.ProOrderWorkorderDTO; -import com.op.system.api.domain.mes.ProRfidProcessDetail; +import com.op.system.api.domain.mes.*; import com.op.system.api.domain.quality.*; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -94,5 +91,10 @@ public interface OpenMapper { List getNotices(SysNoticeGroup noticeQo); + List getExsitCodes(List codes); + + int updateProductNoBatchs(@Param("list") List updates); + + int addProductNoBatchs(@Param("list")List everyList); } diff --git a/op-modules/op-open/src/main/java/com/op/open/service/impl/OpenServiceImpl.java b/op-modules/op-open/src/main/java/com/op/open/service/impl/OpenServiceImpl.java index a1f7633a..6d746d13 100644 --- a/op-modules/op-open/src/main/java/com/op/open/service/impl/OpenServiceImpl.java +++ b/op-modules/op-open/src/main/java/com/op/open/service/impl/OpenServiceImpl.java @@ -24,6 +24,7 @@ import com.op.system.api.domain.dto.WechartDTO; import com.op.system.api.domain.mes.BaseProductDTO; import com.op.system.api.domain.mes.ProRfidProcessDetail; import com.op.system.api.domain.quality.*; +import com.op.system.api.domain.sap.SapCustom; import com.op.system.api.domain.sap.SapSupplier; import org.apache.commons.lang.StringUtils; @@ -627,6 +628,7 @@ public class OpenServiceImpl implements OpenService { } /** + * factoryCode 1000 * 物料编码+productCode * 物料描述+productDescZh * 物料组编码+productGroup @@ -636,29 +638,58 @@ public class OpenServiceImpl implements OpenService { * 计量转换分子+umrez * 分母UMREZ+umren * 检验标准+ mvgr5 - * 毛重(无\0)+ grosseight + * 毛重(无\0)+ grossWeight * 体积 volume * **/ @Override public AjaxResult sendProductCheckNo(List dtos) { try { logger.info("oa更新检验标准发送参数"+JSONObject.toJSONString(dtos)); -// int allsize = dtos.size(); -// if(CollectionUtils.isEmpty(dtos)){ -// return error("oa更新检验标准发送参数为空"); -// } -// int inserttimes = allsize / 100 + 1; -// for (int m = 0; m < inserttimes; m++) { -// List everyList; -// if (m < (inserttimes - 1)) { -// everyList = dtos.subList(m * 100, (m + 1) * 100); -// } else { -// everyList = dtos.subList(m * 100, allsize); -// } -// if (everyList.size() > 0) { -// sapBomMapper.addSupplierBatchs(everyList); -// } -// } + if(CollectionUtils.isEmpty(dtos)){ + return error("oa更新检验标准发送参数为空"); + } + DynamicDataSourceContextHolder.push("ds_"+dtos.get(0).getFactoryCode()); + + //sap返回的产品编码 + List codes = dtos.stream().map(BaseProductDTO::getProductCode).collect(Collectors.toList()); + //sap返回的客户编码-本地已存在 + List exsitCodes = openMapper.getExsitCodes(codes); + //sap返回的产品编码-本地不存在// 差集 (list2 - list1) + List noExsitCodes = codes.stream().filter(item -> !exsitCodes.contains(item)).collect(Collectors.toList()); + + List updates = new ArrayList<>(); + for (String exsitCode : exsitCodes) { + List updates0 = dtos.stream().filter(dto -> dto.getProductCode().equals(exsitCode)).collect(Collectors.toList()); + updates.addAll(updates0); + } + if (!CollectionUtils.isEmpty(updates)) { + int m = openMapper.updateProductNoBatchs(updates); + System.out.println("oa产品更新成功条数:" + m); + } + List adds = new ArrayList<>(); + for (String noExsitCode : noExsitCodes) { + List adds0 = dtos.stream().filter(dto -> dto.getProductCode().equals(noExsitCode)).collect(Collectors.toList()); + adds.addAll(adds0); + } + if (!CollectionUtils.isEmpty(adds)) { + + int allsize = adds.size(); + int inserttimes = allsize / 100 + 1; + for (int m = 0; m < inserttimes; m++) { + List everyList; + if (m < (inserttimes - 1)) { + everyList = adds.subList(m * 100, (m + 1) * 100); + } else { + everyList = adds.subList(m * 100, allsize); + } + if (everyList.size() > 0) { + openMapper.addProductNoBatchs(everyList); + } + } + + System.out.println("oa产品新增成功条数:" + allsize); + } + return success(); } catch (Exception e) { e.printStackTrace(); diff --git a/op-modules/op-open/src/main/resources/mapper/open/OpenMapper.xml b/op-modules/op-open/src/main/resources/mapper/open/OpenMapper.xml index 5bf9cb6f..e6c5cede 100644 --- a/op-modules/op-open/src/main/resources/mapper/open/OpenMapper.xml +++ b/op-modules/op-open/src/main/resources/mapper/open/OpenMapper.xml @@ -27,6 +27,27 @@ update pro_order_workorder set status = #{status} where belong_work_order = #{workorderCode} + + + update base_product + set + product_code = #{item.productCode}, + product_desc_zh = #{item.productDescZh}, + product_group = #{item.productGroup}, + product_group_name = #{item.productGroupName}, + meins = #{item.meins}, + product_model = #{item.productModel}, + umrez = #{item.umrez}, + umren = #{item.umren}, + mvgr5 = #{item.mvgr5}, + gross_weight = #{item.grossWeight}, + volume = #{item.volume}, + update_by = 'oa', + update_time = GETDATE() + where + product_code = #{item.productCode} + + select sng.notice_id noticeId, @@ -412,5 +449,11 @@ from sys_notice sn where sn.notice_id = #{noticeId} +