| | |
| | | import org.jeecg.modules.cms.entity.CuttingReceiveDetail; |
| | | import org.jeecg.modules.cms.entity.CuttingScrap; |
| | | import org.jeecg.modules.cms.entity.CuttingScrapDetail; |
| | | import org.jeecg.modules.cms.service.ICuttingInventoryService; |
| | | import org.jeecg.modules.cms.service.ICuttingScrapDetailService; |
| | | import org.jeecg.modules.cms.service.ICuttingScrapService; |
| | | |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.jeecg.common.aspect.annotation.AutoLog; |
| | | |
| | | /** |
| | | /** |
| | | * @Description: 刀具报废 |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-07-28 |
| | | * @Date: 2025-07-28 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Api(tags="刀具报废") |
| | | @Api(tags = "刀具报废") |
| | | @RestController |
| | | @RequestMapping("/cms/cuttingScrap") |
| | | @Slf4j |
| | | public class CuttingScrapController extends JeecgController<CuttingScrap, ICuttingScrapService> { |
| | | @Autowired |
| | | private ICuttingScrapService cuttingScrapService; |
| | | @Autowired |
| | | private ICuttingScrapService cuttingScrapService; |
| | | |
| | | @Autowired |
| | | private ICuttingScrapDetailService cuttingScrapDetailService; |
| | | |
| | | /** |
| | | * 分页列表查询 |
| | | * |
| | | * @param cuttingScrap |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "刀具报废-分页列表查询") |
| | | @ApiOperation(value="刀具报废-分页列表查询", notes="刀具报废-分页列表查询") |
| | | @GetMapping(value = "/list") |
| | | public Result<IPage<CuttingScrap>> queryPageList(CuttingScrap cuttingScrap, |
| | | @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, |
| | | @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | QueryWrapper<CuttingScrap> queryWrapper = QueryGenerator.initQueryWrapper(cuttingScrap, req.getParameterMap()); |
| | | Page<CuttingScrap> page = new Page<CuttingScrap>(pageNo, pageSize); |
| | | IPage<CuttingScrap> pageList = cuttingScrapService.page(page, queryWrapper); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param jSONObject |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具报废-添加") |
| | | @ApiOperation(value="刀具报废-添加", notes="刀具报废-添加") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_scrap:add") |
| | | @PostMapping(value = "/add") |
| | | public Result<String> add(@RequestBody JSONObject jSONObject) { |
| | | CuttingScrap cuttingScrap = jSONObject.toJavaObject(CuttingScrap.class); |
| | | cuttingScrap.setOrderStatus("1"); |
| | | cuttingScrapService.saveOrUpdate(cuttingScrap); |
| | | //删除原关联数据 |
| | | List<CuttingScrapDetail> cuttingScrapDetailList = cuttingScrapDetailService.lambdaQuery().eq(CuttingScrapDetail::getOrderId,cuttingScrap.getId()).list(); |
| | | cuttingScrapDetailService.removeBatchByIds(cuttingScrapDetailList); |
| | | //添加新关联数据 |
| | | JSONArray jsonArray = jSONObject.getJSONArray("detailData"); |
| | | List<CuttingScrapDetail> list = jsonArray.toJavaList(CuttingScrapDetail.class); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CuttingScrapDetail temp = list.get(i); |
| | | temp.setOrderId(cuttingScrap.getId()); |
| | | cuttingScrapDetailService.save(temp); |
| | | } |
| | | return Result.OK("添加成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 编辑 |
| | | * |
| | | * @param cuttingScrap |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具报废-编辑") |
| | | @ApiOperation(value="刀具报废-编辑", notes="刀具报废-编辑") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_scrap:edit") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) |
| | | public Result<String> edit(@RequestBody CuttingScrap cuttingScrap) { |
| | | cuttingScrapService.updateById(cuttingScrap); |
| | | return Result.OK("编辑成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id删除 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具报废-通过id删除") |
| | | @ApiOperation(value="刀具报废-通过id删除", notes="刀具报废-通过id删除") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_scrap:delete") |
| | | @DeleteMapping(value = "/delete") |
| | | public Result<String> delete(@RequestParam(name="id",required=true) String id) { |
| | | cuttingScrapService.removeById(id); |
| | | return Result.OK("删除成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具报废-批量删除") |
| | | @ApiOperation(value="刀具报废-批量删除", notes="刀具报废-批量删除") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_scrap:deleteBatch") |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) { |
| | | this.cuttingScrapService.removeByIds(Arrays.asList(ids.split(","))); |
| | | return Result.OK("批量删除成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id查询 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "刀具报废-通过id查询") |
| | | @ApiOperation(value="刀具报废-通过id查询", notes="刀具报废-通过id查询") |
| | | @GetMapping(value = "/queryById") |
| | | public Result<CuttingScrap> queryById(@RequestParam(name="id",required=true) String id) { |
| | | CuttingScrap cuttingScrap = cuttingScrapService.getById(id); |
| | | if(cuttingScrap==null) { |
| | | return Result.error("未找到对应数据"); |
| | | } |
| | | return Result.OK(cuttingScrap); |
| | | } |
| | | @Autowired |
| | | private ICuttingScrapDetailService cuttingScrapDetailService; |
| | | |
| | | @Autowired |
| | | private ICuttingInventoryService cuttingInventoryService; |
| | | |
| | | /** |
| | | * 导出excel |
| | | * |
| | | * @param request |
| | | * @param cuttingScrap |
| | | */ |
| | | * 分页列表查询 |
| | | * |
| | | * @param cuttingScrap |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "刀具报废-分页列表查询") |
| | | @ApiOperation(value = "刀具报废-分页列表查询", notes = "刀具报废-分页列表查询") |
| | | @GetMapping(value = "/list") |
| | | public Result<IPage<CuttingScrap>> queryPageList(CuttingScrap cuttingScrap, |
| | | @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | QueryWrapper<CuttingScrap> queryWrapper = QueryGenerator.initQueryWrapper(cuttingScrap, req.getParameterMap()); |
| | | Page<CuttingScrap> page = new Page<CuttingScrap>(pageNo, pageSize); |
| | | IPage<CuttingScrap> pageList = cuttingScrapService.page(page, queryWrapper); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param jSONObject |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具报废-添加") |
| | | @ApiOperation(value = "刀具报废-添加", notes = "刀具报废-添加") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_scrap:add") |
| | | @PostMapping(value = "/add") |
| | | public Result<String> add(@RequestBody JSONObject jSONObject) { |
| | | CuttingScrap cuttingScrap = jSONObject.toJavaObject(CuttingScrap.class); |
| | | cuttingScrap.setOrderStatus("1"); |
| | | cuttingScrapService.saveOrUpdate(cuttingScrap); |
| | | //删除原关联数据 |
| | | List<CuttingScrapDetail> cuttingScrapDetailList = cuttingScrapDetailService.lambdaQuery().eq(CuttingScrapDetail::getOrderId, cuttingScrap.getId()).list(); |
| | | cuttingScrapDetailService.removeBatchByIds(cuttingScrapDetailList); |
| | | //添加新关联数据 |
| | | JSONArray jsonArray = jSONObject.getJSONArray("detailData"); |
| | | List<CuttingScrapDetail> list = jsonArray.toJavaList(CuttingScrapDetail.class); |
| | | |
| | | for (CuttingScrapDetail temp : list) { |
| | | temp.setOrderId(cuttingScrap.getId()); |
| | | cuttingScrapDetailService.save(temp); |
| | | } |
| | | |
| | | // 更新库存刀具状态为"已出库" |
| | | if (!list.isEmpty()) { |
| | | // 收集所有需要更新状态的库存ID |
| | | List<String> inventoryIds = list.stream() |
| | | .map(CuttingScrapDetail::getInventoryId) // 假设CuttingScrapDetail中有inventoryId字段 |
| | | .filter(id -> id != null && !id.isEmpty()) |
| | | .collect(Collectors.toList()); |
| | | |
| | | if (!inventoryIds.isEmpty()) { |
| | | // 更新库存状态为"已出库" |
| | | cuttingInventoryService.updateStatus(inventoryIds, "待报废"); |
| | | } |
| | | } |
| | | return Result.OK("添加成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 编辑 |
| | | * |
| | | * @param cuttingScrap |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具报废-编辑") |
| | | @ApiOperation(value = "刀具报废-编辑", notes = "刀具报废-编辑") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_scrap:edit") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) |
| | | public Result<String> edit(@RequestBody CuttingScrap cuttingScrap) { |
| | | cuttingScrapService.updateById(cuttingScrap); |
| | | return Result.OK("编辑成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id删除 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具报废-通过id删除") |
| | | @ApiOperation(value = "刀具报废-通过id删除", notes = "刀具报废-通过id删除") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_scrap:delete") |
| | | @DeleteMapping(value = "/delete") |
| | | public Result<String> delete(@RequestParam(name = "id", required = true) String id) { |
| | | cuttingScrapService.removeById(id); |
| | | return Result.OK("删除成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具报废-批量删除") |
| | | @ApiOperation(value = "刀具报废-批量删除", notes = "刀具报废-批量删除") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_scrap:deleteBatch") |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { |
| | | this.cuttingScrapService.removeByIds(Arrays.asList(ids.split(","))); |
| | | return Result.OK("批量删除成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id查询 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "刀具报废-通过id查询") |
| | | @ApiOperation(value = "刀具报废-通过id查询", notes = "刀具报废-通过id查询") |
| | | @GetMapping(value = "/queryById") |
| | | public Result<CuttingScrap> queryById(@RequestParam(name = "id", required = true) String id) { |
| | | CuttingScrap cuttingScrap = cuttingScrapService.getById(id); |
| | | if (cuttingScrap == null) { |
| | | return Result.error("未找到对应数据"); |
| | | } |
| | | return Result.OK(cuttingScrap); |
| | | } |
| | | |
| | | /** |
| | | * 导出excel |
| | | * |
| | | * @param request |
| | | * @param cuttingScrap |
| | | */ |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_scrap:exportXls") |
| | | @RequestMapping(value = "/exportXls") |
| | | public ModelAndView exportXls(HttpServletRequest request, CuttingScrap cuttingScrap) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 通过excel导入数据 |
| | | * |
| | | * @param request |
| | | * @param response |
| | | * @return |
| | | */ |
| | | * 通过excel导入数据 |
| | | * |
| | | * @param request |
| | | * @param response |
| | | * @return |
| | | */ |
| | | //@RequiresPermissions("cms_cutting_scrap:importExcel") |
| | | @RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
| | | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | return super.importExcel(request, response, CuttingScrap.class); |
| | | } |
| | | |
| | | /** |
| | | * 根据报废id查询报废明细 |
| | | * |
| | | * @param orderId |
| | | * @return |
| | | */ |
| | | @GetMapping("/detailList") |
| | | public Result<?> detailList(@RequestParam("orderId") String orderId) { |
| | | List<Map<String, Object>> list = cuttingScrapDetailService.detailList(orderId); |
| | | return Result.ok(list); |
| | | } |
| | | /** |
| | | * 根据报废id查询报废明细 |
| | | * |
| | | * @param orderId |
| | | * @return |
| | | */ |
| | | @GetMapping("/detailList") |
| | | public Result<?> detailList(@RequestParam("orderId") String orderId) { |
| | | List<Map<String, Object>> list = cuttingScrapDetailService.detailList(orderId); |
| | | return Result.ok(list); |
| | | } |
| | | |
| | | /** |
| | | * 选择报废刀具的列表 |
| | | */ |
| | | @GetMapping("/getInventoryToolList") |
| | | public Result<?> getInventoryToolList(@RequestParam("pageNo") Integer pageNo, |
| | | @RequestParam("pageSize") Integer pageSize, |
| | | @RequestParam Map<String, Object> params) { |
| | | IPage<Map<String, Object>> inventoryTooList = cuttingScrapService.getInventoryToolList(pageNo, pageSize, params); |
| | | return Result.ok(inventoryTooList); |
| | | } |
| | | |
| | | } |