| | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.lang.Console; |
| | | import cn.hutool.core.lang.UUID; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | 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.data.*; |
| | | import com.deepoove.poi.data.style.*; |
| | | import com.deepoove.poi.util.TableTools; |
| | | import com.deepoove.poi.xwpf.WidthScalePattern; |
| | | import com.yuanchu.mom.common.GetLook; |
| | | import com.yuanchu.mom.common.PrintChina; |
| | | import com.yuanchu.mom.dto.ExcelDto; |
| | |
| | | import com.yuanchu.mom.utils.QueryWrappers; |
| | | import com.yuanchu.mom.vo.InsOrderPlanTaskSwitchVo; |
| | | import com.yuanchu.mom.vo.InsOrderPlanVO; |
| | | import com.yuanchu.mom.vo.Result; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.apache.poi.xwpf.usermodel.*; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | JSONObject jo = JSON.parseObject(JSON.toJSONString(v)); |
| | | InsProduct insProduct = new InsProduct(); |
| | | insProduct.setId(Integer.parseInt(k)); |
| | | InsProductResult result = insProductResultMapper.selectOne(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProduct.getId())); |
| | | if (BeanUtil.isEmpty(result)) { |
| | | List<InsProductResult> results = insProductResultMapper.selectList(Wrappers.<InsProductResult>lambdaQuery().eq(InsProductResult::getInsProductId, insProduct.getId())); |
| | | InsProductResult result; |
| | | if (CollectionUtils.isEmpty(results)) { |
| | | result = new InsProductResult(); |
| | | } else { |
| | | result = results.get(0); |
| | | } |
| | | result.setInsProductId(Integer.parseInt(k)); |
| | | if (jo.get("insValue") != null) { |
| | |
| | | .eq(AuxiliaryOutputWorkingHours::getCheck, userId) |
| | | .eq(AuxiliaryOutputWorkingHours::getInspectProject, insProduct.getInspectionItemSubclass() + insProduct.getInspectionItem()) |
| | | .eq(AuxiliaryOutputWorkingHours::getOrderNo, insOrder.getEntrustCode())); |
| | | if (count == 0) { |
| | | if (count == 0 && ObjectUtils.isNotEmpty(insProduct.getManHour())) { |
| | | //添加每个人的产量工时 |
| | | AuxiliaryOutputWorkingHours auxiliaryOutputWorkingHours = new AuxiliaryOutputWorkingHours(); |
| | | auxiliaryOutputWorkingHours.setInspectProject(insProduct.getInspectionItemSubclass() + insProduct.getInspectionItem());//检测项目 |
| | |
| | | for (InsProduct insProduct : insProducts) { |
| | | if (insProduct.getInsResult() == 0) { |
| | | InsUnPass insUnPass = new InsUnPass(); |
| | | insUnPass.setId(null); |
| | | insUnPass.setModel(insSample.getModel()); |
| | | insUnPass.setSample(insSample.getSample()); |
| | | insUnPass.setInspectionItem(insProduct.getInspectionItem()); |
| | |
| | | insUnPasses.add(insUnPass); |
| | | } |
| | | } |
| | | insUnPassService.saveBatch(insUnPasses); |
| | | } |
| | | insUnPassService.saveBatch(insUnPasses); |
| | | InsOrder insOrder = insOrderMapper.selectById(orderId); |
| | | Map<String, String> user = insProductMapper.selectUserById(insOrder.getUserId()); |
| | | List<SampleProductDto> samples = insSampleMapper.selectSampleProductListByOrderId(orderId); |
| | | InsReport insReport = new InsReport(); |
| | | insReport.setCode(insOrder.getEntrustCode()); |
| | | insReport.setInsOrderId(orderId); |
| | | Set<Integer> set = new HashSet<>(); |
| | | Map<Integer, String> map2 = new HashMap<>(); |
| | | List<Map<String, Object>> tables = new ArrayList<>(); |
| | | Set<String> standardMethod = new HashSet<>(); |
| | | Set<String> deviceSet = new HashSet<>(); |
| | |
| | | AtomicReference<String> resultCh = new AtomicReference<>(""); |
| | | AtomicReference<String> resultEn = new AtomicReference<>(""); |
| | | samples.forEach(a -> { |
| | | Set<Integer> set = new HashSet<>(); |
| | | Map<Integer, String> map2 = new HashMap<>(); |
| | | Long productCount = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getInsSampleId, a.getId())); |
| | | productSize.set(productSize.get() + Integer.parseInt(productCount + "")); |
| | | models.add(a.getModel()); |
| | |
| | | Map<String, InsProduct> pMap = new HashMap<>(); |
| | | Set<String> delRSet = new HashSet<>(); |
| | | delRSet.add("0"); |
| | | delRSet.add("1"); |
| | | for (JSONObject jo1 : temp) { |
| | | JSONObject v = JSON.parseObject(JSON.toJSONString(jo1.get("v"))); |
| | | if (Integer.parseInt(jo1.get("c") + "") > 9) { |
| | |
| | | if (p != null && v.get("ps") != null) { |
| | | String value = JSON.parseObject(JSON.toJSONString(v.get("ps"))).get("value") + ""; |
| | | if (value.equals("要求值")) { |
| | | textRenderData.setText(p.getAsk()); |
| | | textRenderData.setText(ObjectUtils.isNotEmpty(p.getTell()) ? p.getTell() : ""); |
| | | } else if (value.equals("单位")) { |
| | | textRenderData.setText(p.getUnit()); |
| | | } else if (value.equals("结论")) { |
| | |
| | | break; |
| | | } |
| | | } else if (value.equals("序号")) { |
| | | /*if (i == 0 ){ |
| | | index.getAndIncrement(); |
| | | }else if (pMap.get(temp.get(i-1).get("r") + "")!= null && JSON.parseObject(JSON.toJSONString(temp.get(i-1).get("v"))).get("ps") != null){ |
| | | if (pMap.get(temp.get(i-1).get("")).getInspectionItem()!=p.getInspectionItem()) { |
| | | index.getAndIncrement(); |
| | | } |
| | | }*/ |
| | | index.getAndIncrement(); |
| | | textRenderData.setText(index + ""); |
| | | } else if (value.equals("计算值")) { |
| | |
| | | textRenderData.setText(a.getSample()); |
| | | } else if (value.equals("试验方法")) { |
| | | textRenderData.setText(p.getMethodS()); |
| | | } else if (value.equals("检验项")) { |
| | | textRenderData.setText(p.getInspectionItem() + "\r\n" + p.getInspectionItemEn()); |
| | | } else if (value.equals("检验子项")) { |
| | | if (ObjectUtils.isEmpty(p.getInspectionItemSubclassEn())) { |
| | | textRenderData.setText(p.getInspectionItemSubclass()); |
| | | } else { |
| | | textRenderData.setText(p.getInspectionItemSubclass() + "\r\n" + p.getInspectionItemSubclassEn()); |
| | | } |
| | | } else { |
| | | textRenderData.setText(v.get("v") == null ? "" : v.get("v") + ""); |
| | | } |
| | |
| | | tableRenderData.setRows(rows); |
| | | int countSize = tableRenderData.getRows().get(0).getCells().size(); |
| | | for (RowRenderData row : tableRenderData.getRows()) { |
| | | for (CellRenderData cell : row.getCells()) { |
| | | /*for (CellRenderData cell : row.getCells()) { |
| | | System.out.print(cell.getParagraphs().get(0).getContents()); |
| | | } |
| | | System.out.println(""); |
| | | System.out.println("");*/ |
| | | if (row.getCells().size() != countSize) { |
| | | throw new ErrorException("每行单元格不相等"); |
| | | } |
| | |
| | | ConfigureBuilder builder = Configure.builder(); |
| | | builder.useSpringEL(true); |
| | | List<Map<String, String>> finalDeviceList = deviceList; |
| | | Integer userId = insSampleUserMapper.selectOne(Wrappers.<InsSampleUser>lambdaQuery().eq(InsSampleUser::getInsSampleId, orderId).orderByDesc(InsSampleUser::getCreateTime).last("limit 1")).getUserId(); |
| | | Integer userId = insSampleUserMapper.selectOne(Wrappers.<InsSampleUser>lambdaQuery().eq(InsSampleUser::getInsSampleId, orderId).last("limit 1")).getUserId(); |
| | | String signatureUrl; |
| | | try { |
| | | signatureUrl = userMapper.selectById(userId).getSignatureUrl(); |
| | | } catch (Exception e) { |
| | | throw new ErrorException("找不到检验人的签名"); |
| | | } |
| | | Custom custom = customMapper.selectById(user.get("company")); |
| | | //Custom custom = customMapper.selectById(user.get("company")); |
| | | Custom custom = customMapper.selectById(insOrder.getCompanyId()); |
| | | if (!resultCh.get().equals("")) { |
| | | resultCh.set("依据委托要求," + resultCh.get().replaceFirst("、", "") + "等所检项目不符合要求,其余所检项目均符合要求。"); |
| | | resultEn.set("According to commissioned requirements," + resultEn.get().replaceFirst("、", "") + " these inspected items do not meet the requirements, all other inspected items meet the requirements."); |
| | |
| | | //第一行 |
| | | if (j == 0) { |
| | | //第一列 |
| | | textRenderData.setText("管色标\nPipe∑100"); |
| | | textRenderData.setText("管色标Pipe∑100"); |
| | | renderData.add(textRenderData); |
| | | paragraphRenderData.setContents(renderData); |
| | | paragraphRenderDataList.add(paragraphRenderData); |
| | |
| | | cells.add(cellRenderData); |
| | | } else if (j == 1) { |
| | | //第二列 |
| | | textRenderData.setText("光纤色标\nScanning Number∑101"); |
| | | textRenderData.setText("光纤色标\r\nScanning Number∑101"); |
| | | renderData.add(textRenderData); |
| | | paragraphRenderData.setContents(renderData); |
| | | paragraphRenderDataList.add(paragraphRenderData); |
| | |
| | | cells.add(cellRenderData); |
| | | } else { |
| | | //项目信息 |
| | | textRenderData.setText(insProducts1.get((int) (j - 2)).getInspectionItem() + "\n" + insProducts1.get((int) (j - 2)).getInspectionItemEn()+"∑"+(j+101)); |
| | | textRenderData.setText(insProducts1.get((int) (j - 2)).getInspectionItem() + "\r\n" + insProducts1.get((int) (j - 2)).getInspectionItemEn() + "∑" + (j + 101)); |
| | | renderData.add(textRenderData); |
| | | paragraphRenderData.setContents(renderData); |
| | | paragraphRenderDataList.add(paragraphRenderData); |
| | |
| | | //有父子项目关系的第三行 |
| | | if (j == 0) { |
| | | //第一列 |
| | | textRenderData.setText("管色标\nPipe∑100"); |
| | | textRenderData.setText("管色标\r\nPipe∑100"); |
| | | renderData.add(textRenderData); |
| | | paragraphRenderData.setContents(renderData); |
| | | paragraphRenderDataList.add(paragraphRenderData); |
| | |
| | | cells.add(cellRenderData); |
| | | } else if (j == 1) { |
| | | //第二列 |
| | | textRenderData.setText("光纤色标\tScanning Number∑101"); |
| | | textRenderData.setText("光纤色标\r\nScanning Number∑101"); |
| | | renderData.add(textRenderData); |
| | | paragraphRenderData.setContents(renderData); |
| | | paragraphRenderDataList.add(paragraphRenderData); |
| | |
| | | //项目信息 |
| | | //判断是否有项目子类 |
| | | if (insProducts1.get((int) (j - 2)).getInspectionItemSubclass().equals("") || insProducts1.get((int) (j - 2)).getInspectionItemSubclass() == null) { |
| | | textRenderData.setText(insProducts1.get((int) (j - 2)).getInspectionItem() + "\n" + insProducts1.get((int) (j - 2)).getInspectionItemEn()+"∑"+(j+101)); |
| | | textRenderData.setText(insProducts1.get((int) (j - 2)).getInspectionItem() + "\r\n" + insProducts1.get((int) (j - 2)).getInspectionItemEn() + "∑" + (j + 101)); |
| | | } else { |
| | | textRenderData.setText(insProducts1.get((int) (j - 2)).getInspectionItemSubclass() + "\n" + insProducts1.get((int) (j - 2)).getInspectionItemSubclassEn()); |
| | | textRenderData.setText(insProducts1.get((int) (j - 2)).getInspectionItemSubclass() + "\r\n" + insProducts1.get((int) (j - 2)).getInspectionItemSubclassEn()); |
| | | } |
| | | renderData.add(textRenderData); |
| | | paragraphRenderData.setContents(renderData); |
| | |
| | | tableRenderData.setRows(rows); |
| | | int countSize = tableRenderData.getRows().get(0).getCells().size(); |
| | | for (RowRenderData row : tableRenderData.getRows()) { |
| | | for (CellRenderData cell : row.getCells()) { |
| | | /*for (CellRenderData cell : row.getCells()) { |
| | | System.out.print(cell.getParagraphs().get(0).getContents()); |
| | | } |
| | | System.out.println(""); |
| | | System.out.println("");*/ |
| | | if (row.getCells().size() != countSize) { |
| | | throw new ErrorException("每行单元格不相等"); |
| | | } |
| | |
| | | Map<String, Object> table = new HashMap<>(); |
| | | table.put("table2", tableRenderData); |
| | | table.put("report", insReport); |
| | | table.put("sample_number",sample.getSampleCode() ); |
| | | table.put("sample_number", sample.getSampleCode()); |
| | | table.put("type", sample.getModel()); |
| | | tables2.add(table); |
| | | }); |
| | | } |
| | | |
| | | /*获取附件图片类型*/ |
| | | List<Map<String, Object>> images = new ArrayList<>(); |
| | | List<InsOrderFile> insOrderFiles = insOrderFileMapper.selectList(Wrappers.<InsOrderFile>lambdaQuery().eq(InsOrderFile::getType, 1).eq(InsOrderFile::getInsOrderId, orderId)); |
| | | if (CollectionUtils.isNotEmpty(insOrderFiles)) { |
| | | insOrderFiles.forEach(insOrderFile -> { |
| | | Map<String, Object> image = new HashMap<>(); |
| | | PictureRenderData pictureRenderData = Pictures.ofLocal(imgUrl + "/" + insOrderFile.getFileUrl()).sizeInCm(17, 20).create(); |
| | | image.put("url", pictureRenderData); |
| | | image.put("report", insReport); |
| | | images.add(image); |
| | | }); |
| | | } |
| | | //委托人和电话字段判断 |
| | | if (ObjectUtils.isEmpty(insOrder.getPrepareUser())) { |
| | | insOrder.setPrepareUser("/"); |
| | | } |
| | | if (ObjectUtils.isEmpty(insOrder.getPhone())) { |
| | | insOrder.setPhone("/"); |
| | | } |
| | | |
| | | XWPFTemplate template = XWPFTemplate.compile(url, builder.build()).render( |
| | | new HashMap<String, Object>() {{ |
| | | put("order", insOrder); |
| | | put("report", insReport); |
| | | put("user", user); |
| | | //put("user", user); |
| | | put("custom", custom); |
| | | put("sampleSize", samples.size()); |
| | | put("tables", tables); |
| | |
| | | put("insTimeEn", monthNames[insOrder.getInsTime().getMonthValue() - 1] + " " + now.getDayOfMonth() + ", " + now.getYear()); |
| | | put("writeUrl", null); |
| | | put("insUrl", Pictures.ofLocal(imgUrl + "/" + signatureUrl).create()); |
| | | put("images", images); |
| | | put("examineUrl", null); |
| | | put("ratifyUrl", null); |
| | | put("sampleEn", sampleEn); |