| | |
| | | package com.yuanchu.mom.controller; |
| | | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.yuanchu.mom.pojo.RawInspect; |
| | | import com.yuanchu.mom.pojo.vo.RawInsProductVo; |
| | | import com.yuanchu.mom.pojo.vo.RawInspectVo; |
| | | import com.yuanchu.mom.service.*; |
| | | import com.yuanchu.mom.utils.JackSonUtil; |
| | | import com.yuanchu.mom.utils.Jwt; |
| | | import com.yuanchu.mom.vo.Result; |
| | | import io.swagger.annotations.*; |
| | | import org.json.JSONException; |
| | | import org.json.JSONObject; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | |
| | |
| | | @Resource |
| | | Jwt jwt; |
| | | |
| | | @Resource |
| | | MaterialService materialService; |
| | | |
| | | @Resource |
| | | SpecificationsService specificationsService; |
| | | @ApiOperation(value = "新增原材料检验单") |
| | | @PostMapping("/addRawInspects") |
| | | public Result addRawInspects(@RequestHeader("token") String token,@Validated @RequestBody RawInspectVo rawInspectVo) throws Exception { |
| | | Map<String, String> data = JackSonUtil.unmarshal(jwt.readJWT(token).get("data"), Map.class); |
| | | return Result.success(rawInspectService.addRawInspects(data.get("id").replaceAll("\"", ""), rawInspectVo)); |
| | | } |
| | | |
| | | @ApiOperation(value = "查询原材料检验单列表") |
| | | @ApiOperation(value = "分页查询原材料检验单列表") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "pageSize", value = "页数", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "countSize", value = "条数/页", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "formTime", value = "来料日期", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "createTime", value = "报检日期", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "insState", value = "检测状态: 全部默认2", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "judgeState", value = "合格状态: 全部默认2", dataTypeClass = Integer.class, required = true), |
| | | @ApiImplicitParam(name = "code", value = "原材料编码", dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "insState", value = "检测状态(为空=全部)", dataTypeClass = Integer.class), |
| | | @ApiImplicitParam(name = "name", value = "原材料名称", dataTypeClass = String.class) |
| | | }) |
| | | @PostMapping("/selectRawInspectsList") |
| | | public Result selectRawInspectsList(Integer pageSize, Integer countSize, String formTime, String createTime, Integer insState, Integer judgeState) { |
| | | return Result.success(rawInspectService.selectRawInspectsList(pageSize, countSize, formTime, createTime, insState, judgeState)); |
| | | public Result selectRawInspectsList(Integer pageSize, Integer countSize, String formTime, String code, Integer insState, String name) { |
| | | IPage<Map<String, Object>> page = rawInspectService.selectRawInspectsList(new Page<Object>(pageSize, countSize), formTime, code, insState, name); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("total", page.getTotal()); |
| | | map.put("row", page.getRecords()); |
| | | return Result.success(map); |
| | | } |
| | | |
| | | @ApiOperation(value = "根据检验单id查询原材料检验单详情") |
| | |
| | | return Result.fail("已经上报过了,不能再次上报!"); |
| | | } |
| | | return Result.success(rawInspectService.updateRawInspectsById(id)); |
| | | } |
| | | |
| | | @ApiOperation(value = "查询所有原材料信息") |
| | | @GetMapping("/selectMaterial") |
| | | public Result selectMaterial() { |
| | | return Result.success(materialService.selectMaterial()); |
| | | } |
| | | |
| | | @ApiOperation(value = "选择物料名称查询物料信息(物料id和编码)") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "name", value = "原材料名称(物料名称)", dataTypeClass = String.class, required = true) |
| | | }) |
| | | @GetMapping("/selectMcodeId") |
| | | public Result selectMcodeId(String name) { |
| | | return Result.success(materialService.selectMcodeId(name)); |
| | | } |
| | | |
| | | @ApiOperation(value = "选择物料编码(获取物料规格id.名称和型号名称)") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "name", value = "原材料名称(物料名称)", dataTypeClass = String.class, required = true), |
| | | @ApiImplicitParam(name = "code", value = "原材料编号(物料编号)", dataTypeClass = String.class, required = true) |
| | | }) |
| | | @GetMapping("/selectIdByCoNa") |
| | | public Result selectIdByCoNa(String name, String code) { |
| | | return Result.success(materialService.selectIdByCoNa(name, code)); |
| | | } |
| | | |
| | | @ApiOperation(value = "选择物料规格(根据规格id获取物料型号)") |
| | | @ApiImplicitParams(value = { |
| | | @ApiImplicitParam(name = "id", value = "物料规格id", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | @GetMapping("/selectSpBySt") |
| | | public Result selectSpBySt(Integer id) { |
| | | return Result.success(specificationsService.selectSpecificationIdAndName(id)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "新增检验单") |
| | | @PostMapping("/addRawInspects") |
| | | public Result addRawInspects(@RequestHeader("token") String token, @RequestBody RawInspect rawInspect) throws JSONException { |
| | | Map<String, String> map = jwt.readJWT(token); |
| | | String data = map.get("data"); |
| | | JSONObject jsonObject = new JSONObject(data); |
| | | String userName = jsonObject.getString("name"); |
| | | return Result.success(rawInspectService.addRawInspects(userName, rawInspect)); |
| | | } |
| | | |
| | | } |