| | |
| | | import com.yuanchu.limslaboratory.pojo.Inspection; |
| | | import com.yuanchu.limslaboratory.pojo.InspectionProductList; |
| | | import com.yuanchu.limslaboratory.pojo.Product; |
| | | import com.yuanchu.limslaboratory.service.InspectionProductListService; |
| | | import com.yuanchu.limslaboratory.service.InspectionService; |
| | | import com.yuanchu.limslaboratory.service.ProductService; |
| | | import com.yuanchu.limslaboratory.service.SpecificationsService; |
| | | import com.yuanchu.limslaboratory.service.*; |
| | | import com.yuanchu.limslaboratory.utils.JackSonUtil; |
| | | import com.yuanchu.limslaboratory.utils.RedisUtil; |
| | | import com.yuanchu.limslaboratory.vo.Result; |
| | | import io.swagger.annotations.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestHeader; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | |
| | | private InspectionService inspectionService; |
| | | |
| | | @Autowired |
| | | private ProductService productService; |
| | | |
| | | @Autowired |
| | | private SpecificationsService specificationsService; |
| | | private InspectionMaterialListService inspectionMaterialListService; |
| | | |
| | | @Autowired |
| | | private InspectionProductListService inspectionProductListService; |
| | | |
| | | @Autowired |
| | | private MaterialService materialService; |
| | | |
| | | @ApiOperation("添加检验申请单") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "materialId", value = "物料信息id", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "type", value = "检验类型", dataTypeClass = Integer.class, required = true), |
| | | }) |
| | | @PostMapping("/addInspection") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Result addInspection(@RequestHeader("X-Token") String token, int materialId,int type) throws Exception { |
| | | List<Product> list = productService.selectProductByMaterialId(materialId); |
| | | Map<String, Object> map = specificationsService.selectSNameSNName(materialId); |
| | | if (map==null)return Result.fail("找不到该物料信息"); |
| | | public Result addInspection(@RequestHeader("X-Token") String token, int type) throws Exception { |
| | | Object object = RedisUtil.get(token); |
| | | Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(object), Map.class); |
| | | Inspection inspection = new Inspection(); |
| | | inspection.setId(IdWorker.getIdStr()) |
| | | .setType(type) |
| | | .setInspectionStatus(0) |
| | | .setState(1) |
| | | .setVersion(1) |
| | | .setUserName("" + unmarshal.get("name")) |
| | | .setMaterialNum(Integer.valueOf("" + map.get("num"))) |
| | | .setMaterialSupplier("" + map.get("supplier")) |
| | | .setMaterialName("" + map.get("m_name")) |
| | | .setMaterialLocation("" + map.get("location")) |
| | | .setMaterialBatch("" + map.get("batch")) |
| | | .setMaterialReelNumber("" + map.get("reel_number")) |
| | | .setSpecificationsSerialNumber("" + map.get("ss_name")) |
| | | .setSpecificationsVoltageLevel("" + map.get("voltage_level")) |
| | | .setSpecificationsCrossSection("" + map.get("cross_section")) |
| | | .setSpecificationsNumberOfCores("" + map.get("number_of_cores")) |
| | | .setSpecificationsInstruct("" + map.get("instruct")); |
| | | int judge1 = 0; |
| | | int judge2 = 0; |
| | | try { |
| | | judge1 = inspectionService.addInspection(inspection); |
| | | List<InspectionProductList> list2 = new ArrayList<>(); |
| | | list.forEach(a -> { |
| | | InspectionProductList inspectionProductList = new InspectionProductList(); |
| | | inspectionProductList.setName(a.getName()) |
| | | .setMethod(a.getMethod()) |
| | | .setUnit(a.getUnit()) |
| | | .setRequired(a.getRequired()) |
| | | .setInternal(a.getInternal()) |
| | | .setState(1) |
| | | .setVersion(1) |
| | | .setInspectionId(inspection.getId()) |
| | | .setUserId(Integer.parseInt("" + unmarshal.get("id"))) |
| | | .setCreateTime(new Date()) |
| | | .setUpdateTime(new Date()); |
| | | list2.add(inspectionProductList); |
| | | }); |
| | | judge2 = inspectionProductListService.addInspectionProductList(list2); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return Result.success(inspectionService.addInspection("" + unmarshal.get("name"), type)); |
| | | } |
| | | return Result.success(judge1 > 0 && judge2 > 0 ? "提交成功" : "提交失败", judge1 > 0 && judge2 > 0); |
| | | |
| | | @ApiOperation("查询所有检验单列表") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "pageSize", value = "页数", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "countSize", value = "条数/页", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "state", value = "状态(为空=全部)", dataTypeClass = Integer.class) |
| | | }) |
| | | @GetMapping("/selectAllInspection") |
| | | public Result selectAllInspection(int pageSize, int countSize, Integer state) { |
| | | return Result.success(inspectionService.selectAllInspection(pageSize, countSize, state)); |
| | | } |
| | | |
| | | @ApiOperation("查询检验单里面的物料信息") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "inspectionId", value = "报检单ID", dataTypeClass = String.class, required = true), |
| | | }) |
| | | @PostMapping("/selectMaterialByInsId") |
| | | public Result selectMaterialByInsId(String inspectionId) { |
| | | return Result.success(inspectionMaterialListService.selectInspectionMaterialListByInsId(inspectionId)); |
| | | } |
| | | |
| | | @ApiOperation("查询物料信息") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "pageSize", value = "页数", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "countSize", value = "条数/页", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | @GetMapping("/selectMaterialLimit") |
| | | public Result selectMaterialLimit(int pageSize, int countSize) { |
| | | return Result.success(materialService.selectMaterialLimit(pageSize, countSize)); |
| | | } |
| | | |
| | | @ApiOperation("选择物料信息") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "materialId", value = "物料ID", dataTypeClass = Integer.class, required = true), |
| | | }) |
| | | @PostMapping("/selectMaterialById") |
| | | public Result selectMaterialById(String materialId) { |
| | | return Result.success(materialService.selectMaterialById(materialId)); |
| | | } |
| | | |
| | | } |