提交 | 用户 | 时间
|
71e81e
|
1 |
package cn.stylefeng.guns.modular.om.productionOrdeInfo.service.impl; |
懒 |
2 |
|
|
3 |
import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory; |
|
4 |
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo; |
|
5 |
import cn.stylefeng.guns.modular.bs.bomInfo.entity.BomInfo; |
|
6 |
import cn.stylefeng.guns.modular.bs.bomInfo.service.BomInfoService; |
|
7 |
import cn.stylefeng.guns.modular.om.productionOrdeInfo.entity.ProductionOrdeInfo; |
|
8 |
import cn.stylefeng.guns.modular.om.productionOrdeInfo.mapper.ProductionOrdeInfoMapper; |
|
9 |
import cn.stylefeng.guns.modular.om.productionOrdeInfo.model.params.ProductionOrdeInfoParam; |
|
10 |
import cn.stylefeng.guns.modular.om.productionOrdeInfo.model.result.ProductionOrdeInfoResult; |
|
11 |
import cn.stylefeng.guns.modular.om.productionOrdeInfo.service.ProductionOrdeInfoService; |
|
12 |
import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.entity.ProductionOrderBatchInfo; |
|
13 |
import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.model.params.ProductionOrderBatchInfoParam; |
|
14 |
import cn.stylefeng.guns.modular.om.productionOrderBatchInfo.service.ProductionOrderBatchInfoService; |
|
15 |
import cn.stylefeng.roses.core.util.ToolUtil; |
|
16 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
17 |
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
18 |
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
19 |
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
20 |
import org.springframework.beans.factory.annotation.Autowired; |
|
21 |
import org.springframework.stereotype.Service; |
|
22 |
|
|
23 |
import java.io.Serializable; |
|
24 |
import java.text.SimpleDateFormat; |
|
25 |
import java.util.Date; |
|
26 |
import java.util.HashMap; |
|
27 |
import java.util.List; |
|
28 |
import java.util.Map; |
|
29 |
|
|
30 |
/** |
|
31 |
* <p> |
|
32 |
* 生产工单 服务实现类 |
|
33 |
* </p> |
|
34 |
* |
|
35 |
* @author cl |
|
36 |
* @since 2022-10-25 |
|
37 |
*/ |
|
38 |
@Service |
|
39 |
public class ProductionOrdeInfoServiceImpl extends ServiceImpl<ProductionOrdeInfoMapper, ProductionOrdeInfo> implements ProductionOrdeInfoService { |
e37994
|
40 |
/* private static SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); |
71e81e
|
41 |
private static String date = format.format(new Date()); |
e37994
|
42 |
private static String orderDate = "M"+date;*/ |
71e81e
|
43 |
@Autowired |
懒 |
44 |
private ProductionOrdeInfoService productionOrdeInfoService; |
|
45 |
|
|
46 |
@Autowired |
|
47 |
private ProductionOrderBatchInfoService orderBatchInfoService; |
|
48 |
|
|
49 |
@Autowired |
|
50 |
private BomInfoService bomInfoService; |
|
51 |
|
|
52 |
@Override |
|
53 |
public void add(ProductionOrdeInfoParam param){ |
e37994
|
54 |
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); |
L |
55 |
String date = format.format(new Date()); |
|
56 |
String orderDate = "M"+date; |
|
57 |
|
71e81e
|
58 |
List<ProductionOrdeInfo> workOrderNo = productionOrdeInfoService.list(new QueryWrapper<ProductionOrdeInfo>().like("work_order_no", date)); |
懒 |
59 |
if(workOrderNo.size() == 0){ |
|
60 |
param.setWorkOrderNo(orderDate+"0001"); |
|
61 |
}else { |
|
62 |
param.setWorkOrderNo(orderDate+String.format("%04d", workOrderNo.size()+1)); |
|
63 |
} |
|
64 |
ProductionOrdeInfo one = productionOrdeInfoService.getOne(new QueryWrapper<ProductionOrdeInfo>() |
|
65 |
.select("MAX(serial_number) as serial_number") |
|
66 |
); |
|
67 |
if(one!=null){ |
|
68 |
param.setSerialNumber(one.getSerialNumber()+1); |
|
69 |
}else { |
|
70 |
param.setSerialNumber(new Long("1")); |
|
71 |
} |
|
72 |
ProductionOrdeInfo entity = getEntity(param); |
|
73 |
this.save(entity); |
|
74 |
} |
|
75 |
|
|
76 |
@Override |
|
77 |
public void delete(ProductionOrdeInfoParam param){ |
|
78 |
this.removeById(getKey(param)); |
|
79 |
} |
|
80 |
|
|
81 |
@Override |
|
82 |
public void update(ProductionOrdeInfoParam param){ |
|
83 |
//点击开始按钮 更新实际开始时间 |
|
84 |
// if(param.getFlag()!=null){ |
|
85 |
// param.setActualStartTime(new Date()); |
|
86 |
// } |
|
87 |
ProductionOrdeInfo oldEntity = getOldEntity(param); |
|
88 |
ProductionOrdeInfo newEntity = getEntity(param); |
|
89 |
ToolUtil.copyProperties(newEntity, oldEntity); |
|
90 |
this.updateById(newEntity); |
|
91 |
} |
|
92 |
|
|
93 |
@Override |
|
94 |
public ProductionOrdeInfoResult findBySpec(ProductionOrdeInfoParam param){ |
|
95 |
return null; |
|
96 |
} |
|
97 |
|
|
98 |
@Override |
|
99 |
public List<ProductionOrdeInfoResult> findListBySpec(ProductionOrdeInfoParam param){ |
|
100 |
return this.baseMapper.customList(param); |
|
101 |
} |
|
102 |
|
|
103 |
@Override |
|
104 |
public LayuiPageInfo findPageBySpec(ProductionOrdeInfoParam param){ |
|
105 |
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
|
106 |
Page pageContext = getPageContext(); |
|
107 |
IPage page = this.baseMapper.customPageList(pageContext, param); |
|
108 |
List<ProductionOrdeInfoResult> results = page.getRecords(); |
|
109 |
for (ProductionOrdeInfoResult result : results) { |
|
110 |
try{ |
|
111 |
result.setPlanEndTimeString(format.format(result.getPlanEndTime())); |
|
112 |
result.setPlanStartTimeString(format.format(result.getPlanStartTime())); |
|
113 |
}catch (Exception e){ |
|
114 |
|
|
115 |
} |
|
116 |
} |
|
117 |
return LayuiPageFactory.createPageInfo(page); |
|
118 |
} |
|
119 |
|
|
120 |
@Override |
|
121 |
public List lineFinishQty() { |
|
122 |
return this.baseMapper.lineFinishQty(); |
|
123 |
} |
|
124 |
|
|
125 |
@Override |
|
126 |
public void saveOrderBatchInfo(ProductionOrdeInfoParam productionOrdeInfoParam) { |
|
127 |
List<BomInfo> productCode = bomInfoService.list(new QueryWrapper<BomInfo>().eq("product_code", productionOrdeInfoParam.getMaterialCode())); |
|
128 |
List<ProductionOrderBatchInfo> workOrderNo = orderBatchInfoService.list(new QueryWrapper<ProductionOrderBatchInfo>().eq("work_order_no", productionOrdeInfoParam.getWorkOrderNo())); |
|
129 |
if(workOrderNo.size()==0){ |
|
130 |
for (BomInfo bomInfo : productCode) { |
|
131 |
ProductionOrderBatchInfo param = new ProductionOrderBatchInfo(); |
|
132 |
param.setWorkOrderNo(productionOrdeInfoParam.getWorkOrderNo()); |
|
133 |
param.setProductionLine(productionOrdeInfoParam.getProductionLine()); |
|
134 |
param.setLocationCode(bomInfo.getLocationCode()); |
|
135 |
param.setLoadingCode(bomInfo.getLoadingCode()); |
|
136 |
param.setMaterialCode(bomInfo.getMaterialCode()); |
|
137 |
param.setState("否"); |
|
138 |
param.setCreateTime(new Date()); |
|
139 |
orderBatchInfoService.save(param); |
|
140 |
} |
|
141 |
} |
|
142 |
} |
|
143 |
|
|
144 |
@Override |
|
145 |
public HashMap getOrderWeek() { |
|
146 |
return baseMapper.getOrderWeek(); |
|
147 |
} |
|
148 |
|
|
149 |
@Override |
|
150 |
public Integer getPlanQtyByDate(String str) { |
|
151 |
return baseMapper.getPlanQtyByDate(str); |
|
152 |
} |
|
153 |
|
|
154 |
@Override |
|
155 |
public Integer getActualQtyByDate(String str) { |
|
156 |
return baseMapper.getActualQtyByDate(str); |
|
157 |
} |
|
158 |
|
|
159 |
@Override |
|
160 |
public List<ProductionOrdeInfoResult> getListMonth() { |
|
161 |
return baseMapper.getListMonth(); |
|
162 |
} |
|
163 |
|
|
164 |
private Serializable getKey(ProductionOrdeInfoParam param){ |
|
165 |
return param.getId(); |
|
166 |
} |
|
167 |
|
|
168 |
private Page getPageContext() { |
|
169 |
return LayuiPageFactory.defaultPage(); |
|
170 |
} |
|
171 |
|
|
172 |
private ProductionOrdeInfo getOldEntity(ProductionOrdeInfoParam param) { |
|
173 |
return this.getById(getKey(param)); |
|
174 |
} |
|
175 |
|
|
176 |
private ProductionOrdeInfo getEntity(ProductionOrdeInfoParam param) { |
|
177 |
ProductionOrdeInfo entity = new ProductionOrdeInfo(); |
|
178 |
ToolUtil.copyProperties(param, entity); |
|
179 |
return entity; |
|
180 |
} |
|
181 |
|
|
182 |
} |