Browse Source

自动化棒一维护原始记录的棒一明细

lingpeng.li 2 weeks ago
parent
commit
590faf5b3e

+ 79 - 0
zgzt-sys-java/jeecg-module-conn/src/main/java/org/jeecg/modules/billetActual/service/impl/BilletHotsendBaseServiceImpl.java

@@ -4,9 +4,12 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.common.util.DateUtils;
@@ -24,6 +27,8 @@ import org.jeecg.modules.billetHotsendConfig.entity.BilletHotsendTypeConfig;
 import org.jeecg.modules.billetHotsendConfig.service.IBilletHotsendTypeConfigService;
 import org.jeecg.modules.billetLiftingBill.entity.BilletLiftingBill;
 import org.jeecg.modules.billetLiftingBill.service.IBilletLiftingBillService;
+import org.jeecg.modules.billetOriginalProductRecord.entity.BilletOriginalProductRecord;
+import org.jeecg.modules.billetOriginalProductRecord.service.IBilletOriginalProductRecordService;
 import org.jeecg.modules.connConfig.configMqtt.mapper.ConfigMqttMapper;
 import org.jeecg.modules.operateLog.entity.OperateLog;
 import org.jeecg.modules.operateLog.service.IOperateLogService;
@@ -65,6 +70,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
@@ -130,6 +136,8 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 	private IRollDeputyCrossService rollDeputyCrossService;
 	@Autowired
 	private IRollDeputyCrossDetailsService rollDeputyCrossDetailsService;
+	@Autowired
+	private IBilletOriginalProductRecordService billetOriginalProductRecordService;
 
 	/**
 	 * 自动化新增 5号机 直轧棒1   6号机 高线
@@ -264,6 +272,77 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 		billetHotsendDetailsVo.setRollClubCommonList(rollClubCommonLists);
 		log.info("C端自动化数据转换,{}新增参数:{}", operationMsg, JSON.toJSONString(billetHotsendDetailsVo));
 		saveBilletRodLineCommom(billetHotsendDetailsVo);
+
+		ObjectMapper objectMapper = new ObjectMapper();
+
+		for (RollClubCommon rollClubCommonOne : rollClubCommonLists) {
+			try {
+				// 1. 查询对应的钢坯原始生产记录(按 create_time 倒序,取最新一条)
+				QueryWrapper<BilletOriginalProductRecord> queryWrapperB = new QueryWrapper<>();
+				queryWrapperB.eq("ccm_no", rollClubCommonOne.getCcmNo())
+						.eq("shift", rollClubCommonOne.getShift())
+						.eq("shift_group", rollClubCommonOne.getShiftGroup())
+						.eq("heat_no", rollClubCommonOne.getHeatNo())
+						.orderByDesc("create_time");
+
+				BilletOriginalProductRecord one = billetOriginalProductRecordService.getOne(queryWrapperB, false);
+				if (one == null) {
+					log.warn("未找到原始生产记录,heatNo: {}", rollClubCommonOne.getHeatNo());
+					continue;
+				}
+
+				// 2. 解析 JSON 字段 rollClubOneDetails
+				String detailsJson = one.getRollClubOneDetails();
+				Map<String, Object> detailsMap;
+
+				if (detailsJson != null && !detailsJson.trim().isEmpty()) {
+					detailsMap = objectMapper.readValue(detailsJson, new TypeReference<Map<String, Object>>() {});
+				} else {
+					// 初始化结构
+					detailsMap = new HashMap<>();
+					detailsMap.put("lengthGroupCount", new HashMap<String, Integer>());
+					detailsMap.put("directRollingTotalWeight", 0.0);
+					detailsMap.put("directRollingTotalCount", 0);
+				}
+
+				// 3. 当前定尺(size)和重量(billetWeight)
+				String size = rollClubCommonOne.getSize();
+				Double billetWeight = rollClubCommonOne.getBilletWeight();
+
+				@SuppressWarnings("unchecked")
+				Map<String, Integer> lengthGroupCount = (Map<String, Integer>) detailsMap.get("lengthGroupCount");
+
+				// 4. 更新定尺支数
+				lengthGroupCount.put(size, lengthGroupCount.getOrDefault(size, 0) + 1);
+				detailsMap.put("lengthGroupCount", lengthGroupCount);
+
+				// 5. 累加重量
+				double totalWeight = ((Number) detailsMap.getOrDefault("directRollingTotalWeight", 0.0)).doubleValue();
+				double addedWeight = (billetWeight != null ? billetWeight : 0.0);
+
+				BigDecimal updatedWeight = BigDecimal.valueOf(totalWeight)
+						.add(BigDecimal.valueOf(addedWeight))
+						.setScale(4, RoundingMode.HALF_UP);
+
+				detailsMap.put("directRollingTotalWeight", updatedWeight.doubleValue());
+
+				// 6. 累加支数
+				int totalCount = ((Number) detailsMap.getOrDefault("directRollingTotalCount", 0)).intValue();
+				detailsMap.put("directRollingTotalCount", totalCount + 1);
+
+				// 7. 写回 JSON 并保存
+				Integer originalAmount = one.getAmount();
+				// 累加 amount 字段
+				one.setAmount((originalAmount != null ? originalAmount : 0) + 1);
+
+				one.setRollClubOneDetails(objectMapper.writeValueAsString(detailsMap));
+				billetOriginalProductRecordService.updateById(one);
+
+			} catch (Exception e) {
+				log.error("处理 rollClubOneDetails 异常,heatNo: {}, size: {}, 错误: {}",
+						rollClubCommonOne.getHeatNo(), rollClubCommonOne.getSize(), e.getMessage(), e);
+			}
+		}
 		log.info("C端自动化操作结果,{}新增成功:{}", operationMsg, billetNos);
 	}
 	/**

+ 139 - 0
zgzt-sys-java/jeecg-module-conn/src/main/java/org/jeecg/modules/billetOriginalProductRecord/controller/BilletOriginalProductRecordController.java

@@ -0,0 +1,139 @@
+package org.jeecg.modules.billetOriginalProductRecord.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.modules.billetOriginalProductRecord.entity.BilletOriginalProductRecord;
+import org.jeecg.modules.billetOriginalProductRecord.service.IBilletOriginalProductRecordService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Arrays;
+
+ /**
+ * @Description: 钢坯生成原始记录
+ * @Author: jeecg-boot
+ * @Date:   2025-06-23
+ * @Version: V1.0
+ */
+@Api(tags="钢坯生成原始记录")
+@RestController
+@RequestMapping("/billet/billetOriginalProductRecord")
+@Slf4j
+public class BilletOriginalProductRecordController extends JeecgController<BilletOriginalProductRecord, IBilletOriginalProductRecordService> {
+
+	@Autowired
+	private IBilletOriginalProductRecordService billetOriginalProductRecordService;
+
+	@Autowired
+	public RedisTemplate redisTemplate;
+
+	 /**
+	 * 分页列表查询
+	 *
+	 * @param billetOriginalProductRecord
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	//@AutoLog(value = "钢坯生成原始记录-分页列表查询")
+	@ApiOperation(value="钢坯生成原始记录-分页列表查询", notes="钢坯生成原始记录-分页列表查询")
+	@GetMapping(value = "/list")
+	public Result<IPage<BilletOriginalProductRecord>> queryPageList(BilletOriginalProductRecord billetOriginalProductRecord,
+								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+								   HttpServletRequest req) {
+		QueryWrapper<BilletOriginalProductRecord> queryWrapper = QueryGenerator.initQueryWrapper(billetOriginalProductRecord, req.getParameterMap());
+		Page<BilletOriginalProductRecord> page = new Page<BilletOriginalProductRecord>(pageNo, pageSize);
+		IPage<BilletOriginalProductRecord> pageList = billetOriginalProductRecordService.page(page, queryWrapper);
+		return Result.OK(pageList);
+	}
+
+	
+	/**
+	 *   通过id删除
+	 *
+	 * @param id
+	 * @return
+	 */
+	@AutoLog(value = "钢坯生成原始记录-通过id删除")
+	@ApiOperation(value="钢坯生成原始记录-通过id删除", notes="钢坯生成原始记录-通过id删除")
+	@RequiresPermissions("billetOriginalProductRecord:billet_original_product_record:delete")
+	@DeleteMapping(value = "/delete")
+	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
+		billetOriginalProductRecordService.removeById(id);
+		return Result.OK("删除成功!");
+	}
+	
+	/**
+	 *  批量删除
+	 *
+	 * @param ids
+	 * @return
+	 */
+	@AutoLog(value = "钢坯生成原始记录-批量删除")
+	@ApiOperation(value="钢坯生成原始记录-批量删除", notes="钢坯生成原始记录-批量删除")
+	@RequiresPermissions("billetOriginalProductRecord:billet_original_product_record:deleteBatch")
+	@DeleteMapping(value = "/deleteBatch")
+	public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		this.billetOriginalProductRecordService.removeByIds(Arrays.asList(ids.split(",")));
+		return Result.OK("批量删除成功!");
+	}
+	
+	/**
+	 * 通过id查询
+	 *
+	 * @param id
+	 * @return
+	 */
+	//@AutoLog(value = "钢坯生成原始记录-通过id查询")
+	@ApiOperation(value="钢坯生成原始记录-通过id查询", notes="钢坯生成原始记录-通过id查询")
+	@GetMapping(value = "/queryById")
+	public Result<BilletOriginalProductRecord> queryById(@RequestParam(name="id",required=true) String id) {
+		BilletOriginalProductRecord billetOriginalProductRecord = billetOriginalProductRecordService.getById(id);
+		if(billetOriginalProductRecord==null) {
+			return Result.error("未找到对应数据");
+		}
+		return Result.OK(billetOriginalProductRecord);
+	}
+
+    /**
+    * 导出excel
+    *
+    * @param request
+    * @param billetOriginalProductRecord
+    */
+    @RequiresPermissions("billetOriginalProductRecord:billet_original_product_record:exportXls")
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, BilletOriginalProductRecord billetOriginalProductRecord) {
+        return super.exportXls(request, billetOriginalProductRecord, BilletOriginalProductRecord.class, "钢坯生成原始记录");
+    }
+
+    /**
+      * 通过excel导入数据
+    *
+    * @param request
+    * @param response
+    * @return
+    */
+    @RequiresPermissions("billetOriginalProductRecord:billet_original_product_record:importExcel")
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        return super.importExcel(request, response, BilletOriginalProductRecord.class);
+    }
+
+
+ }

+ 170 - 0
zgzt-sys-java/jeecg-module-conn/src/main/java/org/jeecg/modules/billetOriginalProductRecord/entity/BilletOriginalProductRecord.java

@@ -0,0 +1,170 @@
+package org.jeecg.modules.billetOriginalProductRecord.entity;
+
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+import java.util.Date;
+import java.math.BigDecimal;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import lombok.Data;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.jeecg.common.aspect.annotation.Dict;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * @Description: 钢坯生成原始记录
+ * @Author: jeecg-boot
+ * @Date:   2025-06-23
+ * @Version: V1.0
+ */
+@Data
+@TableName("billet_original_product_record")
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="billet_original_product_record对象", description="钢坯生成原始记录")
+public class BilletOriginalProductRecord implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+	/**ID*/
+	@TableId(type = IdType.ASSIGN_ID)
+    @ApiModelProperty(value = "ID")
+    private String id;
+	/**创建人*/
+    @ApiModelProperty(value = "创建人")
+    private String createBy;
+	/**创建时间*/
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+	/**更新人*/
+    @ApiModelProperty(value = "更新人")
+    private String updateBy;
+	/**更新时间*/
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "更新时间")
+    private Date updateTime;
+	/**所属部门*/
+    @ApiModelProperty(value = "所属部门")
+    private String sysOrgCode;
+	/**铸机号*/
+	@Excel(name = "铸机号", width = 15)
+    @ApiModelProperty(value = "铸机号")
+    private String ccmNo;
+	/**炉号*/
+	@Excel(name = "炉号", width = 15)
+    @ApiModelProperty(value = "炉号")
+    private String heatNo;
+	/**班别*/
+	@Excel(name = "班别", width = 15)
+    @Dict(dicCode = "lg_bb")
+    @ApiModelProperty(value = "班别")
+    private String shift;
+	/**班组*/
+	@Excel(name = "班组", width = 15)
+    @Dict(dicCode = "lg_bz")
+    @ApiModelProperty(value = "班组")
+    private String shiftGroup;
+	/**钢种*/
+	@Excel(name = "钢种", width = 15)
+    @ApiModelProperty(value = "钢种")
+    private String grade;
+	/**定尺*/
+	@Excel(name = "定尺", width = 15)
+    @ApiModelProperty(value = "定尺")
+    private Integer length;
+    /**定尺*/
+    @Excel(name = "合计", width = 15)
+    @ApiModelProperty(value = "合计")
+    private Integer amount;
+	/**棒一定尺明细*/
+	@Excel(name = "棒一定尺明细", width = 15)
+    @ApiModelProperty(value = "棒一定尺明细")
+    private String rollClubOneDetails;
+	/**棒二定尺明细*/
+	@Excel(name = "棒二定尺明细", width = 15)
+    @ApiModelProperty(value = "棒二定尺明细")
+    private String rollClubTwoDetails;
+	/**棒三定尺明细*/
+	@Excel(name = "棒三定尺明细", width = 15)
+    @ApiModelProperty(value = "棒三定尺明细")
+    private String rollClubThreeDetails;
+    /**所有定尺明细*/
+    @Excel(name = "所有定尺明细", width = 15)
+    @ApiModelProperty(value = "所有定尺明细")
+    private String lengthDetails;
+	/**1流支数*/
+	@Excel(name = "1流支数", width = 15)
+    @ApiModelProperty(value = "1流支数")
+    private Integer oneStrandSum;
+	/**2流支数*/
+	@Excel(name = "2流支数", width = 15)
+    @ApiModelProperty(value = "2流支数")
+    private Integer twoStrandSum;
+	/**3流支数*/
+	@Excel(name = "3流支数", width = 15)
+    @ApiModelProperty(value = "3流支数")
+    private Integer threeStrandSum;
+	/**4流支数*/
+	@Excel(name = "4流支数", width = 15)
+    @ApiModelProperty(value = "4流支数")
+    private Integer fourStrandSum;
+	/**5流支数*/
+	@Excel(name = "5流支数", width = 15)
+    @ApiModelProperty(value = "5流支数")
+    private Integer fiveStrandSum;
+	/**6流支数*/
+	@Excel(name = "6流支数", width = 15)
+    @ApiModelProperty(value = "6流支数")
+    private Integer sixStrandSum;
+	/**7流支数*/
+	@Excel(name = "7流支数", width = 15)
+    @ApiModelProperty(value = "7流支数")
+    private Integer sevenStrandSum;
+	/**8流支数*/
+	@Excel(name = "8流支数", width = 15)
+    @ApiModelProperty(value = "8流支数")
+    private Integer eightStrandSum;
+	/**热送定尺*/
+	@Excel(name = "热装定尺", width = 15)
+    @ApiModelProperty(value = "热装定尺")
+    private String hotChargeLength;
+	/**堆垛定尺*/
+	@Excel(name = "堆垛定尺", width = 15)
+    @ApiModelProperty(value = "堆垛定尺")
+    private String stackLength;
+	/**备注*/
+	@Excel(name = "备注", width = 15)
+    @ApiModelProperty(value = "备注")
+    private String remark;
+
+    /**
+     * 确认人
+     */
+    @ApiModelProperty(value = "确认人")
+    private String confirmBy;
+    /**
+     *  确认日期
+     */
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "确认日期")
+    private Date confirmTime;
+
+    @Excel(name = "是否编辑过热装", width = 15)
+    @ApiModelProperty(value = "是否编辑过热装")
+    private String isEditCharge;
+
+    @Excel(name = "起垛信息", width = 15)
+    @ApiModelProperty(value = "起垛信息")
+    private String stackInfo;
+
+}

+ 14 - 0
zgzt-sys-java/jeecg-module-conn/src/main/java/org/jeecg/modules/billetOriginalProductRecord/mapper/BilletOriginalProductRecordMapper.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.billetOriginalProductRecord.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.billetOriginalProductRecord.entity.BilletOriginalProductRecord;
+
+/**
+ * @Description: 钢坯生成原始记录
+ * @Author: jeecg-boot
+ * @Date:   2025-06-23
+ * @Version: V1.0
+ */
+public interface BilletOriginalProductRecordMapper extends BaseMapper<BilletOriginalProductRecord> {
+
+}

+ 5 - 0
zgzt-sys-java/jeecg-module-conn/src/main/java/org/jeecg/modules/billetOriginalProductRecord/mapper/xml/BilletOriginalProductRecordMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.billet.billetOriginalProductRecord.mapper.BilletOriginalProductRecordMapper">
+
+</mapper>

+ 15 - 0
zgzt-sys-java/jeecg-module-conn/src/main/java/org/jeecg/modules/billetOriginalProductRecord/service/IBilletOriginalProductRecordService.java

@@ -0,0 +1,15 @@
+package org.jeecg.modules.billetOriginalProductRecord.service;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.billetOriginalProductRecord.entity.BilletOriginalProductRecord;
+
+/**
+ * @Description: 钢坯生成原始记录
+ * @Author: jeecg-boot
+ * @Date:   2025-06-23
+ * @Version: V1.0
+ */
+public interface IBilletOriginalProductRecordService extends IService<BilletOriginalProductRecord> {
+
+}

+ 18 - 0
zgzt-sys-java/jeecg-module-conn/src/main/java/org/jeecg/modules/billetOriginalProductRecord/service/impl/BilletOriginalProductRecordServiceImpl.java

@@ -0,0 +1,18 @@
+package org.jeecg.modules.billetOriginalProductRecord.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.billetOriginalProductRecord.entity.BilletOriginalProductRecord;
+import org.jeecg.modules.billetOriginalProductRecord.mapper.BilletOriginalProductRecordMapper;
+import org.jeecg.modules.billetOriginalProductRecord.service.IBilletOriginalProductRecordService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Description: 钢坯生成原始记录
+ * @Author: jeecg-boot
+ * @Date: 2025-06-23
+ * @Version: V1.0
+ */
+@Service
+public class BilletOriginalProductRecordServiceImpl extends ServiceImpl<BilletOriginalProductRecordMapper, BilletOriginalProductRecord> implements IBilletOriginalProductRecordService {
+
+}