Merge remote-tracking branch 'origin/master'

# Conflicts:
#	aucma-api/src/main/java/com/aucma/api/service/impl/SAPPutStorageServiceImpl.java
master
zhouhy 1 year ago
commit 4aeae10d17

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

@ -65,7 +65,6 @@ public class SAPPortServiceImpl implements ISAPPortService {
// result = "{\"O_TAB\":{\"item\":[{\"MAKTX\":\"压缩机,GP14TG,R134a,ACC\",\"WERKS\":\"2004\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000125\"},{\"MAKTX\":\"压缩机,GP14TG,R134a,ACC\",\"WERKS\":\"2006\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000125\"},{\"MAKTX\":\"压缩机,NL7CLX,R404a,丹佛斯\",\"WERKS\":\"2004\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000126\"},{\"MAKTX\":\"压缩机,NL7CLX,R404a,丹佛斯\",\"WERKS\":\"2006\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000126\"},{\"MAKTX\":\"压缩机,HVY57AA,R600a,奥地利ACC\",\"WERKS\":\"2004\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000127\"},{\"MAKTX\":\"压缩机,HVY57AA,R600a,奥地利ACC\",\"WERKS\":\"2006\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000127\"},{\"MAKTX\":\"压缩机,HVY67AA,R600a,奥地利ACC\",\"WERKS\":\"2004\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000128\"},{\"MAKTX\":\"压缩机,HVY67AA,R600a,奥地利ACC\",\"WERKS\":\"2006\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000128\"},{\"MAKTX\":\"压缩机,MR22FB,R404a,ACC\",\"WERKS\":\"2004\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000129\"},{\"MAKTX\":\"压缩机,MR22FB,R404a,ACC\",\"WERKS\":\"2006\",\"MTART\":\"ROH\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-21\",\"MATNR\":\"000000003000000129\"},{\"MAKTX\":\"盖后加固体,BC/BD-127FA\",\"WERKS\":\"2004\",\"MTART\":\"HALB\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-06\",\"MATNR\":\"000000008106000102\"},{\"MAKTX\":\"SC-246,YZXGWB乳品\",\"WERKS\":\"2006\",\"MTART\":\"FERT\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-22\",\"MATNR\":\"000000009002003478\"},{\"MAKTX\":\"SD-460,YZXGW蒙牛冰品\",\"WERKS\":\"2004\",\"MTART\":\"FERT\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-22\",\"MATNR\":\"000000009000004735\"},{\"MAKTX\":\"BC-100E,特需\",\"WERKS\":\"2006\",\"MTART\":\"FERT\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-02\",\"MATNR\":\"000000009001002406\"},{\"MAKTX\":\"BD(C)-310T,特需\",\"WERKS\":\"2004\",\"MTART\":\"FERT\",\"MEINS\":\"EA\",\"UDATE\":\"2019-08-20\",\"MATNR\":\"000000009000000225\"}]},\"WERKS\":null,\"O_RETURN\":{\"item\":[{\"MESSAGE\":\"查询成功1\",\"ID\":\" 0\",\"TYPE\":\"S\"}]}}";
ObjectMapper resultMapper = new ObjectMapper();
// 将 JSON 字符串 转换为 Java 对象
System.out.println(result);
SAPResultVo resultVo = resultMapper.readValue(result, SAPResultVo.class);
//判断返回数据是否正确
if (StringUtils.isNull(resultVo.getO_RETURN()) || !" 0".equals(resultVo.getO_RETURN().getItem().get(0).get("ID"))){
@ -108,17 +107,14 @@ public class SAPPortServiceImpl implements ISAPPortService {
ObjectMapper objectMapper = new ObjectMapper();
requestParam = objectMapper.writeValueAsString(sapPortDto);
//发送post请求 调用获取工单接口
result = ApiUtils.sendSAPHttpPost(SAPConstants.SAP_PREFIX_URL + SAPConstants.PRODUCTION_ORDERS_URL, requestParam);
// 处理接口返回消息
ObjectMapper resultMapper = new ObjectMapper();
// 将 JSON 字符串转换为 Java 对象
SAPResultOrderInfoVo resultVo = resultMapper.readValue(result, SAPResultOrderInfoVo.class);
//判断返回数据是否正确
if (StringUtils.isNull(resultVo.getO_RETURN()) || !" 0".equals(resultVo.getO_RETURN().getItem().get(0).get("ID"))){
System.out.println(resultVo.getO_RETURN().getItem().get(0).get("ID"));
String id = resultVo.getO_RETURN().getItem().get(0).get("ID");
Integer integer = Integer.valueOf(id);
if (integer!=0&&integer!=null){
@ -171,11 +167,11 @@ public class SAPPortServiceImpl implements ISAPPortService {
//转物料实体类 保存数据
baseDeviceLedgersVos = storageService.insertSAPDeviceLedger(resultVo);
//保存接口日志
PortLogUtils.savePortLog(werks.getItem().get(0).get("IWERK"), "获取设备台账数据" + intervalDate, "getSAPBaseDeviceLedger", requestParam, result, null);
PortLogUtils.savePortLog(werks.getItem().get(0).get("WERKS"), "获取设备台账数据" + intervalDate, "getSAPBaseDeviceLedger", requestParam, result, null);
} catch (Exception e) {
//保存接口日志
System.out.println(e.getMessage());
PortLogUtils.savePortLog(werks.getItem().get(0).get("IWERK"), "获取设备台账数据" + intervalDate, "getSAPBaseDeviceLedger", requestParam, result, e.toString());
PortLogUtils.savePortLog(werks.getItem().get(0).get("WERKS"), "获取设备台账数据" + intervalDate, "getSAPBaseDeviceLedger", requestParam, result, e.toString());
}
return baseDeviceLedgersVos;
}
@ -205,7 +201,6 @@ public class SAPPortServiceImpl implements ISAPPortService {
requestParam = objectMapper.writeValueAsString(sapPortDto);
result = ApiUtils.sendSAPHttpPost(SAPConstants.SAP_PREFIX_URL + SAPConstants.PRODUCTS_BOM_URL, requestParam);
// 处理接口返回消息
System.out.println(result);
ObjectMapper resultMapper = new ObjectMapper();
// 将 JSON 字符串转换为 Java 对象
SAPResultOrderInfoVo resultVo = resultMapper.readValue(result, SAPResultOrderInfoVo.class);
@ -221,11 +216,11 @@ public class SAPPortServiceImpl implements ISAPPortService {
//转物料实体类 保存数据
orderBomInfosVos = storageService.insertSAPOrderBomInfo(resultVo);
//保存接口日志
PortLogUtils.savePortLog(werks.getItem().get(0).get("IWERK"), "获取产品bom数据" + intervalDate, "getSapBaseBomInfo", requestParam, result, null);
PortLogUtils.savePortLog(werks.getItem().get(0).get("WERKS"), "获取产品bom数据" + intervalDate, "getSapBaseBomInfo", requestParam, result, null);
} catch (Exception e) {
//保存接口日志
System.out.println(e.getMessage());
PortLogUtils.savePortLog(werks.getItem().get(0).get("IWERK"), "获取产品bom数据" + intervalDate, "getSapBaseBomInfo", requestParam, result, e.toString());
PortLogUtils.savePortLog(werks.getItem().get(0).get("WERKS"), "获取产品bom数据" + intervalDate, "getSapBaseBomInfo", requestParam, result, e.toString());
}
return orderBomInfosVos;
}

@ -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,10 +121,11 @@ 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()) {
if (!baseDeviceLedgers.isEmpty()) {
BaseDeviceLedger deviceLedger = new BaseDeviceLedger();
deviceLedger.setCostCenter(map.get("KOSTL"));//
deviceLedger.setFactoryCode(map.get("IWERK"));
@ -147,15 +143,21 @@ 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 +169,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));
}

@ -110,6 +110,21 @@ public class OrderBomInfo extends TreeStringEntity {
@Excel(name = "销售单据项目")
private String vbpos;
/**
*
*/
private String ancestors;
@Override
public String getAncestors() {
return ancestors;
}
@Override
public void setAncestors(String ancestors) {
this.ancestors = ancestors;
}
public void setObjId(Long objId) {
this.objId = objId;
}

@ -2,6 +2,7 @@ package com.aucma.base.mapper;
import java.util.List;
import com.aucma.base.domain.OrderBomInfo;
import org.apache.ibatis.annotations.Param;
/**
* BOMMapper
@ -58,4 +59,30 @@ public interface OrderBomInfoMapper
* @return
*/
public int deleteOrderBomInfoByObjIds(Long[] objIds);
/**
* IDBom
* @param materialCode
* @return
*/
List<OrderBomInfo> selectChildrenBomById(String materialCode);
/**
*
*
* @param children
* @return
*/
void updateBomChildren(@Param("depts") List<OrderBomInfo> children);
/**
* BOMBOM
*
* @param materialCode BOM
* @return BOM
*/
public OrderBomInfo selectOrderBomInfoByMaterialCode(@Param("materialCode") String materialCode);
}

@ -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,10 @@
package com.aucma.base.service.impl;
import java.util.List;
import com.aucma.common.exception.base.BaseException;
import com.aucma.common.utils.DateUtils;
import com.aucma.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.aucma.base.mapper.OrderBomInfoMapper;
@ -52,6 +56,17 @@ public class OrderBomInfoServiceImpl implements IOrderBomInfoService
@Override
public int insertOrderBomInfo(OrderBomInfo orderBomInfo)
{
OrderBomInfo bomInfo = orderBomInfoMapper.selectOrderBomInfoByMaterialCode(orderBomInfo.getMaterialCode());
if (StringUtils.isNotNull(bomInfo)){
throw new BaseException("该物料编号:" + orderBomInfo.getMaterialCode() + "已存在!");
}
if (StringUtils.isNotNull(orderBomInfo.getParentId())){
OrderBomInfo info = orderBomInfoMapper.selectOrderBomInfoByMaterialCode(orderBomInfo.getParentId());
orderBomInfo.setAncestors(info.getAncestors() + "," + orderBomInfo.getMaterialCode());
}else {
orderBomInfo.setAncestors(orderBomInfo.getMaterialCode());
}
orderBomInfo.setCreatedTime(DateUtils.getNowDate());
return orderBomInfoMapper.insertOrderBomInfo(orderBomInfo);
}
@ -62,9 +77,48 @@ public class OrderBomInfoServiceImpl implements IOrderBomInfoService
* @return
*/
@Override
public int updateOrderBomInfo(OrderBomInfo orderBomInfo)
public int updateOrderBomInfo(OrderBomInfo orderBomInfoa)
{
return orderBomInfoMapper.updateOrderBomInfo(orderBomInfo);
List<OrderBomInfo> orderBomInfos = orderBomInfoMapper.selectOrderBomInfoList(new OrderBomInfo());
for (OrderBomInfo orderBomInfo : orderBomInfos) {
String parentId = orderBomInfo.getParentId();
if (StringUtils.isNull(parentId)){
orderBomInfo.setAncestors(orderBomInfo.getMaterialCode());
}else {
OrderBomInfo newParentBomInfo = orderBomInfoMapper.selectOrderBomInfoByMaterialCode(parentId);
OrderBomInfo oldBomInfo = orderBomInfoMapper.selectOrderBomInfoByMaterialCode(orderBomInfo.getMaterialCode());
if (StringUtils.isNotNull(newParentBomInfo) && StringUtils.isNotNull(oldBomInfo))
{
String newAncestors = newParentBomInfo.getAncestors() + "," + orderBomInfo.getMaterialCode();
String oldAncestors = oldBomInfo.getAncestors();
orderBomInfo.setAncestors(newAncestors);
updateBomChildren(orderBomInfo.getMaterialCode(), newAncestors, oldAncestors);
}
}
orderBomInfo.setUpdatedTime(DateUtils.getNowDate());
orderBomInfoMapper.updateOrderBomInfo(orderBomInfo);
}
return orderBomInfoMapper.updateOrderBomInfo(orderBomInfoa);
}
/**
*
*
* @param materialCode ID
* @param newAncestors ID
* @param oldAncestors ID
*/
private void updateBomChildren(String materialCode, String newAncestors, String oldAncestors) {
List<OrderBomInfo> children = orderBomInfoMapper.selectChildrenBomById(materialCode);
for (OrderBomInfo child : children)
{
child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
}
if (children.size() > 0)
{
orderBomInfoMapper.updateBomChildren(children);
}
}
/**

@ -5,121 +5,154 @@
<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"/>
<result property="ancestors" column="ancestors" />
</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,
bm.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.ancestors,
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 bm.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>
<if test="ancestors != null and ancestors != ''">and ob.ancestors like concat(concat('%', #{ancestors}), '%')</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>
<select id="selectOrderBomInfoByMaterialCode" resultMap="OrderBomInfoResult">
<include refid="selectOrderBomInfoVo"/>
where ob.material_code = #{materialCode}
</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>
<if test="ancestors != null">ancestors,</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>
<if test="ancestors != null">#{ancestors},</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>
<if test="ancestors != null">ancestors = #{ancestors},</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">
@ -128,4 +161,21 @@
#{objId}
</foreach>
</delete>
<select id="selectChildrenBomById" parameterType="String" resultMap="OrderBomInfoResult">
select * from order_bominfo where FIND_IN_SET(#{materialCode}, ancestors) <![CDATA[ <> ]]> 0
</select>
<update id="updateBomChildren" parameterType="java.util.List">
update order_bominfo set ancestors =
<foreach collection="depts" item="item" index="index"
separator=" " open="case material_code" close="end">
when #{item.materialCode} then #{item.ancestors}
</foreach>
where material_code in
<foreach collection="depts" item="item" index="index"
separator="," open="(" close=")">
#{item.materialCode}
</foreach>
</update>
</mapper>

@ -134,7 +134,10 @@ public class ProductPlanInfoServiceImpl implements IProductPlanInfoService
BaseBomInfo bomInfo = new BaseBomInfo();
bomInfo.setParentId(baseOrderInfo.getMaterialCode());
List<BaseBomInfo> baseBomInfoList = baseBomInfoService.selectBaseBomInfoList(bomInfo);
//若一个工单可下达多计划:则需要根据工单编号和物料编号去重
if (baseBomInfoList.size() == 0){
throw new BaseException("请先维护生产BOM信息");
}
//-- 若一个工单可下达多计划:则需要根据工单编号和物料编号去重
//检查生产BOM是否满足下计划条件
baseBomInfoService.checkBomInfo(baseBomInfoList);

Loading…
Cancel
Save