oa更新质检标准接口

master
zhaoxiaolin 6 months ago
parent 64c0c150f0
commit c3554ad905

@ -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<SysNoticeGroup> getNotices(SysNoticeGroup noticeQo);
List<String> getExsitCodes(List<String> codes);
int updateProductNoBatchs(@Param("list") List<BaseProductDTO> updates);
int addProductNoBatchs(@Param("list")List<BaseProductDTO> everyList);
}

@ -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<BaseProductDTO> 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<BaseProductDTO> 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<String> codes = dtos.stream().map(BaseProductDTO::getProductCode).collect(Collectors.toList());
//sap返回的客户编码-本地已存在
List<String> exsitCodes = openMapper.getExsitCodes(codes);
//sap返回的产品编码-本地不存在// 差集 (list2 - list1)
List<String> noExsitCodes = codes.stream().filter(item -> !exsitCodes.contains(item)).collect(Collectors.toList());
List<BaseProductDTO> updates = new ArrayList<>();
for (String exsitCode : exsitCodes) {
List<BaseProductDTO> 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<BaseProductDTO> adds = new ArrayList<>();
for (String noExsitCode : noExsitCodes) {
List<BaseProductDTO> 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<BaseProductDTO> 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();

@ -27,6 +27,27 @@
<update id="updateWorkOrderStatus">
update pro_order_workorder set status = #{status} where belong_work_order = #{workorderCode}
</update>
<update id="updateProductNoBatchs">
<foreach collection="list" item="item" separator=";">
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}
</foreach>
</update>
<!--获取在邦rfid 工单的信息-->
<select id="getRfidInfo" resultType="com.op.system.api.domain.mes.ProRfidProcessDetail">
@ -385,6 +406,22 @@
)
</foreach>
</insert>
<insert id="addProductNoBatchs">
insert into base_product(
product_code,product_desc_zh,product_group,product_group_name,
meins,product_model,umrez,umren,mvgr5,
gross_weight,volume
,create_by,create_time
) values
<foreach item="item" index="index" collection="list" separator=",">
(
#{item.productCode},#{item.productDescZh},#{item.productGroup},#{item.productGroupName},
#{item.meins},#{item.productModel},#{item.umrez},#{item.umren},#{item.mvgr5},
#{item.grossWeight},#{item.volume},
'oa',GETDATE()
)
</foreach>
</insert>
<select id="getNoticesGroup" resultType="com.op.system.api.domain.SysNoticeGroup">
select sng.notice_id noticeId,
@ -412,5 +449,11 @@
from sys_notice sn
where sn.notice_id = #{noticeId}
</select>
<select id="getExsitCodes" resultType="java.lang.String">
select product_code from base_product where product_code in
<foreach collection="list" item="code" open="(" separator="," close=")">
#{code}
</foreach>
</select>
</mapper>

Loading…
Cancel
Save