parent
586428453c
commit
e3a9cba3fb
4 changed files with 194 additions and 87 deletions
@ -0,0 +1,28 @@ |
||||
package org.springblade.desk.quality.pojo.request; |
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
|
||||
import java.math.BigDecimal; |
||||
|
||||
@Data |
||||
public class InspectionTaskStart { |
||||
|
||||
/** |
||||
* [工单]id |
||||
*/ |
||||
@Schema(description = "[工单]id") |
||||
private BigDecimal workOrderId; |
||||
|
||||
/** |
||||
* [工序]id |
||||
*/ |
||||
@Schema(description = "[工序]id") |
||||
private BigDecimal processId; |
||||
|
||||
/** |
||||
* [制品]id |
||||
*/ |
||||
@Schema(description = "[制品]id") |
||||
private BigDecimal productId; |
||||
} |
||||
@ -0,0 +1,60 @@ |
||||
package org.springblade.desk.quality.service; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import jakarta.annotation.Resource; |
||||
import lombok.Data; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.desk.quality.constant.ColBase; |
||||
import org.springblade.desk.quality.constant.ColValue; |
||||
import org.springblade.desk.quality.mapper.gen.InspectionItemGenMapper; |
||||
import org.springblade.desk.quality.mapper.gen.InspectionResultGenMapper; |
||||
import org.springblade.desk.quality.mapper.gen.InspectionTaskGenMapper; |
||||
import org.springblade.desk.quality.pojo.entity.InspectionItem; |
||||
import org.springblade.desk.quality.pojo.entity.InspectionResult; |
||||
import org.springblade.desk.quality.pojo.entity.InspectionTask; |
||||
import org.springblade.desk.quality.pojo.request.InspectionTaskStart; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Service |
||||
@Data |
||||
public class InspectionTaskService { |
||||
|
||||
@Resource |
||||
private InspectionTaskGenMapper genMapper; |
||||
@Resource |
||||
private InspectionItemGenMapper itemGenMapper; |
||||
@Resource |
||||
private InspectionResultGenMapper resultGenMapper; |
||||
|
||||
public R<InspectionTask> start(InspectionTaskStart start) { |
||||
// todo:check工单有效性
|
||||
|
||||
// todo:check工序有效性
|
||||
|
||||
// todo:check制品有效性
|
||||
InspectionTask taskNew = new InspectionTask(); |
||||
genMapper.insert(taskNew); |
||||
// 查询工艺用到的,所有启用的检验项目。
|
||||
List<InspectionItem> itemList = itemGenMapper.selectList( |
||||
new QueryWrapper<InspectionItem>() |
||||
.eq(ColBase.STATUS, ColValue.STATE_ENABLE) |
||||
.eq("PROCESS_ID", start.getProcessId()) |
||||
); |
||||
if (itemList.isEmpty()) { |
||||
return R.fail("没有关联的检测项目!"); |
||||
} |
||||
// 创建关联的检验结果集合。
|
||||
for (InspectionItem item : itemList) { |
||||
InspectionResult result = new InspectionResult(); |
||||
result.setInspectionTaskId(taskNew.getId()); |
||||
result.setInspectionItemId(item.getId()); |
||||
resultGenMapper.insert(result); |
||||
} |
||||
// 最终返回R
|
||||
R<InspectionTask> rFinal = R.success("成功生成检测任务!"); |
||||
rFinal.setData(taskNew); |
||||
return rFinal; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue