Compare commits

...

2 Commits

Author SHA1 Message Date
HuangHuiKang 09a2c8458c fix:修复已知问题,修改添加检验模板关联产品 3 weeks ago
HuangHuiKang e6197fd60a fix:修复已知问题 3 weeks ago

@ -99,6 +99,8 @@ public interface ErpProductMapper extends BaseMapperX<ErpProductDO> {
return selectList(new LambdaQueryWrapperX<ErpProductDO>().in(ErpProductDO::getName, names));
}
List<ErpProductDO> selectListByIdsWithDeleted(@Param("ids") Collection<Long> ids);
List<ProductRelationRespVO> selectDevicesByProductId(@Param("productId") Long productId);
List<ProductRelationRespVO> selectMoldsByProductId(@Param("productId") Long productId);

@ -349,7 +349,7 @@ public class ErpProductServiceImpl implements ErpProductService {
if (CollUtil.isEmpty(ids)) {
return Collections.emptyList();
}
List<ErpProductDO> list = productMapper.selectBatchIds(ids);
List<ErpProductDO> list = productMapper.selectListByIdsWithDeleted(ids);
return buildProductVOList(list);
}
@ -376,6 +376,9 @@ public class ErpProductServiceImpl implements ErpProductService {
subCategory -> product.setSubCategoryName(subCategory.getName()));
MapUtils.findAndThen(unitMap, product.getUnitId(),
unit -> product.setUnitName(unit.getName()));
if (Boolean.TRUE.equals(product.getDeleted())) {
product.setName(product.getName() + "(已被删除)");
}
});
}
@ -539,4 +542,4 @@ public class ErpProductServiceImpl implements ErpProductService {
return productDO;
}
}
}

@ -8,6 +8,17 @@
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="selectListByIdsWithDeleted" resultType="cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO">
SELECT id, name, bar_code, category_id, sub_category_id, sub_category_name, unit_id,
status, standard, remark, expiry_day, weight, purchase_price, sale_price,
min_price, safety_number, create_time, update_time, creator, updater, deleted
FROM erp_product
WHERE id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="selectDevicesByProductId"
resultType="cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductRelationRespVO">
SELECT DISTINCT
@ -39,4 +50,4 @@
</select>
</mapper>
</mapper>

@ -115,6 +115,7 @@ public interface ErrorCodeConstants {
ErrorCode DV_REPAIR_LINE_NOT_EXISTS = new ErrorCode(5_0088, "设备维修子表记录不存在");
ErrorCode DV_REPAIR_LINE_ID_NOT_EXISTS = new ErrorCode(5_0088, "设备维修子表记录Id为空");
//====================================== 检验记录相关 5_0090=================================================
ErrorCode ZJ_TYPE_NOT_EXISTS = new ErrorCode(5_0090, "检验类型不存在");
ErrorCode ZJ_TYPE_CODE_EXISTS = new ErrorCode(5_0090, "检验类型编码已存在");
@ -125,7 +126,6 @@ public interface ErrorCodeConstants {
ErrorCode ZJ_TASK_NOT_EXISTS = new ErrorCode(5_0094, "检验任务不存在");
ErrorCode ZJ_TASK_CODE_EXISTS = new ErrorCode(5_0094, "检验任务单号已存在");
ErrorCode ZJ_TASK_RESULTS_NOT_EXISTS = new ErrorCode(5_0095, "检验任务-检验结果不存在");
ErrorCode GOVIEW_NOT_EXISTS = new ErrorCode(5_0100, "可视化大屏不存在");

@ -22,6 +22,11 @@ public class BomDetailRespVO {
@Schema(description = "原料ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "17312")
@ExcelProperty("原料ID")
private Long productId;
@Schema(description = "原料编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "")
@ExcelProperty("原料编码")
private String productCode;
@Schema(description = "原料", requiredMode = Schema.RequiredMode.REQUIRED, example = "2336")
@ExcelProperty("原料")
private String productName;

@ -144,7 +144,7 @@ public class DeviceLedgerController {
})
.collect(Collectors.toSet());
Map<Long, OrganizationDO> organizationMap = organizationService.getMap(workshopIds);
Map<Long, OrganizationDO> organizationMap = organizationService.getMapWithDeleted(workshopIds);
// 4. 设置 workshopName
for (DeviceLedgerDO item : pageResult.getList()) {
@ -153,7 +153,11 @@ public class DeviceLedgerController {
Long workshopId = Long.parseLong(item.getWorkshop().trim());
OrganizationDO org = organizationMap.get(workshopId);
if (org != null) {
item.setWorkshopName(org.getName());
String workshopName = org.getName();
if (Boolean.TRUE.equals(org.getDeleted())) {
workshopName += "(已被删除)";
}
item.setWorkshopName(workshopName);
}
} catch (NumberFormatException e) {
}

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.mes.controller.admin.zjschema;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
import cn.iocoder.yudao.module.erp.service.product.ErpProductService;
import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO;
import cn.iocoder.yudao.module.erp.service.product.ErpProductUnitService;
import cn.iocoder.yudao.module.mes.controller.admin.zjitem.vo.ZjItemRespVO;
@ -55,6 +56,8 @@ public class ZjSchemaController {
private ZjTypeService zjTypeService;
@Resource
private ErpProductUnitService productUnitService;
@Resource
private ErpProductService erpProductService;
@PostMapping("/create")
@Operation(summary = "创建检验方案")
@ -86,7 +89,7 @@ public class ZjSchemaController {
@PreAuthorize("@ss.hasPermission('mes:zj-schema:query')")
public CommonResult<ZjSchemaRespVO> getZjSchema(@RequestParam("id") Long id) {
ZjSchemaDO zjSchema = zjSchemaService.getZjSchema(id);
return success(BeanUtils.toBean(zjSchema, ZjSchemaRespVO.class));
return success(buildZjSchemaRespVO(zjSchema));
}
@GetMapping("/page")
@ -94,14 +97,17 @@ public class ZjSchemaController {
@PreAuthorize("@ss.hasPermission('mes:zj-schema:query')")
public CommonResult<PageResult<ZjSchemaRespVO>> getZjSchemaPage(@Valid ZjSchemaPageReqVO pageReqVO) {
PageResult<ZjSchemaDO> pageResult = zjSchemaService.getZjSchemaPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, ZjSchemaRespVO.class));
List<ZjSchemaRespVO> list = pageResult.getList().stream()
.map(this::buildZjSchemaRespVO)
.collect(Collectors.toList());
return success(new PageResult<>(list, pageResult.getTotal()));
}
@GetMapping("/list")
@Operation(summary = "获得检验方案列表")
@PreAuthorize("@ss.hasPermission('mes:zj-schema:query')")
public CommonResult<List<ZjSchemaDO>> getZjSchemaList() {
List<ZjSchemaDO> zjSchemaDOList = zjSchemaService.getZjSchemaList();
public CommonResult<List<ZjSchemaDO>> getZjSchemaList(@RequestParam(value = "productId", required = false) Long productId) {
List<ZjSchemaDO> zjSchemaDOList = zjSchemaService.getZjSchemaList(productId);
return success(zjSchemaDOList);
}
@ -182,4 +188,30 @@ public class ZjSchemaController {
}
});
}
}
private ZjSchemaRespVO buildZjSchemaRespVO(ZjSchemaDO zjSchema) {
if (zjSchema == null) {
return null;
}
ZjSchemaRespVO respVO = BeanUtils.toBean(zjSchema, ZjSchemaRespVO.class);
List<Long> productIds = parseIds(zjSchema.getProduct());
respVO.setProductIds(productIds);
if (CollUtil.isNotEmpty(productIds)) {
respVO.setProducts(erpProductService.getProductVOList(productIds));
} else {
respVO.setProducts(Collections.emptyList());
}
return respVO;
}
private List<Long> parseIds(String ids) {
if (ids == null || ids.trim().isEmpty()) {
return Collections.emptyList();
}
return Arrays.stream(ids.split(","))
.map(String::trim)
.filter(str -> !str.isEmpty())
.map(Long::valueOf)
.collect(Collectors.toList());
}
}

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.mes.controller.admin.zjschema.vo;
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
@ -45,9 +46,15 @@ public class ZjSchemaRespVO {
// @ExcelProperty("关联项目")
private String item;
@Schema(description = "关联产品 ID 列表", example = "[1,2,3]")
private List<Long> productIds;
@Schema(description = "关联产品列表")
private List<ErpProductRespVO> products;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
@ColumnWidth(20)
private LocalDateTime createTime;
}
}

@ -33,4 +33,7 @@ public class ZjSchemaSaveReqVO {
@Schema(description = "关联项目")
private String item;
}
@Schema(description = "关联产品 ID 列表", example = "[1,2,3]")
private List<Long> productIds;
}

@ -15,7 +15,7 @@ public class ZjTaskSaveReqVO {
private Long id;
@Schema(description = "单号", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "单号不能为空")
// @NotEmpty(message = "单号不能为空")
private String code;
@Schema(description = "名称", example = "王五")
@ -41,7 +41,7 @@ public class ZjTaskSaveReqVO {
private String ticket;
@Schema(description = "工序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotEmpty(message = "工序不能为空")
// @NotEmpty(message = "工序不能为空")
private String orgType;
@Schema(description = "负责人id", example = "6442")

@ -52,4 +52,9 @@ public class ZjSchemaDO extends BaseDO {
*/
private String item;
}
/**
* erp_product.id
*/
private String product;
}

@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.mes.controller.admin.organization.vo.Organization
import cn.iocoder.yudao.module.mes.dal.dataobject.organization.OrganizationDO;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
@ -71,4 +72,7 @@ public interface OrganizationMapper extends BaseMapperX<OrganizationDO> {
return selectList(OrganizationDO::getId, outIds);
}
List<OrganizationDO> selectListWithDeleted(@Param("ids") Collection<Long> ids);
}

@ -10,6 +10,7 @@ import cn.iocoder.yudao.module.common.dal.dataobject.moldrepair.MoldRepairDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.zjschema.ZjSchemaDO;
import com.alibaba.excel.util.StringUtils;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import cn.iocoder.yudao.module.mes.controller.admin.zjschema.vo.*;
/**
@ -56,4 +57,6 @@ public interface ZjSchemaMapper extends BaseMapperX<ZjSchemaDO> {
.orderByAsc(ZjSchemaDO::getId));
}
}
List<ZjSchemaDO> selectListByProductId(@Param("productId") Long productId);
}

@ -113,4 +113,8 @@ public interface ZjTaskMapper extends BaseMapperX<ZjTaskDO> {
@Param("status") Integer status,
@Param("cancelReason") String cancelReason);
ZjTaskDO selectByNo(@Param("code") String code);
}

@ -219,7 +219,13 @@ public class BomServiceImpl implements BomService {
return BeanUtils.toBean(list, BomDetailRespVO.class, item -> {
MapUtils.findAndThen(map, item.getProductId(),
product -> item.setProductName(product.getName()));
product -> {
item.setProductName(product.getName());
item.setProductCode(product.getBarCode());
}
);
MapUtils.findAndThen(unitMap, item.getUnitId(),
unit -> item.setUnitName(unit.getName()));
});

@ -6,10 +6,7 @@ import cn.iocoder.yudao.module.mes.controller.admin.organization.vo.*;
import cn.iocoder.yudao.module.mes.dal.dataobject.organization.OrganizationDO;
import javax.validation.Valid;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
@ -81,6 +78,8 @@ public interface OrganizationService {
OrganizationRespVO getOrganizationVO(Long id);
Map<Long, OrganizationDO> getMapWithDeleted(Set<Long> workshopIds);
// List<DeviceParametersDTO> getDeviceParametersByOrganizationId(Long id);
}

@ -762,6 +762,11 @@ public class OrganizationServiceImpl implements OrganizationService {
return respVO;
}
@Override
public Map<Long, OrganizationDO> getMapWithDeleted(Set<Long> ids) {
if (CollUtil.isEmpty(ids)) {
return new HashMap<>();
}
return CollectionUtils.convertMap(organizationMapper.selectListWithDeleted(ids), OrganizationDO::getId);
}
}

@ -55,4 +55,6 @@ public interface ZjSchemaService {
List<ZjSchemaDO> getZjSchemaList();
}
List<ZjSchemaDO> getZjSchemaList(Long productId);
}

@ -1,16 +1,14 @@
package cn.iocoder.yudao.module.mes.service.zjschema;
import cn.iocoder.yudao.module.mes.dal.dataobject.zjitem.ZjItemDO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
import cn.iocoder.yudao.module.mes.controller.admin.zjschema.vo.*;
import cn.iocoder.yudao.module.mes.dal.dataobject.zjschema.ZjSchemaDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.mes.dal.mysql.zjschema.ZjSchemaMapper;
@ -32,19 +30,17 @@ public class ZjSchemaServiceImpl implements ZjSchemaService {
@Override
public Long createZjSchema(ZjSchemaSaveReqVO createReqVO) {
// 插入
ZjSchemaDO zjSchema = BeanUtils.toBean(createReqVO, ZjSchemaDO.class);
zjSchema.setProduct(joinProductIds(createReqVO.getProductIds()));
zjSchemaMapper.insert(zjSchema);
// 返回
return zjSchema.getId();
}
@Override
public void updateZjSchema(ZjSchemaSaveReqVO updateReqVO) {
// 校验存在
validateZjSchemaExists(updateReqVO.getId());
// 更新
ZjSchemaDO updateObj = BeanUtils.toBean(updateReqVO, ZjSchemaDO.class);
updateObj.setProduct(joinProductIds(updateReqVO.getProductIds()));
zjSchemaMapper.updateById(updateObj);
}
@ -77,4 +73,23 @@ public class ZjSchemaServiceImpl implements ZjSchemaService {
return zjSchemaMapper.selectList();
}
}
@Override
public List<ZjSchemaDO> getZjSchemaList(Long productId) {
if (productId == null) {
return zjSchemaMapper.selectList();
}
List<ZjSchemaDO> list = zjSchemaMapper.selectListByProductId(productId);
return list == null || list.isEmpty() ? zjSchemaMapper.selectList() : list;
}
private String joinProductIds(List<Long> productIds) {
if (productIds == null || productIds.isEmpty()) {
return null;
}
return productIds.stream().filter(Objects::nonNull)
.map(String::valueOf)
.distinct()
.collect(Collectors.joining(","));
}
}

@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.erp.controller.admin.autocode.util.AutoCodeUtil;
import cn.iocoder.yudao.module.mes.controller.admin.feedingrecord.vo.FeedingRecordRespVO;
import cn.iocoder.yudao.module.mes.controller.admin.ticketmanagement.vo.TicketManagementBatchUpdateReqVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.organization.OrganizationDO;
@ -18,6 +19,7 @@ import cn.iocoder.yudao.module.mes.dal.mysql.zjschema.ZjSchemaMapper;
import cn.iocoder.yudao.module.mes.dal.mysql.zjtaskresults.ZjTaskResultsMapper;
import cn.iocoder.yudao.module.mes.service.plan.PlanService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.poi.util.StringUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -66,6 +68,8 @@ public class ZjTaskServiceImpl implements ZjTaskService {
@Resource
private PlanService planService;
@Resource
private AutoCodeUtil autoCodeUtil;
@Override
@Transactional(rollbackFor = Exception.class)
@ -74,6 +78,14 @@ public class ZjTaskServiceImpl implements ZjTaskService {
validateCodeOnly(createReqVO.getCode());
// 插入
ZjTaskDO zjTask = BeanUtils.toBean(createReqVO, ZjTaskDO.class);
if (!StringUtils.hasText(createReqVO.getCode())) {
zjTask.setCode(autoCodeUtil.genSerialCode("INSPECTION_CODE_GENERATE",null));
} else {
if (zjTaskMapper.selectByNo(createReqVO.getCode()) != null) {
throw exception(ZJ_TASK_CODE_EXISTS);
}
}
zjTaskMapper.insert(zjTask);

@ -8,5 +8,13 @@
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="selectListWithDeleted" resultType="cn.iocoder.yudao.module.mes.dal.dataobject.organization.OrganizationDO">
SELECT *
FROM mes_organization
WHERE id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
</mapper>

@ -9,4 +9,15 @@
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>
<select id="selectListByProductId" resultType="cn.iocoder.yudao.module.mes.dal.dataobject.zjschema.ZjSchemaDO">
SELECT id, type, name, remark, sample_method, val, item, product,
create_time, update_time, creator, updater, deleted
FROM mes_zj_schema
WHERE deleted = 0
AND product IS NOT NULL
AND product != ''
AND FIND_IN_SET(#{productId}, product)
ORDER BY id DESC
</select>
</mapper>

@ -19,4 +19,12 @@
#{id}
</foreach>
</update>
<select id="selectByNo" resultType="cn.iocoder.yudao.module.mes.dal.dataobject.zjtask.ZjTaskDO">
SELECT *
FROM zj_task
WHERE code = #{code}
LIMIT 1
</select>
</mapper>
Loading…
Cancel
Save