| | |
| | | package com.ruoyi.production.service.impl; |
| | | |
| | | |
| | | import cn.hutool.core.lang.Assert; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.extra.pinyin.PinyinUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.deepoove.poi.XWPFTemplate; |
| | | import com.deepoove.poi.config.Configure; |
| | | import com.deepoove.poi.data.PictureRenderData; |
| | | import com.deepoove.poi.data.Pictures; |
| | | import com.ruoyi.common.utils.HackLoopTableRenderPolicy; |
| | | import com.ruoyi.common.utils.MatrixToImageWriter; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.production.dto.ProductWorkOrderDto; |
| | | import com.ruoyi.production.mapper.ProductWorkOrderFileMapper; |
| | | import com.ruoyi.production.mapper.ProductWorkOrderMapper; |
| | | import com.ruoyi.production.pojo.ProductWorkOrder; |
| | | import com.ruoyi.production.pojo.ProductWorkOrderFile; |
| | | import com.ruoyi.production.service.ProductWorkOrderService; |
| | | import com.ruoyi.quality.pojo.QualityInspectParam; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | public class ProductWorkOrderServiceImpl extends ServiceImpl<ProductWorkOrderMapper, ProductWorkOrder> implements ProductWorkOrderService { |
| | | |
| | | @Autowired |
| | | private ProductWorkOrderMapper productWorkOrdermapper; |
| | | private ProductWorkOrderMapper productWorkOrderMapper; |
| | | @Autowired |
| | | private ProductWorkOrderFileMapper productWorkOrderFileMapper; |
| | | |
| | |
| | | |
| | | @Override |
| | | public IPage<ProductWorkOrderDto> listPage(Page<ProductWorkOrderDto> page, ProductWorkOrderDto productWorkOrder) { |
| | | return productWorkOrdermapper.pageProductWorkOrder(page, productWorkOrder); |
| | | return productWorkOrderMapper.pageProductWorkOrder(page, productWorkOrder); |
| | | } |
| | | |
| | | @Override |
| | | public int updateProductWorkOrder(ProductWorkOrderDto productWorkOrderDto) { |
| | | return productWorkOrdermapper.updateById(productWorkOrderDto); |
| | | return productWorkOrderMapper.updateById(productWorkOrderDto); |
| | | } |
| | | |
| | | @Override |
| | | public void down(HttpServletResponse response, ProductWorkOrder productWorkOrder) { |
| | | ProductWorkOrderDto productWorkOrderDto = productWorkOrdermapper.getProductWorkOrderFlowCard(productWorkOrder.getId()); |
| | | ProductWorkOrderDto productWorkOrderDto = productWorkOrderMapper.getProductWorkOrderFlowCard(productWorkOrder.getId()); |
| | | String codePath; |
| | | try { |
| | | codePath = new MatrixToImageWriter().code(productWorkOrderDto.getId().toString(), tempDir); |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public ProductWorkOrderDto getProductWorkOrderById(Long id) { |
| | | return productWorkOrderMapper.getProductWorkOrderFlowCard(id); |
| | | } |
| | | |
| | | @Override |
| | | public String generateProductWorkOrder(String datePrefix,String processName, String npsNo) { |
| | | datePrefix = StrUtil.isBlank(datePrefix) ? LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")) : datePrefix; |
| | | processName = StrUtil.isBlank(processName) ? "未知" : processName; |
| | | Assert.notNull(npsNo, "生产订单号编号不能为空"); |
| | | ProductWorkOrder lastWorkOrder = productWorkOrderMapper.selectMax(datePrefix); |
| | | int sequenceNumber = 1; // 默认序号 |
| | | if (lastWorkOrder != null && lastWorkOrder.getWorkOrderNo() != null) { |
| | | String lastNo = lastWorkOrder.getWorkOrderNo().toString(); |
| | | if (lastNo.startsWith(datePrefix)) { |
| | | String seqStr = lastNo.substring(datePrefix.length()); |
| | | try { |
| | | sequenceNumber = Integer.parseInt(seqStr) + 1; |
| | | } catch (NumberFormatException e) { |
| | | sequenceNumber = 1; |
| | | } |
| | | } |
| | | } |
| | | String processPinyin = StringUtils.getProcessNo(processName); |
| | | return StrUtil.format("{}{}{}",processPinyin,npsNo,String.format("%03d", sequenceNumber)); |
| | | } |
| | | |
| | | } |