| | |
| | | List<Map<String, Object>> getOptimizeOffsetsInfo(String processId); |
| | | |
| | | int deleteOptimizeOffcut(String projectNumber); |
| | | |
| | | void updateNormalDetails(Map<String, Object> detail, String processId); |
| | | |
| | | void deleteOffcutDetails(String processId); |
| | | |
| | | void addUpdateOffcut(Map<String, Object> detail, String processId, String glassType, String glassThickness); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | public Boolean updateOptimizeResult(Map<String, Object> object,String processId){ |
| | | public Boolean updateOptimizeResult(Map<String, Object> object, String processId) { |
| | | try { |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | |
| | | List<Map<String, Object>> objectMapList = (List<Map<String, Object>>) object.get("layouts"); |
| | | |
| | | Map<String, Object> glassInfo = glassOptimizeMapper.getGlassInfo(processId); |
| | | |
| | | for (Map<String, Object> objectMap : objectMapList) { |
| | | List<Map<String, Object>> objectMap2 = (List<Map<String, Object>>) objectMap.get("glassDetails"); |
| | | |
| | | // 分离 glassDetails 为两部分 |
| | | List<Map<String, Object>> normalDetails = new ArrayList<>(); // isRemain 为 false 的部分 |
| | | List<Map<String, Object>> offCutDetails = new ArrayList<>(); // isRemain 为 true 的部分 |
| | | |
| | | for (Map<String, Object> detail : objectMap2) { |
| | | boolean isRemain = false; |
| | | if (detail.containsKey("isRemain")) { |
| | | Object isRemainObj = detail.get("isRemain"); |
| | | if (isRemainObj != null) { |
| | | if (isRemainObj instanceof Number) { |
| | | // 数字类型: 1表示true,0表示false |
| | | isRemain = ((Number) isRemainObj).intValue() == 1; |
| | | } else if (isRemainObj instanceof Boolean) { |
| | | // 布尔类型 |
| | | isRemain = (Boolean) isRemainObj; |
| | | } else { |
| | | // 字符串类型: "1"/"true"表示true,"0"/"false"表示false |
| | | String isRemainStr = isRemainObj.toString().toLowerCase(); |
| | | isRemain = "1".equals(isRemainStr) || "true".equals(isRemainStr); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (isRemain) { |
| | | offCutDetails.add(detail); |
| | | } else { |
| | | normalDetails.add(detail); |
| | | } |
| | | } |
| | | |
| | | // 保存所有数据到 optimize_detail |
| | | if (!normalDetails.isEmpty()) { |
| | | for (Map<String, Object> detail : normalDetails) { |
| | | glassOptimizeMapper.updateNormalDetails(detail, processId); |
| | | } |
| | | } |
| | | |
| | | // 例如对 remainDetails 部分先删除 offcut 再处理 |
| | | if (!offCutDetails.isEmpty()) { |
| | | glassOptimizeMapper.deleteOffcutDetails(processId); |
| | | if (glassInfo != null) { |
| | | String glassType = (String) glassInfo.get("glass_type"); |
| | | String glassThickness = (String) glassInfo.get("glass_thickness"); |
| | | // 余料存入optimizeoffcut |
| | | for (Map<String, Object> detail : offCutDetails) { |
| | | glassOptimizeMapper.addUpdateOffcut(detail, processId, glassType, glassThickness); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | // 更新优化结果文件 |
| | | String jsonString = mapper.writeValueAsString(object); |
| | | glassOptimizeMapper.updateOptimizeResult(jsonString,processId); |
| | | glassOptimizeMapper.updateOptimizeResult(jsonString, processId); |
| | | |
| | | return true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | stock_id, |
| | | width, |
| | | height, |
| | | realwidth, |
| | | realheight, |
| | | usage_rate, |
| | | stock_code, |
| | | up_trim, |
| | |
| | | #{glass.stockId}, |
| | | #{glass.width}, |
| | | #{glass.height}, |
| | | #{glass.realWidth}, |
| | | #{glass.realHeight}, |
| | | #{glass.usageRate}, |
| | | #{glass.stockCode}, |
| | | #{glass.upTrim}, |
| | |
| | | #{glassThickness} |
| | | |
| | | ) |
| | | </insert> |
| | | <insert id="addUpdateOffcut"> |
| | | INSERT INTO pp.optimize_offcut ( |
| | | project_no, |
| | | stock_id, |
| | | width, |
| | | height, |
| | | x_axis, |
| | | y_axis, |
| | | model, |
| | | thickness |
| | | ) VALUES ( |
| | | #{processId}, |
| | | 1, |
| | | #{detail.width}, |
| | | #{detail.height}, |
| | | #{detail.x}, |
| | | #{detail.y}, |
| | | #{glassType}, |
| | | #{glassThickness}) |
| | | </insert> |
| | | |
| | | |
| | |
| | | UPDATE pp.flow_card |
| | | SET rack = #{rackValue} |
| | | WHERE process_id = #{processId} AND technology_number = #{technologyNumber} |
| | | </update> |
| | | <update id="updateNormalDetails"> |
| | | UPDATE pp.optimize_detail |
| | | SET |
| | | x_axis = #{detail.x}, |
| | | y_axis = #{detail.y} |
| | | WHERE |
| | | project_no = #{processId} AND polys_id = #{detail.polySort} |
| | | </update> |
| | | |
| | | <select id="simulatedTypesettingUsingOpt"> |
| | |
| | | WHERE |
| | | project_no = #{projectNumber} |
| | | </delete> |
| | | <delete id="deleteOffcutDetails"> |
| | | delete from pp.optimize_offcut where project_no = #{processId} |
| | | </delete> |
| | | |
| | | |
| | | <select id="selectOptimizeProject"> |
| | |
| | | SELECT |
| | | width, |
| | | height, |
| | | realwidth, |
| | | realheight, |
| | | stock_id AS stockId, |
| | | stock_code AS stockCode, |
| | | usage_rate AS usageRate, |