change - sap接口去重

master
yinq 2 years ago
parent 242c5a05a3
commit 4bdd6471fb

@ -32,6 +32,7 @@ public interface ISAPPutStorageService {
*
* */
public ArrayList<BaseOrderInfo> insertSAPBaseOrderInfo(SAPResultOrderInfoVo resultVo) throws ParseException;
/**
*
* @param resultVo

@ -1,6 +1,5 @@
package com.aucma.api.service.impl;
import com.aucma.api.domain.vo.SAPResultBomVo;
import com.aucma.api.domain.vo.SAPResultOrderInfoVo;
import com.aucma.api.domain.vo.SAPResultVo;
import com.aucma.api.service.ISAPPutStorageService;
@ -13,19 +12,13 @@ import com.aucma.base.service.IBaseMaterialInfoService;
import com.aucma.base.service.IBaseOrderInfoService;
import com.aucma.base.service.IOrderBomInfoService;
import com.aucma.common.utils.DateUtils;
import com.aucma.common.utils.SecurityUtils;
import com.aucma.production.domain.BaseBomInfo;
import com.aucma.production.service.IBaseBomInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@ -46,6 +39,7 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService {
@Autowired
private IBaseOrderInfoService baseOrderInfoService;
@Autowired
private IOrderBomInfoService orderBomInfoService;
@ -60,6 +54,7 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService {
List<HashMap<String, String>> itemList = resultVo.getO_TAB().get("item");
for (HashMap<String, String> map : itemList) {
BaseMaterialInfo baseMaterialInfo = new BaseMaterialInfo();
baseMaterialInfo.setPlantCode(map.get("WERKS"));
baseMaterialInfo.setMaterialCode(map.get("MATNR"));
List<BaseMaterialInfo> baseMaterialInfoList = baseMaterialInfoService.selectBaseMaterialInfoList(baseMaterialInfo);
if (baseMaterialInfoList.isEmpty()) {
@ -84,9 +79,10 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService {
ArrayList<BaseOrderInfo> baseOrderInfoList = new ArrayList<>();
List<HashMap<String, String>> itemList = resultVo.getO_TAB().get("item");
for (HashMap<String, String> map : itemList) {
String aufnr = map.get("AUFNR");
BaseOrderInfo boInfo = new BaseOrderInfo();
boInfo.setOrderCode(aufnr);
boInfo.setOrderCode(map.get("AUFNR"));
boInfo.setMaterialCode(map.get("MATNR"));
boInfo.setFactoryCode(map.get("WERKS"));
List<BaseOrderInfo> baseOrderInfos = baseOrderInfoService.selectBaseOrderInfoList(boInfo);
if (baseOrderInfos.isEmpty()) {
BaseOrderInfo baseOrderInfo = new BaseOrderInfo();
@ -104,7 +100,6 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService {
baseOrderInfo.setEndDate(new SimpleDateFormat("yyyy-MM-dd").parse(map.get("GSTRP")));
baseOrderInfo.setCreatedTime(DateUtils.getNowDate());
baseOrderInfoService.insertBaseOrderInfo(baseOrderInfo);
baseOrderInfoList.add(baseOrderInfo);
}
@ -126,9 +121,10 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService {
List<HashMap<String, String>> itemList = resultVo.getO_TAB().get("item");
for (HashMap<String, String> map : itemList) {
BaseDeviceLedger device = new BaseDeviceLedger();
device.setCostCenter(map.get("KOSTL"));;
device.setDeviceCode(map.get("EQUNR"));
device.setFactoryCode(map.get("IWERK"));
List<BaseDeviceLedger> baseDeviceLedgers = baseDeviceLedgerService.selectBaseDeviceLedgerList(device);
if (!baseDeviceLedgers.isEmpty()) {
BaseDeviceLedger deviceLedger = new BaseDeviceLedger();
deviceLedger.setCostCenter(map.get("KOSTL"));//
@ -147,15 +143,20 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService {
return baseDeviceLedgerArrayList;
}
/**
* bom
*
* */
@Override
public ArrayList<OrderBomInfo> insertSAPOrderBomInfo(SAPResultOrderInfoVo resultVo) throws ParseException {
ArrayList<OrderBomInfo> orderBomInfoList = new ArrayList<>();
List<HashMap<String, String>> itemList = resultVo.getO_TAB().get("item");
for (HashMap<String, String> map : itemList) {
OrderBomInfo orderBomInfo1 = new OrderBomInfo();
orderBomInfo1.setMaterialCode(map.get("IDNRK"));
List<OrderBomInfo> orderBomInfos = orderBomInfoService.selectOrderBomInfoList(orderBomInfo1);
OrderBomInfo bomInfo = new OrderBomInfo();
bomInfo.setMaterialCode(map.get("IDNRK"));
bomInfo.setParentId(map.get("MATNR"));
bomInfo.setFactoryCode(map.get("WERKS"));
List<OrderBomInfo> orderBomInfos = orderBomInfoService.selectOrderBomInfoList(bomInfo);
if (orderBomInfos.isEmpty()) {
OrderBomInfo orderBomInfo = new OrderBomInfo();
orderBomInfo.setFactoryCode(map.get("WERKS"));
@ -167,8 +168,6 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService {
orderBomInfo.setSort(map.get("SORTF"));
orderBomInfo.setVbeln(map.get("VBELN"));
orderBomInfo.setVbpos(map.get("VBPOS"));
orderBomInfo.setCreatedTime(DateUtils.getNowDate());
// baseBomInfo.setCreatedBy(SecurityUtils.getLoginUser().getUsername());
orderBomInfoService.insertOrderBomInfo(orderBomInfo);
orderBomInfoList.add(orderBomInfo);
}

@ -75,7 +75,6 @@ public class BaseMaterialInfoController extends BaseController {
@PostMapping
public AjaxResult add(@RequestBody BaseMaterialInfo baseMaterialInfo) {
baseMaterialInfo.setCreatedBy(getUsername());
baseMaterialInfo.setCreatedTime(DateUtils.getNowDate());
return toAjax(baseMaterialInfoService.insertBaseMaterialInfo(baseMaterialInfo));
}

@ -86,7 +86,6 @@ public class OrderBomInfoController extends BaseController {
@PostMapping
public AjaxResult add(@RequestBody OrderBomInfo orderBomInfo) {
orderBomInfo.setCreatedBy(getUsername());
orderBomInfo.setCreatedTime(DateUtils.getNowDate());
return toAjax(orderBomInfoService.insertOrderBomInfo(orderBomInfo));
}

@ -1,6 +1,8 @@
package com.aucma.base.service.impl;
import java.util.List;
import com.aucma.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.aucma.base.mapper.BaseMaterialInfoMapper;
@ -52,6 +54,7 @@ public class BaseMaterialInfoServiceImpl implements IBaseMaterialInfoService
@Override
public int insertBaseMaterialInfo(BaseMaterialInfo baseMaterialInfo)
{
baseMaterialInfo.setCreatedTime(DateUtils.getNowDate());
return baseMaterialInfoMapper.insertBaseMaterialInfo(baseMaterialInfo);
}

@ -1,6 +1,8 @@
package com.aucma.base.service.impl;
import java.util.List;
import com.aucma.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.aucma.base.mapper.OrderBomInfoMapper;
@ -52,6 +54,7 @@ public class OrderBomInfoServiceImpl implements IOrderBomInfoService
@Override
public int insertOrderBomInfo(OrderBomInfo orderBomInfo)
{
orderBomInfo.setCreatedTime(DateUtils.getNowDate());
return orderBomInfoMapper.insertOrderBomInfo(orderBomInfo);
}

@ -5,121 +5,143 @@
<mapper namespace="com.aucma.base.mapper.OrderBomInfoMapper">
<resultMap type="OrderBomInfo" id="OrderBomInfoResult">
<result property="objId" column="obj_id" />
<result property="bomCode" column="bom_code" />
<result property="materialCode" column="material_code" />
<result property="materialName" column="material_name" />
<result property="materialType" column="material_type" />
<result property="standardAmount" column="standard_amount" />
<result property="parentId" column="parent_id" />
<result property="isFlag" column="is_flag" />
<result property="createdBy" column="created_by" />
<result property="createdTime" column="created_time" />
<result property="updatedBy" column="updated_by" />
<result property="updatedTime" column="updated_time" />
<result property="factoryCode" column="factory_code" />
<result property="sort" column="sort" />
<result property="vbeln" column="vbeln" />
<result property="vbpos" column="vbpos" />
<result property="objId" column="obj_id"/>
<result property="bomCode" column="bom_code"/>
<result property="materialCode" column="material_code"/>
<result property="materialName" column="material_name"/>
<result property="materialType" column="material_type"/>
<result property="standardAmount" column="standard_amount"/>
<result property="parentId" column="parent_id"/>
<result property="isFlag" column="is_flag"/>
<result property="createdBy" column="created_by"/>
<result property="createdTime" column="created_time"/>
<result property="updatedBy" column="updated_by"/>
<result property="updatedTime" column="updated_time"/>
<result property="factoryCode" column="factory_code"/>
<result property="sort" column="sort"/>
<result property="vbeln" column="vbeln"/>
<result property="vbpos" column="vbpos"/>
</resultMap>
<sql id="selectOrderBomInfoVo">
select obj_id, bom_code, material_code, material_name, material_type, standard_amount, parent_id, is_flag, created_by, created_time, updated_by, updated_time, factory_code, sort, vbeln, vbpos from order_bominfo
select ob.obj_id,
ob.bom_code,
ob.material_code,
bm.material_name,
ob.material_type,
ob.standard_amount,
ob.parent_id,
ob.is_flag,
ob.created_by,
ob.created_time,
ob.updated_by,
ob.updated_time,
ob.factory_code,
ob.sort,
ob.vbeln,
ob.vbpos
from order_bominfo ob
left join BASE_MATERIALINFO bm ON bm.MATERIAL_CODE = ob.material_code
</sql>
<select id="selectOrderBomInfoList" parameterType="OrderBomInfo" resultMap="OrderBomInfoResult">
<include refid="selectOrderBomInfoVo"/>
<where>
<if test="bomCode != null and bomCode != ''"> and bom_code = #{bomCode}</if>
<if test="materialCode != null and materialCode != ''"> and material_code = #{materialCode}</if>
<if test="materialName != null and materialName != ''"> and material_name like concat(concat('%', #{materialName}), '%')</if>
<if test="materialType != null and materialType != ''"> and material_type = #{materialType}</if>
<if test="standardAmount != null "> and standard_amount = #{standardAmount}</if>
<if test="parentId != null and parentId != ''"> and parent_id = #{parentId}</if>
<if test="isFlag != null "> and is_flag = #{isFlag}</if>
<if test="createdBy != null and createdBy != ''"> and created_by = #{createdBy}</if>
<if test="createdTime != null "> and created_time = #{createdTime}</if>
<if test="updatedBy != null and updatedBy != ''"> and updated_by = #{updatedBy}</if>
<if test="updatedTime != null "> and updated_time = #{updatedTime}</if>
<if test="factoryCode != null and factoryCode != ''"> and factory_code = #{factoryCode}</if>
<if test="sort != null and sort != ''"> and sort = #{sort}</if>
<if test="vbeln != null and vbeln != ''"> and vbeln = #{vbeln}</if>
<if test="vbpos != null and vbpos != ''"> and vbpos = #{vbpos}</if>
<if test="bomCode != null and bomCode != ''">and ob.bom_code = #{bomCode}</if>
<if test="materialCode != null and materialCode != ''">and ob.material_code = #{materialCode}</if>
<if test="materialName != null and materialName != ''">and ob.material_name like concat(concat('%',
#{materialName}), '%')
</if>
<if test="materialType != null and materialType != ''">and ob.material_type = #{materialType}</if>
<if test="standardAmount != null ">and ob.standard_amount = #{standardAmount}</if>
<if test="parentId != null and parentId != ''">and ob.parent_id = #{parentId}</if>
<if test="isFlag != null ">and ob.is_flag = #{isFlag}</if>
<if test="createdBy != null and createdBy != ''">and ob.created_by = #{createdBy}</if>
<if test="createdTime != null ">and ob.created_time = #{createdTime}</if>
<if test="updatedBy != null and updatedBy != ''">and ob.updated_by = #{updatedBy}</if>
<if test="updatedTime != null ">and ob.updated_time = #{updatedTime}</if>
<if test="factoryCode != null and factoryCode != ''">and ob.factory_code = #{factoryCode}</if>
<if test="sort != null and sort != ''">and ob.sort = #{sort}</if>
<if test="vbeln != null and vbeln != ''">and ob.vbeln = #{vbeln}</if>
<if test="vbpos != null and vbpos != ''">and ob.vbpos = #{vbpos}</if>
</where>
order by ob.parent_id, ob.sort
</select>
<select id="selectOrderBomInfoByObjId" parameterType="Long" resultMap="OrderBomInfoResult">
<include refid="selectOrderBomInfoVo"/>
where obj_id = #{objId}
<include refid="selectOrderBomInfoVo"/>
where ob.obj_id = #{objId}
</select>
<insert id="insertOrderBomInfo" parameterType="OrderBomInfo">
<selectKey keyProperty="objId" resultType="long" order="BEFORE">
SELECT seq_order_bominfo.NEXTVAL as objId FROM DUAL
</selectKey>
<selectKey keyProperty="objId" resultType="long" order="BEFORE">
SELECT seq_order_bominfo.NEXTVAL as objId FROM DUAL
</selectKey>
insert into order_bominfo
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="objId != null">obj_id,</if>
<if test="bomCode != null">bom_code,</if>
<if test="materialCode != null">material_code,</if>
<if test="materialName != null">material_name,</if>
<if test="materialType != null">material_type,</if>
<if test="standardAmount != null">standard_amount,</if>
<if test="parentId != null">parent_id,</if>
<if test="isFlag != null">is_flag,</if>
<if test="createdBy != null">created_by,</if>
<if test="createdTime != null">created_time,</if>
<if test="updatedBy != null">updated_by,</if>
<if test="updatedTime != null">updated_time,</if>
<if test="factoryCode != null">factory_code,</if>
<if test="sort != null">sort,</if>
<if test="vbeln != null">vbeln,</if>
<if test="vbpos != null">vbpos,</if>
<if test="objId != null">obj_id,</if>
<if test="bomCode != null">bom_code,</if>
<if test="materialCode != null">material_code,</if>
<if test="materialName != null">material_name,</if>
<if test="materialType != null">material_type,</if>
<if test="standardAmount != null">standard_amount,</if>
<if test="parentId != null">parent_id,</if>
<if test="isFlag != null">is_flag,</if>
<if test="createdBy != null">created_by,</if>
<if test="createdTime != null">created_time,</if>
<if test="updatedBy != null">updated_by,</if>
<if test="updatedTime != null">updated_time,</if>
<if test="factoryCode != null">factory_code,</if>
<if test="sort != null">sort,</if>
<if test="vbeln != null">vbeln,</if>
<if test="vbpos != null">vbpos,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="objId != null">#{objId},</if>
<if test="bomCode != null">#{bomCode},</if>
<if test="materialCode != null">#{materialCode},</if>
<if test="materialName != null">#{materialName},</if>
<if test="materialType != null">#{materialType},</if>
<if test="standardAmount != null">#{standardAmount},</if>
<if test="parentId != null">#{parentId},</if>
<if test="isFlag != null">#{isFlag},</if>
<if test="createdBy != null">#{createdBy},</if>
<if test="createdTime != null">#{createdTime},</if>
<if test="updatedBy != null">#{updatedBy},</if>
<if test="updatedTime != null">#{updatedTime},</if>
<if test="factoryCode != null">#{factoryCode},</if>
<if test="sort != null">#{sort},</if>
<if test="vbeln != null">#{vbeln},</if>
<if test="vbpos != null">#{vbpos},</if>
<if test="objId != null">#{objId},</if>
<if test="bomCode != null">#{bomCode},</if>
<if test="materialCode != null">#{materialCode},</if>
<if test="materialName != null">#{materialName},</if>
<if test="materialType != null">#{materialType},</if>
<if test="standardAmount != null">#{standardAmount},</if>
<if test="parentId != null">#{parentId},</if>
<if test="isFlag != null">#{isFlag},</if>
<if test="createdBy != null">#{createdBy},</if>
<if test="createdTime != null">#{createdTime},</if>
<if test="updatedBy != null">#{updatedBy},</if>
<if test="updatedTime != null">#{updatedTime},</if>
<if test="factoryCode != null">#{factoryCode},</if>
<if test="sort != null">#{sort},</if>
<if test="vbeln != null">#{vbeln},</if>
<if test="vbpos != null">#{vbpos},</if>
</trim>
</insert>
<update id="updateOrderBomInfo" parameterType="OrderBomInfo">
update order_bominfo
<trim prefix="SET" suffixOverrides=",">
<if test="bomCode != null">bom_code = #{bomCode},</if>
<if test="materialCode != null">material_code = #{materialCode},</if>
<if test="materialName != null">material_name = #{materialName},</if>
<if test="materialType != null">material_type = #{materialType},</if>
<if test="standardAmount != null">standard_amount = #{standardAmount},</if>
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="isFlag != null">is_flag = #{isFlag},</if>
<if test="createdBy != null">created_by = #{createdBy},</if>
<if test="createdTime != null">created_time = #{createdTime},</if>
<if test="updatedBy != null">updated_by = #{updatedBy},</if>
<if test="updatedTime != null">updated_time = #{updatedTime},</if>
<if test="factoryCode != null">factory_code = #{factoryCode},</if>
<if test="sort != null">sort = #{sort},</if>
<if test="vbeln != null">vbeln = #{vbeln},</if>
<if test="vbpos != null">vbpos = #{vbpos},</if>
<if test="bomCode != null">bom_code = #{bomCode},</if>
<if test="materialCode != null">material_code = #{materialCode},</if>
<if test="materialName != null">material_name = #{materialName},</if>
<if test="materialType != null">material_type = #{materialType},</if>
<if test="standardAmount != null">standard_amount = #{standardAmount},</if>
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="isFlag != null">is_flag = #{isFlag},</if>
<if test="createdBy != null">created_by = #{createdBy},</if>
<if test="createdTime != null">created_time = #{createdTime},</if>
<if test="updatedBy != null">updated_by = #{updatedBy},</if>
<if test="updatedTime != null">updated_time = #{updatedTime},</if>
<if test="factoryCode != null">factory_code = #{factoryCode},</if>
<if test="sort != null">sort = #{sort},</if>
<if test="vbeln != null">vbeln = #{vbeln},</if>
<if test="vbpos != null">vbpos = #{vbpos},</if>
</trim>
where obj_id = #{objId}
</update>
<delete id="deleteOrderBomInfoByObjId" parameterType="Long">
delete from order_bominfo where obj_id = #{objId}
delete
from order_bominfo
where obj_id = #{objId}
</delete>
<delete id="deleteOrderBomInfoByObjIds" parameterType="String">

Loading…
Cancel
Save