inspect-server/src/main/java/com/yuanchu/mom/controller/InsOrderController.java
@@ -42,7 +42,7 @@ //获取检验下单数据 @ValueClassify("检验下单") @ApiOperation(value = "查询检验下单数据") @ApiOperation(value = "查询检验单列表") @PostMapping("/selectInsOrderParameter") public Result selectInsOrderParameter(@RequestBody Map<String, Object> data) throws Exception { Page page = JackSonUtil.unmarshal(JackSonUtil.marshal(data.get("page")), Page.class); @@ -51,7 +51,7 @@ } @ValueClassify("检验下单") @ApiOperation(value = "是否全部查询") @ApiOperation(value = "是否查看所有检验单") @PostMapping("/selectAllInsOrder") public Result selectAllInsOrder(){ return Result.success(); @@ -154,7 +154,7 @@ insOrderService.updateStatus(id); return Result.success(); } @ValueClassify("检验下单") @PutMapping("/updateInspected") @ValueAuth public Result<?> updateInspected(Integer id){ inspect-server/src/main/java/com/yuanchu/mom/mapper/InsProductMapper.java
@@ -23,6 +23,8 @@ List<ProductResultDto2> getProductAndResult(Integer sampleId); int updateInspected(@Param("id") Integer id); List<InsProduct> selectFiberInsProduct(List<Integer> ids); } inspect-server/src/main/java/com/yuanchu/mom/mapper/InsSampleMapper.java
@@ -26,6 +26,8 @@ List<SampleProductDto> selectSampleProductListByOrderId(Integer id); List<SampleProductDto> selectSampleProductListByOrderId2(Integer id); List<SampleProductDto> getInsOrderAndSample(Integer id, String laboratory); String getSampleEn(String sample); inspect-server/src/main/java/com/yuanchu/mom/pojo/InsProduct.java
@@ -30,6 +30,8 @@ */ private String inspectionItem; private String inspectionItemEn; /** * 检验项分类 */ @@ -40,6 +42,8 @@ */ private String inspectionItemSubclass; private String inspectionItemSubclassEn; /** * 工厂 */ inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderPlanServiceImpl.java
@@ -101,6 +101,9 @@ @Resource private UserMapper userMapper; @Resource private CustomMapper customMapper; @Value("${file.path}") private String imgUrl; @@ -342,9 +345,8 @@ Integer num = (type == 1 ? 5 : 4); LocalDateTime now = LocalDateTime.now(); insOrderStateMapper.update(null, Wrappers.<InsOrderState>lambdaUpdate().eq(InsOrderState::getInsOrderId, orderId).eq(InsOrderState::getLaboratory, laboratory).set(InsOrderState::getInsTime, now).set(InsOrderState::getInsState, num).set(InsOrderState::getVerifyTell, tell).set(InsOrderState::getVerifyUser, getLook.selectPowerByMethodAndUserId(null).get("userId"))); List<InsOrderState> insOrderStates = insOrderStateMapper.selectList(Wrappers.<InsOrderState>lambdaQuery().eq(InsOrderState::getInsOrderId, orderId)); long count = insOrderStates.stream().filter(a -> a.getInsState() == 5).count(); if (count == insOrderStates.size() && num == 5) { Long count = insOrderStateMapper.selectCount(Wrappers.<InsOrderState>lambdaQuery().eq(InsOrderState::getInsOrderId, orderId).ne(InsOrderState::getInsState, 5)); if (count == 0 && num == 5) { /*样品下的项目只要有一个项目不合格则检验结果为0,否则为1*/ List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId)); for (InsSample insSample : insSamples) { @@ -359,7 +361,7 @@ } InsOrder insOrder = insOrderMapper.selectById(orderId); Map<String, String> user = insProductMapper.selectUserById(insOrder.getUserId()); List<SampleProductDto> samples = insSampleMapper.selectSampleProductListByOrderId(orderId); List<SampleProductDto> samples = insSampleMapper.selectSampleProductListByOrderId2(orderId); InsReport insReport = new InsReport(); insReport.setCode(insOrder.getEntrustCode()); insReport.setInsOrderId(orderId); @@ -371,13 +373,16 @@ Set<String> models = new HashSet<>(); AtomicReference<Integer> productSize = new AtomicReference<>(0); String[] monthNames = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; AtomicReference<String> resultCh = new AtomicReference<>(""); AtomicReference<String> resultEn = new AtomicReference<>(""); samples.forEach(a -> { Long productCount = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getInsSampleId, a.getId())); productSize.set(productSize.get()+Integer.parseInt(productCount+"")); models.add(a.getModel()); standardMethod.add(baseMapper.getStandardMethodCode(a.getStandardMethodListId())); Set<String> templateSet = new HashSet<>(); getTemplateThing(set, map2, a); for (InsProduct b : a.getInsProduct()) { productSize.set(productSize.get() + 1); if (b.getInsProductResult() != null) { List<JSONObject> jsonObjects = JSON.parseArray(b.getInsProductResult().getEquipValue(), JSONObject.class); for (JSONObject jsonObject : jsonObjects) { @@ -508,6 +513,8 @@ textRenderData.setText("√"); break; case 0: resultCh.set(resultCh.get() + "、" + p.getInspectionItem() + (Objects.equals(p.getInspectionItemSubclass(), "") ?"":" "+p.getInspectionItemSubclass())); resultEn.set(resultEn.get() + "、" + p.getInspectionItemEn() + ((Objects.equals(p.getInspectionItemSubclassEn(), "")||Objects.equals(p.getInspectionItemSubclassEn(), null)) ?"":" "+p.getInspectionItemSubclassEn())); textRenderData.setText("×"); break; default: @@ -544,6 +551,8 @@ textRenderData.setText("✔"); break; case 0: resultCh.set(resultCh.get() + "、" + p.getInspectionItem() + (p.getInspectionItemSubclass().equals("")?"":" "+p.getInspectionItemSubclass())); resultEn.set(resultEn.get() + "、" + p.getInspectionItemEn() + ((Objects.equals(p.getInspectionItemSubclassEn(), "")||Objects.equals(p.getInspectionItemSubclassEn(), null)) ?"":" "+p.getInspectionItemSubclassEn())); textRenderData.setText("✖"); break; default: @@ -577,9 +586,21 @@ } TextRenderData[] text2 = text.toArray(new TextRenderData[0]); rowRenderData = Rows.of(text2).rowAtleastHeight(1).center().create(); rows.add(rowRenderData); if(rowRenderData.getCells().size()!=0){ rows.add(rowRenderData); } TableRenderData tableRenderData = new TableRenderData(); tableRenderData.setRows(rows); int countSize = tableRenderData.getRows().get(0).getCells().size(); for (RowRenderData row : tableRenderData.getRows()) { /*for (CellRenderData cell : row.getCells()) { System.out.print(cell.getParagraphs().get(0).getContents()); } System.out.println("");*/ if(row.getCells().size()!=countSize){ throw new ErrorException("每行单元格不相等"); } } TableStyle tableStyle = new TableStyle(); tableStyle.setColWidths(new int[]{650, 1600, 2000, 750, 2800, 1100, 1100}); tableStyle.setWidth("10000"); @@ -653,14 +674,20 @@ } catch (Exception e) { throw new ErrorException("找不到检验人的签名"); } if (signatureUrl == null || "".equals(signatureUrl)) { throw new ErrorException("找不到检验人的签名"); Custom custom = customMapper.selectById(user.get("company")); 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."); }else{ resultCh.set("依据委托要求,所检项目均符合要求。"); resultEn.set("According to commissioned requirements, all the tested items meet the requirements."); } XWPFTemplate template = XWPFTemplate.compile(url, builder.build()).render( new HashMap<String, Object>() {{ put("order", insOrder); put("report", insReport); put("user", user); put("custom", custom); put("sampleSize", samples.size()); put("tables", tables); put("tableSize", tables.size() + 1); @@ -685,6 +712,8 @@ put("seal2", null); put("formTypeCh", formType); put("formTypeEn", insOrder.getFormType()); put("resultCh", resultCh.get()); put("resultEn", resultEn.get()); }}); try { String name = insReport.getCode().replace("/", "") + ".docx"; @@ -791,13 +820,16 @@ public int submitPlan(Integer orderId, String laboratory, Integer verifyUser) { List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId).select(InsSample::getId)); List<Integer> ids = insSamples.stream().map(a -> a.getId()).collect(Collectors.toList()); List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().in(InsProduct::getInsSampleId, ids).eq(InsProduct::getSonLaboratory, laboratory).eq(InsProduct::getState, 1).isNull(InsProduct::getInsResult)); List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().in(InsProduct::getInsSampleId, ids).eq(InsProduct::getSonLaboratory, laboratory).eq(InsProduct::getState, 1).isNull(InsProduct::getInsResult).isNull(InsProduct::getInsFiberId).isNull(InsProduct::getInsFibersId)); insProducts.addAll(insProductMapper.selectFiberInsProduct(ids)); if (insProducts.size() > 0) { String str = ""; int count = 0; for (InsProduct product : insProducts) { str += product.getInspectionItem() + " " + product.getInspectionItemSubclass() + ";"; count++; str += "<br/>"+count + ":" +product.getInspectionItem() + " " + product.getInspectionItemSubclass() + "<br/>"; } throw new ErrorException("以下是未检验的项目:" + str); throw new ErrorException("<strong>存在待检验的项目:</strong><br/>" + str); } insOrderStateMapper.update(null, Wrappers.<InsOrderState>lambdaUpdate().eq(InsOrderState::getInsOrderId, orderId).eq(InsOrderState::getLaboratory, laboratory).set(InsOrderState::getInsTime, LocalDateTime.now()).set(InsOrderState::getInsState, 3).set(InsOrderState::getVerifyUser, verifyUser)); Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId"); inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java
@@ -80,7 +80,11 @@ sampleOrderDto.setCreateUser(map1.get("userId")); }else { //组织 sampleOrderDto.setCompany(customMapper.selectById(user.getCompany()).getCompany()); try { sampleOrderDto.setCompany(customMapper.selectById(user.getCompany()).getCompany()); }catch (NullPointerException e){ throw new ErrorException("找不到所属单位"); } } } Map<String, Object> map = new HashMap<>(); @@ -99,7 +103,7 @@ insOrderMapper.updateById(insOrder); List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId).select(InsSample::getId)); List<Integer> ids = insSamples.stream().map(a -> a.getId()).collect(Collectors.toList()); List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().in(InsProduct::getInsSampleId, ids).eq(InsProduct::getState, 1).select(InsProduct::getSonLaboratory).groupBy(InsProduct::getSonLaboratory)); List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery().in(InsProduct::getInsSampleId, ids).eq(InsProduct::getState, 1).isNull(InsProduct::getInsFibersId).isNull(InsProduct::getInsFiberId).select(InsProduct::getSonLaboratory).groupBy(InsProduct::getSonLaboratory)); for (InsProduct insProduct : insProducts) { InsOrderState insOrderState = new InsOrderState(); insOrderState.setInsOrderId(orderId); @@ -125,7 +129,7 @@ @Transactional(rollbackFor = Exception.class) public int addInsOrder(List<SampleProductDto> list, InsOrder insOrder) { insOrder.setState(0); String code = insOrderMapper.getLaboratoryCode(insOrder.getLaboratory()); String code = customMapper.selectById(insOrder.getCompanyId()).getCode2(); insOrder.setEntrustCode(giveCode.giveCode("JCZX-" + code + "-", "ins_order", "-", "yyyyMMdd")); insOrderMapper.insert(insOrder); list.forEach(a -> { @@ -140,7 +144,7 @@ } if (ObjectUtil.isNotEmpty(a.getBushing())) { for (BushingDto bushingDto : a.getBushing()) { bushingDto.setInsSampleId(a.getInsOrderId()); bushingDto.setInsSampleId(a.getId()); insBushingMapper.insert(bushingDto); if(bushingDto.getFiber().size()!=0){ for (FiberDto fiberDto : bushingDto.getFiber()) { inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java
@@ -56,6 +56,9 @@ String[] models = insSample.getModel().split("-(?=[^-]*$)");//拆分最后一个【-】 List<StandardProductList> list = standardProductListMapper.selectList(Wrappers.<StandardProductList>lambdaQuery().eq(StandardProductList::getStandardMethodListId, insSample.getStandardMethodListId()).eq(StandardProductList::getState, 1).eq(StandardProductList::getModel, models[0])); if (list.size() == 0) { if(Objects.equals(insSample.getFactory(), "") || insSample.getFactory() == null){ return null; } String[] split = insSample.getFactory().split(" - "); list = standardProductListMapper.selectList(Wrappers.<StandardProductList>lambdaQuery() .eq(StandardProductList::getStandardMethodListId, insSample.getStandardMethodListId()) inspect-server/src/main/resources/mapper/InsProductMapper.xml
@@ -87,4 +87,14 @@ where ip.ins_sample_id = #{sampleId} and ip.ins_result is not null </select> <select id="selectFiberInsProduct" resultType="com.yuanchu.mom.pojo.InsProduct"> select * from ins_product where state = 1 and (ins_fibers_id is not null or ins_fiber_id is not null) and ins_result is null and ins_sample_id in <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> #{item} </foreach> </select> </mapper> inspect-server/src/main/resources/mapper/InsSampleMapper.xml
@@ -113,8 +113,10 @@ select isa.*, ip.id ip_id, inspection_item, inspection_item_en, inspection_item_classify, inspection_item_subclass, inspection_item_subclass_en, ip.factory ip_factory, ip.laboratory ip_laboratory, ip.sample_type ip_sample_type, @@ -160,8 +162,10 @@ select isa.*, ip.id ip_id, inspection_item, inspection_item_en, inspection_item_classify, inspection_item_subclass, inspection_item_subclass_en, ip.factory ip_factory, ip.laboratory ip_laboratory, ip.sample_type ip_sample_type, @@ -211,6 +215,53 @@ select name_en from `center-lims`.product where name = #{sample} </select> <select id="selectSampleProductListByOrderId2" resultMap="sampleDto"> select isa.*, ip.id ip_id, inspection_item, inspection_item_en, inspection_item_classify, inspection_item_subclass, inspection_item_subclass_en, ip.factory ip_factory, ip.laboratory ip_laboratory, ip.sample_type ip_sample_type, ip.sample ip_sample, ip.model ip_model, son_laboratory, ip.unit ip_unit, price, man_hour, man_hour_group, inspection_item_type, inspection_value_type, device_group, checkout_number, section, value_type, method, man_day, bsm, ask, `last_value`, ip.ins_result ip_ins_result, state, ins_sample_id, ip.create_user ip_create_user, ip.update_user ip_update_user, ip.create_time ip_create_time, ip.update_time ip_update_time, template_id, ipr.ins_value, ipr.com_value, ipr.equip_value, ip.method_s from ins_sample isa left join ins_product ip on isa.id = ip.ins_sample_id left join ins_product_result ipr on ip.id = ipr.ins_product_id where ins_order_id = #{id} and state = 1 </select> <resultMap id="sampleDto" type="com.yuanchu.mom.dto.SampleProductDto"> <id property="id" column="id" jdbcType="INTEGER"/> @@ -239,8 +290,10 @@ <resultMap id="product" type="com.yuanchu.mom.pojo.InsProduct"> <id property="id" column="ip_id" jdbcType="INTEGER"/> <result property="inspectionItem" column="inspection_item" jdbcType="VARCHAR"/> <result property="inspectionItemEn" column="inspection_item_en" jdbcType="VARCHAR"/> <result property="inspectionItemClassify" column="inspection_item_classify" jdbcType="VARCHAR"/> <result property="inspectionItemSubclass" column="inspection_item_subclass" jdbcType="VARCHAR"/> <result property="inspectionItemSubclassEn" column="inspection_item_subclass_en" jdbcType="VARCHAR"/> <result property="factory" column="ip_factory" jdbcType="VARCHAR"/> <result property="laboratory" column="ip_laboratory" jdbcType="VARCHAR"/> <result property="sampleType" column="ip_sample_type" jdbcType="VARCHAR"/> inspect-server/src/main/resources/static/report-template.docxBinary files differ