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; public ArrayList<BaseOrderInfo> insertSAPBaseOrderInfo(SAPResultOrderInfoVo resultVo) throws ParseException;
/** /**
* *
* @param resultVo * @param resultVo

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

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

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

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

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

@ -5,52 +5,72 @@
<mapper namespace="com.aucma.base.mapper.OrderBomInfoMapper"> <mapper namespace="com.aucma.base.mapper.OrderBomInfoMapper">
<resultMap type="OrderBomInfo" id="OrderBomInfoResult"> <resultMap type="OrderBomInfo" id="OrderBomInfoResult">
<result property="objId" column="obj_id" /> <result property="objId" column="obj_id"/>
<result property="bomCode" column="bom_code" /> <result property="bomCode" column="bom_code"/>
<result property="materialCode" column="material_code" /> <result property="materialCode" column="material_code"/>
<result property="materialName" column="material_name" /> <result property="materialName" column="material_name"/>
<result property="materialType" column="material_type" /> <result property="materialType" column="material_type"/>
<result property="standardAmount" column="standard_amount" /> <result property="standardAmount" column="standard_amount"/>
<result property="parentId" column="parent_id" /> <result property="parentId" column="parent_id"/>
<result property="isFlag" column="is_flag" /> <result property="isFlag" column="is_flag"/>
<result property="createdBy" column="created_by" /> <result property="createdBy" column="created_by"/>
<result property="createdTime" column="created_time" /> <result property="createdTime" column="created_time"/>
<result property="updatedBy" column="updated_by" /> <result property="updatedBy" column="updated_by"/>
<result property="updatedTime" column="updated_time" /> <result property="updatedTime" column="updated_time"/>
<result property="factoryCode" column="factory_code" /> <result property="factoryCode" column="factory_code"/>
<result property="sort" column="sort" /> <result property="sort" column="sort"/>
<result property="vbeln" column="vbeln" /> <result property="vbeln" column="vbeln"/>
<result property="vbpos" column="vbpos" /> <result property="vbpos" column="vbpos"/>
</resultMap> </resultMap>
<sql id="selectOrderBomInfoVo"> <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> </sql>
<select id="selectOrderBomInfoList" parameterType="OrderBomInfo" resultMap="OrderBomInfoResult"> <select id="selectOrderBomInfoList" parameterType="OrderBomInfo" resultMap="OrderBomInfoResult">
<include refid="selectOrderBomInfoVo"/> <include refid="selectOrderBomInfoVo"/>
<where> <where>
<if test="bomCode != null and bomCode != ''"> and bom_code = #{bomCode}</if> <if test="bomCode != null and bomCode != ''">and ob.bom_code = #{bomCode}</if>
<if test="materialCode != null and materialCode != ''"> and material_code = #{materialCode}</if> <if test="materialCode != null and materialCode != ''">and ob.material_code = #{materialCode}</if>
<if test="materialName != null and materialName != ''"> and material_name like concat(concat('%', #{materialName}), '%')</if> <if test="materialName != null and materialName != ''">and ob.material_name like concat(concat('%',
<if test="materialType != null and materialType != ''"> and material_type = #{materialType}</if> #{materialName}), '%')
<if test="standardAmount != null "> and standard_amount = #{standardAmount}</if> </if>
<if test="parentId != null and parentId != ''"> and parent_id = #{parentId}</if> <if test="materialType != null and materialType != ''">and ob.material_type = #{materialType}</if>
<if test="isFlag != null "> and is_flag = #{isFlag}</if> <if test="standardAmount != null ">and ob.standard_amount = #{standardAmount}</if>
<if test="createdBy != null and createdBy != ''"> and created_by = #{createdBy}</if> <if test="parentId != null and parentId != ''">and ob.parent_id = #{parentId}</if>
<if test="createdTime != null "> and created_time = #{createdTime}</if> <if test="isFlag != null ">and ob.is_flag = #{isFlag}</if>
<if test="updatedBy != null and updatedBy != ''"> and updated_by = #{updatedBy}</if> <if test="createdBy != null and createdBy != ''">and ob.created_by = #{createdBy}</if>
<if test="updatedTime != null "> and updated_time = #{updatedTime}</if> <if test="createdTime != null ">and ob.created_time = #{createdTime}</if>
<if test="factoryCode != null and factoryCode != ''"> and factory_code = #{factoryCode}</if> <if test="updatedBy != null and updatedBy != ''">and ob.updated_by = #{updatedBy}</if>
<if test="sort != null and sort != ''"> and sort = #{sort}</if> <if test="updatedTime != null ">and ob.updated_time = #{updatedTime}</if>
<if test="vbeln != null and vbeln != ''"> and vbeln = #{vbeln}</if> <if test="factoryCode != null and factoryCode != ''">and ob.factory_code = #{factoryCode}</if>
<if test="vbpos != null and vbpos != ''"> and vbpos = #{vbpos}</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> </where>
order by ob.parent_id, ob.sort
</select> </select>
<select id="selectOrderBomInfoByObjId" parameterType="Long" resultMap="OrderBomInfoResult"> <select id="selectOrderBomInfoByObjId" parameterType="Long" resultMap="OrderBomInfoResult">
<include refid="selectOrderBomInfoVo"/> <include refid="selectOrderBomInfoVo"/>
where obj_id = #{objId} where ob.obj_id = #{objId}
</select> </select>
<insert id="insertOrderBomInfo" parameterType="OrderBomInfo"> <insert id="insertOrderBomInfo" parameterType="OrderBomInfo">
@ -119,7 +139,9 @@
</update> </update>
<delete id="deleteOrderBomInfoByObjId" parameterType="Long"> <delete id="deleteOrderBomInfoByObjId" parameterType="Long">
delete from order_bominfo where obj_id = #{objId} delete
from order_bominfo
where obj_id = #{objId}
</delete> </delete>
<delete id="deleteOrderBomInfoByObjIds" parameterType="String"> <delete id="deleteOrderBomInfoByObjIds" parameterType="String">

Loading…
Cancel
Save