| | |
| | | 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/cuttingReceive") |
| | | @Slf4j |
| | | public class CuttingReceiveController extends JeecgController<CuttingReceive, ICuttingReceiveService> { |
| | | @Autowired |
| | | private ICuttingReceiveService cuttingReceiveService; |
| | | @Autowired |
| | | private ICuttingReceiveService cuttingReceiveService; |
| | | |
| | | @Autowired |
| | | private ICuttingReceiveDetailService cuttingReceiveDetailService; |
| | | |
| | | /** |
| | | * 分页列表查询 |
| | | * |
| | | * @param cuttingReceive |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "刀具领用单-分页列表查询") |
| | | @ApiOperation(value="刀具领用单-分页列表查询", notes="刀具领用单-分页列表查询") |
| | | @GetMapping(value = "/list") |
| | | public Result<IPage<CuttingReceive>> queryPageList(CuttingReceive cuttingReceive, |
| | | @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, |
| | | @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | QueryWrapper<CuttingReceive> queryWrapper = QueryGenerator.initQueryWrapper(cuttingReceive, req.getParameterMap()); |
| | | Page<CuttingReceive> page = new Page<CuttingReceive>(pageNo, pageSize); |
| | | IPage<CuttingReceive> pageList = cuttingReceiveService.page(page, queryWrapper); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param jSONObject |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具领用单-添加") |
| | | @ApiOperation(value="刀具领用单-添加", notes="刀具领用单-添加") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_receive:add") |
| | | @PostMapping(value = "/add") |
| | | public Result<String> add(@RequestBody JSONObject jSONObject) { |
| | | CuttingReceive cuttingReceive = jSONObject.toJavaObject(CuttingReceive.class); |
| | | cuttingReceive.setOrderStatus("1"); |
| | | cuttingReceiveService.saveOrUpdate(cuttingReceive); |
| | | //删除原关联数据 |
| | | List<CuttingReceiveDetail> cuttingReceiveDetailList = cuttingReceiveDetailService.lambdaQuery().eq(CuttingReceiveDetail::getOrderId,cuttingReceive.getId()).list(); |
| | | cuttingReceiveDetailService.removeBatchByIds(cuttingReceiveDetailList); |
| | | //添加新关联数据 |
| | | JSONArray jsonArray = jSONObject.getJSONArray("detailData"); |
| | | List<CuttingReceiveDetail> list = jsonArray.toJavaList(CuttingReceiveDetail.class); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CuttingReceiveDetail temp = list.get(i); |
| | | temp.setOrderId(cuttingReceive.getId()); |
| | | cuttingReceiveDetailService.save(temp); |
| | | } |
| | | return Result.OK("添加成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 编辑 |
| | | * |
| | | * @param cuttingReceive |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具领用单-编辑") |
| | | @ApiOperation(value="刀具领用单-编辑", notes="刀具领用单-编辑") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_receive:edit") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) |
| | | public Result<String> edit(@RequestBody CuttingReceive cuttingReceive) { |
| | | cuttingReceiveService.updateById(cuttingReceive); |
| | | return Result.OK("编辑成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id删除 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具领用单-通过id删除") |
| | | @ApiOperation(value="刀具领用单-通过id删除", notes="刀具领用单-通过id删除") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_receive:delete") |
| | | @DeleteMapping(value = "/delete") |
| | | public Result<String> delete(@RequestParam(name="id",required=true) String id) { |
| | | cuttingReceiveService.removeById(id); |
| | | return Result.OK("删除成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具领用单-批量删除") |
| | | @ApiOperation(value="刀具领用单-批量删除", notes="刀具领用单-批量删除") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_receive:deleteBatch") |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) { |
| | | this.cuttingReceiveService.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<CuttingReceive> queryById(@RequestParam(name="id",required=true) String id) { |
| | | CuttingReceive cuttingReceive = cuttingReceiveService.getById(id); |
| | | if(cuttingReceive==null) { |
| | | return Result.error("未找到对应数据"); |
| | | } |
| | | return Result.OK(cuttingReceive); |
| | | } |
| | | @Autowired |
| | | private ICuttingReceiveDetailService cuttingReceiveDetailService; |
| | | |
| | | /** |
| | | * 导出excel |
| | | * |
| | | * @param request |
| | | * @param cuttingReceive |
| | | */ |
| | | * 分页列表查询 |
| | | * |
| | | * @param cuttingReceive |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "刀具领用单-分页列表查询") |
| | | @ApiOperation(value = "刀具领用单-分页列表查询", notes = "刀具领用单-分页列表查询") |
| | | @GetMapping(value = "/list") |
| | | public Result<IPage<CuttingReceive>> queryPageList(CuttingReceive cuttingReceive, |
| | | @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | QueryWrapper<CuttingReceive> queryWrapper = QueryGenerator.initQueryWrapper(cuttingReceive, req.getParameterMap()); |
| | | Page<CuttingReceive> page = new Page<CuttingReceive>(pageNo, pageSize); |
| | | IPage<CuttingReceive> pageList = cuttingReceiveService.page(page, queryWrapper); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param jSONObject |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具领用单-添加") |
| | | @ApiOperation(value = "刀具领用单-添加", notes = "刀具领用单-添加") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_receive:add") |
| | | @PostMapping(value = "/add") |
| | | public Result<String> add(@RequestBody JSONObject jSONObject) { |
| | | CuttingReceive cuttingReceive = jSONObject.toJavaObject(CuttingReceive.class); |
| | | cuttingReceive.setOrderStatus("1"); |
| | | cuttingReceiveService.saveOrUpdate(cuttingReceive); |
| | | //删除原关联数据 |
| | | List<CuttingReceiveDetail> cuttingReceiveDetailList = cuttingReceiveDetailService.lambdaQuery().eq(CuttingReceiveDetail::getOrderId, cuttingReceive.getId()).list(); |
| | | cuttingReceiveDetailService.removeBatchByIds(cuttingReceiveDetailList); |
| | | //添加新关联数据 |
| | | JSONArray jsonArray = jSONObject.getJSONArray("detailData"); |
| | | List<CuttingReceiveDetail> list = jsonArray.toJavaList(CuttingReceiveDetail.class); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CuttingReceiveDetail temp = list.get(i); |
| | | temp.setOrderId(cuttingReceive.getId()); |
| | | cuttingReceiveDetailService.save(temp); |
| | | } |
| | | return Result.OK("添加成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 编辑 |
| | | * |
| | | * @param cuttingReceive |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具领用单-编辑") |
| | | @ApiOperation(value = "刀具领用单-编辑", notes = "刀具领用单-编辑") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_receive:edit") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) |
| | | public Result<String> edit(@RequestBody CuttingReceive cuttingReceive) { |
| | | cuttingReceiveService.updateById(cuttingReceive); |
| | | return Result.OK("编辑成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id删除 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具领用单-通过id删除") |
| | | @ApiOperation(value = "刀具领用单-通过id删除", notes = "刀具领用单-通过id删除") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_receive:delete") |
| | | @DeleteMapping(value = "/delete") |
| | | public Result<String> delete(@RequestParam(name = "id", required = true) String id) { |
| | | cuttingReceiveService.removeById(id); |
| | | return Result.OK("删除成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具领用单-批量删除") |
| | | @ApiOperation(value = "刀具领用单-批量删除", notes = "刀具领用单-批量删除") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_receive:deleteBatch") |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { |
| | | this.cuttingReceiveService.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<CuttingReceive> queryById(@RequestParam(name = "id", required = true) String id) { |
| | | CuttingReceive cuttingReceive = cuttingReceiveService.getById(id); |
| | | if (cuttingReceive == null) { |
| | | return Result.error("未找到对应数据"); |
| | | } |
| | | return Result.OK(cuttingReceive); |
| | | } |
| | | |
| | | /** |
| | | * 导出excel |
| | | * |
| | | * @param request |
| | | * @param cuttingReceive |
| | | */ |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_receive:exportXls") |
| | | @RequestMapping(value = "/exportXls") |
| | | public ModelAndView exportXls(HttpServletRequest request, CuttingReceive cuttingReceive) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 通过excel导入数据 |
| | | * |
| | | * @param request |
| | | * @param response |
| | | * @return |
| | | */ |
| | | * 通过excel导入数据 |
| | | * |
| | | * @param request |
| | | * @param response |
| | | * @return |
| | | */ |
| | | //@RequiresPermissions("cms_cutting_receive:importExcel") |
| | | @RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
| | | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | return super.importExcel(request, response, CuttingReceive.class); |
| | | } |
| | | |
| | | /** |
| | | * 根据领用id查询领用明细 |
| | | * |
| | | * @param orderId |
| | | * @return |
| | | */ |
| | | @GetMapping("/detailList") |
| | | public Result<?> detailList(@RequestParam("orderId") String orderId) { |
| | | List<Map<String, Object>> list = cuttingReceiveDetailService.detailList(orderId); |
| | | return Result.ok(list); |
| | | } |
| | | /** |
| | | * 根据领用id查询领用明细 |
| | | * |
| | | * @param orderId |
| | | * @return |
| | | */ |
| | | @GetMapping("/detailList") |
| | | public Result<?> detailList(@RequestParam("orderId") String orderId) { |
| | | List<Map<String, Object>> list = cuttingReceiveDetailService.detailList(orderId); |
| | | return Result.ok(list); |
| | | } |
| | | |
| | | } |