update - 自动同步生产BOM、自动生成生产计划

master
yinq 2 years ago
parent ee29102b28
commit 9089cef779

@ -22,12 +22,6 @@ public class SAPResultBomVo {
@JsonProperty(value = "O_RETURN") @JsonProperty(value = "O_RETURN")
private WERKSDto O_RETURN; private WERKSDto O_RETURN;
@JsonProperty(value = "EDATE")
private String EDATE;
@JsonProperty(value = "NDATE")
private String NDATE;
@JsonProperty(value = "XTYPE")
private String XTYPE;
public HashMap<String, List<HashMap<String, String>>> getO_TAB() { public HashMap<String, List<HashMap<String, String>>> getO_TAB() {
return O_TAB; return O_TAB;
@ -53,29 +47,6 @@ public class SAPResultBomVo {
O_RETURN = o_RETURN; O_RETURN = o_RETURN;
} }
public String getEDATE() {
return EDATE;
}
public void setEDATE(String EDATE) {
this.EDATE = EDATE;
}
public String getNDATE() {
return NDATE;
}
public void setNDATE(String NDATE) {
this.NDATE = NDATE;
}
public String getXTYPE() {
return XTYPE;
}
public void setXTYPE(String XTYPE) {
this.XTYPE = XTYPE;
}
@Override @Override
public String toString() { public String toString() {
@ -83,9 +54,6 @@ public class SAPResultBomVo {
"O_TAB=" + O_TAB + "O_TAB=" + O_TAB +
", WERKS=" + WERKS + ", WERKS=" + WERKS +
", O_RETURN=" + O_RETURN + ", O_RETURN=" + O_RETURN +
", EDATE='" + EDATE + '\'' +
", NDATE='" + NDATE + '\'' +
", XTYPE='" + XTYPE + '\'' +
'}'; '}';
} }
} }

@ -44,6 +44,6 @@ public interface ISAPPutStorageService {
* bom * bom
* *
* */ * */
public ArrayList<OrderBomInfo> insertSAPOrderBomInfo(SAPResultOrderInfoVo resultVo) throws ParseException; public ArrayList<OrderBomInfo> insertSAPOrderBomInfo(SAPResultBomVo resultVo) throws ParseException;
} }

@ -4,6 +4,7 @@ package com.aucma.api.service.impl;
import com.aucma.api.domain.dto.SAPBOMPortDto; import com.aucma.api.domain.dto.SAPBOMPortDto;
import com.aucma.api.domain.dto.SAPPortDto; import com.aucma.api.domain.dto.SAPPortDto;
import com.aucma.api.domain.dto.WERKSDto; import com.aucma.api.domain.dto.WERKSDto;
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.ISAPPortService; import com.aucma.api.service.ISAPPortService;
@ -17,6 +18,7 @@ import com.aucma.base.domain.OrderBomInfo;
import com.aucma.common.exception.base.BaseException; import com.aucma.common.exception.base.BaseException;
import com.aucma.common.utils.StringUtils; import com.aucma.common.utils.StringUtils;
import com.aucma.system.utils.PortLogUtils; import com.aucma.system.utils.PortLogUtils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -111,7 +113,7 @@ public class SAPPortServiceImpl implements ISAPPortService {
if (StringUtils.isNull(resultVo.getO_RETURN()) || !resultVo.getO_RETURN().getItem().get(0).get("ID").contains("0")){ if (StringUtils.isNull(resultVo.getO_RETURN()) || !resultVo.getO_RETURN().getItem().get(0).get("ID").contains("0")){
throw new BaseException("处理接口返回消息错误ID不为0或O_RETURN为空"); throw new BaseException("处理接口返回消息错误ID不为0或O_RETURN为空");
} }
//转物料实体类 保存数据 //转工单实体类 保存数据
baseOrderInfoVos = storageService.insertSAPBaseOrderInfo(resultVo); baseOrderInfoVos = storageService.insertSAPBaseOrderInfo(resultVo);
//保存接口日志 //保存接口日志
PortLogUtils.savePortLog(werks.getItem().get(0).get("WERKS"), "获取生产工单" + intervalDate, "getSAPBaseOrderInfo", requestParam, result, null); PortLogUtils.savePortLog(werks.getItem().get(0).get("WERKS"), "获取生产工单" + intervalDate, "getSAPBaseOrderInfo", requestParam, result, null);
@ -194,7 +196,7 @@ public class SAPPortServiceImpl implements ISAPPortService {
// 处理接口返回消息 // 处理接口返回消息
ObjectMapper resultMapper = new ObjectMapper(); ObjectMapper resultMapper = new ObjectMapper();
// 将 JSON 字符串转换为 Java 对象 // 将 JSON 字符串转换为 Java 对象
SAPResultOrderInfoVo resultVo = resultMapper.readValue(result, SAPResultOrderInfoVo.class); SAPResultBomVo resultVo = resultMapper.readValue(result, SAPResultBomVo.class);
//判断返回数据是否正确 //判断返回数据是否正确
if (StringUtils.isNull(resultVo.getO_RETURN()) || !resultVo.getO_RETURN().getItem().get(0).get("ID").contains("0")){ if (StringUtils.isNull(resultVo.getO_RETURN()) || !resultVo.getO_RETURN().getItem().get(0).get("ID").contains("0")){
throw new BaseException("处理接口返回消息错误ID不为0或O_RETURN为空"); throw new BaseException("处理接口返回消息错误ID不为0或O_RETURN为空");

@ -1,5 +1,6 @@
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;
@ -60,13 +61,14 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService {
ArrayList<BaseMaterialInfo> baseMaterialInfoArrayList = new ArrayList<>(); ArrayList<BaseMaterialInfo> baseMaterialInfoArrayList = 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) {
if (StringUtils.isEmpty(map.get("WERKS")) || !map.get("WERKS").equals(SAPConstants.FACTORY_CODE)){ if (StringUtils.isEmpty(map.get("WERKS")) || !map.get("WERKS").equals(SAPConstants.FACTORY_CODE)) {
continue; continue;
} }
BaseMaterialInfo baseMaterialInfo = new BaseMaterialInfo(); BaseMaterialInfo baseMaterialInfo = new BaseMaterialInfo();
baseMaterialInfo.setPlantCode(map.get("WERKS")); 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()) {
BaseMaterialInfo materialInfo = new BaseMaterialInfo(); BaseMaterialInfo materialInfo = new BaseMaterialInfo();
materialInfo.setMaterialCode(map.get("MATNR")); materialInfo.setMaterialCode(map.get("MATNR"));
@ -76,14 +78,62 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService {
materialInfo.setMaterialUnit(map.get("MEINS")); materialInfo.setMaterialUnit(map.get("MEINS"));
materialInfo.setMaterialMatkl(map.get("MATKL")); materialInfo.setMaterialMatkl(map.get("MATKL"));
materialInfo.setDISPO(map.get("DISPO")); materialInfo.setDISPO(map.get("DISPO"));
materialInfo.setIncrementDate(DateUtils.dateTime(DateUtils.YYYY_MM_DD,map.get("UDATE"))); this.getMaterialType(materialInfo);
materialInfo.setMaterialCategories("100");
materialInfo.setIncrementDate(DateUtils.dateTime(DateUtils.YYYY_MM_DD, map.get("UDATE")));
baseMaterialInfoService.insertBaseMaterialInfo(materialInfo); baseMaterialInfoService.insertBaseMaterialInfo(materialInfo);
baseMaterialInfoArrayList.add(materialInfo); baseMaterialInfoArrayList.add(materialInfo);
} else {
//修改物料数据
BaseMaterialInfo materialInfo = baseMaterialInfoList.get(0);
materialInfo.setMaterialName(map.get("MAKTX"));
materialInfo.setMaterialType(map.get("MTART"));
materialInfo.setMaterialUnit(map.get("MEINS"));
materialInfo.setMaterialMatkl(map.get("MATKL"));
String dispo = map.get("DISPO");
materialInfo.setDISPO(dispo);
this.getMaterialType(materialInfo);
materialInfo.setMaterialCategories("100");
materialInfo.setIncrementDate(DateUtils.dateTime(DateUtils.YYYY_MM_DD, map.get("UDATE")));
baseMaterialInfoService.updateBaseMaterialInfo(materialInfo);
baseMaterialInfoArrayList.add(materialInfo);
} }
} }
return baseMaterialInfoArrayList; return baseMaterialInfoArrayList;
} }
/**
*
*
* @param materialInfo
* @return
*/
private BaseMaterialInfo getMaterialType(BaseMaterialInfo materialInfo) {
String dispo = materialInfo.getDISPO();
if (StringUtils.isNotEmpty(dispo)) {
//100=成品;200=箱体;300=门体)
if (dispo.equals("100") || dispo.equals("200") || dispo.equals("300")) {
materialInfo.setMaterialSubclass(dispo);
}
}
//400=围板;500=内胆
if (StringUtils.isEmpty(materialInfo.getMaterialSubclass()) && materialInfo.getMaterialName().contains("内胆部件")) {
materialInfo.setMaterialSubclass("500");
}
if (StringUtils.isEmpty(materialInfo.getMaterialSubclass()) && materialInfo.getMaterialName().contains("预装箱体")) {
materialInfo.setMaterialSubclass("400");
}
if (StringUtils.isEmpty(materialInfo.getMaterialSubclass()) && materialInfo.getMaterialName().contains("箱壳部件")) {
materialInfo.setMaterialSubclass("400");
}
//其他
if (StringUtils.isEmpty(materialInfo.getMaterialSubclass())) {
materialInfo.setMaterialSubclass("900");
}
return materialInfo;
}
/** /**
* *
*/ */
@ -92,7 +142,7 @@ 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) {
if (StringUtils.isEmpty(map.get("WERKS")) || !map.get("WERKS").equals(SAPConstants.FACTORY_CODE)){ if (StringUtils.isEmpty(map.get("WERKS")) || !map.get("WERKS").equals(SAPConstants.FACTORY_CODE)) {
continue; continue;
} }
BaseOrderInfo boInfo = new BaseOrderInfo(); BaseOrderInfo boInfo = new BaseOrderInfo();
@ -113,8 +163,10 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService {
} }
baseOrderInfo.setFactoryCode(map.get("WERKS")); baseOrderInfo.setFactoryCode(map.get("WERKS"));
baseOrderInfo.setOrderType(map.get("AUART")); baseOrderInfo.setOrderType(map.get("AUART"));
baseOrderInfo.setBeginDate(new SimpleDateFormat("yyyy-MM-dd").parse(map.get("GLTRP"))); baseOrderInfo.setWorkCenterCode(map.get("ARBPL"));
baseOrderInfo.setEndDate(new SimpleDateFormat("yyyy-MM-dd").parse(map.get("GSTRP"))); baseOrderInfo.setRoutingCode(map.get("AUFPL"));
baseOrderInfo.setBeginDate(new SimpleDateFormat("yyyy-MM-dd").parse(map.get("GSTRP")));
baseOrderInfo.setEndDate(new SimpleDateFormat("yyyy-MM-dd").parse(map.get("GLTRP")));
// 同步生产日历 // 同步生产日历
CalendarInfo calendarInfo = new CalendarInfo(); CalendarInfo calendarInfo = new CalendarInfo();
@ -128,29 +180,33 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService {
calendarInfoService.insertCalendarInfo(calendarInfo); calendarInfoService.insertCalendarInfo(calendarInfo);
baseOrderInfoService.insertBaseOrderInfo(baseOrderInfo); baseOrderInfoService.insertBaseOrderInfo(baseOrderInfo);
baseOrderInfoList.add(baseOrderInfo); baseOrderInfoList.add(baseOrderInfo);
}else { } else {
//更新SAP计划 //更新SAP计划
BaseOrderInfo baseOrderInfo = baseOrderInfos.get(0); BaseOrderInfo baseOrderInfo = baseOrderInfos.get(0);
if (baseOrderInfo.getIsRelease() == 0){ if (baseOrderInfo.getIsRelease() == 0) {
//SAP计划已下达到工位不更新数据 //SAP计划已下达到生产计划工位不更新数据
continue; continue;
} }
baseOrderInfo.setOrderStatus(map.get("STTXT")); baseOrderInfo.setOrderStatus(map.get("STTXT"));
baseOrderInfo.setSaleOrderCode(map.get("KDAUF")); baseOrderInfo.setSaleOrderCode(map.get("KDAUF"));
baseOrderInfo.setMaterialName(map.get("MAKTX")); baseOrderInfo.setMaterialName(map.get("MAKTX"));
baseOrderInfo.setOrderType(map.get("AUART"));
if (!map.get("GAMNG").equals(null)) { if (!map.get("GAMNG").equals(null)) {
baseOrderInfo.setOrderAmount(new BigDecimal(map.get("GAMNG"))); baseOrderInfo.setOrderAmount(new BigDecimal(map.get("GAMNG")));
} }
baseOrderInfo.setOrderType(map.get("AUART"));
baseOrderInfo.setBeginDate(new SimpleDateFormat("yyyy-MM-dd").parse(map.get("GLTRP"))); baseOrderInfo.setWorkCenterCode(map.get("ARBPL"));
baseOrderInfo.setEndDate(new SimpleDateFormat("yyyy-MM-dd").parse(map.get("GSTRP"))); baseOrderInfo.setRoutingCode(map.get("AUFPL"));
baseOrderInfo.setBeginDate(new SimpleDateFormat("yyyy-MM-dd").parse(map.get("GSTRP")));
baseOrderInfo.setEndDate(new SimpleDateFormat("yyyy-MM-dd").parse(map.get("GLTRP")));
baseOrderInfoService.updateBaseOrderInfo(baseOrderInfo); baseOrderInfoService.updateBaseOrderInfo(baseOrderInfo);
// 同步生产日历 // 同步生产日历
CalendarInfo calendar = new CalendarInfo(); CalendarInfo calendar = new CalendarInfo();
calendar.setSapPlanCode(baseOrderInfo.getOrderCode()); calendar.setSapPlanCode(baseOrderInfo.getOrderCode());
calendar.setMaterialCode(baseOrderInfo.getMaterialCode());
List<CalendarInfo> calendarInfos = calendarInfoService.selectCalendarInfoList(calendar); List<CalendarInfo> calendarInfos = calendarInfoService.selectCalendarInfoList(calendar);
if (calendarInfos.size() == 1){ if (calendarInfos.size() == 1) {
CalendarInfo calendarInfo = calendarInfos.get(0); CalendarInfo calendarInfo = calendarInfos.get(0);
calendarInfo.setMaterialName(baseOrderInfo.getMaterialName()); calendarInfo.setMaterialName(baseOrderInfo.getMaterialName());
calendarInfo.setPlanStartDate(baseOrderInfo.getBeginDate()); calendarInfo.setPlanStartDate(baseOrderInfo.getBeginDate());
@ -176,11 +232,12 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService {
ArrayList<BaseDeviceLedger> baseDeviceLedgerArrayList = new ArrayList<>(); ArrayList<BaseDeviceLedger> baseDeviceLedgerArrayList = 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) {
if (StringUtils.isEmpty(map.get("WERKS")) || !map.get("WERKS").equals(SAPConstants.FACTORY_CODE)){ if (StringUtils.isEmpty(map.get("WERKS")) || !map.get("WERKS").equals(SAPConstants.FACTORY_CODE)) {
continue; continue;
} }
BaseDeviceLedger device = new BaseDeviceLedger(); BaseDeviceLedger device = new BaseDeviceLedger();
device.setCostCenter(map.get("KOSTL"));; device.setCostCenter(map.get("KOSTL"));
;
device.setDeviceCode(map.get("EQUNR")); device.setDeviceCode(map.get("EQUNR"));
device.setFactoryCode(map.get("IWERK")); device.setFactoryCode(map.get("IWERK"));
List<BaseDeviceLedger> baseDeviceLedgers = baseDeviceLedgerService.selectBaseDeviceLedgerList(device); List<BaseDeviceLedger> baseDeviceLedgers = baseDeviceLedgerService.selectBaseDeviceLedgerList(device);
@ -204,14 +261,13 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService {
/** /**
* bom * bom
* */
* */
@Override @Override
public ArrayList<OrderBomInfo> insertSAPOrderBomInfo(SAPResultOrderInfoVo resultVo) throws ParseException { public ArrayList<OrderBomInfo> insertSAPOrderBomInfo(SAPResultBomVo 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) {
if (StringUtils.isEmpty(map.get("WERKS")) || !map.get("WERKS").equals(SAPConstants.FACTORY_CODE)){ if (StringUtils.isEmpty(map.get("WERKS")) || !map.get("WERKS").equals(SAPConstants.FACTORY_CODE)) {
continue; continue;
} }
OrderBomInfo bomInfo = new OrderBomInfo(); OrderBomInfo bomInfo = new OrderBomInfo();
@ -230,7 +286,11 @@ 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"));
orderBomInfoService.insertOrderBomInfo(orderBomInfo); try {
orderBomInfoService.insertOrderBomInfo(orderBomInfo);
} catch (Exception e) {
e.printStackTrace();
}
orderBomInfoList.add(orderBomInfo); orderBomInfoList.add(orderBomInfo);
} }
} }

@ -86,7 +86,6 @@ public class BaseMaterialInfoController extends BaseController {
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody BaseMaterialInfo baseMaterialInfo) { public AjaxResult edit(@RequestBody BaseMaterialInfo baseMaterialInfo) {
baseMaterialInfo.setUpdatedBy(getUsername()); baseMaterialInfo.setUpdatedBy(getUsername());
baseMaterialInfo.setUpdatedTime(DateUtils.getNowDate());
return toAjax(baseMaterialInfoService.updateBaseMaterialInfo(baseMaterialInfo)); return toAjax(baseMaterialInfoService.updateBaseMaterialInfo(baseMaterialInfo));
} }

@ -148,6 +148,32 @@ public class BaseOrderInfo extends BaseEntity {
@Excel(name = "完成日期", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "完成日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date completeDate; private Date completeDate;
/**
*
*/
private String workCenterCode;
/**
* 线
*/
private String routingCode;
public String getWorkCenterCode() {
return workCenterCode;
}
public void setWorkCenterCode(String workCenterCode) {
this.workCenterCode = workCenterCode;
}
public String getRoutingCode() {
return routingCode;
}
public void setRoutingCode(String routingCode) {
this.routingCode = routingCode;
}
public Long getIsRelease() { public Long getIsRelease() {
return isRelease; return isRelease;
} }

@ -28,6 +28,14 @@ public interface OrderBomInfoMapper
*/ */
public List<OrderBomInfo> selectOrderBomInfoList(OrderBomInfo orderBomInfo); public List<OrderBomInfo> selectOrderBomInfoList(OrderBomInfo orderBomInfo);
/**
* BOM
*
* @param orderBomInfo BOM
* @return BOM
*/
public List<OrderBomInfo> selectFinishedProductBomInfoList(OrderBomInfo orderBomInfo);
/** /**
* BOM * BOM
* *

@ -67,6 +67,7 @@ public class BaseMaterialInfoServiceImpl implements IBaseMaterialInfoService
@Override @Override
public int updateBaseMaterialInfo(BaseMaterialInfo baseMaterialInfo) public int updateBaseMaterialInfo(BaseMaterialInfo baseMaterialInfo)
{ {
baseMaterialInfo.setUpdatedTime(DateUtils.getNowDate());
return baseMaterialInfoMapper.updateBaseMaterialInfo(baseMaterialInfo); return baseMaterialInfoMapper.updateBaseMaterialInfo(baseMaterialInfo);
} }

@ -56,13 +56,17 @@ public class OrderBomInfoServiceImpl implements IOrderBomInfoService
@Override @Override
public int insertOrderBomInfo(OrderBomInfo orderBomInfo) public int insertOrderBomInfo(OrderBomInfo orderBomInfo)
{ {
OrderBomInfo bomInfo = orderBomInfoMapper.selectOrderBomInfoByMaterialCode(orderBomInfo.getMaterialCode()); // OrderBomInfo bomInfo = orderBomInfoMapper.selectOrderBomInfoByMaterialCode(orderBomInfo.getMaterialCode());
if (StringUtils.isNotNull(bomInfo)){ // if (StringUtils.isNotNull(bomInfo)){
throw new BaseException("该物料编号:" + orderBomInfo.getMaterialCode() + "已存在!"); // throw new BaseException("该物料编号:" + orderBomInfo.getMaterialCode() + "已存在!");
} // }
if (StringUtils.isNotNull(orderBomInfo.getParentId())){ if (StringUtils.isNotNull(orderBomInfo.getParentId())){
OrderBomInfo info = orderBomInfoMapper.selectOrderBomInfoByMaterialCode(orderBomInfo.getParentId()); OrderBomInfo info = orderBomInfoMapper.selectOrderBomInfoByMaterialCode(orderBomInfo.getParentId());
orderBomInfo.setAncestors(info.getAncestors() + "," + orderBomInfo.getMaterialCode()); if (StringUtils.isNotNull(info)){
orderBomInfo.setAncestors(info.getAncestors() + "," + orderBomInfo.getMaterialCode());
}else {
orderBomInfo.setAncestors(orderBomInfo.getParentId() + "," + orderBomInfo.getMaterialCode());
}
}else { }else {
orderBomInfo.setAncestors(orderBomInfo.getMaterialCode()); orderBomInfo.setAncestors(orderBomInfo.getMaterialCode());
} }
@ -73,15 +77,14 @@ public class OrderBomInfoServiceImpl implements IOrderBomInfoService
/** /**
* BOM * BOM
* *
* @param orderBomInfo BOM * @param orderBom BOM
* @return * @return
*/ */
@Override @Override
public int updateOrderBomInfo(OrderBomInfo orderBomInfoa) public int updateOrderBomInfo(OrderBomInfo orderBom)
{ {
List<OrderBomInfo> orderBomInfos = orderBomInfoMapper.selectOrderBomInfoList(new OrderBomInfo()); List<OrderBomInfo> orderBomInfos = orderBomInfoMapper.selectOrderBomInfoList(new OrderBomInfo());
for (OrderBomInfo orderBomInfo : orderBomInfos) { for (OrderBomInfo orderBomInfo : orderBomInfos) {
String parentId = orderBomInfo.getParentId(); String parentId = orderBomInfo.getParentId();
if (StringUtils.isNull(parentId)){ if (StringUtils.isNull(parentId)){
orderBomInfo.setAncestors(orderBomInfo.getMaterialCode()); orderBomInfo.setAncestors(orderBomInfo.getMaterialCode());
@ -99,7 +102,7 @@ public class OrderBomInfoServiceImpl implements IOrderBomInfoService
orderBomInfo.setUpdatedTime(DateUtils.getNowDate()); orderBomInfo.setUpdatedTime(DateUtils.getNowDate());
orderBomInfoMapper.updateOrderBomInfo(orderBomInfo); orderBomInfoMapper.updateOrderBomInfo(orderBomInfo);
} }
return orderBomInfoMapper.updateOrderBomInfo(orderBomInfoa); return orderBomInfoMapper.updateOrderBomInfo(orderBom);
} }
/** /**

@ -105,7 +105,7 @@
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="objId != null">#{objId},</if> <if test="objId != null">#{objId},</if>
<if test="materialCode != null">#{materialCode},</if> <if test="materialCode != null">#{materialCode},</if>
<if test="materialName != null">#{materialName},</if> <if test="materialName != null">#{materialName,jdbcType=NVARCHAR},</if>
<if test="materialCategories != null">#{materialCategories},</if> <if test="materialCategories != null">#{materialCategories},</if>
<if test="materialSubclass != null">#{materialSubclass},</if> <if test="materialSubclass != null">#{materialSubclass},</if>
<if test="materialType != null">#{materialType},</if> <if test="materialType != null">#{materialType},</if>
@ -128,7 +128,7 @@
update base_materialinfo update base_materialinfo
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="materialCode != null">material_code = #{materialCode},</if> <if test="materialCode != null">material_code = #{materialCode},</if>
<if test="materialName != null">material_name = #{materialName},</if> <if test="materialName != null">material_name = #{materialName,jdbcType=NVARCHAR},</if>
<if test="materialCategories != null">material_categories = #{materialCategories},</if> <if test="materialCategories != null">material_categories = #{materialCategories},</if>
<if test="materialSubclass != null">material_subclass = #{materialSubclass},</if> <if test="materialSubclass != null">material_subclass = #{materialSubclass},</if>
<if test="materialType != null">material_type = #{materialType},</if> <if test="materialType != null">material_type = #{materialType},</if>

@ -26,60 +26,66 @@
<result property="updatedTime" column="updated_time"/> <result property="updatedTime" column="updated_time"/>
<result property="completeDate" column="complete_date"/> <result property="completeDate" column="complete_date"/>
<result property="isRelease" column="is_release"/> <result property="isRelease" column="is_release"/>
<result property="workCenterCode" column="work_center_code"/>
<result property="routingCode" column="routing_code"/>
</resultMap> </resultMap>
<sql id="selectBaseOrderInfoVo"> <sql id="selectBaseOrderInfoVo">
select obj_id, select oi.obj_id,
order_code, oi.order_code,
saleorder_code, oi.saleorder_code,
saleorder_linenumber, oi.saleorder_linenumber,
material_code, oi.material_code,
material_name, oi.material_name,
matkl, oi.matkl,
order_amount, oi.order_amount,
complete_amount, oi.complete_amount,
order_type, oi.order_type,
order_status, oi.order_status,
begin_date, oi.begin_date,
end_date, oi.end_date,
factory_code, oi.factory_code,
is_flag, oi.is_flag,
is_release, oi.is_release,
created_by, oi.work_center_code,
created_time, oi.routing_code,
updated_by, oi.created_by,
updated_time, oi.created_time,
complete_date oi.updated_by,
from base_orderinfo oi.updated_time,
oi.complete_date
from base_orderinfo oi
</sql> </sql>
<select id="selectBaseOrderInfoList" parameterType="BaseOrderInfo" resultMap="BaseOrderInfoResult"> <select id="selectBaseOrderInfoList" parameterType="BaseOrderInfo" resultMap="BaseOrderInfoResult">
<include refid="selectBaseOrderInfoVo"/> <include refid="selectBaseOrderInfoVo"/>
JOIN BASE_MATERIALINFO bm ON bm.MATERIAL_CODE = oi.material_code AND bm.DISPO IN ('100')
<where> <where>
<if test="orderCode != null and orderCode != ''">and order_code = #{orderCode}</if> <if test="orderCode != null and orderCode != ''">and oi.order_code = #{orderCode}</if>
<if test="saleOrderCode != null and saleOrderCode != ''">and saleorder_code = #{saleOrderCode}</if> <if test="saleOrderCode != null and saleOrderCode != ''">and oi.saleorder_code = #{saleOrderCode}</if>
<if test="saleOrderLineNumber != null and saleOrderLineNumber != ''">and saleorder_linenumber = <if test="saleOrderLineNumber != null and saleOrderLineNumber != ''">and oi.saleorder_linenumber =
#{saleOrderLineNumber} #{saleOrderLineNumber}
</if> </if>
<if test="materialCode != null and materialCode != ''">and material_code = #{materialCode}</if> <if test="materialCode != null and materialCode != ''">and oi.material_code = #{materialCode}</if>
<if test="materialName != null and materialName != ''">and material_name like concat(concat('%', <if test="materialName != null and materialName != ''">and oi.material_name like concat(concat('%',
#{materialName}), '%') #{materialName}), '%')
</if> </if>
<if test="matkl != null and matkl != ''">and matkl = #{matkl}</if> <if test="matkl != null and matkl != ''">and oi.matkl = #{matkl}</if>
<if test="orderAmount != null ">and order_amount = #{orderAmount}</if> <if test="orderAmount != null ">and oi.order_amount = #{orderAmount}</if>
<if test="completeAmount != null ">and complete_amount = #{completeAmount}</if> <if test="completeAmount != null ">and oi.complete_amount = #{completeAmount}</if>
<if test="orderType != null and orderType != ''">and order_type = #{orderType}</if> <if test="orderType != null and orderType != ''">and oi.order_type = #{orderType}</if>
<if test="orderStatus != null and orderStatus != ''">and order_status = #{orderStatus}</if> <if test="orderStatus != null and orderStatus != ''">and oi.order_status = #{orderStatus}</if>
<if test="beginDate != null ">and begin_date = #{beginDate}</if> <if test="beginDate != null ">and oi.begin_date = #{beginDate}</if>
<if test="endDate != null ">and end_date = #{endDate}</if> <if test="endDate != null ">and oi.end_date = #{endDate}</if>
<if test="factoryCode != null and factoryCode != ''">and factory_code = #{factoryCode}</if> <if test="factoryCode != null and factoryCode != ''">and oi.factory_code = #{factoryCode}</if>
<if test="isFlag != null ">and is_flag = #{isFlag}</if> <if test="isFlag != null ">and is_flag = #{isFlag}</if>
<if test="createdBy != null and createdBy != ''">and created_by = #{createdBy}</if> <if test="createdBy != null and createdBy != ''">and oi.created_by = #{createdBy}</if>
<if test="createdTime != null ">and created_time = #{createdTime}</if> <if test="createdTime != null ">and oi.created_time = #{createdTime}</if>
<if test="updatedBy != null and updatedBy != ''">and updated_by = #{updatedBy}</if> <if test="updatedBy != null and updatedBy != ''">and oi.updated_by = #{updatedBy}</if>
<if test="updatedTime != null ">and updated_time = #{updatedTime}</if> <if test="updatedTime != null ">and oi.updated_time = #{updatedTime}</if>
<if test="completeDate != null ">and complete_date = #{completeDate}</if> <if test="completeDate != null ">and oi.complete_date = #{completeDate}</if>
<if test="isRelease != null ">and is_release = #{isRelease}</if> <if test="isRelease != null ">and oi.is_release = #{isRelease}</if>
<if test="workCenterCode != null ">and oi.work_center_code = #{workCenterCode}</if>
</where> </where>
order by order_code desc order by order_code desc
</select> </select>
@ -116,6 +122,8 @@
<if test="updatedBy != null">updated_by,</if> <if test="updatedBy != null">updated_by,</if>
<if test="updatedTime != null">updated_time,</if> <if test="updatedTime != null">updated_time,</if>
<if test="completeDate != null">complete_date,</if> <if test="completeDate != null">complete_date,</if>
<if test="workCenterCode != null">work_center_code,</if>
<if test="routingCode != null">routing_code,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="objId != null">#{objId},</if> <if test="objId != null">#{objId},</if>
@ -123,7 +131,7 @@
<if test="saleOrderCode != null">#{saleOrderCode},</if> <if test="saleOrderCode != null">#{saleOrderCode},</if>
<if test="saleOrderLineNumber != null">#{saleOrderLineNumber},</if> <if test="saleOrderLineNumber != null">#{saleOrderLineNumber},</if>
<if test="materialCode != null">#{materialCode},</if> <if test="materialCode != null">#{materialCode},</if>
<if test="materialName != null">#{materialName},</if> <if test="materialName != null">#{materialName,jdbcType=NVARCHAR},</if>
<if test="matkl != null">#{matkl},</if> <if test="matkl != null">#{matkl},</if>
<if test="orderAmount != null">#{orderAmount},</if> <if test="orderAmount != null">#{orderAmount},</if>
<if test="completeAmount != null">#{completeAmount},</if> <if test="completeAmount != null">#{completeAmount},</if>
@ -139,6 +147,8 @@
<if test="updatedBy != null">#{updatedBy},</if> <if test="updatedBy != null">#{updatedBy},</if>
<if test="updatedTime != null">#{updatedTime},</if> <if test="updatedTime != null">#{updatedTime},</if>
<if test="completeDate != null">#{completeDate},</if> <if test="completeDate != null">#{completeDate},</if>
<if test="workCenterCode != null">#{workCenterCode},</if>
<if test="routingCode != null">#{routingCode},</if>
</trim> </trim>
</insert> </insert>
@ -149,7 +159,7 @@
<if test="saleOrderCode != null">saleorder_code = #{saleOrderCode},</if> <if test="saleOrderCode != null">saleorder_code = #{saleOrderCode},</if>
<if test="saleOrderLineNumber != null">saleorder_linenumber = #{saleOrderLineNumber},</if> <if test="saleOrderLineNumber != null">saleorder_linenumber = #{saleOrderLineNumber},</if>
<if test="materialCode != null">material_code = #{materialCode},</if> <if test="materialCode != null">material_code = #{materialCode},</if>
<if test="materialName != null">material_name = #{materialName},</if> <if test="materialName != null">material_name = #{materialName,jdbcType=NVARCHAR},</if>
<if test="matkl != null">matkl = #{matkl},</if> <if test="matkl != null">matkl = #{matkl},</if>
<if test="orderAmount != null">order_amount = #{orderAmount},</if> <if test="orderAmount != null">order_amount = #{orderAmount},</if>
<if test="completeAmount != null">complete_amount = #{completeAmount},</if> <if test="completeAmount != null">complete_amount = #{completeAmount},</if>

@ -50,13 +50,12 @@
<include refid="selectOrderBomInfoVo"/> <include refid="selectOrderBomInfoVo"/>
<where> <where>
<if test="bomCode != null and bomCode != ''">and ob.bom_code = #{bomCode}</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="materialCode != null and materialCode != ''">and ob.material_code like concat(#{materialCode}, '%')</if>
<if test="materialName != null and materialName != ''">and bm.material_name like concat(concat('%', <if test="materialName != null and materialName != ''">and bm.material_name like concat(concat('%',#{materialName}), '%')
#{materialName}), '%')
</if> </if>
<if test="materialType != null and materialType != ''">and ob.material_type = #{materialType}</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="standardAmount != null ">and ob.standard_amount = #{standardAmount}</if>
<if test="parentId != null and parentId != ''">and ob.parent_id = #{parentId}</if> <if test="parentId != null and parentId != ''">and ob.parent_id = like concat(#{parentId}, '%')</if>
<if test="isFlag != null ">and ob.is_flag = #{isFlag}</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="createdBy != null and createdBy != ''">and ob.created_by = #{createdBy}</if>
<if test="createdTime != null ">and ob.created_time = #{createdTime}</if> <if test="createdTime != null ">and ob.created_time = #{createdTime}</if>
@ -166,6 +165,21 @@
select * from order_bominfo where FIND_IN_SET(#{materialCode}, ancestors) <![CDATA[ <> ]]> 0 select * from order_bominfo where FIND_IN_SET(#{materialCode}, ancestors) <![CDATA[ <> ]]> 0
</select> </select>
<select id="selectFinishedProductBomInfoList" parameterType="OrderBomInfo" resultMap="OrderBomInfoResult">
select bm.MATERIAL_CODE,
bm.material_name,
bm.MATERIAL_SUBCLASS material_type,
ob.parent_id,
ob.factory_code plant_code
from order_bominfo ob
left join BASE_MATERIALINFO bm ON bm.MATERIAL_CODE = ob.parent_id
<where>
<if test="materialCode != null and materialCode != ''">and ob.parent_id like concat(#{materialCode}, '%')</if>
</where>
group by bm.MATERIAL_CODE,bm.material_name,bm.MATERIAL_SUBCLASS,ob.parent_id,ob.factory_code
</select>
<update id="updateBomChildren" parameterType="java.util.List"> <update id="updateBomChildren" parameterType="java.util.List">
update order_bominfo set ancestors = update order_bominfo set ancestors =
<foreach collection="depts" item="item" index="index" <foreach collection="depts" item="item" index="index"

@ -109,4 +109,16 @@ public class BaseBomInfoController extends BaseController {
public AjaxResult remove(@PathVariable Long[] objIds) { public AjaxResult remove(@PathVariable Long[] objIds) {
return toAjax(baseBomInfoService.deleteBaseBomInfoByObjIds(objIds)); return toAjax(baseBomInfoService.deleteBaseBomInfoByObjIds(objIds));
} }
/**
* BOM
* @param baseBomInfo
* @return
*/
@GetMapping("/addAutomaticSynchronizationBOM" )
public AjaxResult addAutomaticSynchronizationBOM(BaseBomInfo baseBomInfo) {
List<BaseBomInfo> list = baseBomInfoService.addAutomaticSynchronizationBOM(baseBomInfo);
return success(list);
}
} }

@ -65,4 +65,11 @@ public interface IBaseBomInfoService
* @param baseBomInfoList * @param baseBomInfoList
*/ */
void checkBomInfo(List<BaseBomInfo> baseBomInfoList); void checkBomInfo(List<BaseBomInfo> baseBomInfoList);
/**
* BOM
* @param baseBomInfo
* @return
*/
List<BaseBomInfo> addAutomaticSynchronizationBOM(BaseBomInfo baseBomInfo);
} }

@ -2,8 +2,11 @@ package com.aucma.production.service.impl;
import java.util.List; import java.util.List;
import com.aucma.base.domain.OrderBomInfo;
import com.aucma.base.mapper.OrderBomInfoMapper;
import com.aucma.common.exception.ServiceException; import com.aucma.common.exception.ServiceException;
import com.aucma.common.exception.base.BaseException; import com.aucma.common.exception.base.BaseException;
import com.aucma.common.utils.DateUtils;
import com.aucma.common.utils.StringUtils; import com.aucma.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -23,6 +26,8 @@ public class BaseBomInfoServiceImpl implements IBaseBomInfoService
@Autowired @Autowired
private BaseBomInfoMapper baseBomInfoMapper; private BaseBomInfoMapper baseBomInfoMapper;
@Autowired
private OrderBomInfoMapper orderBomInfoMapper;
/** /**
* BOM * BOM
* *
@ -56,8 +61,8 @@ public class BaseBomInfoServiceImpl implements IBaseBomInfoService
@Override @Override
public int insertBaseBomInfo(BaseBomInfo baseBomInfo) public int insertBaseBomInfo(BaseBomInfo baseBomInfo)
{ {
BaseBomInfo bomInfo = baseBomInfoMapper.selectBaseBomInfoByMaterialCode(baseBomInfo.getMaterialCode()); List<BaseBomInfo> baseBomInfos = baseBomInfoMapper.selectBaseBomInfoList(baseBomInfo);
if (StringUtils.isNotNull(bomInfo)){ if (StringUtils.isNotNull(baseBomInfos)){
throw new BaseException("该物料编号:" + baseBomInfo.getMaterialCode() + "已存在!"); throw new BaseException("该物料编号:" + baseBomInfo.getMaterialCode() + "已存在!");
} }
if (StringUtils.isNotNull(baseBomInfo.getParentId())){ if (StringUtils.isNotNull(baseBomInfo.getParentId())){
@ -155,4 +160,38 @@ public class BaseBomInfoServiceImpl implements IBaseBomInfoService
} }
} }
/**
* BOM
* @param baseBomInfo
* @return
*/
@Override
public List<BaseBomInfo> addAutomaticSynchronizationBOM(BaseBomInfo baseBomInfo) {
// 获取成品BOM
OrderBomInfo bomInfo = new OrderBomInfo();
bomInfo.setMaterialCode("90");
List<OrderBomInfo> orderBomInfos = orderBomInfoMapper.selectFinishedProductBomInfoList(bomInfo);
// 保存成品BOM信息
for (OrderBomInfo orderBomInfo : orderBomInfos) {
try {
BaseBomInfo info = new BaseBomInfo();
info.setBomCode(orderBomInfo.getMaterialCode());
info.setMaterialCode(orderBomInfo.getMaterialCode());
info.setMaterialName(orderBomInfo.getMaterialName());
info.setMaterialType("100");
info.setStandardAmount(1L);
info.setPlantCode(info.getPlantCode());
info.setCreatedTime(DateUtils.getNowDate());
this.insertBaseBomInfo(info);
} catch (Exception e) {
e.printStackTrace();
}
}
// 获取子BOM信息
// 保存子成品BOM信息
return null;
}
} }

@ -128,7 +128,8 @@ public class ProductPlanInfoServiceImpl implements IProductPlanInfoService
String saleOrderCode = baseOrderInfo.getSaleOrderCode(); String saleOrderCode = baseOrderInfo.getSaleOrderCode();
String saleOrderLineNumber = baseOrderInfo.getSaleOrderLineNumber(); String saleOrderLineNumber = baseOrderInfo.getSaleOrderLineNumber();
BigDecimal orderAmount = baseOrderInfo.getOrderAmount(); BigDecimal orderAmount = baseOrderInfo.getOrderAmount();
if (StringUtils.isNull(orderAmount) || (orderAmount.compareTo(new BigDecimal(1))==-1)){ int i = orderAmount.compareTo(new BigDecimal(1));
if (orderAmount.compareTo(new BigDecimal(1)) < 0){
throw new BaseException("该工单计划数量不合法!"); throw new BaseException("该工单计划数量不合法!");
} }
//获取生产BOM信息 //获取生产BOM信息

@ -5,23 +5,23 @@
<mapper namespace="com.aucma.production.mapper.BaseBomInfoMapper"> <mapper namespace="com.aucma.production.mapper.BaseBomInfoMapper">
<resultMap type="BaseBomInfo" id="BaseBomInfoResult"> <resultMap type="BaseBomInfo" id="BaseBomInfoResult">
<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="plantCode" column="plant_code" /> <result property="plantCode" column="plant_code"/>
<result property="productLineCode" column="product_line_code" /> <result property="productLineCode" column="product_line_code"/>
<result property="productLineName" column="product_line_name" /> <result property="productLineName" column="product_line_name"/>
<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="ancestors" column="ancestors" /> <result property="ancestors" column="ancestors"/>
<result property="plantName" column="factory_name" /> <result property="plantName" column="factory_name"/>
</resultMap> </resultMap>
<sql id="selectBaseBomInfoVo"> <sql id="selectBaseBomInfoVo">
@ -50,94 +50,101 @@
<select id="selectBaseBomInfoList" parameterType="BaseBomInfo" resultMap="BaseBomInfoResult"> <select id="selectBaseBomInfoList" parameterType="BaseBomInfo" resultMap="BaseBomInfoResult">
<include refid="selectBaseBomInfoVo"/> <include refid="selectBaseBomInfoVo"/>
<where> <where>
<if test="bomCode != null and bomCode != ''"> and bb.bom_code = #{bomCode}</if> <if test="bomCode != null and bomCode != ''">and bb.bom_code = #{bomCode}</if>
<if test="materialCode != null and materialCode != ''"> and bb.material_code = #{materialCode}</if> <if test="materialCode != null and materialCode != ''">and bb.material_code like concat(#{material_code}, '%')</if>
<if test="materialName != null and materialName != ''"> and bb.material_name like concat(concat('%', #{materialName}), '%')</if> <if test="materialName != null and materialName != ''">and bb.material_name like concat(concat('%',#{materialName}), '%')
<if test="materialType != null and materialType != ''"> and bb.material_type = #{materialType}</if> </if>
<if test="standardAmount != null "> and bb.standard_amount = #{standardAmount}</if> <if test="materialType != null and materialType != ''">and bb.material_type = #{materialType}</if>
<if test="parentId != null and parentId != ''"> and bb.parent_id = #{parentId}</if> <if test="standardAmount != null ">and bb.standard_amount = #{standardAmount}</if>
<if test="plantCode != null and plantCode != ''"> and bb.plant_code = #{plantCode}</if> <if test="parentId != null and parentId != ''">and bb.parent_id = #{parentId}</if>
<if test="productLineCode != null and productLineCode != ''"> and bb.product_line_code = #{productLineCode}</if> <if test="plantCode != null and plantCode != ''">and bb.plant_code = #{plantCode}</if>
<if test="isFlag != null "> and bb.is_flag = #{isFlag}</if> <if test="productLineCode != null and productLineCode != ''">and bb.product_line_code =
<if test="createdBy != null and createdBy != ''"> and bb.created_by = #{createdBy}</if> #{productLineCode}
<if test="createdTime != null "> and bb.created_time = #{createdTime}</if> </if>
<if test="updatedBy != null and updatedBy != ''"> and bb.updated_by = #{updatedBy}</if> <if test="isFlag != null ">and bb.is_flag = #{isFlag}</if>
<if test="updatedTime != null "> and bb.updated_time = #{updatedTime}</if> <if test="createdBy != null and createdBy != ''">and bb.created_by = #{createdBy}</if>
<if test="ancestors != null and ancestors != ''"> and bb.ancestors like concat(concat('%', #{ancestors}), '%')</if> <if test="createdTime != null ">and bb.created_time = #{createdTime}</if>
<if test="updatedBy != null and updatedBy != ''">and bb.updated_by = #{updatedBy}</if>
<if test="updatedTime != null ">and bb.updated_time = #{updatedTime}</if>
<if test="ancestors != null and ancestors != ''">and bb.ancestors like concat(concat('%', #{ancestors}),
'%')
</if>
</where> </where>
order by bb.created_time desc order by bb.created_time desc
</select> </select>
<select id="selectBaseBomInfoByObjId" parameterType="Long" resultMap="BaseBomInfoResult"> <select id="selectBaseBomInfoByObjId" parameterType="Long" resultMap="BaseBomInfoResult">
<include refid="selectBaseBomInfoVo"/> <include refid="selectBaseBomInfoVo"/>
where bb.obj_id = #{objId} where bb.obj_id = #{objId}
</select> </select>
<select id="selectBaseBomInfoByMaterialCode" resultMap="BaseBomInfoResult"> <select id="selectBaseBomInfoByMaterialCode" resultMap="BaseBomInfoResult">
<include refid="selectBaseBomInfoVo"/> <include refid="selectBaseBomInfoVo"/>
where bb.material_code = #{materialCode} where bb.material_code = #{materialCode}
</select> </select>
<select id="selectChildrenBomById" parameterType="String" resultMap="BaseBomInfoResult"> <select id="selectChildrenBomById" parameterType="String" resultMap="BaseBomInfoResult">
select * from BASE_BOMINFO where FIND_IN_SET(#{materialCode}, ancestors) <![CDATA[ <> ]]> 0 select *
from BASE_BOMINFO
where FIND_IN_SET(#{materialCode}, ancestors) <![CDATA[ <> ]]> 0
</select> </select>
<insert id="insertBaseBomInfo" parameterType="BaseBomInfo"> <insert id="insertBaseBomInfo" parameterType="BaseBomInfo">
<selectKey keyProperty="objId" resultType="long" order="BEFORE"> <selectKey keyProperty="objId" resultType="long" order="BEFORE">
SELECT seq_base_bominfo.NEXTVAL as objId FROM DUAL SELECT seq_base_bominfo.NEXTVAL as objId FROM DUAL
</selectKey> </selectKey>
insert into base_bominfo insert into base_bominfo
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="objId != null">obj_id,</if> <if test="objId != null">obj_id,</if>
<if test="bomCode != null">bom_code,</if> <if test="bomCode != null">bom_code,</if>
<if test="materialCode != null">material_code,</if> <if test="materialCode != null">material_code,</if>
<if test="materialName != null">material_name,</if> <if test="materialName != null">material_name,</if>
<if test="materialType != null">material_type,</if> <if test="materialType != null">material_type,</if>
<if test="standardAmount != null">standard_amount,</if> <if test="standardAmount != null">standard_amount,</if>
<if test="parentId != null">parent_id,</if> <if test="parentId != null">parent_id,</if>
<if test="plantCode != null">plant_code,</if> <if test="plantCode != null">plant_code,</if>
<if test="productLineCode != null">product_line_code,</if> <if test="productLineCode != null">product_line_code,</if>
<if test="isFlag != null">is_flag,</if> <if test="isFlag != null">is_flag,</if>
<if test="createdBy != null">created_by,</if> <if test="createdBy != null">created_by,</if>
<if test="createdTime != null">created_time,</if> <if test="createdTime != null">created_time,</if>
<if test="updatedBy != null">updated_by,</if> <if test="updatedBy != null">updated_by,</if>
<if test="updatedTime != null">updated_time,</if> <if test="updatedTime != null">updated_time,</if>
<if test="ancestors != null">ancestors,</if> <if test="ancestors != null">ancestors,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="objId != null">#{objId},</if> <if test="objId != null">#{objId},</if>
<if test="bomCode != null">#{bomCode},</if> <if test="bomCode != null">#{bomCode},</if>
<if test="materialCode != null">#{materialCode},</if> <if test="materialCode != null">#{materialCode},</if>
<if test="materialName != null">#{materialName},</if> <if test="materialName != null">#{materialName},</if>
<if test="materialType != null">#{materialType},</if> <if test="materialType != null">#{materialType},</if>
<if test="standardAmount != null">#{standardAmount},</if> <if test="standardAmount != null">#{standardAmount},</if>
<if test="parentId != null">#{parentId},</if> <if test="parentId != null">#{parentId},</if>
<if test="plantCode != null">#{plantCode},</if> <if test="plantCode != null">#{plantCode},</if>
<if test="productLineCode != null">#{productLineCode},</if> <if test="productLineCode != null">#{productLineCode},</if>
<if test="isFlag != null">#{isFlag},</if> <if test="isFlag != null">#{isFlag},</if>
<if test="createdBy != null">#{createdBy},</if> <if test="createdBy != null">#{createdBy},</if>
<if test="createdTime != null">#{createdTime},</if> <if test="createdTime != null">#{createdTime},</if>
<if test="updatedBy != null">#{updatedBy},</if> <if test="updatedBy != null">#{updatedBy},</if>
<if test="updatedTime != null">#{updatedTime},</if> <if test="updatedTime != null">#{updatedTime},</if>
<if test="ancestors != null">#{ancestors},</if> <if test="ancestors != null">#{ancestors},</if>
</trim> </trim>
</insert> </insert>
<update id="updateBaseBomInfo" parameterType="BaseBomInfo"> <update id="updateBaseBomInfo" parameterType="BaseBomInfo">
update base_bominfo update base_bominfo
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="bomCode != null">bom_code = #{bomCode},</if> <if test="bomCode != null">bom_code = #{bomCode},</if>
<if test="materialCode != null">material_code = #{materialCode},</if> <if test="materialCode != null">material_code = #{materialCode},</if>
<if test="materialName != null">material_name = #{materialName},</if> <if test="materialName != null">material_name = #{materialName},</if>
<if test="materialType != null">material_type = #{materialType},</if> <if test="materialType != null">material_type = #{materialType},</if>
<if test="standardAmount != null">standard_amount = #{standardAmount},</if> <if test="standardAmount != null">standard_amount = #{standardAmount},</if>
<if test="parentId != null">parent_id = #{parentId},</if> <if test="parentId != null">parent_id = #{parentId},</if>
<if test="plantCode != null">plant_code = #{plantCode},</if> <if test="plantCode != null">plant_code = #{plantCode},</if>
<if test="productLineCode != null">product_line_code = #{productLineCode},</if> <if test="productLineCode != null">product_line_code = #{productLineCode},</if>
<if test="isFlag != null">is_flag = #{isFlag},</if> <if test="isFlag != null">is_flag = #{isFlag},</if>
<if test="createdBy != null">created_by = #{createdBy},</if> <if test="createdBy != null">created_by = #{createdBy},</if>
<if test="createdTime != null">created_time = #{createdTime},</if> <if test="createdTime != null">created_time = #{createdTime},</if>
<if test="updatedBy != null">updated_by = #{updatedBy},</if> <if test="updatedBy != null">updated_by = #{updatedBy},</if>
<if test="updatedTime != null">updated_time = #{updatedTime},</if> <if test="updatedTime != null">updated_time = #{updatedTime},</if>
<if test="ancestors != null">ancestors = #{ancestors},</if> <if test="ancestors != null">ancestors = #{ancestors},</if>
</trim> </trim>
where obj_id = #{objId} where obj_id = #{objId}
</update> </update>
@ -155,7 +162,9 @@
</update> </update>
<delete id="deleteBaseBomInfoByObjId" parameterType="Long"> <delete id="deleteBaseBomInfoByObjId" parameterType="Long">
delete from base_bominfo where obj_id = #{objId} delete
from base_bominfo
where obj_id = #{objId}
</delete> </delete>
<delete id="deleteBaseBomInfoByObjIds" parameterType="String"> <delete id="deleteBaseBomInfoByObjIds" parameterType="String">

@ -77,7 +77,7 @@
<if test="objId != null">#{objId},</if> <if test="objId != null">#{objId},</if>
<if test="sapPlanCode != null">#{sapPlanCode},</if> <if test="sapPlanCode != null">#{sapPlanCode},</if>
<if test="materialCode != null">#{materialCode},</if> <if test="materialCode != null">#{materialCode},</if>
<if test="materialName != null">#{materialName},</if> <if test="materialName != null">#{materialName,jdbcType=NVARCHAR},</if>
<if test="planStartDate != null">#{planStartDate},</if> <if test="planStartDate != null">#{planStartDate},</if>
<if test="planEndDate != null">#{planEndDate},</if> <if test="planEndDate != null">#{planEndDate},</if>
<if test="planAmount != null">#{planAmount},</if> <if test="planAmount != null">#{planAmount},</if>
@ -97,7 +97,7 @@
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="sapPlanCode != null">sap_plan_code = #{sapPlanCode},</if> <if test="sapPlanCode != null">sap_plan_code = #{sapPlanCode},</if>
<if test="materialCode != null">material_code = #{materialCode},</if> <if test="materialCode != null">material_code = #{materialCode},</if>
<if test="materialName != null">material_name = #{materialName},</if> <if test="materialName != null">material_name = #{materialName,jdbcType=NVARCHAR},</if>
<if test="planStartDate != null">plan_start_date = #{planStartDate},</if> <if test="planStartDate != null">plan_start_date = #{planStartDate},</if>
<if test="planEndDate != null">plan_end_date = #{planEndDate},</if> <if test="planEndDate != null">plan_end_date = #{planEndDate},</if>
<if test="planAmount != null">plan_amount = #{planAmount},</if> <if test="planAmount != null">plan_amount = #{planAmount},</if>

Loading…
Cancel
Save