parent
87501ef21f
commit
72a9bc3b1d
9 changed files with 445 additions and 281 deletions
@ -1,19 +1,109 @@ |
||||
package org.jeecg.modules.maker.service.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import org.jeecg.modules.maker.entity.ZyMaker; |
||||
import org.jeecg.modules.maker.mapper.ZyMakerMapper; |
||||
import org.jeecg.modules.maker.service.IZyMakerService; |
||||
import org.jeecg.modules.workorder.entity.WorkOrder; |
||||
import org.jeecg.modules.workorder.service.IWorkOrderService; |
||||
import org.jeecg.modules.workproduct.entity.ZyProduct; |
||||
import org.jeecg.modules.workproduct.service.IZyProductService; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import org.springframework.util.ObjectUtils; |
||||
import org.springframework.util.StringUtils; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.ArrayList; |
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
import java.util.regex.Pattern; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* @Description: 制单管理 |
||||
* @Author: jeecg-boot |
||||
* @Date: 2021-11-27 |
||||
* @Date: 2021-11-27 |
||||
* @Version: V1.0 |
||||
*/ |
||||
@Service |
||||
public class ZyMakerServiceImpl extends ServiceImpl<ZyMakerMapper, ZyMaker> implements IZyMakerService { |
||||
|
||||
@Autowired |
||||
private IWorkOrderService workOrderService; |
||||
@Autowired |
||||
private IZyProductService productService; |
||||
|
||||
@Resource |
||||
private ZyMakerMapper zyMakerMapper; |
||||
|
||||
////点击制单 点击后按产品模块分解成制单写入制单表
|
||||
@Override |
||||
public void listMakerAdd() { |
||||
//先拿到所有产品 产品暂定为服装款式里面的数据
|
||||
List<WorkOrder> workOrderList = workOrderService.list(); |
||||
for (WorkOrder workOrder : workOrderList) { |
||||
ZyMaker maker = new ZyMaker(); |
||||
//制单编号 工单编号(22)+顺序号(2)
|
||||
maker.setCode(getMakerCode(workOrder.getProductCode())); |
||||
//工单编号
|
||||
maker.setWorkerCode(workOrder.getProductCode()); |
||||
this.save(maker); |
||||
} |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public List<ZyMaker> ZyMakerVo(List<ZyMaker> records) { |
||||
if (ObjectUtils.isEmpty(records)) { |
||||
return null; |
||||
} |
||||
//根据工单编号找到产品编号 产品名称
|
||||
for (ZyMaker maker : records) { |
||||
ZyProduct zyProductMapper = zyMakerMapper.getProduct(maker.getWorkerCode()); |
||||
// LambdaQueryWrapper<ZyProduct> queryWrapper = new LambdaQueryWrapper<>();
|
||||
// queryWrapper.eq(ZyProduct::getWorkOrderId, maker.getWorkerCode());
|
||||
// ZyProduct zyProduct = productService.getOne(queryWrapper);
|
||||
//产品编号
|
||||
if (!ObjectUtils.isEmpty(zyProductMapper)){ |
||||
if (StringUtils.hasText(zyProductMapper.getProductCode())) { |
||||
maker.setProductCode(zyProductMapper.getProductCode()); |
||||
} |
||||
if (StringUtils.hasText(zyProductMapper.getProductName())) { |
||||
maker.setProductName(zyProductMapper.getProductName()); |
||||
} |
||||
} |
||||
|
||||
//产品名称
|
||||
|
||||
} |
||||
return records; |
||||
} |
||||
|
||||
private String getMakerCode(String productCode) { |
||||
if (StringUtils.isEmpty(productCode)) { |
||||
return "null"; |
||||
} |
||||
List<ZyMaker> zyMakerList = this.list(); |
||||
List<String> collect = zyMakerList.stream().map(ZyMaker::getCode).collect(Collectors.toList()); |
||||
List<Long> longList = new ArrayList<>(); |
||||
for (String makerCode : collect) { |
||||
String newNums = makerCode.trim(); |
||||
if (StringUtils.isEmpty(newNums)) continue; |
||||
if (newNums.length() <= 2) longList.add(Long.valueOf(newNums)); |
||||
else { |
||||
//拿到后6位 substring(4) 截掉前4位
|
||||
String substring = newNums.substring(newNums.length() - 2); |
||||
longList.add(Long.valueOf(substring)); |
||||
} |
||||
} |
||||
long max = Collections.max(longList) + 1; |
||||
if (Long.toString(max).length() > 2) { |
||||
String toString = Long.toString(max); |
||||
return toString.substring(toString.length() - 2); |
||||
} |
||||
return String.format("%02d", max); |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue