change - 切换SAP订单工作中心,下发生产计划

master
yinq 1 year ago
parent 5cb1d898f0
commit 034655d49b

@ -4,6 +4,7 @@ import com.aucma.api.domain.dto.SAPBOMPortDto;
import com.aucma.api.domain.dto.SAPPortDto;
import com.aucma.api.domain.dto.WERKSDto;
import com.aucma.api.service.ISAPPortService;
import com.aucma.api.service.ISAPPutStorageService;
import com.aucma.base.domain.BaseDeviceLedger;
import com.aucma.base.domain.BaseMaterialInfo;
import com.aucma.base.domain.BaseOrderInfo;
@ -34,6 +35,8 @@ public class SAPPortController extends BaseController {
@Autowired
private ISAPPortService sapPortService;
@Autowired
private ISAPPutStorageService storageService;
/**
* SAP
* @param paramMap
@ -117,4 +120,13 @@ public class SAPPortController extends BaseController {
return toAjax(sapPortService.addSAPCalendar(calendarInfo));
}
/**
* 线
* @param baseOrderInfo
* @return
*/
@PostMapping("/replaceProductionLine")
public AjaxResult replaceProductionLine(@RequestBody BaseOrderInfo baseOrderInfo) {
return toAjax(storageService.replaceProductionLine(baseOrderInfo));
}
}

@ -46,4 +46,10 @@ public interface ISAPPutStorageService {
* */
public ArrayList<OrderBomInfo> insertSAPOrderBomInfo(SAPResultBomVo resultVo) throws ParseException;
/**
* 线
* @param baseOrderInfo
* @return
*/
int replaceProductionLine(BaseOrderInfo baseOrderInfo);
}

@ -14,12 +14,14 @@ import com.aucma.base.service.IBaseMaterialInfoService;
import com.aucma.base.service.IBaseOrderInfoService;
import com.aucma.base.service.IOrderBomInfoService;
import com.aucma.base.utils.MaterialConstants;
import com.aucma.common.exception.ServiceException;
import com.aucma.common.utils.DateUtils;
import com.aucma.common.utils.StringUtils;
import com.aucma.production.domain.CalendarInfo;
import com.aucma.production.domain.ProductPlanInfo;
import com.aucma.production.service.ICalendarInfoService;
import com.aucma.production.service.IProductPlanInfoService;
import com.aucma.system.utils.PortLogUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -209,6 +211,9 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService {
} else {
//更新SAP计划
BaseOrderInfo baseOrderInfoOld = baseOrderInfos.get(0);
if (baseOrderInfoOld.getManualUpdateFlag().equals("1")){
continue;
}
BaseOrderInfo baseOrderInfo = new BaseOrderInfo();
baseOrderInfo.setObjId(baseOrderInfoOld.getObjId());
baseOrderInfo.setMaterialCode(baseOrderInfoOld.getMaterialCode());
@ -357,4 +362,65 @@ public class SAPPutStorageServiceImpl implements ISAPPutStorageService {
return orderBomInfoList;
}
/**
* 线
* @param baseOrderInfo
* @return
*/
@Override
public int replaceProductionLine(BaseOrderInfo baseOrderInfo) {
BaseOrderInfo orderInfo = baseOrderInfoService.selectBaseOrderInfoByObjId(baseOrderInfo.getObjId());
// 订单数量==切换数量 => 修改工作中心
if (baseOrderInfo.getReplaceAmount() == baseOrderInfo.getOrderAmount().longValue()){
orderInfo.setManualUpdateFlag("1");
orderInfo.setWorkCenterCode(baseOrderInfo.getWorkCenterCode());
int i = baseOrderInfoService.updateBaseOrderInfo(orderInfo);
if (i > 0){
ProductPlanInfo productPlanInfo = new ProductPlanInfo();
productPlanInfo.setOrderCode(orderInfo.getOrderCode());
//删除旧计划
List<ProductPlanInfo> productPlanInfoList = productPlanInfoService.selectProductPlanInfoList(productPlanInfo);
for (ProductPlanInfo planInfo : productPlanInfoList) {
productPlanInfoService.deleteProductPlanInfoByObjId(planInfo.getObjId());
}
productPlanInfoService.releaseOrderPlan(orderInfo);
}
return 1;
}
// 订单数量 < 切换数量 => 添加一条并且修改工作中心
try {
//更新历史SAP订单订单数量
BaseOrderInfo info = new BaseOrderInfo();
info.setObjId(orderInfo.getObjId());
info.setOrderAmount(new BigDecimal(baseOrderInfo.getOrderAmount().longValue() - baseOrderInfo.getReplaceAmount()));
info.setManualUpdateFlag("1");
baseOrderInfoService.updateBaseOrderInfo(info);
//更新历史生产计划订单数量
ProductPlanInfo productPlanInfo = new ProductPlanInfo();
productPlanInfo.setOrderCode(orderInfo.getOrderCode());
List<ProductPlanInfo> productPlanInfoList = productPlanInfoService.selectProductPlanInfoList(productPlanInfo);
for (ProductPlanInfo planInfo : productPlanInfoList) {
ProductPlanInfo plan = new ProductPlanInfo();
plan.setObjId(planInfo.getObjId());
planInfo.setPlanAmount(baseOrderInfo.getOrderAmount().longValue() - baseOrderInfo.getReplaceAmount());
productPlanInfoService.updateProductPlanInfo(plan);
}
//插入新SAP订单 更换后工作中心
BaseOrderInfo orderOldInfo = baseOrderInfoService.selectBaseOrderInfoByObjId(orderInfo.getObjId());
orderOldInfo.setObjId(null);
orderOldInfo.setCompleteAmount(0L);
orderOldInfo.setOrderAmount(new BigDecimal(baseOrderInfo.getReplaceAmount()));
orderOldInfo.setWorkCenterCode(baseOrderInfo.getWorkCenterCode());
orderOldInfo.setCompleteDate(null);
baseOrderInfoService.insertBaseOrderInfo(orderOldInfo);
//新订单下计划
productPlanInfoService.releaseOrderPlan(orderOldInfo);
PortLogUtils.savePortLog("1301", "手动更换订单产线" + baseOrderInfo.getOrderCode(),
"replaceProductionLine", baseOrderInfo.toString(), null, null);
} catch (Exception e) {
PortLogUtils.savePortLog("1301", "手动更换订单产线" + baseOrderInfo.getOrderCode(),
"replaceProductionLine", baseOrderInfo.toString(), null, e.toString());
}
return 1;
}
}

@ -158,6 +158,32 @@ public class BaseOrderInfo extends BaseEntity {
*/
private String routingCode;
/**
* 线
*/
private Long replaceAmount;
/**
* 0=1=
*/
private String manualUpdateFlag;
public Long getReplaceAmount() {
return replaceAmount;
}
public void setReplaceAmount(Long replaceAmount) {
this.replaceAmount = replaceAmount;
}
public String getManualUpdateFlag() {
return manualUpdateFlag;
}
public void setManualUpdateFlag(String manualUpdateFlag) {
this.manualUpdateFlag = manualUpdateFlag;
}
public String getWorkCenterCode() {
return workCenterCode;
}

@ -28,6 +28,7 @@
<result property="isRelease" column="is_release"/>
<result property="workCenterCode" column="work_center_code"/>
<result property="routingCode" column="routing_code"/>
<result property="manualUpdateFlag" column="manual_update_flag"/>
</resultMap>
<sql id="selectBaseOrderInfoVo">
@ -49,6 +50,7 @@
oi.is_release,
oi.work_center_code,
oi.routing_code,
oi.manual_update_flag,
oi.created_by,
oi.created_time,
oi.updated_by,
@ -75,6 +77,7 @@
<if test="completeAmount != null ">and oi.complete_amount = #{completeAmount}</if>
<if test="orderType != null and orderType != ''">and oi.order_type = #{orderType}</if>
<if test="orderStatus != null and orderStatus != ''">and oi.order_status = #{orderStatus}</if>
<if test="manualUpdateFlag != null and manualUpdateFlag != ''">and oi.manual_update_flag = #{manualUpdateFlag}</if>
<if test="beginDate != null ">and oi.begin_date = #{beginDate}</if>
<if test="endDate != null ">and oi.end_date = #{endDate}</if>
<if test="factoryCode != null and factoryCode != ''">and oi.factory_code = #{factoryCode}</if>
@ -128,6 +131,7 @@
<if test="completeDate != null">complete_date,</if>
<if test="workCenterCode != null">work_center_code,</if>
<if test="routingCode != null">routing_code,</if>
<if test="manualUpdateFlag != null">manual_update_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="objId != null">#{objId},</if>
@ -153,6 +157,7 @@
<if test="completeDate != null">#{completeDate},</if>
<if test="workCenterCode != null">#{workCenterCode},</if>
<if test="routingCode != null">#{routingCode},</if>
<if test="manualUpdateFlag != null">#{manualUpdateFlag},</if>
</trim>
</insert>
@ -181,6 +186,7 @@
<if test="completeDate != null">complete_date = #{completeDate},</if>
<if test="workCenterCode != null">work_center_code = #{workCenterCode},</if>
<if test="routingCode != null">routing_code = #{routingCode},</if>
<if test="manualUpdateFlag != null">manual_update_flag = #{manualUpdateFlag},</if>
</trim>
where obj_id = #{objId}
</update>

Loading…
Cancel
Save