提交 | 用户 | 时间
|
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) { |
a55627
|
127 |
List<BomInfo> productCode = bomInfoService.list(new QueryWrapper<BomInfo>() |
懒 |
128 |
.eq("product_code", productionOrdeInfoParam.getMaterialCode()) |
|
129 |
.isNotNull("location_code") |
|
130 |
); |
71e81e
|
131 |
List<ProductionOrderBatchInfo> workOrderNo = orderBatchInfoService.list(new QueryWrapper<ProductionOrderBatchInfo>().eq("work_order_no", productionOrdeInfoParam.getWorkOrderNo())); |
懒 |
132 |
if(workOrderNo.size()==0){ |
|
133 |
for (BomInfo bomInfo : productCode) { |
|
134 |
ProductionOrderBatchInfo param = new ProductionOrderBatchInfo(); |
|
135 |
param.setWorkOrderNo(productionOrdeInfoParam.getWorkOrderNo()); |
|
136 |
param.setProductionLine(productionOrdeInfoParam.getProductionLine()); |
|
137 |
param.setLocationCode(bomInfo.getLocationCode()); |
|
138 |
param.setLoadingCode(bomInfo.getLoadingCode()); |
|
139 |
param.setMaterialCode(bomInfo.getMaterialCode()); |
be26d5
|
140 |
param.setStatus("否"); |
懒 |
141 |
param.setQuantity(0); |
|
142 |
param.setResidueQuantity(0); |
|
143 |
param.setUnit(bomInfo.getLineCode()); |
71e81e
|
144 |
param.setCreateTime(new Date()); |
懒 |
145 |
orderBatchInfoService.save(param); |
|
146 |
} |
|
147 |
} |
|
148 |
} |
|
149 |
|
|
150 |
@Override |
|
151 |
public HashMap getOrderWeek() { |
|
152 |
return baseMapper.getOrderWeek(); |
|
153 |
} |
|
154 |
|
|
155 |
@Override |
|
156 |
public Integer getPlanQtyByDate(String str) { |
|
157 |
return baseMapper.getPlanQtyByDate(str); |
|
158 |
} |
|
159 |
|
|
160 |
@Override |
|
161 |
public Integer getActualQtyByDate(String str) { |
|
162 |
return baseMapper.getActualQtyByDate(str); |
|
163 |
} |
|
164 |
|
|
165 |
@Override |
|
166 |
public List<ProductionOrdeInfoResult> getListMonth() { |
|
167 |
return baseMapper.getListMonth(); |
|
168 |
} |
|
169 |
|
a2805e
|
170 |
@Override |
懒 |
171 |
public List<ProductionOrdeInfoResult> getColumnarDate() { |
|
172 |
return baseMapper.getColumnarDate(); |
|
173 |
} |
|
174 |
|
9bd546
|
175 |
@Override |
懒 |
176 |
public List<ProductionOrdeInfoResult> orderDescListFive() { |
|
177 |
return baseMapper.orderDescListFive(); |
|
178 |
} |
|
179 |
|
71e81e
|
180 |
private Serializable getKey(ProductionOrdeInfoParam param){ |
懒 |
181 |
return param.getId(); |
|
182 |
} |
|
183 |
|
|
184 |
private Page getPageContext() { |
|
185 |
return LayuiPageFactory.defaultPage(); |
|
186 |
} |
|
187 |
|
|
188 |
private ProductionOrdeInfo getOldEntity(ProductionOrdeInfoParam param) { |
|
189 |
return this.getById(getKey(param)); |
|
190 |
} |
|
191 |
|
|
192 |
private ProductionOrdeInfo getEntity(ProductionOrdeInfoParam param) { |
|
193 |
ProductionOrdeInfo entity = new ProductionOrdeInfo(); |
|
194 |
ToolUtil.copyProperties(param, entity); |
|
195 |
return entity; |
|
196 |
} |
|
197 |
|
|
198 |
} |