12 changed files with 1115 additions and 1 deletions
-
241src/main/java/com/srq/common/utils/BigDecimalUtils.java
-
2src/main/java/com/srq/modules/base/service/BaseService.java
-
108src/main/java/com/srq/modules/schedule/controller/ScheduleController.java
-
118src/main/java/com/srq/modules/schedule/dao/ScheduleMapper.java
-
54src/main/java/com/srq/modules/schedule/entity/ScheduleCheckData.java
-
190src/main/java/com/srq/modules/schedule/entity/ScheduleData.java
-
57src/main/java/com/srq/modules/schedule/entity/ScheduleDetail.java
-
43src/main/java/com/srq/modules/schedule/entity/ShopOrderRoutingData.java
-
13src/main/java/com/srq/modules/schedule/entity/WorkCenterOperatorAndResourceData.java
-
136src/main/java/com/srq/modules/schedule/service/Impl/ScheduleServiceImpl.java
-
64src/main/java/com/srq/modules/schedule/service/ScheduleService.java
-
90src/main/resources/mapper/schedule/ScheduleMapper.xml
@ -0,0 +1,241 @@ |
|||
package com.srq.common.utils; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.text.NumberFormat; |
|||
|
|||
/** |
|||
* @Description BigDecimal运算类 |
|||
* @ClassName BigDecimalUtils |
|||
* @author Yangzz |
|||
* @date 2021/6/18 18:13 |
|||
**/ |
|||
public class BigDecimalUtils { |
|||
|
|||
//默认除法运算精度 |
|||
private static final int DEF_DIV_SCALE = 2; |
|||
|
|||
//建立货币格式化引用 |
|||
private static final NumberFormat currency = NumberFormat.getCurrencyInstance(); |
|||
|
|||
//建立百分比格式化引用 |
|||
private static final NumberFormat percent = NumberFormat.getPercentInstance(); |
|||
|
|||
/** |
|||
* 加法 |
|||
* @param num |
|||
* @param num1 |
|||
* @return |
|||
*/ |
|||
public static BigDecimal add(BigDecimal num, BigDecimal num1) { |
|||
return num.add(num1); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 提供精确的加法运算(默认四舍五入,根据scale保留小数位数) |
|||
* @param num |
|||
* @param num1 |
|||
* @param scale |
|||
* @return |
|||
*/ |
|||
public static BigDecimal add(BigDecimal num, BigDecimal num1, int scale) { |
|||
return num.add(num1).setScale(scale, BigDecimal.ROUND_HALF_UP); |
|||
} |
|||
|
|||
/** |
|||
* 提供精确的加法运算(默认四舍五入,根据scale保留小数位数) |
|||
* @param num |
|||
* @param num1 |
|||
* @param scale |
|||
* @return |
|||
*/ |
|||
public static BigDecimal add(BigDecimal num, BigDecimal num1,BigDecimal num2, int scale) { |
|||
BigDecimal bigDecimal = num.add(num1).setScale(scale, BigDecimal.ROUND_HALF_UP); |
|||
return bigDecimal.add(num2).setScale(scale, BigDecimal.ROUND_HALF_UP); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 提供精确的加法运算(默认四舍五入,根据scale保留小数位数) |
|||
* @param add |
|||
* @param add1 |
|||
* @param scale |
|||
* @return |
|||
*/ |
|||
public static BigDecimal add(String add, String add1, int scale) { |
|||
BigDecimal num = new BigDecimal(add); |
|||
BigDecimal num1 = new BigDecimal(add1); |
|||
return num.add(num1).setScale(scale, BigDecimal.ROUND_HALF_UP); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 减法 |
|||
* @param num |
|||
* @param num1 |
|||
* @return |
|||
*/ |
|||
public static BigDecimal sub(BigDecimal num, BigDecimal num1) { |
|||
return num.subtract(num1); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 提供精确的减法运算(默认四舍五入,根据scale保留小数位数) |
|||
* @param num |
|||
* @param num1 |
|||
* @param scale |
|||
* @return |
|||
*/ |
|||
public static BigDecimal sub(BigDecimal num, BigDecimal num1, int scale) { |
|||
return num.subtract(num1).setScale(scale, BigDecimal.ROUND_HALF_UP); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 提供精确的减法运算(默认四舍五入,根据scale保留小数位数) |
|||
* @param minus |
|||
* @param minus1 |
|||
* @return |
|||
*/ |
|||
public static BigDecimal sub(String minus, String minus1, int scale) { |
|||
BigDecimal num = new BigDecimal(minus); |
|||
BigDecimal num1 = new BigDecimal(minus1); |
|||
return sub(num, num1, scale); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 乘法 |
|||
* @param num |
|||
* @param num1 |
|||
* @return |
|||
*/ |
|||
public static BigDecimal multiply(BigDecimal num, BigDecimal num1) { |
|||
return num.multiply(num1); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 提供精确的乘法运算(默认四舍五入,保留小数位数根据scale决定) |
|||
* @param num |
|||
* @param num1 |
|||
* @param scale |
|||
* @return |
|||
*/ |
|||
public static BigDecimal multiply(String num, String num1, int scale) { |
|||
BigDecimal mul = new BigDecimal(num); |
|||
BigDecimal mul1 = new BigDecimal(num1); |
|||
return multiply(mul, mul1, scale); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 提供精确的乘法运算(默认四舍五入,保留小数位数根据scale确定) |
|||
* @param num |
|||
* @param num1 |
|||
* @param scale |
|||
* @return |
|||
*/ |
|||
public static BigDecimal multiply(BigDecimal num, BigDecimal num1, int scale) { |
|||
return num.multiply(num1).setScale(scale, BigDecimal.ROUND_HALF_UP); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 除法(除法除不尽会抛异常) |
|||
* @param num |
|||
* @param num1 |
|||
* @return |
|||
*/ |
|||
public static BigDecimal divide(BigDecimal num, BigDecimal num1) { |
|||
return num.divide(num1, DEF_DIV_SCALE); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 提供精确的除法运算(默认四舍五入保留两位小数) |
|||
* @param dividend |
|||
* @param divisor |
|||
* @return |
|||
*/ |
|||
public static BigDecimal divide(BigDecimal dividend, BigDecimal divisor, int scale) { |
|||
return dividend.divide(divisor, scale, BigDecimal.ROUND_HALF_UP); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 提供精确的除法运算(默认四舍五入,保留小数位数根据scale决定) |
|||
* @param dividend |
|||
* @param divisor |
|||
* @param scale |
|||
* @return |
|||
*/ |
|||
public static BigDecimal divide(String dividend, String divisor, int scale) { |
|||
BigDecimal num = new BigDecimal(dividend); |
|||
BigDecimal num1 = new BigDecimal(divisor); |
|||
return divide(num, num1, scale); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 提供精确的取余数运算(小数保留位数根据scale决定) |
|||
* @param dividend |
|||
* @param divisor |
|||
* @param scale |
|||
* @return |
|||
*/ |
|||
public static BigDecimal balance(BigDecimal dividend, BigDecimal divisor, int scale) { |
|||
return dividend.remainder(divisor).setScale(scale); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 提供精确的取余数运算(默认保留两位小数) |
|||
* @param dividend |
|||
* @param divisor |
|||
* @return |
|||
*/ |
|||
public static BigDecimal balance(BigDecimal dividend, BigDecimal divisor) { |
|||
return dividend.remainder(divisor).setScale(DEF_DIV_SCALE); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 比较BigDecimal,相等返回0,num>num1返回1,num<num1返回-1 |
|||
* @param num |
|||
* @param num1 |
|||
* @return |
|||
*/ |
|||
public static int compareTo(BigDecimal num, BigDecimal num1) { |
|||
return num.compareTo(num1); |
|||
} |
|||
|
|||
/** |
|||
* 比较BigDecimal,相等返回0,大于0返回1,小于0返回-1 |
|||
* @param num |
|||
* @return |
|||
*/ |
|||
public static int compareToZero(BigDecimal num) { |
|||
return num.compareTo(new BigDecimal(0)); |
|||
} |
|||
|
|||
/** |
|||
* BigDecimal货币格式化 |
|||
* @param money |
|||
* @return |
|||
*/ |
|||
public static String currencyFormat(BigDecimal money) { |
|||
return currency.format(money); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* BigDecimal百分比格式化 |
|||
* @param rate |
|||
* @return |
|||
*/ |
|||
public static String rateFormat(BigDecimal rate) { |
|||
return percent.format(rate); |
|||
} |
|||
} |
|||
@ -0,0 +1,108 @@ |
|||
package com.srq.modules.schedule.controller; |
|||
|
|||
import com.srq.common.utils.R; |
|||
import com.srq.modules.base.entity.OperatorWorkCenterData; |
|||
import com.srq.modules.base.entity.WorkCenterData; |
|||
|
|||
import com.srq.modules.schedule.entity.ScheduleData; |
|||
import com.srq.modules.schedule.entity.ShopOrderRoutingData; |
|||
import com.srq.modules.schedule.entity.WorkCenterOperatorAndResourceData; |
|||
import com.srq.modules.schedule.service.ScheduleService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
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; |
|||
|
|||
/** |
|||
* |
|||
* @ClassName: BaseController |
|||
* @Description: 基础功能controller |
|||
* @author rq |
|||
* @date 2021年9月25日 |
|||
* |
|||
*/ |
|||
@RestController |
|||
@RequestMapping(value="/schedule") |
|||
public class ScheduleController { |
|||
@Autowired |
|||
private ScheduleService scheduleService; |
|||
|
|||
/** |
|||
* @Description 获取派工的数据 |
|||
* @Title getShopOrderRoutingData |
|||
* @param inData |
|||
* @author rq |
|||
* @date 2022/10/21 17:35 |
|||
* @return R |
|||
* @throw |
|||
*/ |
|||
@PostMapping(value="/getShopOrderRoutingData") |
|||
public R getShopOrderRoutingData(@RequestBody ShopOrderRoutingData inData){ |
|||
List<ShopOrderRoutingData> resultList = scheduleService.getShopOrderRoutingData(inData); |
|||
return R.ok().put("rows", resultList); |
|||
} |
|||
|
|||
/** |
|||
* @Description 获取加工中心的人员 |
|||
* @Title getWorkCenterOperatorList |
|||
* @param inData |
|||
* @author rq |
|||
* @date 2022/10/21 17:35 |
|||
* @return R |
|||
* @throw |
|||
*/ |
|||
@PostMapping(value="/getWorkCenterOperatorList") |
|||
public R getWorkCenterOperatorList(@RequestBody WorkCenterOperatorAndResourceData inData){ |
|||
List<WorkCenterOperatorAndResourceData> resultList = scheduleService.getWorkCenterOperatorList(inData); |
|||
return R.ok().put("rows", resultList); |
|||
} |
|||
|
|||
/** |
|||
* @Description 获取加工中心的机台 |
|||
* @Title getAvailableResourceList |
|||
* @param inData |
|||
* @author rq |
|||
* @date 2022/10/21 17:35 |
|||
* @return R |
|||
* @throw |
|||
*/ |
|||
@PostMapping(value="/getAvailableResourceList") |
|||
public R getAvailableResourceList(@RequestBody WorkCenterOperatorAndResourceData inData){ |
|||
List<WorkCenterOperatorAndResourceData> resultList = scheduleService.getAvailableResourceList(inData); |
|||
return R.ok().put("rows", resultList); |
|||
} |
|||
|
|||
/** |
|||
* @Description 派工 |
|||
* @Title scheduleForShopOrder |
|||
* @param inData |
|||
* @author rq |
|||
* @date 2022/7/22 15:40 |
|||
* @return R |
|||
* @throw |
|||
*/ |
|||
@PostMapping("/scheduleForShopOrder") |
|||
public R scheduleForShopOrder(@RequestBody ScheduleData inData){ |
|||
BigDecimal qty= scheduleService.scheduleForShopOrder(inData); |
|||
return R.ok().put("qty",qty); |
|||
} |
|||
|
|||
/** |
|||
* @Description 批量派工 |
|||
* @Title scheduleForShopOrder |
|||
* @param inList |
|||
* @author rq |
|||
* @date 2022/7/22 15:40 |
|||
* @return R |
|||
* @throw |
|||
*/ |
|||
@PostMapping("/schedulesForShopOrder") |
|||
public R schedulesForShopOrder(@RequestBody List<ScheduleData> inList){ |
|||
scheduleService.schedulesForShopOrder(inList); |
|||
return R.ok(); |
|||
} |
|||
} |
|||
@ -0,0 +1,118 @@ |
|||
package com.srq.modules.schedule.dao; |
|||
|
|||
import com.srq.modules.schedule.entity.ScheduleCheckData; |
|||
import com.srq.modules.schedule.entity.ScheduleData; |
|||
import com.srq.modules.schedule.entity.ShopOrderRoutingData; |
|||
import com.srq.modules.schedule.entity.WorkCenterOperatorAndResourceData; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
import java.util.List; |
|||
|
|||
@Mapper |
|||
public interface ScheduleMapper { |
|||
/** |
|||
* @Description 获取派工的数据 |
|||
* @Title getShopOrderRoutingData |
|||
* @param inData |
|||
* @author rq |
|||
* @date 2022/10/21 17:39 |
|||
* @return List<ShopOrderRoutingData> |
|||
* @throw |
|||
*/ |
|||
List<ShopOrderRoutingData> getShopOrderRoutingData(ShopOrderRoutingData inData); |
|||
|
|||
/** |
|||
* @Description 获取加工中心的人员 |
|||
* @Title getWorkCenterOperatorList |
|||
* @param inData |
|||
* @author rq |
|||
* @date 2022/10/21 17:35 |
|||
* @return List<WorkCenterOperatorAndResourceData> |
|||
* @throw |
|||
*/ |
|||
List<WorkCenterOperatorAndResourceData> getWorkCenterOperatorList(WorkCenterOperatorAndResourceData inData); |
|||
|
|||
/** |
|||
* @Description 获取加工中心的机台 |
|||
* @Title getAvailableResourceList |
|||
* @param inData |
|||
* @author rq |
|||
* @date 2022/10/21 17:35 |
|||
* @return List<WorkCenterOperatorAndResourceData> |
|||
* @throw |
|||
*/ |
|||
List<WorkCenterOperatorAndResourceData> getAvailableResourceList(WorkCenterOperatorAndResourceData inData); |
|||
|
|||
/** |
|||
* @Description 生产订单排产查看数量 |
|||
* @Title checkScheduleQty |
|||
* @param inData |
|||
* @author rq |
|||
* @date 2022/8/3 10:46 |
|||
* @return List<ScheduleCheckData> |
|||
* @throw |
|||
*/ |
|||
List<ScheduleCheckData> checkScheduleQty(ScheduleData inData); |
|||
/** |
|||
* @Description 检查下有没有关联表了 |
|||
* @Title checkScheduleList |
|||
* @param inData |
|||
* @author rq |
|||
* @date 2022/8/3 10:46 |
|||
* @return List<ScheduleCheckData> |
|||
* @throw |
|||
*/ |
|||
List<ScheduleCheckData> checkScheduleList(ScheduleData inData); |
|||
|
|||
/** |
|||
* @Description 创建关联表 |
|||
* @Title ScheduleData |
|||
* @param inData |
|||
* @author rq |
|||
* @date 2022/8/3 10:46 |
|||
* @throw |
|||
*/ |
|||
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); |
|||
} |
|||
@ -0,0 +1,54 @@ |
|||
package com.srq.modules.schedule.entity; |
|||
|
|||
import org.apache.ibatis.type.Alias; |
|||
|
|||
import java.math.BigDecimal; |
|||
|
|||
@Alias("ScheduleCheckData") |
|||
public class ScheduleCheckData { |
|||
private BigDecimal qty; |
|||
private BigDecimal scheduledQty; |
|||
private BigDecimal canScheduledQty; |
|||
private String status; |
|||
private String orderNo; |
|||
|
|||
public BigDecimal getCanScheduledQty() { |
|||
return canScheduledQty; |
|||
} |
|||
|
|||
public void setCanScheduledQty(BigDecimal canScheduledQty) { |
|||
this.canScheduledQty = canScheduledQty; |
|||
} |
|||
|
|||
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; |
|||
} |
|||
|
|||
public String getOrderNo() { |
|||
return orderNo; |
|||
} |
|||
|
|||
public void setOrderNo(String orderNo) { |
|||
this.orderNo = orderNo; |
|||
} |
|||
} |
|||
@ -0,0 +1,190 @@ |
|||
package com.srq.modules.schedule.entity; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
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 Integer 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; |
|||
@DateTimeFormat(pattern = "yyyy-MM-dd") |
|||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
|||
private Date orderDate; |
|||
private String orderRef1; |
|||
List<ScheduleDetail> 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 Integer getItemNo() { |
|||
return itemNo; |
|||
} |
|||
|
|||
public void setItemNo(Integer 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<ScheduleDetail> getScheduleDetail() { |
|||
return scheduleDetail; |
|||
} |
|||
|
|||
public void setScheduleDetail(List<ScheduleDetail> 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; |
|||
} |
|||
|
|||
public Date getOrderDate() { |
|||
return orderDate; |
|||
} |
|||
|
|||
public void setOrderDate(Date orderDate) { |
|||
this.orderDate = orderDate; |
|||
} |
|||
|
|||
public String getOrderRef1() { |
|||
return orderRef1; |
|||
} |
|||
|
|||
public void setOrderRef1(String orderRef1) { |
|||
this.orderRef1 = orderRef1; |
|||
} |
|||
} |
|||
@ -0,0 +1,57 @@ |
|||
package com.srq.modules.schedule.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; |
|||
} |
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
package com.srq.modules.schedule.entity; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import lombok.Data; |
|||
import org.springframework.format.annotation.DateTimeFormat; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.Date; |
|||
|
|||
@Data |
|||
public class ShopOrderRoutingData { |
|||
private String site; |
|||
private String orderNo; |
|||
@DateTimeFormat(pattern = "yyyy-MM-dd") |
|||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
|||
private Date needDate; |
|||
private String status; |
|||
private BigDecimal lotSize; |
|||
private String partNo; |
|||
private Integer itemNo; |
|||
private String operationDesc; |
|||
private String workCenterNo; |
|||
private String partDesc; |
|||
private BigDecimal qtyScheduled; |
|||
private BigDecimal qtyReported; |
|||
@DateTimeFormat(pattern = "yyyy-MM-dd") |
|||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
|||
private Date startDate1; |
|||
@DateTimeFormat(pattern = "yyyy-MM-dd") |
|||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
|||
private Date endDate1; |
|||
@DateTimeFormat(pattern = "yyyy-MM-dd") |
|||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
|||
private Date startDate2; |
|||
@DateTimeFormat(pattern = "yyyy-MM-dd") |
|||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
|||
private Date endDate2; |
|||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
|||
private Date enterDate; |
|||
|
|||
private String planStatus; |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
package com.srq.modules.schedule.entity; |
|||
|
|||
import lombok.Data; |
|||
|
|||
@Data |
|||
public class WorkCenterOperatorAndResourceData { |
|||
private String site; |
|||
private String operatorName; |
|||
private String operatorID; |
|||
private String workCenterNo; |
|||
private String resourceID; |
|||
private String resourceDesc; |
|||
} |
|||
@ -0,0 +1,136 @@ |
|||
package com.srq.modules.schedule.service.Impl; |
|||
|
|||
import com.srq.common.utils.BigDecimalUtils; |
|||
import com.srq.modules.schedule.dao.ScheduleMapper; |
|||
import com.srq.modules.schedule.entity.ScheduleCheckData; |
|||
import com.srq.modules.schedule.entity.ScheduleData; |
|||
import com.srq.modules.schedule.entity.ShopOrderRoutingData; |
|||
import com.srq.modules.schedule.entity.WorkCenterOperatorAndResourceData; |
|||
import com.srq.modules.schedule.service.ScheduleService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.List; |
|||
|
|||
@Service |
|||
public class ScheduleServiceImpl implements ScheduleService { |
|||
@Autowired |
|||
private ScheduleMapper scheduleMapper; |
|||
|
|||
@Override |
|||
public List<ShopOrderRoutingData> getShopOrderRoutingData(ShopOrderRoutingData inData){ |
|||
|
|||
return scheduleMapper.getShopOrderRoutingData(inData); |
|||
} |
|||
|
|||
@Override |
|||
public List<WorkCenterOperatorAndResourceData> getWorkCenterOperatorList(WorkCenterOperatorAndResourceData inData){ |
|||
return scheduleMapper.getWorkCenterOperatorList(inData); |
|||
} |
|||
|
|||
@Override |
|||
public List<WorkCenterOperatorAndResourceData> getAvailableResourceList(WorkCenterOperatorAndResourceData inData){ |
|||
return scheduleMapper.getAvailableResourceList(inData); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional |
|||
public BigDecimal scheduleForShopOrder(ScheduleData inData){ |
|||
List<ScheduleCheckData> checkScheduleQty=scheduleMapper.checkScheduleQty(inData); |
|||
if (checkScheduleQty.size()==0){ |
|||
throw new RuntimeException("该生产订单已不存在请核实!"); |
|||
} |
|||
// List<SOToolData> checkTool = scheduleMapper.checkTool(inData.getSite(),inData.getOrderNo(),inData.getItemNo()); |
|||
// if(checkTool.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<ScheduleCheckData> checkScheduleList=scheduleMapper.checkScheduleList(inData); |
|||
if(checkScheduleList.size()==0){ |
|||
scheduleMapper.saveScheduleList(inData); |
|||
} |
|||
for (int i = 0; i <inData.getScheduleDetail().size() ; i++) { |
|||
int seqNo=scheduleMapper.getDataSequence(); |
|||
scheduleMapper.updateDataSequence(); |
|||
ScheduleData saveData=new ScheduleData(); |
|||
saveData.setOrderNo(inData.getOrderNo()); |
|||
saveData.setSite(inData.getSite()); |
|||
saveData.setPartNo(inData.getPartNo()); |
|||
saveData.setItemNo(inData.getItemNo()); |
|||
saveData.setWorkCenterNo(inData.getWorkCenterNo()); |
|||
saveData.setSeqNo(seqNo); |
|||
saveData.setScheduleQty(inData.getScheduleDetail().get(i).getScheduleQty()); |
|||
saveData.setResourceId(inData.getScheduleDetail().get(i).getResourceId()); |
|||
saveData.setShiftNo(inData.getScheduleDetail().get(i).getShiftNo()); |
|||
saveData.setScheduleDate(inData.getScheduleDetail().get(i).getScheduleDate()); |
|||
saveData.setOperatorId(inData.getScheduleDetail().get(i).getOperatorId()); |
|||
scheduleMapper.saveSchedule(saveData); |
|||
|
|||
} |
|||
scheduleMapper.updateScheduleListQty(inData); |
|||
return returnQty; |
|||
} |
|||
|
|||
|
|||
@Override |
|||
@Transactional |
|||
public void schedulesForShopOrder(List<ScheduleData> inList){ |
|||
for (int i = 0; i < inList.size(); i++) { |
|||
ScheduleData inData=inList.get(i); |
|||
List<ScheduleCheckData> checkScheduleQty=scheduleMapper.checkScheduleQty(inData); |
|||
|
|||
if (checkScheduleQty.size()==0){ |
|||
throw new RuntimeException(checkScheduleQty.get(0).getOrderNo()+"该生产订单已不存在请核实!"); |
|||
} |
|||
//把查出来剩下多少可以派工的数量赋值一下 |
|||
inData.setSumQty(checkScheduleQty.get(0).getCanScheduledQty()); |
|||
inData.getScheduleDetail().get(0).setScheduleQty(checkScheduleQty.get(0).getCanScheduledQty()); |
|||
// List<SOToolData> checkTool = scheduleMapper.checkTool(inData.getSite(),inData.getOrderNo(),inData.getItemNo()); |
|||
// if(checkTool.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("可派工数量小于目前派工数量!"); |
|||
// } |
|||
int checkNum= BigDecimalUtils.compareTo(checkScheduleQty.get(0).getCanScheduledQty(),new BigDecimal(0)); |
|||
if(checkNum!=1){ |
|||
throw new RuntimeException(checkScheduleQty.get(0).getOrderNo()+"该生产订单以及派工完毕无法批量派工!"); |
|||
} |
|||
inData.setQty(checkScheduleQty.get(0).getQty()); |
|||
List<ScheduleCheckData> checkScheduleList=scheduleMapper.checkScheduleList(inData); |
|||
if(checkScheduleList.size()==0){ |
|||
scheduleMapper.saveScheduleList(inData); |
|||
} |
|||
for (int j = 0; j <inData.getScheduleDetail().size() ; j++) { |
|||
int seqNo=scheduleMapper.getDataSequence(); |
|||
scheduleMapper.updateDataSequence(); |
|||
ScheduleData saveData=new ScheduleData(); |
|||
saveData.setOrderNo(inData.getOrderNo()); |
|||
saveData.setSite(inData.getSite()); |
|||
saveData.setPartNo(inData.getPartNo()); |
|||
saveData.setItemNo(inData.getItemNo()); |
|||
saveData.setWorkCenterNo(inData.getWorkCenterNo()); |
|||
saveData.setSeqNo(seqNo); |
|||
saveData.setScheduleQty(inData.getScheduleDetail().get(j).getScheduleQty()); |
|||
saveData.setResourceId(inData.getScheduleDetail().get(j).getResourceId()); |
|||
saveData.setShiftNo(inData.getScheduleDetail().get(j).getShiftNo()); |
|||
saveData.setScheduleDate(inData.getScheduleDetail().get(j).getScheduleDate()); |
|||
saveData.setOperatorId(inData.getScheduleDetail().get(j).getOperatorId()); |
|||
scheduleMapper.saveSchedule(saveData); |
|||
|
|||
} |
|||
scheduleMapper.updateScheduleListQty(inData); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,64 @@ |
|||
package com.srq.modules.schedule.service; |
|||
|
|||
|
|||
import com.srq.modules.schedule.entity.ScheduleData; |
|||
import com.srq.modules.schedule.entity.ShopOrderRoutingData; |
|||
import com.srq.modules.schedule.entity.WorkCenterOperatorAndResourceData; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.List; |
|||
|
|||
public interface ScheduleService { |
|||
|
|||
/** |
|||
* @Description 获取派工的数据 |
|||
* @Title getShopOrderRoutingData |
|||
* @param inData |
|||
* @author rq |
|||
* @date 2022/10/21 17:39 |
|||
* @return List<ShopOrderRoutingData> |
|||
* @throw |
|||
*/ |
|||
List<ShopOrderRoutingData> getShopOrderRoutingData(ShopOrderRoutingData inData); |
|||
/** |
|||
* @Description 获取加工中心的人员 |
|||
* @Title getWorkCenterOperatorList |
|||
* @param inData |
|||
* @author rq |
|||
* @date 2022/10/21 17:35 |
|||
* @return List<WorkCenterOperatorAndResourceData> |
|||
* @throw |
|||
*/ |
|||
List<WorkCenterOperatorAndResourceData> getWorkCenterOperatorList(WorkCenterOperatorAndResourceData inData); |
|||
|
|||
/** |
|||
* @Description 获取加工中心的机台 |
|||
* @Title getAvailableResourceList |
|||
* @param inData |
|||
* @author rq |
|||
* @date 2022/10/21 17:35 |
|||
* @return List<WorkCenterOperatorAndResourceData> |
|||
* @throw |
|||
*/ |
|||
List<WorkCenterOperatorAndResourceData> getAvailableResourceList(WorkCenterOperatorAndResourceData inData); |
|||
|
|||
/** |
|||
* @Description 单次派工 |
|||
* @Title scheduleForShopOrder |
|||
* @param inData |
|||
* @author rq |
|||
* @date 2022/7/29 14:04 |
|||
* @return BigDecimal |
|||
* @throw |
|||
*/ |
|||
BigDecimal scheduleForShopOrder(ScheduleData inData); |
|||
/** |
|||
* @Description 批量派工 |
|||
* @Title schedulesForShopOrder |
|||
* @param inList |
|||
* @author rq |
|||
* @date 2022/7/29 |
|||
* @throw |
|||
*/ |
|||
void schedulesForShopOrder(List<ScheduleData> inList); |
|||
} |
|||
@ -0,0 +1,90 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.srq.modules.schedule.dao.ScheduleMapper"> |
|||
<select id="getShopOrderRoutingData" resultType="com.srq.modules.schedule.entity.ShopOrderRoutingData"> |
|||
SELECT so.Site,so.OrderNo ,so.NeedDate,so.Status,so.LotSize,so.PartNo,sr.ItemNo,sr.OperationDesc, |
|||
sr.WorkCenterNo,p.PartDesc,isnull(sl.QtyScheduled,0) QtyScheduled,isnull(sl.QtyReported,0) QtyReported, |
|||
so.EnterDate |
|||
FROM view_ShopOrder so |
|||
LEFT JOIN view_SORouting sr on so.site=sr.Site and so.OrderNo=sr.OrderNo |
|||
left join view_Part p on so.site=P.Site and so.PartNo=p.PartNo |
|||
left join so_schedule_list sl on sl.Site=so.Site and sl.OrderNo=so.OrderNo and sr.ItemNo=sl.ItemNo |
|||
<where> |
|||
and so.site=#{site} |
|||
<if test="startDate1 != null"> |
|||
and so.EnterDate>=#{startDate1} |
|||
</if> |
|||
<if test="endDate1 != null"> |
|||
and #{endDate1}>=so.EnterDate |
|||
</if> |
|||
<if test="startDate2 != null"> |
|||
and so.NeedDate>=#{startDate2} |
|||
</if> |
|||
<if test="endDate2 != null"> |
|||
and #{endDate2}>=so.NeedDate |
|||
</if> |
|||
<if test="itemNo != null"> |
|||
and sr.itemNo=#{itemNo} |
|||
</if> |
|||
<if test="status != null and status != ''"> |
|||
and so.status in ${status} |
|||
</if> |
|||
<if test="partNo != null and partNo != ''"> |
|||
and so.partNo like #{partNo} |
|||
</if> |
|||
<if test="planStatus != null and planStatus != ''"> |
|||
and ${planStatus} |
|||
</if> |
|||
</where> |
|||
|
|||
order by so.NeedDate,so.EnterDate |
|||
</select> |
|||
|
|||
<select id="getWorkCenterOperatorList" resultType="com.srq.modules.schedule.entity.WorkCenterOperatorAndResourceData"> |
|||
SELECT a.OperatorID,a.OperatorName,a.Site |
|||
FROM Operator a left join operator_work_center b on a.site=b.site and a.OperatorID=b.OperatorID |
|||
where b.WorkCenterNo =#{workCenterNo} and a.site=#{site} |
|||
and a.active='Y' |
|||
</select> |
|||
|
|||
<select id="getAvailableResourceList" resultType="com.srq.modules.schedule.entity.WorkCenterOperatorAndResourceData"> |
|||
SELECT site,WorkCenterNo,ResourceID,ResourceDesc |
|||
FROM WorkCenterResource |
|||
where WorkCenterNo =#{workCenterNo} and site=#{site} |
|||
and active='Y' |
|||
</select> |
|||
|
|||
<select id="checkScheduleQty" resultType="ScheduleCheckData"> |
|||
Select a.orderNo, a.lotSize as Qty,isnull(b.QtyScheduled,0) scheduledQty,a.lotSize -isnull(b.QtyScheduled,0) as canScheduledQty |
|||
from view_ShopOrder a left join so_schedule_list b on a.site=b.site and a.orderNo=b.orderNo and b.itemNo=#{itemNo} |
|||
where a.Site=#{site} and a.OrderNo=#{orderNo} |
|||
</select> |
|||
|
|||
<select id="checkScheduleList" resultType="ScheduleCheckData"> |
|||
Select QtyScheduled from so_schedule_list where Site=#{site} and OrderNo=#{orderNo} and itemNo=#{itemNo} |
|||
</select> |
|||
<insert id="saveScheduleList"> |
|||
insert into so_schedule_list(Site,OrderNo,ItemNo,QtyScheduled,QtyReported,PartNo,QtyApprove) values (#{site},#{orderNo},#{itemNo},0,0,#{partNo},0) |
|||
</insert> |
|||
|
|||
<select id="getDataSequence" resultType="integer"> |
|||
select seqNo from DataSequence where SeqType= 'A' |
|||
</select> |
|||
<update id="updateDataSequence"> |
|||
update DataSequence set seqNo=seqNo+1 where SeqType= 'A' |
|||
</update> |
|||
|
|||
<insert id="saveSchedule"> |
|||
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,operatorId,partNo) |
|||
values(#{site},#{orderNo},#{itemNo},#{seqNo},#{scheduleQty},0,0,null,0,#{scheduleDate},#{scheduleDate} |
|||
,'*','',1,'N',0,'N',#{scheduleDate},#{resourceId},#{shiftNo},#{workCenterNo} |
|||
,'N','N','N',null,null |
|||
,'N','N',#{efficiency},GETDATE(),#{operatorId},#{partNo}) |
|||
</insert> |
|||
<update id="updateScheduleListQty"> |
|||
update so_schedule_list set QtyScheduled=QtyScheduled+#{sumQty} where Site=#{site} and OrderNo=#{orderNo} and itemNo=#{itemNo} |
|||
</update> |
|||
</mapper> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue