Merge branch 'main' into hhk

plp
HuangHuiKang 3 weeks ago
commit ef6a87bdc5

@ -90,8 +90,9 @@ public class MoldBrandController {
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<MoldBrandRespVO> list = moldBrandService.getMoldBrandPage(pageReqVO).getList();
List<MoldBrandRespVO> moldBrandRespVOS = BeanUtils.toBean(list, MoldBrandRespVO.class);
// 导出 Excel
ExcelUtils.write(response, "模具型号.xls", "数据", MoldBrandRespVO.class, list);
ExcelUtils.write(response, "模具型号.xls", "数据", MoldBrandRespVO.class, moldBrandRespVOS);
}
// ==================== 子表(模具) ====================
@ -101,6 +102,14 @@ public class MoldBrandController {
List<MoldDO> doList = moldBrandService.selectBy(moldDO);
return success(doList);
}
@GetMapping("/getMoldAllList")
@Operation(summary = "获得模具型号")
public CommonResult<List<MoldDO>> getMoldAllList() {
List<MoldDO> doList = moldBrandService.getAllList();
return success(doList);
}
@GetMapping("/mold/page")
@Operation(summary = "获得模具分页")
@Parameter(name = "brandId", description = "型号id")

@ -0,0 +1,35 @@
package cn.iocoder.yudao.module.erp.controller.admin.mold.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum OrgTypeStatusEnum {
zhijiang("zhijiang", "制浆"),
duidie("duidie", "堆叠"),
chengxing("chengxing", "成型"),
honggan("honggan", "烘干"),
zhuanyi("zhuanyi", "转移"),
jiashi("jiashi", "加湿"),
reya("reya", "热压"),
qiebian("qiebian", "切边"),
pinjian("pinjian", "品检"),
dabao("dabao", "打包"),
tiebiao("tiebiao", "贴标"),
sufeng("sufeng", "塑封"),
pinyin("pinyin", "品印");
private final String orgtype;
private final String description;
public static OrgTypeStatusEnum getByCode(String code) {
for (OrgTypeStatusEnum status : values()) {
if (status.getOrgtype().equals(code)) {
return status;
}
}
return null;
}
}

@ -53,4 +53,7 @@ public class MoldBrandPageReqVO extends PageParam {
@Schema(description = "工序", example = "你说的对")
private String orgType;
@Schema(description = "id集合导出用")
private String ids;
}

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.erp.controller.admin.mold.vo;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
@ -11,6 +12,7 @@ import com.alibaba.excel.annotation.*;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
@Schema(description = "管理后台 - 模具型号 Response VO")
@Data
@ExcelIgnoreUnannotated
@ -35,24 +37,24 @@ public class MoldBrandRespVO {
@Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2336")
private Long productId;
@Schema(description = "产品", requiredMode = Schema.RequiredMode.REQUIRED, example = "2336")
@ExcelProperty("产品")
// @ExcelProperty("产品")
private String productName;
@Schema(description = "预期寿命(小时)")
@ExcelProperty("预期寿命(小时)")
@Schema(description = "预期寿命/次")
@ExcelProperty("预期寿命/次")
private BigDecimal useTime;
@Schema(description = "维保模式", example = "2")
@ExcelProperty(value = "维保模式", converter = DictConvert.class)
// @ExcelProperty(value = "维保模式", converter = DictConvert.class)
@DictFormat("maintain_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private Integer maintainType;
@Schema(description = "维保周期")
@ExcelProperty("维保周期")
// @ExcelProperty("维保周期")
private BigDecimal maintainTime;
@Schema(description = "模具系数", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("模具系数")
@Schema(description = "模数", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("模数")
private Long moldSize;
@Schema(description = "备注", example = "你说的对")
@ -60,14 +62,17 @@ public class MoldBrandRespVO {
private String remark;
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("是否启用")
// @ExcelProperty("是否启用")
private Boolean isEnable;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
@ColumnWidth(20)
private LocalDateTime createTime;
@Schema(description = "工序", example = "你说的对")
@DictFormat("mes_org_type")
@ExcelProperty(value = "工序")
private String orgType;
// , converter = OrgTypeConverter.class
}

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.erp.controller.admin.mold.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
@ -54,4 +55,10 @@ public class MoldPageReqVO extends PageParam {
@Schema(description = "型号id", example = "15258")
private Long brandId;
@Schema(description = "id集合导出用")
private String ids;
// @Schema(description = "机台名字")
// private String machineName;
}

@ -34,15 +34,15 @@ public class MoldRespVO {
@Schema(description = "单位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "19527")
private Long unitId;
@Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "个")
@ExcelProperty("单位")
// @ExcelProperty("单位")
private String unitName;
@Schema(description = "机台ID", example = "24428")
@ExcelProperty("机台ID")
@Schema(description = "设备ID", example = "24428")
@ExcelProperty("使用设备")
private Long machineId;
@Schema(description = "使用时间(小时)")
@ExcelProperty("使用时间(小时)")
@Schema(description = "使用次数/次")
@ExcelProperty("使用次数/次")
private BigDecimal useTime;
@Schema(description = "入库时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ -56,7 +56,7 @@ public class MoldRespVO {
private Integer status;
@Schema(description = "模具图片")
@ExcelProperty("模具图片")
// @ExcelProperty("模具图片")
private String images;
@Schema(description = "备注", example = "你猜")
@ -64,15 +64,19 @@ public class MoldRespVO {
private String remark;
@Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("是否启用")
// @ExcelProperty("是否启用")
private Boolean isEnable;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
// @ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "型号id", requiredMode = Schema.RequiredMode.REQUIRED, example = "15258")
@ExcelProperty("型号id")
private Long brandId;
@Schema(description = "附件地址")
@ExcelProperty("附件地址")
private String fileUrl;
}

@ -0,0 +1,86 @@
package cn.iocoder.yudao.module.erp.controller.admin.mold.vo;
import cn.iocoder.yudao.module.erp.controller.admin.mold.enums.OrgTypeStatusEnum;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import org.springframework.stereotype.Component;
/**
*
*/
@Component
public class OrgTypeConverter implements Converter<String> { // 泛型改为 String对应英文字符串
/**
* ExcelExcel/ Java
*/
@Override
public String convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
String cellValue = cellData.getStringValue();
if (cellValue == null || cellValue.trim().isEmpty()) {
return null;
}
// 优先匹配中文 → 转换为对应的英文常量名
for (OrgTypeStatusEnum status : OrgTypeStatusEnum.values()) {
if (status.getDescription().equals(cellValue)) { // 注意枚举的描述方法是 getDesc
return status.name(); // 返回枚举的英文常量名(如 IN_USE
}
}
// 匹配英文 → 直接返回兼容Excel中填英文的场景
for (OrgTypeStatusEnum status : OrgTypeStatusEnum.values()) {
if (status.name().equals(cellValue)) {
return cellValue;
}
}
// 无匹配则抛出异常
throw new IllegalArgumentException("设备状态格式错误: " + cellValue + ",仅支持中文(在机/在库/维修中/保养中/报废或英文IN_USE/IN_STOCK/UNDER_REPAIR/UNDER_MAINTENANCE/SCRAPPED");
}
/**
* ExcelJava Excel
*/
@Override
public WriteCellData<?> convertToExcelData(String value, ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (value == null || value.trim().isEmpty()) {
return new WriteCellData<>("");
}
// 根据英文常量名匹配枚举,转换为中文
OrgTypeStatusEnum status = null;
try {
status = OrgTypeStatusEnum.valueOf(value); // 通过英文名称获取枚举
} catch (IllegalArgumentException e) {
// 若英文匹配失败,尝试兜底匹配中文(兼容异常场景)
for (OrgTypeStatusEnum s : OrgTypeStatusEnum.values()) {
if (s.getDescription().equals(value)) {
status = s;
break;
}
}
}
String text = status != null ? status.getDescription() : "未知";
return new WriteCellData<>(text);
}
// 必须实现的接口方法指定转换的Java类型
@Override
public Class<?> supportJavaTypeKey() {
return String.class;
}
// 必须实现的接口方法指定Excel单元格类型
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
}

@ -5,9 +5,13 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.MoldBrandPageReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.mold.MoldBrandDO;
import com.alibaba.excel.util.StringUtils;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.erp.controller.admin.mold.vo.*;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* Mapper
@ -18,7 +22,23 @@ import java.util.List;
public interface MoldBrandMapper extends BaseMapperX<MoldBrandDO> {
default PageResult<MoldBrandDO> selectPage(MoldBrandPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<MoldBrandDO>()
// return selectPage(reqVO, new LambdaQueryWrapperX<MoldBrandDO>()
// .eqIfPresent(MoldBrandDO::getCode, reqVO.getCode())
// .likeIfPresent(MoldBrandDO::getName, reqVO.getName())
// .eqIfPresent(MoldBrandDO::getMoldType, reqVO.getMoldType())
// .eqIfPresent(MoldBrandDO::getProductId, reqVO.getProductId())
// .eqIfPresent(MoldBrandDO::getUseTime, reqVO.getUseTime())
// .eqIfPresent(MoldBrandDO::getMaintainType, reqVO.getMaintainType())
// .eqIfPresent(MoldBrandDO::getMaintainTime, reqVO.getMaintainTime())
// .eqIfPresent(MoldBrandDO::getMoldSize, reqVO.getMoldSize())
// .eqIfPresent(MoldBrandDO::getRemark, reqVO.getRemark())
// .eqIfPresent(MoldBrandDO::getIsEnable, reqVO.getIsEnable())
// .eqIfPresent(MoldBrandDO::getOrgType, reqVO.getOrgType())
// .betweenIfPresent(MoldBrandDO::getCreateTime, reqVO.getCreateTime())
// .orderByDesc(MoldBrandDO::getId));
LambdaQueryWrapperX<MoldBrandDO> moldBrandDOLambdaQueryWrapperX = new LambdaQueryWrapperX<>();
moldBrandDOLambdaQueryWrapperX
.eqIfPresent(MoldBrandDO::getCode, reqVO.getCode())
.likeIfPresent(MoldBrandDO::getName, reqVO.getName())
.eqIfPresent(MoldBrandDO::getMoldType, reqVO.getMoldType())
@ -29,8 +49,24 @@ public interface MoldBrandMapper extends BaseMapperX<MoldBrandDO> {
.eqIfPresent(MoldBrandDO::getMoldSize, reqVO.getMoldSize())
.eqIfPresent(MoldBrandDO::getRemark, reqVO.getRemark())
.eqIfPresent(MoldBrandDO::getIsEnable, reqVO.getIsEnable())
.eqIfPresent(MoldBrandDO::getOrgType, reqVO.getOrgType())
.betweenIfPresent(MoldBrandDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(MoldBrandDO::getId));
.orderByDesc(MoldBrandDO::getId);
// 单独处理 ids 条件
if (StringUtils.isNotBlank(reqVO.getIds())) {
List<Long> idList = Arrays.stream(reqVO.getIds().split(","))
.map(String::trim)
.map(Long::valueOf)
.collect(Collectors.toList());
moldBrandDOLambdaQueryWrapperX.in(MoldBrandDO::getId, idList);
}
return selectPage(reqVO, moldBrandDOLambdaQueryWrapperX);
}
default List<MoldBrandDO> selectBy(MoldBrandPageReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<MoldBrandDO>()
@ -44,6 +80,7 @@ public interface MoldBrandMapper extends BaseMapperX<MoldBrandDO> {
.eqIfPresent(MoldBrandDO::getMoldSize, reqVO.getMoldSize())
.eqIfPresent(MoldBrandDO::getRemark, reqVO.getRemark())
.eqIfPresent(MoldBrandDO::getIsEnable, reqVO.getIsEnable())
.eqIfPresent(MoldBrandDO::getOrgType, reqVO.getOrgType())
.betweenIfPresent(MoldBrandDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(MoldBrandDO::getId));
}

@ -147,4 +147,6 @@ public interface MoldBrandService {
* @return
*/
MoldBrandProductDO getMoldBrandProduct(Long id);
List<MoldDO> getAllList();
}

@ -91,11 +91,13 @@ public class MoldBrandServiceImpl implements MoldBrandService {
public List<MoldBrandDO> selectBy(MoldBrandPageReqVO reqVO){
return moldBrandMapper.selectBy(reqVO);
}
@Override
public PageResult<MoldBrandRespVO> getMoldBrandPage(MoldBrandPageReqVO pageReqVO) {
PageResult<MoldBrandDO> pageResult = moldBrandMapper.selectPage(pageReqVO);
return new PageResult<>(buildMoldBrandVOList(pageResult.getList()),pageResult.getTotal());
return new PageResult<>(buildMoldBrandVOList(pageResult.getList()), pageResult.getTotal());
}
private List<MoldBrandRespVO> buildMoldBrandVOList(List<MoldBrandDO> list) {
if (CollUtil.isEmpty(list)) {
return Collections.emptyList();
@ -231,4 +233,9 @@ public class MoldBrandServiceImpl implements MoldBrandService {
private void deleteMoldBrandProductByBrandId(Long brandId) {
moldBrandProductMapper.deleteByBrandId(brandId);
}
@Override
public List<MoldDO> getAllList() {
return moldMapper.selectList();
}
}

@ -1,5 +1,16 @@
package cn.iocoder.yudao.module.iot.controller.admin.recipedevicerecord;
import cn.iocoder.yudao.module.iot.controller.admin.recipe.vo.RecipePageReqVO;
import cn.iocoder.yudao.module.iot.controller.admin.recipe.vo.RecipeRespVO;
import cn.iocoder.yudao.module.iot.controller.admin.recipepointrecord.vo.RecipePointRecordSaveReqVO;
import cn.iocoder.yudao.module.iot.dal.dataobject.recipe.RecipeDO;
import cn.iocoder.yudao.module.iot.dal.dataobject.recipeplandetail.RecipePlanDetailDO;
import cn.iocoder.yudao.module.iot.dal.dataobject.recipepointrecord.RecipePointRecordDO;
import cn.iocoder.yudao.module.iot.dal.devicecontactmodel.DeviceContactModelDO;
import cn.iocoder.yudao.module.iot.service.device.DeviceService;
import cn.iocoder.yudao.module.iot.service.recipe.RecipeService;
import cn.iocoder.yudao.module.iot.service.recipeplandetail.RecipePlanDetailService;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
@ -30,43 +41,23 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.recipedevicerecord.RecipeDevic
import cn.iocoder.yudao.module.iot.service.recipedevicerecord.RecipeDeviceRecordService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.iot.controller.admin.recipedevicerecord.vo.*;
import cn.iocoder.yudao.module.iot.dal.dataobject.recipedevicerecord.RecipeDeviceRecordDO;
import cn.iocoder.yudao.module.iot.service.recipedevicerecord.RecipeDeviceRecordService;
// 新增必要的导入
import cn.iocoder.yudao.module.iot.service.recipedeviceattribute.RecipeDeviceAttributeService;
import cn.iocoder.yudao.module.iot.service.device.TDengineService;
import cn.iocoder.yudao.module.iot.dal.dataobject.recipedeviceattribute.RecipeDeviceAttributeDO;
import cn.iocoder.yudao.module.iot.dal.dataobject.recipepoint.RecipePointDO;
import cn.iocoder.yudao.module.iot.service.recipepoint.RecipePointService;
import cn.iocoder.yudao.module.iot.dal.dataobject.recipepointrecord.RecipePointRecordDO;
import cn.iocoder.yudao.module.iot.service.recipepointrecord.RecipePointRecordService;
@Tag(name = "管理后台 - 设备点位采集值记录")
@ -80,6 +71,13 @@ public class RecipeDeviceRecordController {
// 新增注入的服务
@Resource
private RecipeDeviceAttributeService recipeDeviceAttributeService;
@Resource
private RecipePlanDetailService recipePlanDetailService;
@Resource
private RecipeService recipeService;
@Resource
private TDengineService tDengineService;
@Resource
@ -89,6 +87,11 @@ public class RecipeDeviceRecordController {
@Resource
private ObjectMapper objectMapper;
@Resource
private DeviceService deviceService;
@PostMapping("/create")
@Operation(summary = "创建设备点位采集值记录")
@PreAuthorize("@ss.hasPermission('iot:recipe-device-record:create')")
@ -145,117 +148,53 @@ public class RecipeDeviceRecordController {
/**
*
* @param recipeId ID
* @param pointList [{id: 1, refer: "参考值1"}, {id: 2, refer: "参考值2"}]
* @return
* @throws JsonProcessingException JSON
*/
@PostMapping("/batch-create")
@Operation(summary = "批量创建设备点位采集记录和配方点位记录")
@PreAuthorize("@ss.hasPermission('iot:recipe-device-record:create')")
public CommonResult<Boolean> batchCreateRecipeDeviceRecord(
@RequestParam("id") Long recipeId) {
RecipePlanDetailDO recipePlanDetailDO = recipePlanDetailService.getRecipePlanDetail(recipeId);
//RecipeRespVO recipeRespVO = recipeService.getRecipeWithDeviceId(recipePlanDetailDO.getRecipeId());
//RecipeDO recipeDO = recipeService.getRecipe(recipePlanDetailDO.getRecipeId());
// ========== 第一步:查询配方关联的点位属性信息 ==========
// 1.1 根据recipeId查询iot_recipe_device_attribute表记录
//
//
// /**
// * 批量创建设备点位采集记录和配方点位记录
// * @param recipeId 配方ID
// * @param pointList 点位列表 [{id: 1, refer: "参考值1"}, {id: 2, refer: "参考值2"}]
// * @return 创建结果
// * @throws JsonProcessingException JSON处理异常
// */
// @PostMapping("/batch-create")
// @Operation(summary = "批量创建设备点位采集记录和配方点位记录")
// @PreAuthorize("@ss.hasPermission('iot:recipe-device-record:create')")
// public CommonResult<Boolean> batchCreateRecipeDeviceRecord(
// @RequestParam("recipeId") Long recipeId,
// @RequestBody List<PointReferVO> pointList) throws JsonProcessingException {
//
// // ========== 第一步:查询配方关联的点位属性信息 ==========
// // 1.1 根据recipeId查询iot_recipe_device_attribute表记录
// List<RecipeDeviceAttributeDO> attributeList = recipeDeviceAttributeService.getByRecipeId(recipeId);
recipePlanDetailDO.setRecipeId(32L);
List<RecipeDeviceAttributeDO> attributeList = recipeDeviceAttributeService.getByRecipeId(recipePlanDetailDO.getRecipeId());
// if (CollectionUtils.isEmpty(attributeList)) {
// return success(false); // 无关联属性,直接返回
// }
//
// // 1.2 构建attributeName -> (attributeId, dataUnit)的映射关系
// Map<String, AttributeInfo> attributeMap = new HashMap<>();
// for (RecipeDeviceAttributeDO attributeDO : attributeList) {
// // 根据attribute_id查询iot_device_contact_model表获取attribute_name和data_unit
// // 假设通过service方法获取需根据实际业务调整
// Map<String, String> modelAttr = recipeDeviceAttributeService.getDeviceContactModelAttr(attributeDO.getAttributeId());
// String attributeName = modelAttr.get("attributeName");
// String dataUnit = modelAttr.get("dataUnit");
//
// attributeMap.put(attributeName, new AttributeInfo(
// attributeDO.getId(), attributeName, dataUnit, attributeDO.getDeviceId()));
// }
//
// // ========== 第二步:获取设备运行参数并创建设备点位采集记录 ==========
// // 2.1 获取设备运行参数JSON数据复用singleDevice逻辑取第一个设备ID
// if (attributeList.isEmpty()) {
// return success(false);
// }
// Long deviceId = attributeList.get(0).getDeviceId();
// Map<String, List<Map<String, Object>>> deviceData = recipeDeviceAttributeService.singleDevice(deviceId);
//
// // 2.2 解析JSON数据并匹配属性名
// if (deviceData != null && deviceData.containsKey("data")) {
// // 解析嵌套的data节点适配示例JSON结构
// String dataJson = objectMapper.writeValueAsString(deviceData.get("data"));
// JsonNode dataNode = objectMapper.readTree(dataJson);
//
// // 遍历所有数据分类(设备基础数据、班次信息等)
// Iterator<Map.Entry<String, JsonNode>> categoryIterator = dataNode.fields();
// while (categoryIterator.hasNext()) {
// Map.Entry<String, JsonNode> categoryEntry = categoryIterator.next();
// JsonNode attrListNode = categoryEntry.getValue();
//
// // 遍历分类下的每个属性
// if (attrListNode.isArray()) {
// for (JsonNode attrNode : attrListNode) {
// String attributeName = attrNode.get("attributeName").asText();
// JsonNode addressValueNode = attrNode.get("addressValue");
// Object addressValue = addressValueNode.isNull() ? null :
// (addressValueNode.isNumber() ? addressValueNode.numberValue() : addressValueNode.textValue());
//
// // 匹配第一步的属性名,匹配成功则创建记录
// if (attributeMap.containsKey(attributeName)) {
// AttributeInfo attrInfo = attributeMap.get(attributeName);
//
// // 构建设备点位采集记录DO
// RecipeDeviceRecordDO recordDO = new RecipeDeviceRecordDO();
// recordDO.setRecipeId(recipeId);
// recordDO.setAttributeName(attributeName);
// recordDO.setAddressValue(addressValue != null ? addressValue.toString() : null);
// recordDO.setDataUnit(attrInfo.getDataUnit());
// recordDO.setDeviceId(deviceId);
//
// // 创建记录
// recipeDeviceRecordService.createRecipeDeviceRecord(recordDO);
// }
// }
// }
// }
// }
//
// // ========== 第三步:创建配方点位记录 ==========
// for (PointReferVO pointVO : pointList) {
// // 3.1 根据id查询iot_recipe_point表记录
// RecipePointDO pointDO = recipePointService.getRecipePoint(pointVO.getId());
// if (pointDO == null) {
// continue; // 点位不存在则跳过
// }
//
// // 3.2 构建配方点位记录DO
// RecipePointRecordDO pointRecordDO = new RecipePointRecordDO();
// pointRecordDO.setPointId(pointDO.getId());
// pointRecordDO.setName(pointDO.getName());
// pointRecordDO.setMax(pointDO.getMax());
// pointRecordDO.setMin(pointDO.getMin());
// pointRecordDO.setDataUnit(pointDO.getDataUnit());
// pointRecordDO.setRemark(pointDO.getRemark());
// pointRecordDO.setRefer(pointVO.getRefer()); // 入参的refer值
// pointRecordDO.setRecipeId(recipeId);
//
// // 3.3 创建配方点位记录
// recipePointRecordService.createRecipePointRecord(pointRecordDO);
// }
//
// return success(true);
// }
Map<Long, Map<String, Object>> deviceDataMap = deviceService.createDeviceDataMap(103L);//recipeRespVO.getDeviceId()
for (RecipeDeviceAttributeDO attributeDO : attributeList) {
Map<String, Object> data = deviceDataMap.get(attributeDO.getAttributeId());
if (data != null ) {
// 创建
RecipeDeviceRecordDO recipeDeviceRecordDO = new RecipeDeviceRecordDO();
recipeDeviceRecordDO.setRecipeId(recipeId);
recipeDeviceRecordDO.setAttributeCode(attributeDO.getAttributeName());
recipeDeviceRecordDO.setDataType(attributeDO.getDataType());
recipeDeviceRecordDO.setDataUnit(attributeDO.getDataUnit());
if (data.get("addressValue") != null && data.get("addressValue").toString() != null) {
recipeDeviceRecordDO.setValue(data.get("addressValue").toString());
}
recipeDeviceRecordService.createRecipeDeviceRecord(BeanUtils.toBean(recipeDeviceRecordDO, RecipeDeviceRecordSaveReqVO.class));
}
}
return success(true);
}
// ========== 内部辅助类 ==========
/**

@ -49,4 +49,7 @@ public class RecipeDeviceRecordPageReqVO extends PageParam {
@Schema(description = "采集值")
private Double value;
@Schema(description = "配方id", example = "32535")
private Long recipeId;
}

@ -58,6 +58,9 @@ public class RecipeDeviceRecordRespVO {
@Schema(description = "采集值")
@ExcelProperty("采集值")
private Double value;
private String value;
@Schema(description = "配方id", example = "32535")
private Long recipeId;
}

@ -40,6 +40,9 @@ public class RecipeDeviceRecordSaveReqVO {
private Long deviceId;
@Schema(description = "采集值")
private Double value;
private String value;
@Schema(description = "配方id", example = "32535")
private Long recipeId;
}

@ -38,6 +38,7 @@ public class RecipePlanDetailController {
@Resource
private RecipePlanDetailService recipePlanDetailService;
@PostMapping("/create")
@Operation(summary = "创建配方计划详情表(配方库)")
@PreAuthorize("@ss.hasPermission('iot:recipe-plan-detail:create')")

@ -92,4 +92,13 @@ public class RecipePointController {
BeanUtils.toBean(list, RecipePointRespVO.class));
}
@GetMapping("/list")
@Operation(summary = "获得手动配置参数表(绑定配方)分页")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('iot:recipe-point:query')")
public CommonResult<List<RecipePointRespVO>> getRecipePointList(@RequestParam("id") Long recipeId) {
List<RecipePointDO> list = recipePointService.getRecipePointPageList(recipeId);
return success(BeanUtils.toBean(list, RecipePointRespVO.class));
}
}

@ -92,4 +92,15 @@ public class RecipePointRecordController {
BeanUtils.toBean(list, RecipePointRecordRespVO.class));
}
@PostMapping("/batch-create")
@Operation(summary = "批量创建IoT配方点位记录")
@PreAuthorize("@ss.hasPermission('iot:recipe-point-record:create')")
public CommonResult<Boolean> createRecipePointRecordBatch(@Valid @RequestBody List<RecipePointRecordSaveReqVO> createReqVOList) {
for (RecipePointRecordSaveReqVO createReqVO : createReqVOList) {
createReqVO.setId(null);
recipePointRecordService.createRecipePointRecord(createReqVO);
}
return success(true);
}
}

@ -66,6 +66,11 @@ public class RecipeDeviceRecordDO extends BaseDO {
/**
*
*/
private Double value;
private String value;
/**
* id
*/
private Long recipeId;
}

@ -61,6 +61,6 @@ public class RecipePointRecordDO extends BaseDO {
/**
*
*/
private BigDecimal refer;
private String refer;
}

@ -103,7 +103,9 @@ public interface RecipeDeviceAttributeMapper extends BaseMapperX<RecipeDeviceAtt
* @param recipeId ID
* @return
*/
List<RecipeDeviceAttributeDO> selectByRecipeId(@Param("recipeId") Long recipeId);
default List<RecipeDeviceAttributeDO> selectByRecipeId(@Param("recipeId") Long recipeId) {
return selectList(RecipeDeviceAttributeDO::getRecipeId, recipeId);
};
// 分页关联查询
PageResult<RecipeDeviceAttributePageRespDTO> selectPageWithAttribute(RecipeDeviceAttributePageReqVO reqVO);

@ -28,6 +28,7 @@ public interface RecipeDeviceRecordMapper extends BaseMapperX<RecipeDeviceRecord
.eqIfPresent(RecipeDeviceRecordDO::getRatio, reqVO.getRatio())
.eqIfPresent(RecipeDeviceRecordDO::getRemark, reqVO.getRemark())
.eqIfPresent(RecipeDeviceRecordDO::getDeviceId, reqVO.getDeviceId())
.eqIfPresent(RecipeDeviceRecordDO::getRecipeId, reqVO.getRecipeId())
.betweenIfPresent(RecipeDeviceRecordDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(RecipeDeviceRecordDO::getValue, reqVO.getValue())
.orderByDesc(RecipeDeviceRecordDO::getId));

@ -30,5 +30,7 @@ public interface RecipePointMapper extends BaseMapperX<RecipePointDO> {
.eqIfPresent(RecipePointDO::getRefer, reqVO.getRefer())
.orderByDesc(RecipePointDO::getId));
}
default List<RecipePointDO> selectList(Long recipeId) {
return selectList(RecipePointDO::getRecipeId, recipeId);
}
}

@ -123,4 +123,6 @@ public interface DeviceService {
List<Map<String, Object>> historyRecord(Long deviceId,String collectionStartTime, String collectionEndTime);
Map<Long, Map<String, Object>> createDeviceDataMap(Long deviceId);
}

@ -236,13 +236,10 @@ public class DeviceServiceImpl implements DeviceService {
}
}
return deviceModelAttributeDOPageResult;
}
@Override
public Map<Long, Map<String, Object>> createDeviceDataMap(Long deviceId) {
// 创建结果Map键为数据记录ID (Long),值为该条记录的详细信息 (Map<String, Object>)
Map<Long, Map<String, Object>> resultMap = new HashMap<>();

@ -52,6 +52,6 @@ public interface RecipePointService {
*/
PageResult<RecipePointDO> getRecipePointPage(RecipePointPageReqVO pageReqVO);
List<RecipePointDO> getRecipePointPageList(Long recipeId);
}

@ -74,5 +74,8 @@ public class RecipePointServiceImpl implements RecipePointService {
return Optional.ofNullable(recipePointMapper.selectById(id))
.orElse(null);
}
@Override
public List<RecipePointDO> getRecipePointPageList(Long recipeId) {
return recipePointMapper.selectList(recipeId);
}
}

@ -18,17 +18,20 @@ public class MoldGetPageReqVO extends PageParam {
@Schema(description = "领模单号", example = "2476")
private Long orderId;
@Schema(description = "模具编码")
private String code;
@Schema(description = "关联模具id")
private Long moldId;
@Schema(description = "模具名称", example = "张三")
private String name;
private String moldName;
@Schema(description = "状态")
private String state;
@Schema(description = "领模人")
private String person;
private Long person;
@Schema(description = "领模人")
private String personName;
@Schema(description = "设备id", example = "1850")
private Long deviceId;

@ -20,6 +20,9 @@ public class MoldGetRespVO {
@ExcelProperty("领模单号")
private Long orderId;
@Schema(description = "关联模具id", requiredMode = Schema.RequiredMode.REQUIRED)
private Long moldId;
@Schema(description = "模具编码", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("模具编码")
private String code;
@ -32,9 +35,12 @@ public class MoldGetRespVO {
@ExcelProperty("状态")
private String state;
@Schema(description = "领模人id")
private Long person;
@Schema(description = "领模人")
@ExcelProperty("领模人")
private String person;
private String personName;
@Schema(description = "设备id", example = "1850")
@ExcelProperty("设备id")

@ -20,10 +20,9 @@ public class MoldGetSaveReqVO {
@Schema(description = "模具编码", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "模具编码不能为空")
private String code;
private Long moldId;
@Schema(description = "模具名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
@NotEmpty(message = "模具名称不能为空")
@Schema(description = "模具名称", example = "张三")
private String name;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED)
@ -31,7 +30,7 @@ public class MoldGetSaveReqVO {
private String state;
@Schema(description = "领模人")
private String person;
private Long person;
@Schema(description = "设备id", example = "1850")
private Long deviceId;

@ -207,6 +207,7 @@ public class PlanController {
// 入库
else if ("store".equals(statusUpdateVO.getCode())) {
planDO.setStatus(PlanStatusEnum..getValue());
planService.createPlanStockIn(statusUpdateVO,planDO);
}
planMapper.updateById(planDO);
return success(true);

@ -35,7 +35,7 @@ public class MoldGetDO extends BaseDO {
/**
*
*/
private String code;
private Long moldId;
/**
*
*/
@ -47,7 +47,7 @@ public class MoldGetDO extends BaseDO {
/**
*
*/
private String person;
private Long person;
/**
* id
*/

@ -20,8 +20,8 @@ public interface MoldGetMapper extends BaseMapperX<MoldGetDO> {
default PageResult<MoldGetDO> selectPage(MoldGetPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<MoldGetDO>()
.eqIfPresent(MoldGetDO::getOrderId, reqVO.getOrderId())
.eqIfPresent(MoldGetDO::getCode, reqVO.getCode())
.likeIfPresent(MoldGetDO::getName, reqVO.getName())
.eqIfPresent(MoldGetDO::getMoldId, reqVO.getMoldId())
.likeIfPresent(MoldGetDO::getName, reqVO.getMoldName())
.eqIfPresent(MoldGetDO::getState, reqVO.getState())
.eqIfPresent(MoldGetDO::getPerson, reqVO.getPerson())
.eqIfPresent(MoldGetDO::getDeviceId, reqVO.getDeviceId())

@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.mes.controller.admin.itemrequisition.vo.ItemRequi
import cn.iocoder.yudao.module.mes.controller.admin.plan.vo.PlanPageReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.plan.vo.PlanRespVO;
import cn.iocoder.yudao.module.mes.controller.admin.plan.vo.PlanSaveReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.plan.vo.PlanStatusUpdateVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.plan.PlanDO;
import cn.iocoder.yudao.module.mes.service.itemrequisition.entity.ItemRequisitionAndStock;
@ -93,4 +94,6 @@ public interface PlanService {
List<ErpProductRespVO> getProductByPlanStatus(List<Integer> statusList);
List<PlanDO> getPlanBy(PlanPageReqVO pageReqVO);
void createPlanStockIn(PlanStatusUpdateVO statusUpdateVO,PlanDO planDO);
}

@ -5,17 +5,16 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO;
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.in.ErpStockInSaveReqVO;
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutSaveReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO;
import cn.iocoder.yudao.module.erp.service.product.ErpProductService;
import cn.iocoder.yudao.module.erp.service.stock.ErpStockInService;
import cn.iocoder.yudao.module.erp.service.stock.ErpStockOutService;
import cn.iocoder.yudao.module.erp.service.stock.ErpStockService;
import cn.iocoder.yudao.module.mes.controller.admin.itemrequisition.vo.ItemRequisitionSaveReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.itemrequisition.vo.ItemRequisitionStatusEnum;
import cn.iocoder.yudao.module.mes.controller.admin.plan.vo.PlanPageReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.plan.vo.PlanRespVO;
import cn.iocoder.yudao.module.mes.controller.admin.plan.vo.PlanSaveReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.plan.vo.PlanStatusEnum;
import cn.iocoder.yudao.module.mes.controller.admin.plan.vo.*;
import cn.iocoder.yudao.module.mes.controller.admin.task.vo.TaskStatusEnum;
import cn.iocoder.yudao.module.mes.dal.dataobject.itemrequisition.ItemRequisitionDetailDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.paigongrecord.PaigongRecordDO;
@ -70,7 +69,10 @@ public class PlanServiceImpl implements PlanService {
private ItemAnalysisService analysisService;
@Resource
private ErpStockOutService stockService;
private ErpStockOutService stockOutService;
@Resource
private ErpStockInService stockInService;
@Override
@Transactional(rollbackFor = Exception.class)
@ -136,16 +138,38 @@ public class PlanServiceImpl implements PlanService {
stockOut.setOutType("领料出库");
for (ItemRequisitionAndStock requisition : list) {
ErpStockOutSaveReqVO.Item item = new ErpStockOutSaveReqVO.Item();
// todo 修改仓库
item.setWarehouseId(3L);
item.setProductId(requisition.getItemId());
item.setCount(requisition.getNumber());
itemList.add(item);
}
stockOut.setItems(itemList);
stockService.createStockOut(stockOut);
stockOutService.createStockOut(stockOut);
return plan.getId();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void createPlanStockIn(PlanStatusUpdateVO statusUpdateVO,PlanDO planDO) {
// 创建入产品入库单
ErpStockInSaveReqVO stockIn = new ErpStockInSaveReqVO();
List<ErpStockInSaveReqVO.Item> itemList = new ArrayList<>();
stockIn.setInTime(LocalDateTime.now());
stockIn.setInType("产品入库");
ErpStockInSaveReqVO.Item item = new ErpStockInSaveReqVO.Item();
// todo 修改仓库
item.setWarehouseId(4L);
item.setProductId(planDO.getProductId());
if (planDO.getPassNumber() == null) {
planDO.setPassNumber(0L);
}
item.setCount(BigDecimal.valueOf(planDO.getPassNumber()));
itemList.add(item);
stockIn.setItems(itemList);
stockInService.createStockIn(stockIn);
}
@Override
public void updatePlan(PlanSaveReqVO updateReqVO) {
// 校验存在

Loading…
Cancel
Save