diff --git a/src/main/java/com/heai/modules/production/controller/DailyPlanController.java b/src/main/java/com/heai/modules/production/controller/DailyPlanController.java index 31f4edf..45a5d5a 100644 --- a/src/main/java/com/heai/modules/production/controller/DailyPlanController.java +++ b/src/main/java/com/heai/modules/production/controller/DailyPlanController.java @@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.math.BigDecimal; import java.util.List; import java.util.Map; @@ -358,4 +359,19 @@ public class DailyPlanController { List> resultList = dailyPlanService.getAvailableResourceList(inData); return R.ok().put("rows", resultList).put("total",resultList.size()); } + + /** + * @Description TODO + * @Title getAvailableResourceList + * @param inData + * @author rq + * @date 2022/7/22 15:40 + * @return R + * @throw + */ + @PostMapping("/scheduleForShopOrder") + public R scheduleForShopOrder(@RequestBody ScheduleData inData){ + BigDecimal qty= dailyPlanService.scheduleForShopOrder(inData); + return R.ok().put("qty",qty); + } } diff --git a/src/main/java/com/heai/modules/production/dao/DailyPlanMapper.java b/src/main/java/com/heai/modules/production/dao/DailyPlanMapper.java index 3fe92fa..b15882f 100644 --- a/src/main/java/com/heai/modules/production/dao/DailyPlanMapper.java +++ b/src/main/java/com/heai/modules/production/dao/DailyPlanMapper.java @@ -141,4 +141,53 @@ public interface DailyPlanMapper { * @throw */ List getWorkCenterOperatorList(OperatorData inData); + + List checkScheduleQty(ScheduleData inData); + + List checkScheduleList(ScheduleData inData); + + void saveScheduleList(ScheduleData inData); + + /** + * @Description 获取派工单号 + * @Title getDataSequence + * @param + * @author rq + * @date 2022/8/1 17:06 + * @return int + * @throw + */ + int getDataSequence(); + + /** + * @Description 更新派工单 + * @Title updateDataSequence + * @param + * @author rq + * @date 2022/8/1 17:21 + * @return void + * @throw + */ + void updateDataSequence(); + /** + * @Description 保存派工单 + * @Title saveSchedule + * @param inData + * @author rq + * @date 2022/8/2 22:22 + * @return void + * @throw + */ + void saveSchedule(ScheduleData inData); + + /** + * @Description TODO + * @Title 修改数量 + * @param inData + * @author rq + * @date 2022/8/2 22:49 + * @return void + * @throw + */ + void updateScheduleListQty(ScheduleData inData); } diff --git a/src/main/java/com/heai/modules/production/entity/ScheduleCheckData.java b/src/main/java/com/heai/modules/production/entity/ScheduleCheckData.java new file mode 100644 index 0000000..e3908f1 --- /dev/null +++ b/src/main/java/com/heai/modules/production/entity/ScheduleCheckData.java @@ -0,0 +1,35 @@ +package com.heai.modules.production.entity; + +import org.apache.ibatis.type.Alias; + +import java.math.BigDecimal; +@Alias("ScheduleCheckData") +public class ScheduleCheckData { + private BigDecimal qty; + private BigDecimal scheduledQty; + private String status; + + public BigDecimal getQty() { + return qty; + } + + public void setQty(BigDecimal qty) { + this.qty = qty; + } + + public BigDecimal getScheduledQty() { + return scheduledQty; + } + + public void setScheduledQty(BigDecimal scheduledQty) { + this.scheduledQty = scheduledQty; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/src/main/java/com/heai/modules/production/entity/ScheduleData.java b/src/main/java/com/heai/modules/production/entity/ScheduleData.java new file mode 100644 index 0000000..219df44 --- /dev/null +++ b/src/main/java/com/heai/modules/production/entity/ScheduleData.java @@ -0,0 +1,170 @@ +package com.heai.modules.production.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.heai.modules.production.util.BigDecimalUtils; +import org.apache.ibatis.type.Alias; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; +@Alias("ScheduleData") +public class ScheduleData { + private String orderNo; + private String site; + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date needDate; + private String partNo; + private Float itemNo; + private BigDecimal qty; + private String workCenterNo; + private BigDecimal sumQty; + private int seqNo; + private BigDecimal scheduleQty; + private String resourceId; + private String shiftNo; + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date scheduleDate; + private String operatorId; + private String scheduleType; + private float efficiency; + List scheduleDetail; + + public String getOrderNo() { + return orderNo; + } + + public void setOrderNo(String orderNo) { + this.orderNo = orderNo; + } + + public String getSite() { + return site; + } + + public void setSite(String site) { + this.site = site; + } + + public Date getNeedDate() { + return needDate; + } + + public void setNeedDate(Date needDate) { + this.needDate = needDate; + } + + public String getPartNo() { + return partNo; + } + + public void setPartNo(String partNo) { + this.partNo = partNo; + } + + public Float getItemNo() { + return itemNo; + } + + public void setItemNo(Float itemNo) { + this.itemNo = itemNo; + } + + public String getWorkCenterNo() { + return workCenterNo; + } + + public void setWorkCenterNo(String workCenterNo) { + this.workCenterNo = workCenterNo; + } + + public BigDecimal getSumQty() { + return sumQty; + } + + public void setSumQty(BigDecimal sumQty) { + this.sumQty = sumQty; + } + + public List getScheduleDetail() { + return scheduleDetail; + } + + public void setScheduleDetail(List scheduleDetail) { + this.scheduleDetail = scheduleDetail; + } + + public BigDecimal getQty() { + return qty; + } + + public void setQty(BigDecimal qty) { + this.qty = qty; + } + + public int getSeqNo() { + return seqNo; + } + + public void setSeqNo(int seqNo) { + this.seqNo = seqNo; + } + + public BigDecimal getScheduleQty() { + return scheduleQty; + } + + public void setScheduleQty(BigDecimal scheduleQty) { + this.scheduleQty = scheduleQty; + } + + public String getResourceId() { + return resourceId; + } + + public void setResourceId(String resourceId) { + this.resourceId = resourceId; + } + + public String getShiftNo() { + return shiftNo; + } + + public void setShiftNo(String shiftNo) { + this.shiftNo = shiftNo; + } + + public Date getScheduleDate() { + return scheduleDate; + } + + public void setScheduleDate(Date scheduleDate) { + this.scheduleDate = scheduleDate; + } + + public String getOperatorId() { + return operatorId; + } + + public void setOperatorId(String operatorId) { + this.operatorId = operatorId; + } + + public String getScheduleType() { + return scheduleType; + } + + public void setScheduleType(String scheduleType) { + this.scheduleType = scheduleType; + } + + public float getEfficiency() { + return efficiency; + } + + public void setEfficiency(float efficiency) { + this.efficiency = efficiency; + } +} diff --git a/src/main/java/com/heai/modules/production/entity/ScheduleDetail.java b/src/main/java/com/heai/modules/production/entity/ScheduleDetail.java new file mode 100644 index 0000000..3c3f272 --- /dev/null +++ b/src/main/java/com/heai/modules/production/entity/ScheduleDetail.java @@ -0,0 +1,57 @@ +package com.heai.modules.production.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.util.Date; + +public class ScheduleDetail { + private BigDecimal scheduleQty; + private String resourceId; + private String shiftNo; + @DateTimeFormat(pattern = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date scheduleDate; + private String operatorId; + + public BigDecimal getScheduleQty() { + return scheduleQty; + } + + public void setScheduleQty(BigDecimal scheduleQty) { + this.scheduleQty = scheduleQty; + } + + public String getResourceId() { + return resourceId; + } + + public void setResourceId(String resourceId) { + this.resourceId = resourceId; + } + + public String getShiftNo() { + return shiftNo; + } + + public void setShiftNo(String shiftNo) { + this.shiftNo = shiftNo; + } + + public Date getScheduleDate() { + return scheduleDate; + } + + public void setScheduleDate(Date scheduleDate) { + this.scheduleDate = scheduleDate; + } + + public String getOperatorId() { + return operatorId; + } + + public void setOperatorId(String operatorId) { + this.operatorId = operatorId; + } +} diff --git a/src/main/java/com/heai/modules/production/service/DailyPlanService.java b/src/main/java/com/heai/modules/production/service/DailyPlanService.java index a01bf15..3f1b748 100644 --- a/src/main/java/com/heai/modules/production/service/DailyPlanService.java +++ b/src/main/java/com/heai/modules/production/service/DailyPlanService.java @@ -5,6 +5,7 @@ import com.heai.modules.board.entity.ViewKanbanSoHunlianPlanData; import com.heai.modules.production.entity.*; import org.springframework.web.bind.annotation.RequestBody; +import java.math.BigDecimal; import java.util.List; import java.util.Map; @@ -282,4 +283,15 @@ public interface DailyPlanService { * @throw */ List> getAvailableResourceList(WorkCenterResourceData inData); + + /** + * @Description TODO + * @Title scheduleForShopOrder + * @param inData + * @author rq + * @date 2022/7/29 14:04 + * @return BigDecimal + * @throw + */ + BigDecimal scheduleForShopOrder(ScheduleData inData); } diff --git a/src/main/java/com/heai/modules/production/service/impl/DailyPlanServiceImpl.java b/src/main/java/com/heai/modules/production/service/impl/DailyPlanServiceImpl.java index d21a2ab..a600fe0 100644 --- a/src/main/java/com/heai/modules/production/service/impl/DailyPlanServiceImpl.java +++ b/src/main/java/com/heai/modules/production/service/impl/DailyPlanServiceImpl.java @@ -9,11 +9,13 @@ import com.heai.modules.board.entity.ViewKanbanSoHunlianPlanData; import com.heai.modules.production.dao.*; import com.heai.modules.production.entity.*; import com.heai.modules.production.service.DailyPlanService; +import com.heai.modules.production.util.BigDecimalUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.RequestBody; +import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; @@ -512,4 +514,44 @@ public class DailyPlanServiceImpl implements DailyPlanService { return resultList; } + @Override + @Transactional + public BigDecimal scheduleForShopOrder(ScheduleData inData){ + List checkScheduleQty=dailyPlanMapper.checkScheduleQty(inData); + if (checkScheduleQty.size()==0){ + throw new RuntimeException("该生产订单已不存在请核实!"); + } + BigDecimal compQty=BigDecimalUtils.sub(checkScheduleQty.get(0).getQty(),checkScheduleQty.get(0).getScheduledQty()); + int checkNum= BigDecimalUtils.compareTo(compQty,inData.getSumQty()); + BigDecimal returnQty=BigDecimalUtils.add(checkScheduleQty.get(0).getScheduledQty(),inData.getSumQty()); + if(checkNum==-1){ + throw new RuntimeException("可派工数量小于目前派工数量!"); + } + inData.setQty(checkScheduleQty.get(0).getQty()); + List checkScheduleList=dailyPlanMapper.checkScheduleList(inData); + if(checkScheduleList.size()==0){ + dailyPlanMapper.saveScheduleList(inData); + } + for (int i = 0; i num1返回1,num select top 10000 a.site, a.OrderNo,a.PartNo,a.Status,a.PlanStartDate,a.NeedDate,a.LotSize,a.EnterDate,a.UserName, P.PartDescription,P.Spec,isnull(SL.scheduledQty,0) as scheduledQty,s.workCenterNo,S.qtyReported,S.qtyApprove,S.machSetupTime, - S.machRunFactor,S.factorUnit,S.ItemNo,S.OperationDesc + S.machRunFactor,S.factorUnit,S.ItemNo,S.OperationDesc,s.Efficiency FROM ShopOrder a LEFT JOIN Part P ON P.PartNo=a.PartNo AND a.site=P.Site LEFT JOIN SORouting S on S.site=a.site and S.OrderNo=a.orderNo @@ -197,7 +197,7 @@ + + + + + + + insert into ScheduleList(Site,OrderNo,ItemNo,Type,Type_db,Qty,scheduledQty) values (#{site},#{orderNo},#{itemNo},'生产订单派工单','S',#{qty},0) + + + + + update DataSequence set seqNo=seqNo+1 where SeqType= 'A' + + + + Insert into soscheduledrouting(Site,OrderNo,ItemNo,SeqNo,QtyRequired,QtyReported,QtyApprove,TimeRequired,TimeReported,PlanStartTime,PlanFinishTime + ,BarcodeID,Remark,Crewsize,ClosedFlag,QtyScrapt,OutWorkFlag,S_ScheduledDate,S_ResourceID,S_ShiftNo,S_WorkCenterNo + ,SelectedFlag,SourceFlag,ParkFlag,TimeRequired_Original,QtyRequired_Original + ,StartProdFlag,CancelledProdFlag,Efficiency,EnteredDate,scheduleType) + values(#{site},#{orderNo},#{itemNo},#{seqNo},#{scheduleQty},0,0,dbo.Get_SOScheduleRouting_TimeRequired(#{site},#{orderNo},#{itemNo},#{scheduleQty}),0,#{scheduleDate},#{scheduleDate} + ,'*','',1,'N',0,'N',#{scheduleDate},#{resourceId},#{shiftNo},#{workCenterNo} + ,'N','N','N',dbo.Get_SOScheduleRouting_TimeRequired(#{site},#{orderNo},#{itemNo},#{scheduleQty}),#{scheduleQty} + ,'N','N',#{efficiency},GETDATE(),'生产订单派工单') + + + + update ScheduleList set scheduledQty=scheduledQty+#{sumQty} where Site=#{site} and OrderNo=#{orderNo} and itemNo=#{itemNo} and type=#{scheduleType} + \ No newline at end of file