| | |
| | | Integer SHIFT_TYPE_1 = 1; |
| | | Integer SHIFT_TYPE_2 = 2; |
| | | |
| | | /** |
| | | * SAP请求成功编码 |
| | | */ |
| | | String SAP_SUCCESS_CODE = "S"; |
| | | |
| | | } |
| | |
| | | temp.setOrderId(cuttingReceive.getId()); |
| | | cuttingReceiveDetailService.save(temp); |
| | | } |
| | | // 更新库存刀具状态为"已出库" |
| | | // 更新库存刀具状态为"待出库" |
| | | if (!list.isEmpty()) { |
| | | // 收集所有需要更新状态的库存ID |
| | | List<String> inventoryIds = list.stream() |
| | |
| | | .collect(Collectors.toList()); |
| | | |
| | | if (!inventoryIds.isEmpty()) { |
| | | // 更新库存状态为"已出库" |
| | | // 更新库存状态为"待出库" |
| | | cuttingInventoryService.updateStatus(inventoryIds, "待出库"); |
| | | } |
| | | } |
| | |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_receive:delete") |
| | | @DeleteMapping(value = "/delete") |
| | | public Result<String> delete(@RequestParam(name = "id") String id) { |
| | | // 先查询出领用单明细,获取相关的库存ID |
| | | List<CuttingReceiveDetail> detailList = cuttingReceiveDetailService.lambdaQuery() |
| | | .eq(CuttingReceiveDetail::getOrderId, id) |
| | | .list(); |
| | | // 删除领用单主表和明细表数据 |
| | | cuttingReceiveService.removeById(id); |
| | | cuttingReceiveDetailService.removeById(id); |
| | | |
| | | // 获取库存ID列表 |
| | | List<String> inventoryIds = detailList.stream() |
| | | .map(CuttingReceiveDetail::getInventoryId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 将相关刀具库存状态改回之前的状态 |
| | | if (!inventoryIds.isEmpty()) { |
| | | cuttingInventoryService.restoreStatus(inventoryIds); |
| | | } |
| | | |
| | | return Result.OK("删除成功!"); |
| | | } |
| | | |
| | |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | public Result<String> deleteBatch(@RequestParam(name = "ids") String ids) { |
| | | this.cuttingReceiveService.removeByIds(Arrays.asList(ids.split(","))); |
| | | //FIXME: 批量删除时,库存状态未恢复。也需要批量恢复库存状态。 |
| | | return Result.OK("批量删除成功!"); |
| | | } |
| | | |
| | |
| | | return cuttingReceiveService.submit(orderId); |
| | | } |
| | | |
| | | //TODO: @GetMapping("/handleBack") |
| | | @GetMapping("/handleBack") |
| | | public Result<?> handleBack(@RequestParam("orderId") String orderId) { |
| | | return cuttingReceiveService.handleBack(orderId); |
| | | } |
| | | } |
| | |
| | | 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); |
| | | } |
| | | |
| | | } |
| | |
| | | import java.net.URLDecoder; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.system.query.QueryGenerator; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | |
| | | 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/cuttingScrapDetail") |
| | | @Slf4j |
| | | public class CuttingScrapDetailController extends JeecgController<CuttingScrapDetail, ICuttingScrapDetailService> { |
| | | @Autowired |
| | | private ICuttingScrapDetailService cuttingScrapDetailService; |
| | | |
| | | /** |
| | | * 分页列表查询 |
| | | * |
| | | * @param cuttingScrapDetail |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "刀具报废明细-分页列表查询") |
| | | @ApiOperation(value="刀具报废明细-分页列表查询", notes="刀具报废明细-分页列表查询") |
| | | @GetMapping(value = "/list") |
| | | public Result<IPage<CuttingScrapDetail>> queryPageList(CuttingScrapDetail cuttingScrapDetail, |
| | | @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, |
| | | @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | QueryWrapper<CuttingScrapDetail> queryWrapper = QueryGenerator.initQueryWrapper(cuttingScrapDetail, req.getParameterMap()); |
| | | Page<CuttingScrapDetail> page = new Page<CuttingScrapDetail>(pageNo, pageSize); |
| | | IPage<CuttingScrapDetail> pageList = cuttingScrapDetailService.page(page, queryWrapper); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param cuttingScrapDetail |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具报废明细-添加") |
| | | @ApiOperation(value="刀具报废明细-添加", notes="刀具报废明细-添加") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_scrap_detail:add") |
| | | @PostMapping(value = "/add") |
| | | public Result<String> add(@RequestBody CuttingScrapDetail cuttingScrapDetail) { |
| | | cuttingScrapDetailService.save(cuttingScrapDetail); |
| | | return Result.OK("添加成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 编辑 |
| | | * |
| | | * @param cuttingScrapDetail |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具报废明细-编辑") |
| | | @ApiOperation(value="刀具报废明细-编辑", notes="刀具报废明细-编辑") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_scrap_detail:edit") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) |
| | | public Result<String> edit(@RequestBody CuttingScrapDetail cuttingScrapDetail) { |
| | | cuttingScrapDetailService.updateById(cuttingScrapDetail); |
| | | return Result.OK("编辑成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id删除 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具报废明细-通过id删除") |
| | | @ApiOperation(value="刀具报废明细-通过id删除", notes="刀具报废明细-通过id删除") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_scrap_detail:delete") |
| | | @DeleteMapping(value = "/delete") |
| | | public Result<String> delete(@RequestParam(name="id",required=true) String id) { |
| | | cuttingScrapDetailService.removeById(id); |
| | | return Result.OK("删除成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具报废明细-批量删除") |
| | | @ApiOperation(value="刀具报废明细-批量删除", notes="刀具报废明细-批量删除") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_scrap_detail:deleteBatch") |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) { |
| | | this.cuttingScrapDetailService.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<CuttingScrapDetail> queryById(@RequestParam(name="id",required=true) String id) { |
| | | CuttingScrapDetail cuttingScrapDetail = cuttingScrapDetailService.getById(id); |
| | | if(cuttingScrapDetail==null) { |
| | | return Result.error("未找到对应数据"); |
| | | } |
| | | return Result.OK(cuttingScrapDetail); |
| | | } |
| | | @Autowired |
| | | private ICuttingScrapDetailService cuttingScrapDetailService; |
| | | |
| | | /** |
| | | * 导出excel |
| | | * |
| | | * @param request |
| | | * @param cuttingScrapDetail |
| | | */ |
| | | * 分页列表查询 |
| | | * |
| | | * @param cuttingScrapDetail |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "刀具报废明细-分页列表查询") |
| | | @ApiOperation(value = "刀具报废明细-分页列表查询", notes = "刀具报废明细-分页列表查询") |
| | | @GetMapping(value = "/list") |
| | | public Result<IPage<CuttingScrapDetail>> queryPageList(CuttingScrapDetail cuttingScrapDetail, |
| | | @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | QueryWrapper<CuttingScrapDetail> queryWrapper = QueryGenerator.initQueryWrapper(cuttingScrapDetail, req.getParameterMap()); |
| | | Page<CuttingScrapDetail> page = new Page<CuttingScrapDetail>(pageNo, pageSize); |
| | | IPage<CuttingScrapDetail> pageList = cuttingScrapDetailService.page(page, queryWrapper); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param cuttingScrapDetail |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具报废明细-添加") |
| | | @ApiOperation(value = "刀具报废明细-添加", notes = "刀具报废明细-添加") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_scrap_detail:add") |
| | | @PostMapping(value = "/add") |
| | | public Result<String> add(@RequestBody CuttingScrapDetail cuttingScrapDetail) { |
| | | cuttingScrapDetailService.save(cuttingScrapDetail); |
| | | return Result.OK("添加成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 编辑 |
| | | * |
| | | * @param cuttingScrapDetail |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具报废明细-编辑") |
| | | @ApiOperation(value = "刀具报废明细-编辑", notes = "刀具报废明细-编辑") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_scrap_detail:edit") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) |
| | | public Result<String> edit(@RequestBody CuttingScrapDetail cuttingScrapDetail) { |
| | | cuttingScrapDetailService.updateById(cuttingScrapDetail); |
| | | return Result.OK("编辑成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id删除 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具报废明细-通过id删除") |
| | | @ApiOperation(value = "刀具报废明细-通过id删除", notes = "刀具报废明细-通过id删除") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_scrap_detail:delete") |
| | | @DeleteMapping(value = "/delete") |
| | | public Result<String> delete(@RequestParam(name = "id", required = true) String id) { |
| | | cuttingScrapDetailService.removeById(id); |
| | | return Result.OK("删除成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "刀具报废明细-批量删除") |
| | | @ApiOperation(value = "刀具报废明细-批量删除", notes = "刀具报废明细-批量删除") |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_scrap_detail:deleteBatch") |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { |
| | | this.cuttingScrapDetailService.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<CuttingScrapDetail> queryById(@RequestParam(name = "id", required = true) String id) { |
| | | CuttingScrapDetail cuttingScrapDetail = cuttingScrapDetailService.getById(id); |
| | | if (cuttingScrapDetail == null) { |
| | | return Result.error("未找到对应数据"); |
| | | } |
| | | return Result.OK(cuttingScrapDetail); |
| | | } |
| | | |
| | | /** |
| | | * 导出excel |
| | | * |
| | | * @param request |
| | | * @param cuttingScrapDetail |
| | | */ |
| | | //@RequiresPermissions("org.jeecg.modules:cms_cutting_scrap_detail:exportXls") |
| | | @RequestMapping(value = "/exportXls") |
| | | public ModelAndView exportXls(HttpServletRequest request, CuttingScrapDetail cuttingScrapDetail) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 通过excel导入数据 |
| | | * |
| | | * @param request |
| | | * @param response |
| | | * @return |
| | | */ |
| | | * 通过excel导入数据 |
| | | * |
| | | * @param request |
| | | * @param response |
| | | * @return |
| | | */ |
| | | //@RequiresPermissions("cms_cutting_scrap_detail:importExcel") |
| | | @RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
| | | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| | |
| | | |
| | | @TableField(exist = false) // 表示这不是数据库字段 |
| | | private String cuttingBarcodeSearch; |
| | | |
| | | @TableField(exist = false) // 表示这不是数据库字段 |
| | | private String workpieceMaterial; |
| | | |
| | | @TableField(exist = false) // 表示这不是数据库字段 |
| | | private BigDecimal ratedLife; |
| | | |
| | | } |
| | |
| | | @Excel(name = "使用寿命", width = 15) |
| | | @ApiModelProperty(value = "使用寿命") |
| | | private Integer usedLife; |
| | | |
| | | } |
| | |
| | | /**报废单状态*/ |
| | | @Excel(name = "报废单状态", width = 15) |
| | | @ApiModelProperty(value = "报废单状态") |
| | | @Dict(dicCode = "order_status") |
| | | private String orderStatus; |
| | | /**申请人*/ |
| | | @Excel(name = "申请人", width = 15) |
| | |
| | | package org.jeecg.modules.cms.mapper; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.jeecg.modules.cms.entity.CuttingScrap; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | |
| | | */ |
| | | public interface CuttingScrapMapper extends BaseMapper<CuttingScrap> { |
| | | |
| | | IPage<Map<String, Object>> getInventoryToolList(IPage<Map> pageData, Map<String, Object> params); |
| | | } |
| | |
| | | t1.id, |
| | | t1.order_id orderId, |
| | | t1.cutting_id cuttingId, |
| | | t2.cutting_code cuttingCode, |
| | | t2.cutting_name cuttingName |
| | | t1.inventory_id inventoryId, |
| | | -- t1.workpiece_material workpieceMaterial, |
| | | -- t1.used_life usedLife, |
| | | t2.cutting_barcode cuttingBarcode, |
| | | t2.inventory_status inventoryStatus, |
| | | t2.current_life currentLife, |
| | | t2.id, |
| | | t3.id, |
| | | t3.cutting_code cuttingCode, |
| | | t3.cutting_name cuttingName |
| | | FROM |
| | | cms_cutting_scrap_detail t1 |
| | | LEFT JOIN cms_cutting_tool t2 ON t1.cutting_id = t2.id |
| | | LEFT JOIN cms_cutting_inventory t2 ON t1.inventory_id = t2.id |
| | | LEFT JOIN cms_cutting_tool t3 ON t1.cutting_id = t3.id |
| | | WHERE t1.order_id = #{orderId} |
| | | </select> |
| | | </mapper> |
| | |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="org.jeecg.modules.cms.mapper.CuttingScrapMapper"> |
| | | |
| | | <select id="getInventoryToolList" parameterType="Map" resultType="Map"> |
| | | SELECT |
| | | t1.cutting_id cuttingId, |
| | | t1.id, |
| | | t1.cutting_barcode cuttingBarcode, |
| | | t1.current_life currentLife, |
| | | t2.cutting_code cuttingCode, |
| | | t2.cutting_name cuttingName, |
| | | t2.cutting_category, |
| | | t3.item_text cuttingCategory |
| | | FROM cms_cutting_inventory t1 |
| | | LEFT JOIN cms_cutting_tool t2 ON t1.cutting_id = t2.id |
| | | LEFT JOIN (select * from v_sys_dict where dict_code = 'cutting_category') t3 on t3.item_value = t2.cutting_category |
| | | WHERE t1.inventory_status != '待报废' |
| | | AND t1.inventory_status != '已报废' |
| | | AND t2.del_flag = 0 |
| | | </select> |
| | | </mapper> |
| | |
| | | |
| | | IPage<Map<String, Object>> statisticsByCuttingIdAndStatus(Page<Map<String, Object>> page); |
| | | void updateStatus(List<String> ids, String status); |
| | | |
| | | void restoreStatus(List<String> ids); |
| | | } |
| | |
| | | |
| | | IPage<Map<String, Object>> getInventoryToolList(Integer pageNo, Integer pageSize, Map<String, Object> params); |
| | | Result<?> submit(String orderId); |
| | | |
| | | Result<?> handleBack(String orderId); |
| | | } |
| | |
| | | package org.jeecg.modules.cms.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.jeecg.modules.cms.entity.CuttingScrap; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @Description: 刀具报废 |
| | |
| | | */ |
| | | public interface ICuttingScrapService extends IService<CuttingScrap> { |
| | | |
| | | IPage<Map<String, Object>> getInventoryToolList(Integer pageNo, Integer pageSize, Map<String, Object> params); |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.modules.cms.entity.CuttingInventory; |
| | | import org.jeecg.modules.cms.mapper.CuttingInventoryMapper; |
| | | import org.jeecg.modules.cms.service.ICuttingInventoryService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @Description: 刀具库存 |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateStatus(List<String> ids, String status) { |
| | | if (ids != null && !ids.isEmpty() && StringUtils.isNotBlank(status)) { |
| | | // UpdateWrapper<CuttingInventory> updateWrapper = new UpdateWrapper<>(); |
| | | // updateWrapper.in("id", ids); |
| | | // updateWrapper.set("inventory_status", status); // 根据实际数据库字段名调整 |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String username = "System"; // 默认用户名 |
| | | if (user != null) { |
| | | username = oConvertUtils.getString(user.getUsername(), "System"); |
| | | } |
| | | UpdateWrapper<CuttingInventory> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.in("id", ids); |
| | | updateWrapper.set("inventory_status", status); // 根据实际数据库字段名调整 |
| | | updateWrapper.set("inventory_status", status); |
| | | updateWrapper.set("update_time", new Date()); |
| | | updateWrapper.set("update_by", username); |
| | | this.update(updateWrapper); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void restoreStatus(List<String> ids) { |
| | | if (ids != null && !ids.isEmpty()) { |
| | | // 获取当前登录用户信息 |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String username = "System"; // 默认用户名 |
| | | if (user != null) { |
| | | username = oConvertUtils.getString(user.getUsername(), "System"); |
| | | } |
| | | |
| | | // 方式1: 查询当前状态并根据状态决定恢复到哪个状态 |
| | | List<CuttingInventory> inventoryList = this.listByIds(ids); |
| | | List<String> toRestoreIds = inventoryList.stream() |
| | | .filter(inv -> "待出库".equals(inv.getInventoryStatus())) // 只处理"待出库"状态的 |
| | | .map(CuttingInventory::getId) |
| | | .collect(Collectors.toList()); |
| | | //FIXME:在报废前有多个状态,如果报废作废,刀具库存状态如何退回原来的状态。 |
| | | if (!toRestoreIds.isEmpty()) { |
| | | UpdateWrapper<CuttingInventory> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.in("id", toRestoreIds); |
| | | updateWrapper.set("inventory_status", "正常"); |
| | | updateWrapper.set("update_time", new Date()); |
| | | updateWrapper.set("update_by", username); |
| | | this.update(updateWrapper); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | import io.micrometer.core.annotation.Timed; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.modules.cms.entity.CuttingInventory; |
| | | import org.jeecg.modules.cms.entity.CuttingReceive; |
| | | import org.jeecg.modules.cms.entity.CuttingReceiveDetail; |
| | | import org.jeecg.modules.cms.entity.RatedLife; |
| | | import org.jeecg.modules.cms.mapper.CuttingReceiveMapper; |
| | | import org.jeecg.modules.cms.service.ICuttingInventoryService; |
| | | import org.jeecg.modules.cms.service.ICuttingReceiveDetailService; |
| | | import org.jeecg.modules.cms.service.ICuttingReceiveService; |
| | | import org.jeecg.modules.cms.service.IRatedLifeService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | private ICuttingInventoryService cuttingInventoryService; |
| | | @Autowired |
| | | private ICuttingReceiveDetailService cuttingReceiveDetailService; |
| | | @Autowired |
| | | private IRatedLifeService ratedLifeService; |
| | | @Override |
| | | public IPage<Map<String, Object>> getInventoryToolList(Integer pageNo, Integer pageSize, Map<String, Object> params) { |
| | | IPage<Map> pageData = new Page<Map>(pageNo, pageSize); |
| | |
| | | return Result.error("提交失败: " + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public synchronized Result<?> handleBack(String orderId) { |
| | | long startTime = System.currentTimeMillis(); |
| | | try { |
| | | // 1. 更新领用单状态为已归还 |
| | | CuttingReceive cuttingReceive = this.getById(orderId); |
| | | if (cuttingReceive == null) { |
| | | return Result.error("未找到对应的领用单"); |
| | | } |
| | | |
| | | // 检查领用单状态,只允许状态为"已领用"的领用单进行归还操作 |
| | | if (!"2".equals(cuttingReceive.getOrderStatus())) { |
| | | return Result.error("只有状态为已领用的领用单才能执行归还操作"); |
| | | } |
| | | |
| | | cuttingReceive.setOrderStatus("3"); // 设置为已归还状态 |
| | | boolean updateResult = this.updateById(cuttingReceive); |
| | | if (!updateResult) { |
| | | return Result.error("更新领用单状态失败,可能已被其他用户处理"); |
| | | } |
| | | |
| | | // 2. 获取领用明细 |
| | | List<CuttingReceiveDetail> detailList = cuttingReceiveDetailService.lambdaQuery() |
| | | .eq(CuttingReceiveDetail::getOrderId, orderId) |
| | | .list(); |
| | | |
| | | // 3. 收集所有需要更新状态的库存ID |
| | | List<String> inventoryIds = new ArrayList<>(); |
| | | for (CuttingReceiveDetail detail : detailList) { |
| | | if (detail.getInventoryId() != null && !detail.getInventoryId().isEmpty()) { |
| | | inventoryIds.add(detail.getInventoryId()); |
| | | } |
| | | } |
| | | |
| | | // 4. 批量更新库存状态为"正常" |
| | | if (!inventoryIds.isEmpty()) { |
| | | cuttingInventoryService.updateStatus(inventoryIds, "正常"); |
| | | } |
| | | // 5. 寿命扣减 |
| | | for (CuttingReceiveDetail detail : detailList) { |
| | | if (detail.getInventoryId() != null && !detail.getInventoryId().isEmpty()) { |
| | | CuttingInventory inventory = cuttingInventoryService.getById(detail.getInventoryId()); |
| | | //FIXME:ratedLife空指针 |
| | | RatedLife ratedLife = ratedLifeService.lambdaQuery() //额定寿命 |
| | | .eq(RatedLife::getCuttingId, inventory.getCuttingId()) |
| | | .eq(RatedLife::getWorkpieceMaterial, inventory.getWorkpieceMaterial()) |
| | | .one(); |
| | | |
| | | BigDecimal currentLife = inventory.getCurrentLife().divide(BigDecimal.valueOf(100),java.math.RoundingMode.HALF_UP);//当前寿命百分比 |
| | | Integer useLife = detail.getUsedLife();//使用寿命 |
| | | //计算公式: (ratedLife * currentLife - useLife) * 100 |
| | | BigDecimal newLife = ratedLife.getRatedLife() |
| | | .multiply(currentLife) |
| | | .subtract(BigDecimal.valueOf(useLife)) |
| | | .multiply(BigDecimal.valueOf(100)); |
| | | // 更新库存寿命 |
| | | inventory.setCurrentLife(newLife); |
| | | cuttingInventoryService.updateById(inventory); |
| | | } |
| | | } |
| | | long endTime = System.currentTimeMillis(); |
| | | log.info("刀具归还处理完成,耗时: {} ms", (endTime - startTime)); |
| | | return Result.ok("归还成功"); |
| | | |
| | | } catch (Exception e) { |
| | | long endTime = System.currentTimeMillis(); |
| | | log.error("处理归还失败,orderId: " + orderId + ",耗时: " + (endTime - startTime) + " ms", e); |
| | | return Result.error("归还失败: " + e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | |
| | | package org.jeecg.modules.cms.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.jeecg.modules.cms.entity.CuttingScrap; |
| | | import org.jeecg.modules.cms.mapper.CuttingScrapMapper; |
| | | import org.jeecg.modules.cms.service.ICuttingScrapService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @Description: 刀具报废 |
| | |
| | | */ |
| | | @Service |
| | | public class CuttingScrapServiceImpl extends ServiceImpl<CuttingScrapMapper, CuttingScrap> implements ICuttingScrapService { |
| | | @Override |
| | | public IPage<Map<String, Object>> getInventoryToolList(Integer pageNo, Integer pageSize, Map<String, Object> params) { |
| | | IPage<Map> pageData = new Page<Map>(pageNo, pageSize); |
| | | return super.getBaseMapper().getInventoryToolList(pageData,params); |
| | | } |
| | | |
| | | } |
| | |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | import org.jeecg.common.util.TranslateDictTextUtils; |
| | | import org.jeecg.modules.eam.constant.AssetStatusEnum; |
| | | import org.jeecg.modules.eam.constant.MaintenanceCategoryEnum; |
| | | import org.jeecg.modules.eam.constant.MaintenanceStandardStatusEnum; |
| | | import org.jeecg.modules.eam.entity.EamEquipment; |
| | |
| | | // @AutoLog(value = "设备台账-分页列表查询") |
| | | @ApiOperation(value = "设备台账-分页列表查询", notes = "设备台账-分页列表查询") |
| | | @GetMapping(value = "/list") |
| | | public Result<?> queryPageList(EamEquipmentQuery eamEquipment, |
| | | @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | public Result<?> queryPageList(EamEquipmentQuery eamEquipment, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | // QueryWrapper<EamEquipment> queryWrapper = QueryGenerator.initQueryWrapper(eamEquipment, req.getParameterMap()); |
| | | IPage<EamEquipment> page = new Page<>(pageNo, pageSize); |
| | | IPage<EamEquipment> pageList = eamEquipmentService.queryPageList(page, eamEquipment); |
| | |
| | | return Result.error("未找到对应数据"); |
| | | } |
| | | EamEquipmentExtend extend = eamEquipmentExtendService.getById(id); |
| | | if(extend != null){ |
| | | if (extend != null) { |
| | | eamEquipment.setRepairStatus(extend.getRepairStatus()); |
| | | eamEquipment.setMaintenanceStatus(extend.getMaintenanceStatus()); |
| | | } |
| | |
| | | // 获取上传文件对象 |
| | | MultipartFile file = entity.getValue(); |
| | | ImportParams params = new ImportParams(); |
| | | params.setTitleRows(0); |
| | | params.setHeadRows(1); |
| | | params.setNeedSave(true); |
| | | params.setHeadRows(1); // 跳过第1行,从第2行开始读取列名 |
| | | params.setTitleRows(1); // 第1行为标题行(可选) |
| | | params.setStartSheetIndex(0); |
| | | params.setSheetNum(1); |
| | | try { |
| | | List<EamEquipment> list = ExcelImportUtil.importExcel(file.getInputStream(), EamEquipment.class, params); |
| | | //update-begin-author:taoyan date:20190528 for:批量插入数据 |
| | | long start = System.currentTimeMillis(); |
| | | // service.saveBatch(list); |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (EamEquipment eamEquipment : list) { |
| | | //必填字段校验 |
| | | boolean isInvalid = false; |
| | | StringBuilder errorMsg = new StringBuilder(); |
| | | // 设备编号和设备名称校验 |
| | | if (StringUtils.isBlank(eamEquipment.getEquipmentCode()) || StringUtils.isBlank(eamEquipment.getEquipmentName())) { |
| | | sb.append(String.format("设备编码[%s]或设备名称[%s]为空,无法导入\n\n", eamEquipment.getEquipmentCode(), eamEquipment.getEquipmentName())); |
| | | continue; |
| | | errorMsg.append(String.format("设备编码[%s]或设备名称为空,无法导入\n\n", eamEquipment.getEquipmentCode(), eamEquipment.getEquipmentName())); |
| | | isInvalid = true; |
| | | } |
| | | if (StringUtils.isBlank(eamEquipment.getEquipmentCategory())) { |
| | | sb.append(String.format("设备编码[%s]设备分类为空,无法导入\n\n", eamEquipment.getEquipmentCode())); |
| | | continue; |
| | | // 所属产线校验 |
| | | if (StringUtils.isBlank(eamEquipment.getOrgId())) { |
| | | errorMsg.append(String.format("设备编码[%s]所属产线为空,无法导入\n\n", eamEquipment.getEquipmentCode())); |
| | | isInvalid = true; |
| | | } |
| | | if (StringUtils.isBlank(eamEquipment.getOrgId()) || StringUtils.isBlank(eamEquipment.getEquipmentManager())) { |
| | | sb.append(String.format("设备编码[%s]使用车间或设备管理员为空,无法导入\n\n", eamEquipment.getEquipmentCode())); |
| | | continue; |
| | | } |
| | | // if (eamEquipment.getAcceptanceCheckDate() == null) { |
| | | // sb.append(String.format("设备编码[%s]验收为空,无法导入\n\r", eamEquipment.getEquipmentCode())); |
| | | // continue; |
| | | // } |
| | | // if (StringUtils.isBlank(eamEquipment.getTechnologyStatus())) { |
| | | // sb.append(String.format("设备编码[%s]技术状态为空,无法导入\n\r", eamEquipment.getEquipmentCode())); |
| | | // continue; |
| | | // } |
| | | // 设备编码唯一性校验 |
| | | EamEquipment one = eamEquipmentService.getOne(new LambdaQueryWrapper<EamEquipment>().eq(EamEquipment::getEquipmentCode, eamEquipment.getEquipmentCode()).eq(EamEquipment::getDelFlag, CommonConstant.DEL_FLAG_0)); |
| | | if (one != null) { |
| | | sb.append(String.format("设备编码[%s]已存在,无法重复导入\n\r", eamEquipment.getEquipmentCode())); |
| | | errorMsg.append(String.format("设备编码[%s]已存在,无法重复导入\n\r", eamEquipment.getEquipmentCode())); |
| | | isInvalid = true; |
| | | } |
| | | // 校验不通过,记录错误并跳过导入 |
| | | if (isInvalid) { |
| | | sb.append(errorMsg); |
| | | continue; |
| | | } |
| | | // 校验通过,执行导入 |
| | | if (!CommonConstant.DEFAULT_1.equals(eamEquipment.getMdcFlag())) { |
| | | eamEquipment.setMdcFlag(CommonConstant.DEFAULT_0); |
| | | } |
| | | EamEquipment equipment = eamEquipmentService.saveEquipment(eamEquipment); |
| | | if (equipment == null) { |
| | | //保存失败,跳过本次循环 |
| | | sb.append(String.format("设备编码[%s]保存失败,无法导入\n\r", eamEquipment.getEquipmentCode())); |
| | | continue; |
| | | } |
| | | //调用mdcEquipment插入MDC设备 |
| | | // if (CommonConstant.DEFAULT_1.equals(eamEquipment.getMdcFlag())) { |
| | | // //插入MDC设备 |
| | | // MdcEquipment mdcEquipment = new MdcEquipment(); |
| | | // mdcEquipment.setEquipmentId(eamEquipment.getEquipmentCode()); |
| | | // mdcEquipment.setEquipmentType(eamEquipment.getDeviceType()); |
| | | // mdcEquipment.setEquipmentName(eamEquipment.getEquipmentName()); |
| | | // mdcEquipmentService.addNewEquipmentFromEam(mdcEquipment, eamEquipment.getOrgId()); |
| | | // } |
| | | // MDC设备相关逻辑(若有需要) |
| | | // if (CommonConstant.DEFAULT_1.equals(eamEquipment.getMdcFlag())) { |
| | | // MdcEquipment mdcEquipment = new MdcEquipment(); |
| | | // mdcEquipment.setEquipmentId(eamEquipment.getEquipmentCode()); |
| | | // mdcEquipment.setEquipmentType(eamEquipment.getDeviceType()); |
| | | // mdcEquipment.setEquipmentName(eamEquipment.getEquipmentName()); |
| | | // mdcEquipmentService.addNewEquipmentFromEam(mdcEquipment, eamEquipment.getOrgId()); |
| | | // } |
| | | } |
| | | //400条 saveBatch消耗时间1592毫秒 循环插入消耗时间1947毫秒 |
| | | //1200条 saveBatch消耗时间3687毫秒 循环插入消耗时间5212毫秒 |
| | |
| | | } |
| | | return Result.ok("文件导入成功!数据行数:" + list.size()); |
| | | } catch (Exception e) { |
| | | //update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示 |
| | | |
| | | String msg = e.getMessage(); |
| | | log.error(msg, e); |
| | | if (msg != null && msg.indexOf("Duplicate entry") >= 0) { |
| | |
| | | } else { |
| | | return Result.error("文件导入失败:" + e.getMessage()); |
| | | } |
| | | //update-end-author:taoyan date:20211124 for: 导入数据重复增加提示 |
| | | |
| | | } finally { |
| | | try { |
| | | file.getInputStream().close(); |
| | |
| | | return Result.error("文件导入失败!"); |
| | | } |
| | | |
| | | // @ApiOperation(value = "设备表-通过车间ids获取设备树", notes = "设备表-通过车间ids获取设备树") |
| | | // @GetMapping(value = "/loadTreeListByProductionIds") |
| | | // public Result<List<EamEquipmentTree>> loadTreeListByProductionIds(@RequestParam(name = "ids", required = true) String ids) { |
| | | // Result<List<EamEquipmentTree>> result = new Result<>(); |
| | | // try { |
| | | // List<EamEquipmentTree> mdcEquipmentTreeList = eamEquipmentService.loadTreeListByProductionIds(ids); |
| | | // result.setSuccess(true); |
| | | // result.setResult(mdcEquipmentTreeList); |
| | | // } catch (Exception e) { |
| | | // log.error(e.getMessage(), e); |
| | | // } |
| | | // return result; |
| | | // } |
| | | |
| | | /** |
| | | * 检索设备 |
| | | * @param keyword 查询关键词 设备编号,设备名称模糊匹配 |
| | | * |
| | | * @param keyword 查询关键词 设备编号,设备名称模糊匹配 |
| | | * @param pageSize 一次返回多少记录 |
| | | * @param id 设备主键 |
| | | * @param id 设备主键 |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "设备表-异步加载设备列表", notes = "设备表-异步加载设备列表") |
| | | @GetMapping(value = "/asyncLoadEquipment") |
| | | public Result<?> asyncLoadEquipment(@RequestParam(name="keyword",required = false) String keyword, |
| | | @RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize, |
| | | @RequestParam(name="id",required = false) String id) { |
| | | public Result<?> asyncLoadEquipment(@RequestParam(name = "keyword", required = false) String keyword, @RequestParam(value = "pageSize", required = false, defaultValue = "20") Integer pageSize, @RequestParam(name = "id", required = false) String id) { |
| | | List<EquipmentSearchResult> resultList = eamEquipmentService.asyncLoadEquipment(keyword, pageSize, id); |
| | | return Result.ok(resultList); |
| | | } |
| | |
| | | if (workOrder == null) { |
| | | return Result.error("工单不存在!"); |
| | | } |
| | | List<Map<String, Object>> equipmentMapList = eamEquipmentService.list(new LambdaQueryWrapper<EamEquipment>() |
| | | .eq(EamEquipment::getOrgId, workOrder.getFactoryId()) |
| | | .eq(EamEquipment::getDelFlag, CommonConstant.DEL_FLAG_0) |
| | | .apply("NOT EXISTS (SELECT 1 FROM eam_inspection_order t WHERE t.equipment_id = eam_equipment.id AND t.work_order_id = {0})", orderId) |
| | | .apply("EXISTS (SELECT 1 FROM eam_maintenance_standard t WHERE t.equipment_id = eam_equipment.id AND t.del_flag = {0} " + |
| | | "AND t.standard_status = {1} AND t.maintenance_category = {2})", |
| | | CommonConstant.DEL_FLAG_0, MaintenanceStandardStatusEnum.NORMAL.name(), MaintenanceCategoryEnum.POINT_INSPECTION.name())) |
| | | .stream().map(e -> (Map<String, Object>) new HashMap<String, Object>() {{ |
| | | put("value", e.getId()); |
| | | put("label", e.getEquipmentCode() + "[" + e.getEquipmentName() + "]"); |
| | | put("text", e.getEquipmentCode() + "[" + e.getEquipmentName() + "]"); |
| | | }}).collect(Collectors.toList()); |
| | | List<Map<String, Object>> equipmentMapList = eamEquipmentService.list(new LambdaQueryWrapper<EamEquipment>().eq(EamEquipment::getOrgId, workOrder.getFactoryId()).eq(EamEquipment::getDelFlag, CommonConstant.DEL_FLAG_0).apply("NOT EXISTS (SELECT 1 FROM eam_inspection_order t WHERE t.equipment_id = eam_equipment.id AND t.work_order_id = {0})", orderId).apply("EXISTS (SELECT 1 FROM eam_maintenance_standard t WHERE t.equipment_id = eam_equipment.id AND t.del_flag = {0} " + "AND t.standard_status = {1} AND t.maintenance_category = {2})", CommonConstant.DEL_FLAG_0, MaintenanceStandardStatusEnum.NORMAL.name(), MaintenanceCategoryEnum.POINT_INSPECTION.name())).stream().map(e -> (Map<String, Object>) new HashMap<String, Object>() {{ |
| | | put("value", e.getId()); |
| | | put("label", e.getEquipmentCode() + "[" + e.getEquipmentName() + "]"); |
| | | put("text", e.getEquipmentCode() + "[" + e.getEquipmentName() + "]"); |
| | | }}).collect(Collectors.toList()); |
| | | return Result.ok(equipmentMapList); |
| | | } |
| | | |
| | |
| | | if (workOrder == null) { |
| | | return Result.error("工单不存在!"); |
| | | } |
| | | List<Map<String, Object>> equipmentMapList = eamEquipmentService.list(new LambdaQueryWrapper<EamEquipment>() |
| | | .eq(EamEquipment::getOrgId, workOrder.getFactoryId()) |
| | | .eq(EamEquipment::getDelFlag, CommonConstant.DEL_FLAG_0) |
| | | .apply("EXISTS (SELECT 1 FROM eam_equipment_process_parameters t WHERE t.equipment_id = eam_equipment.id)") |
| | | .apply("NOT EXISTS (SELECT 1 FROM eam_process_check t WHERE t.equipment_id = eam_equipment.id AND t.work_order_id = {0})", orderId)) |
| | | .stream().map(e -> (Map<String, Object>) new HashMap<String, Object>() {{ |
| | | put("value", e.getId()); |
| | | put("label", e.getEquipmentCode() + "[" + e.getEquipmentName() + "]"); |
| | | put("text", e.getEquipmentCode() + "[" + e.getEquipmentName() + "]"); |
| | | }}).collect(Collectors.toList()); |
| | | List<Map<String, Object>> equipmentMapList = eamEquipmentService.list(new LambdaQueryWrapper<EamEquipment>().eq(EamEquipment::getOrgId, workOrder.getFactoryId()).eq(EamEquipment::getDelFlag, CommonConstant.DEL_FLAG_0).apply("EXISTS (SELECT 1 FROM eam_equipment_process_parameters t WHERE t.equipment_id = eam_equipment.id)").apply("NOT EXISTS (SELECT 1 FROM eam_process_check t WHERE t.equipment_id = eam_equipment.id AND t.work_order_id = {0})", orderId)).stream().map(e -> (Map<String, Object>) new HashMap<String, Object>() {{ |
| | | put("value", e.getId()); |
| | | put("label", e.getEquipmentCode() + "[" + e.getEquipmentName() + "]"); |
| | | put("text", e.getEquipmentCode() + "[" + e.getEquipmentName() + "]"); |
| | | }}).collect(Collectors.toList()); |
| | | return Result.ok(equipmentMapList); |
| | | } |
| | | } |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.poi.ss.usermodel.*; |
| | | import org.apache.poi.xssf.usermodel.*; |
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.aspect.annotation.AutoLog; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | |
| | | import org.jeecg.modules.eam.entity.EamMaintenanceStandardDetail; |
| | | import org.jeecg.modules.eam.request.EamMaintenanceStandardRequest; |
| | | import org.jeecg.modules.eam.service.IEamEquipmentService; |
| | | import org.jeecg.modules.eam.service.IEamMaintenanceOrderDetailService; |
| | | import org.jeecg.modules.eam.service.IEamMaintenanceStandardDetailService; |
| | | import org.jeecg.modules.eam.service.IEamMaintenanceStandardService; |
| | | import org.jeecg.modules.eam.vo.MaintenanceStandardDetailVo; |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/inspectionImportExcel", method = RequestMethod.POST) |
| | | public Result<?> inspectionImportExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | public Result<?> inspectionImportExcel(HttpServletRequest request, HttpServletResponse response) throws IOException { |
| | | MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; |
| | | Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); |
| | | |
| | | for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { |
| | | // 获取上传文件对象 |
| | | MultipartFile file = entity.getValue(); |
| | | byte[] bytes = file.getBytes(); |
| | | ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
| | | |
| | | ImportParams params = new ImportParams(); |
| | | params.setTitleRows(2); |
| | | params.setHeadRows(1); |
| | | params.setSheetNum(1); |
| | | params.setLastOfInvalidRow(23); |
| | | params.setTitleRows(2); // 跳过前2行标题 |
| | | params.setHeadRows(2); // 第3行是表头 |
| | | params.setSheetNum(1); // 读取第一个工作表 |
| | | params.setNeedSave(true); |
| | | |
| | | EamMaintenanceStandardRequest standardRequest = new EamMaintenanceStandardRequest(); |
| | | try { |
| | | //读取设备编号,图片等 |
| | | readExcel(file, standardRequest); |
| | | log.info("读取到的设备编码: {}", standardRequest.getEquipmentCode()); |
| | | |
| | | EamEquipment equipment = eamEquipmentService.selectByEquipmentCode(standardRequest.getEquipmentCode()); |
| | | if(equipment == null) { |
| | | log.error("设备不存在:{}", standardRequest.getEquipmentCode()); |
| | | continue; |
| | | } |
| | | standardRequest.setStandardName(standardRequest.getEquipmentName() + "点检标准"); |
| | | |
| | | standardRequest.setStandardName(equipment.getEquipmentName() + "点检标准"); |
| | | standardRequest.setMaintenanceCategory(MaintenanceCategoryEnum.POINT_INSPECTION.name()); |
| | | standardRequest.setEquipmentId(equipment.getId()); |
| | | |
| | | //读取保养明细内容 |
| | | List<MaintenanceStandardImport> list = ExcelImportUtil.importExcel(file.getInputStream(), MaintenanceStandardImport.class, params); |
| | | // 读取保养明细内容前添加调试信息 |
| | | log.info("Excel导入参数: titleRows={}, headRows={}, lastOfInvalidRow={}", |
| | | params.getTitleRows(), params.getHeadRows(), params.getLastOfInvalidRow()); |
| | | |
| | | List<MaintenanceStandardImport> list = ExcelImportUtil.importExcel(file.getInputStream(), MaintenanceStandardImport.class, params); |
| | | log.info("实际读取到的明细数量: {}", list.size()); |
| | | //明细项 |
| | | List<EamMaintenanceStandardDetail> tableList = list.stream().map(EamMaintenanceStandardDetail::new).collect(Collectors.toList()); |
| | | List<EamMaintenanceStandardDetail> tableList = new ArrayList<>(); |
| | | for(MaintenanceStandardImport maintenanceStandardImport : list) { |
| | | try { |
| | | Integer.valueOf(maintenanceStandardImport.getItemCode()); |
| | | } catch (NumberFormatException e) { |
| | | break; |
| | | } |
| | | tableList.add(new EamMaintenanceStandardDetail(maintenanceStandardImport)); |
| | | } |
| | | |
| | | standardRequest.setTableDetailList(tableList); |
| | | log.info("转换后的明细数量: {}", tableList.size()); |
| | | |
| | | String codeSeq = businessCodeRuleService.generateBusinessCodeSeq(BusinessCodeConst.MAINTENANCE_STANDARD_CODE_RULE); |
| | | standardRequest.setStandardCode(codeSeq); |
| | | boolean b = eamMaintenanceStandardService.addMaintenanceStandard(standardRequest); |
| | |
| | | log.error("保存失败! {}", standardRequest.getEquipmentCode()); |
| | | } |
| | | } catch (Exception e) { |
| | | //update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示 |
| | | String msg = e.getMessage(); |
| | | log.error("文件 {} 处理异常: {}", file.getOriginalFilename(), msg, e); |
| | | //update-end-author:taoyan date:20211124 for: 导入数据重复增加提示 |
| | | } finally { |
| | | try { |
| | | file.getInputStream().close(); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 通过excel导入数据 |
| | | * 季保通过excel导入数据 |
| | | * |
| | | * @param request |
| | | * @param response |
| | |
| | | params.setTitleRows(2); |
| | | params.setHeadRows(1); |
| | | params.setSheetNum(1); |
| | | params.setLastOfInvalidRow(23); |
| | | params.setNeedSave(true); |
| | | EamMaintenanceStandardRequest standardRequest = new EamMaintenanceStandardRequest(); |
| | | try { |
| | |
| | | continue; |
| | | } |
| | | standardRequest.setStandardName(standardRequest.getEquipmentName() + "保养标准"); |
| | | |
| | | standardRequest.setMaintenanceCategory(MaintenanceCategoryEnum.QUARTERLY_MAINTENANCE.name()); |
| | | standardRequest.setEquipmentId(equipment.getId()); |
| | | //读取保养明细内容 |
| | |
| | | return Result.ok("文件导入完成!"); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 年保通过excel导入数据 |
| | | * |
| | | * @param request |
| | | * @param response |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/annualMaintenanceImportExcel", method = RequestMethod.POST) |
| | | public Result<?> annualMaintenanceImportExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; |
| | | Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); |
| | | for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { |
| | | // 获取上传文件对象 |
| | | MultipartFile file = entity.getValue(); |
| | | |
| | | ImportParams params = new ImportParams(); |
| | | params.setTitleRows(2); |
| | | params.setHeadRows(1); |
| | | params.setSheetNum(1); |
| | | params.setLastOfInvalidRow(23); |
| | | params.setNeedSave(true); |
| | | EamMaintenanceStandardRequest standardRequest = new EamMaintenanceStandardRequest(); |
| | | try { |
| | | //读取设备编号,图片等 |
| | | readWeekExcel(file, standardRequest); |
| | | EamEquipment equipment = eamEquipmentService.selectByEquipmentCode(standardRequest.getEquipmentCode()); |
| | | if(equipment == null) { |
| | | log.error("设备不存在:{}", standardRequest.getEquipmentCode()); |
| | | continue; |
| | | } |
| | | standardRequest.setStandardName(standardRequest.getEquipmentName() + "保养标准"); |
| | | |
| | | standardRequest.setMaintenanceCategory(MaintenanceCategoryEnum.ANNUAL_MAINTENANCE.name()); |
| | | standardRequest.setEquipmentId(equipment.getId()); |
| | | //读取保养明细内容 |
| | | List<WeekMaintenanceStandardImport> list = ExcelImportUtil.importExcel(file.getInputStream(), WeekMaintenanceStandardImport.class, params); |
| | | //明细项 |
| | | List<EamMaintenanceStandardDetail> tableList = list.stream().map(EamMaintenanceStandardDetail::new).collect(Collectors.toList()); |
| | | standardRequest.setTableDetailList(tableList); |
| | | String codeSeq = businessCodeRuleService.generateBusinessCodeSeq(BusinessCodeConst.MAINTENANCE_STANDARD_CODE_RULE); |
| | | standardRequest.setStandardCode(codeSeq); |
| | | boolean b = eamMaintenanceStandardService.addMaintenanceStandard(standardRequest); |
| | | if (!b) { |
| | | log.error("保存失败! {}", standardRequest.getEquipmentCode()); |
| | | } |
| | | } catch (Exception e) { |
| | | //update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示 |
| | | String msg = e.getMessage(); |
| | | log.error("文件 {} 处理异常: {}", file.getOriginalFilename(), msg, e); |
| | | //update-end-author:taoyan date:20211124 for: 导入数据重复增加提示 |
| | | } finally { |
| | | try { |
| | | file.getInputStream().close(); |
| | | } catch (IOException e) { |
| | | log.error(e.getMessage(), e); |
| | | } |
| | | } |
| | | } |
| | | return Result.ok("文件导入完成!"); |
| | | } |
| | | /** |
| | | * 读取Excel 第一行, 第二行的信息,包括图片信息 |
| | | * @param file |
| | |
| | | //第二行读取 |
| | | Row row = sheet.getRow(1); |
| | | //设备编码 |
| | | Cell equipmentCode = row.getCell(5); |
| | | Cell equipmentCode = row.getCell(8); |
| | | Cell targetCell = row.getCell(0); |
| | | //文件编码 |
| | | String fileCodeValue = getCellValue(targetCell); |
| | |
| | | throw new JeecgBootException("Excel【" + file.getOriginalFilename() + "】第二行第一列获取到的设备编号为空!"); |
| | | } |
| | | request.setFileCode(fileCodeValue.trim()); |
| | | if(CellType.NUMERIC.equals(equipmentCode.getCellType())) { |
| | | request.setEquipmentCode(String.valueOf((int) equipmentCode.getNumericCellValue())); |
| | | }else if(CellType.STRING.equals(equipmentCode.getCellType())) { |
| | | request.setEquipmentCode(equipmentCode.getStringCellValue()); |
| | | String equipmentCodeStr = extractEquipmentCode(equipmentCode); |
| | | if (StringUtils.isBlank(equipmentCodeStr)) { |
| | | throw new JeecgBootException("Excel【 " + file.getOriginalFilename() + "】没有读取到有效的设备编号,导入失败!"); |
| | | } |
| | | request.setEquipmentCode(equipmentCodeStr); |
| | | if (StringUtils.isBlank(request.getEquipmentCode())) { |
| | | throw new JeecgBootException("Excel【 " + file.getOriginalFilename() + "】没有读取到设备编号,导入失败!"); |
| | | } |
| | |
| | | } else { |
| | | request.setInitialDate(new Date()); |
| | | } |
| | | //设备名称 |
| | | // Cell equipmentName = row.getCell(13); |
| | | // request.setEquipmentName(equipmentName.getStringCellValue()); |
| | | |
| | | |
| | | row = sheet.getRow(4); |
| | | //保养周期 |
| | | Cell period = row.getCell(7); |
| | |
| | | } |
| | | |
| | | Sheet sheet = book.getSheetAt(0); |
| | | //第一行读取 |
| | | Row row = sheet.getRow(0); |
| | | //第二行读取 |
| | | Row row = sheet.getRow(1); |
| | | //设备编码 |
| | | Cell equipmentCode = row.getCell(10); |
| | | Cell equipmentCode = row.getCell(13); |
| | | Cell targetCell = row.getCell(0); |
| | | String fileCodeValue = getCellValue(targetCell); |
| | | if (fileCodeValue == null || fileCodeValue.trim().isEmpty()) { |
| | | throw new JeecgBootException("Excel【" + file.getOriginalFilename() + "】第二行第一列获取到的设备编号为空!"); |
| | | } |
| | | request.setFileCode(fileCodeValue.trim()); |
| | | if(CellType.NUMERIC.equals(equipmentCode.getCellType())) { |
| | | request.setEquipmentCode(String.valueOf((int) equipmentCode.getNumericCellValue())); |
| | | }else if(CellType.STRING.equals(equipmentCode.getCellType())) { |
| | |
| | | throw new JeecgBootException("Excel【 " + file.getOriginalFilename() + "】没有读取到设备编号,导入失败!"); |
| | | } |
| | | //初始日期 |
| | | Cell initialDate = row.getCell(6); |
| | | Cell initialDate = row.getCell(11); |
| | | if (DateUtil.isCellDateFormatted(initialDate)) { |
| | | request.setInitialDate(initialDate.getDateCellValue()); |
| | | } else { |
| | | request.setInitialDate(new Date()); |
| | | } |
| | | //设备名称 |
| | | Cell equipmentName = row.getCell(8); |
| | | request.setEquipmentName(equipmentName.getStringCellValue()); |
| | | // Cell equipmentName = row.getCell(8); |
| | | // request.setEquipmentName(equipmentName.getStringCellValue()); |
| | | |
| | | //第二行读取 |
| | | row = sheet.getRow(1); |
| | | row = sheet.getRow(4); |
| | | //保养周期 |
| | | Cell period = row.getCell(6); |
| | | Cell period = row.getCell(7); |
| | | if (CellType.NUMERIC.equals(period.getCellType())) { |
| | | request.setMaintenancePeriod((int) period.getNumericCellValue()); |
| | | } else { |
| | |
| | | log.error("读取Excel信息失败:{}", e.getMessage(), e); |
| | | } |
| | | } |
| | | |
| | | private int findDataEndRow(InputStream inputStream) throws IOException { |
| | | Workbook workbook = null; |
| | | try { |
| | | workbook = WorkbookFactory.create(inputStream); |
| | | Sheet sheet = workbook.getSheetAt(0); |
| | | int lastRowNum = sheet.getLastRowNum(); |
| | | log.info("Excel文件总行数: {}", lastRowNum); |
| | | |
| | | // 找到"实施要领"行,作为数据结束的标志 |
| | | for (int i = 0; i <= lastRowNum; i++) { |
| | | Row row = sheet.getRow(i); |
| | | if (row == null) continue; |
| | | |
| | | // 检查第A列是否包含"实施要领" |
| | | Cell cell = row.getCell(0); |
| | | if (cell != null && cell.getCellType() == CellType.STRING) { |
| | | String value = getCellValue(cell).replaceAll("\\s+", ""); |
| | | if ("实施要领".equals(value)) { |
| | | log.info("找到'实施要领'在第{}行", i); |
| | | return i - 1; // 返回"实施要领"行之前的行号 |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 如果没有找到"实施要领",返回最后一行 |
| | | log.info("未找到'实施要领',返回最后一行: {}", lastRowNum); |
| | | return lastRowNum; |
| | | } finally { |
| | | if (workbook != null) { |
| | | workbook.close(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 从单元格中提取设备编号,去除前缀如"设备编号:" |
| | | * @param cell 单元格对象 |
| | | * @return 纯设备编号字符串 |
| | | */ |
| | | private String extractEquipmentCode(Cell cell) { |
| | | if (cell == null) { |
| | | return null; |
| | | } |
| | | |
| | | String cellValue = getCellValue(cell); |
| | | if (StringUtils.isBlank(cellValue)) { |
| | | return null; |
| | | } |
| | | |
| | | // 去除前后空格 |
| | | cellValue = cellValue.trim(); |
| | | |
| | | // 使用正则表达式提取数字部分 |
| | | Pattern pattern = Pattern.compile("\\d+"); |
| | | Matcher matcher = pattern.matcher(cellValue); |
| | | |
| | | if (matcher.find()) { |
| | | return matcher.group(); |
| | | } |
| | | |
| | | // 如果没有找到数字,返回原值(可能有其他格式) |
| | | return cellValue; |
| | | } |
| | | } |
| | |
| | | @Data |
| | | public class MaintenanceStandardImport implements Serializable { |
| | | |
| | | @Excel(name = "NO", width = 15) |
| | | // @Excel(name = "NO", width = 15) |
| | | // private String itemCode; |
| | | // |
| | | // @Excel(name = "点检内容", width = 15) |
| | | // private String itemName; |
| | | // |
| | | // @Excel(name = "点检方法", width = 15) |
| | | // private String subItemName; |
| | | // |
| | | // @Excel(name = "部位名称", width = 15) |
| | | // private String itemPart; |
| | | // |
| | | // @Excel(name = "基准", width = 15) |
| | | // private String itemDemand; |
| | | |
| | | |
| | | |
| | | |
| | | @Excel(name = "NO") |
| | | private String itemCode; |
| | | |
| | | @Excel(name = "点检内容", width = 15) |
| | | private String itemName; |
| | | @Excel(name = "点检条件") |
| | | private String condition; |
| | | |
| | | @Excel(name = "点检方法", width = 15) |
| | | private String subItemName; |
| | | |
| | | @Excel(name = "部位名称", width = 15) |
| | | @Excel(name = "部位名称") |
| | | private String itemPart; |
| | | |
| | | @Excel(name = "基准", width = 15) |
| | | @Excel(name = "点检内容") |
| | | private String itemName; |
| | | |
| | | @Excel(name = "点检方法") |
| | | private String subItemName; |
| | | |
| | | @Excel(name = "基准") |
| | | private String itemDemand; |
| | | |
| | | @Excel(name = "异常处理基准") |
| | | private String abnormal; |
| | | |
| | | @Excel(name = "周期") |
| | | private String period; |
| | | |
| | | } |
| | |
| | | /** |
| | | * 设备统一编号 |
| | | */ |
| | | @Excel(name = "设备编号", width = 15, orderNum = "1") |
| | | @Excel(name = "设备编号", width = 15, orderNum = "5") |
| | | @ApiModelProperty(value = "设备编号") |
| | | private String equipmentCode; |
| | | |
| | | |
| | | /** |
| | | * 设备名称 |
| | | */ |
| | | @Excel(name = "设备名称", width = 15, orderNum = "2") |
| | | @Excel(name = "设备名称", width = 15, orderNum = "4") |
| | | @ApiModelProperty(value = "设备名称") |
| | | private String equipmentName; |
| | | /** |
| | | * 使用部门 |
| | | */ |
| | | @Excel(name = "使用车间", width = 25, dictTable = "mdc_production", dicText = "production_name", dicCode = "id", orderNum = "9") |
| | | @ApiModelProperty(value = "使用部门") |
| | | @Dict(dicCode = "mdc_production, production_name, id") |
| | | @Excel(name = "所属产线", width = 25, dictTable = "base_factory", dicText = "factory_name", dicCode = "id", orderNum = "3") |
| | | @ApiModelProperty(value = "所属产线") |
| | | @Dict(dicCode = "base_factory, factory_name, id") |
| | | private String orgId; |
| | | /** |
| | | * 设备管理员 |
| | |
| | | /** |
| | | * 设备型号 |
| | | */ |
| | | @Excel(name = "设备型号", width = 15, orderNum = "3") |
| | | @Excel(name = "设备型号", width = 15, orderNum = "5") |
| | | @ApiModelProperty(value = "设备型号") |
| | | private String equipmentModel; |
| | | /** |
| | |
| | | /** |
| | | * 出厂编号 |
| | | */ |
| | | @Excel(name = "出厂编号", width = 15, orderNum = "12") |
| | | @Excel(name = "出厂编号", width = 15, orderNum = "7") |
| | | @ApiModelProperty(value = "出厂编号") |
| | | private String factoryNumber; |
| | | /** |
| | | * 机床厂家 |
| | | * 生产厂家 |
| | | */ |
| | | @Excel(name = "机床厂家", width = 15, orderNum = "13") |
| | | @ApiModelProperty(value = "机床厂家") |
| | | @Excel(name = "生产厂家", width = 15, orderNum = "8") |
| | | @ApiModelProperty(value = "生产厂家") |
| | | private String manufacturingEnterprise; |
| | | /** |
| | | * 来源国家 |
| | | */ |
| | | @Excel(name = "来源国家", width = 25, orderNum = "14") |
| | | @Excel(name = "来源国家", width = 25) |
| | | @ApiModelProperty(value = "来源国家") |
| | | private String originCountry; |
| | | /** |
| | | * 设备供应商 |
| | | */ |
| | | @Excel(name = "设备供应商", width = 25, orderNum = "15") |
| | | @Excel(name = "设备供应商", width = 25) |
| | | @ApiModelProperty(value = "设备供应商") |
| | | private String supplier; |
| | | /** |
| | | * 出厂日期 |
| | | */ |
| | | @Excel(name = "出厂日期", width = 25, format = "yyyy/MM/dd", orderNum = "16") |
| | | @Excel(name = "出厂日期", width = 25, format = "yyyy/MM/dd") |
| | | @ApiModelProperty(value = "出厂日期") |
| | | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private Date leaveFactoryDate; |
| | | /** |
| | | * 验收日期 |
| | | * 进厂日期 |
| | | */ |
| | | @Excel(name = "投用日期", width = 25, format = "yyyy/MM/dd", orderNum = "17") |
| | | @ApiModelProperty(value = "验收日期") |
| | | |
| | | // @Excel(name = "进厂日期", width = 25, format = "yyyy.MM.dd", orderNum = "6") |
| | | @Excel(name = "进厂日期", width = 25, format = "yyyy.MM.dd", orderNum = "6") |
| | | @ApiModelProperty(value = "进厂日期") |
| | | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private Date acceptanceCheckDate; |
| | |
| | | /** |
| | | * 立项卡号 |
| | | */ |
| | | @Excel(name = "资产编号", width = 15, orderNum = "1") |
| | | @ApiModelProperty(value = "立项卡号") |
| | | private String cardNumber; |
| | | /** |
| | |
| | | */ |
| | | @ApiModelProperty(value = "参考文件") |
| | | private String referenceFile; |
| | | /** |
| | | * 最新生成工单时间 |
| | | * 下一次生成时间为此时间 + 保养周期 |
| | | */ |
| | | @ApiModelProperty(value = "最新生成工单时间") |
| | | private Date lastGenerateTime; |
| | | |
| | | //列表展示 |
| | | @TableField(exist = false) |
| | |
| | | public EamMaintenanceStandardDetail(MaintenanceStandardImport dto) { |
| | | this.itemCode = Integer.valueOf(dto.getItemCode()); |
| | | this.itemPart = dto.getItemPart(); |
| | | this.checkMethod=dto.getCondition(); |
| | | this.itemName = dto.getItemName(); |
| | | this.itemDemand = dto.getItemDemand(); |
| | | } |
| | |
| | | if (sysUser == null) { |
| | | return page; |
| | | } |
| | | if (StringUtils.isNotBlank(sysUser.getEquipmentIds())) { |
| | | //选择了设备,根据设备id过滤设备 |
| | | List<String> equipArr = Arrays.asList(sysUser.getEquipmentIds().split(",")); |
| | | queryWrapper.in("e.equipment_code", equipArr); |
| | | } else { |
| | | //没有选择设备,根据车间过滤设备 |
| | | queryWrapper.exists("select 1 from mdc_user_production t where t.user_id={0} and t.pro_id=e.org_id", sysUser.getId()); |
| | | } |
| | | // if (StringUtils.isNotBlank(sysUser.getEquipmentIds())) { |
| | | // //选择了设备,根据设备id过滤设备 |
| | | // List<String> equipArr = Arrays.asList(sysUser.getEquipmentIds().split(",")); |
| | | // queryWrapper.in("e.equipment_code", equipArr); |
| | | // } else { |
| | | // //没有选择设备,根据车间过滤设备 |
| | | // queryWrapper.exists("select 1 from mdc_user_production t where t.user_id={0} and t.pro_id=e.org_id", sysUser.getId()); |
| | | // } |
| | | //查询条件过滤 |
| | | if (eamEquipment != null) { |
| | | if (StringUtils.isNotBlank(eamEquipment.getEquipmentCode())) { |
| | |
| | | if (sysUser == null) { |
| | | return page; |
| | | } |
| | | if (StringUtils.isNotBlank(sysUser.getEquipmentIds())) { |
| | | //选择了设备,根据设备id过滤设备 |
| | | List<String> equipArr = Arrays.asList(sysUser.getEquipmentIds().split(",")); |
| | | queryWrapper.in("e.equipment_code", equipArr); |
| | | } else { |
| | | //没有选择设备,根据车间过滤设备 |
| | | queryWrapper.exists("select 1 from mdc_user_production t where t.user_id={0} and t.pro_id=e.org_id ", sysUser.getId()); |
| | | } |
| | | // if (StringUtils.isNotBlank(sysUser.getEquipmentIds())) { |
| | | // //选择了设备,根据设备id过滤设备 |
| | | // List<String> equipArr = Arrays.asList(sysUser.getEquipmentIds().split(",")); |
| | | // queryWrapper.in("e.equipment_code", equipArr); |
| | | // } else { |
| | | // //没有选择设备,根据车间过滤设备 |
| | | // queryWrapper.exists("select 1 from mdc_user_production t where t.user_id={0} and t.pro_id=e.org_id ", sysUser.getId()); |
| | | // } |
| | | if(eamMaintenanceStandard != null) { |
| | | //编码 模糊查询 |
| | | if(StringUtils.isNotBlank(eamMaintenanceStandard.getStandardCode())) { |
| | |
| | | }).collect(Collectors.toList()); |
| | | return Result.OK(res); |
| | | } |
| | | |
| | | @ApiOperation(value = "SAP生产订单-根据订单号同步最新信息", notes = "SAP生产订单-根据订单号同步最新信息") |
| | | @GetMapping(value = "/syncSapProductionOrder") |
| | | public Result<?> syncSapProductionOrder(@RequestParam(name = "id") String id) { |
| | | boolean b = mesProductionOrderService.syncSapProductionOrder(id); |
| | | if (!b) { |
| | | return Result.error("同步失败!"); |
| | | } |
| | | return Result.ok("同步成功!"); |
| | | } |
| | | } |
| | |
| | | package org.jeecg.modules.mes.job; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.modules.lsw.service.ILswMaterialService; |
| | | import org.jeecg.modules.mdc.util.DateUtils; |
| | | import org.jeecg.modules.mdc.util.ThrowableUtil; |
| | |
| | | @Value("${xhj.orderStatus:REL}") |
| | | private String ORDER_STATUS; |
| | | |
| | | /** |
| | | * 请求成功编码 |
| | | */ |
| | | private static final String SUCCESS_CODE = "S"; |
| | | |
| | | @Autowired |
| | | private ProductionOrderSync productionOrderSync; |
| | | @Autowired |
| | |
| | | try { |
| | | //调用SAP接口获取生产订单 |
| | | Map<String, Object> productionOrderMap = productionOrderSync.syncProductionOrder(request); |
| | | if (productionOrderMap == null || !SUCCESS_CODE.equals(productionOrderMap.get("ztype"))) { |
| | | if (productionOrderMap == null || !CommonConstant.SAP_SUCCESS_CODE.equals(productionOrderMap.get("ztype"))) { |
| | | log.error("未同步到订单信息!日期:{}", LocalDateTime.now()); |
| | | return; |
| | | } |
| | |
| | | String orderCodes = String.join(",", orderMap.keySet()); |
| | | //订单BOM同步 |
| | | Map<String, Object> orderBomMap = orderBomSync.syncOrderBom(FACTORY_CODE, orderCodes); |
| | | if (orderBomMap == null || !SUCCESS_CODE.equals(orderBomMap.get("ztype"))) { |
| | | if (orderBomMap == null || !CommonConstant.SAP_SUCCESS_CODE.equals(orderBomMap.get("ztype"))) { |
| | | log.error("未同步到订单BOM信息!日期:{}", LocalDateTime.now()); |
| | | return; |
| | | } |
| | |
| | | } |
| | | //订单工序同步 |
| | | Map<String, Object> orderProcessMap = orderProcessSync.syncOrderProcess(FACTORY_CODE, orderCodes); |
| | | if (orderBomMap == null || !SUCCESS_CODE.equals(orderProcessMap.get("ztype"))) { |
| | | if (orderBomMap == null || !CommonConstant.SAP_SUCCESS_CODE.equals(orderProcessMap.get("ztype"))) { |
| | | log.error("未同步到订单工序信息!日期:{}", LocalDateTime.now()); |
| | | return; |
| | | } |
| | |
| | | package org.jeecg.modules.mes.job; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.modules.lsw.service.ILswMaterialService; |
| | | import org.jeecg.modules.mdc.util.DateUtils; |
| | | import org.jeecg.modules.mdc.util.ThrowableUtil; |
| | |
| | | @Value("${xhj.orderStatus:REL}") |
| | | private String ORDER_STATUS; |
| | | |
| | | /** |
| | | * 请求成功编码 |
| | | */ |
| | | private static final String SUCCESS_CODE = "S"; |
| | | |
| | | @Autowired |
| | | private ProductionOrderSync productionOrderSync; |
| | | @Autowired |
| | |
| | | try { |
| | | //调用SAP接口获取生产订单 |
| | | Map<String, Object> productionOrderMap = productionOrderSync.syncProductionOrder(request); |
| | | if (productionOrderMap == null || !SUCCESS_CODE.equals(productionOrderMap.get("ztype"))) { |
| | | if (productionOrderMap == null || !CommonConstant.SAP_SUCCESS_CODE.equals(productionOrderMap.get("ztype"))) { |
| | | log.error("未同步到订单信息!日期:{}", LocalDateTime.now()); |
| | | return; |
| | | } |
| | |
| | | String orderCodes = String.join(",", orderMap.keySet()); |
| | | //订单BOM同步 |
| | | Map<String, Object> orderBomMap = orderBomSync.syncOrderBom(FACTORY_CODE, orderCodes); |
| | | if (orderBomMap == null || !SUCCESS_CODE.equals(orderBomMap.get("ztype"))) { |
| | | if (orderBomMap == null || !CommonConstant.SAP_SUCCESS_CODE.equals(orderBomMap.get("ztype"))) { |
| | | log.error("未同步到订单BOM信息!日期:{}", LocalDateTime.now()); |
| | | return; |
| | | } |
| | |
| | | } |
| | | //订单工序同步 |
| | | Map<String, Object> orderProcessMap = orderProcessSync.syncOrderProcess(FACTORY_CODE, orderCodes); |
| | | if (orderBomMap == null || !SUCCESS_CODE.equals(orderProcessMap.get("ztype"))) { |
| | | if (orderBomMap == null || !CommonConstant.SAP_SUCCESS_CODE.equals(orderProcessMap.get("ztype"))) { |
| | | log.error("未同步到订单工序信息!日期:{}", LocalDateTime.now()); |
| | | return; |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | String getLastSyncUpdateDate(); |
| | | |
| | | /** |
| | | * 同步SAP生产订单的最新状态 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | boolean syncSapProductionOrder(String id); |
| | | } |
| | |
| | | import org.jeecg.modules.mes.service.IMesKittingCompletenessCheckService; |
| | | import org.jeecg.modules.mes.service.IMesProductionWorkOrderService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import java.util.List; |
| | |
| | | public class MesKittingCompletenessCheckServiceImpl extends ServiceImpl<MesKittingCompletenessCheckMapper, MesKittingCompletenessCheck> implements IMesKittingCompletenessCheckService { |
| | | |
| | | @Autowired |
| | | @Lazy |
| | | private IMesProductionWorkOrderService mesProductionWorkOrderService; |
| | | |
| | | @Override |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.modules.mdc.util.DateUtils; |
| | | import org.jeecg.common.exception.JeecgBootException; |
| | | import org.jeecg.modules.mes.entity.MesProductionOrder; |
| | | import org.jeecg.modules.mes.mapper.MesProductionOrderMapper; |
| | | import org.jeecg.modules.mes.service.IMesProductionOrderService; |
| | | import org.jeecg.modules.sap.dto.ProductionOrderDTO; |
| | | import org.jeecg.modules.sap.request.ProductionOrderSyncRequest; |
| | | import org.jeecg.modules.sap.service.ProductionOrderSync; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.*; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @Description: SAP生产订单 |
| | |
| | | */ |
| | | @Service |
| | | public class MesProductionOrderServiceImpl extends ServiceImpl<MesProductionOrderMapper, MesProductionOrder> implements IMesProductionOrderService { |
| | | //工厂编码(新火炬 2301) |
| | | @Value("${xhj.factoryCode:2301}") |
| | | private String FACTORY_CODE; |
| | | |
| | | @Autowired |
| | | private ProductionOrderSync productionOrderSync; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | @Override |
| | | public String getLastSyncCreateDate() { |
| | | String lastSyncDate = this.getBaseMapper().getLastSyncCreateDate(); |
| | | if(lastSyncDate == null){ |
| | | if (lastSyncDate == null) { |
| | | return null; |
| | | } |
| | | return lastSyncDate.replaceAll("-", ""); |
| | |
| | | @Override |
| | | public String getLastSyncUpdateDate() { |
| | | String lastSyncDate = this.getBaseMapper().getLastSyncUpdateDate(); |
| | | if(lastSyncDate == null){ |
| | | if (lastSyncDate == null) { |
| | | return null; |
| | | } |
| | | return lastSyncDate.replaceAll("-", ""); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean syncSapProductionOrder(String id) { |
| | | MesProductionOrder entity = super.getById(id); |
| | | if (entity == null) { |
| | | throw new JeecgBootException("生产订单不存在,请刷新重置!"); |
| | | } |
| | | ProductionOrderSyncRequest request = new ProductionOrderSyncRequest(); |
| | | request.setOrderCode(entity.getOrderCode()); |
| | | request.setFactoryCode(FACTORY_CODE); |
| | | try { |
| | | Map<String, Object> resultMap = productionOrderSync.syncProductionOrder(request); |
| | | if (resultMap == null) { |
| | | throw new JeecgBootException("响应结果为空!"); |
| | | } |
| | | if (!CommonConstant.SAP_SUCCESS_CODE.equals(resultMap.get("ztype"))) { |
| | | throw new JeecgBootException(resultMap.get("zmess").toString()); |
| | | } |
| | | //调用成功,获取返回数据 |
| | | Object result = resultMap.get("result"); |
| | | boolean b = result instanceof List; |
| | | if (!b) { |
| | | throw new JeecgBootException("返回结果格式错误!"); |
| | | } |
| | | List<ProductionOrderDTO> productionOrderDTOList = (List<ProductionOrderDTO>) result; |
| | | if (CollectionUtil.isEmpty(productionOrderDTOList)) { |
| | | throw new JeecgBootException("SAP未查询到生成订单!"); |
| | | } |
| | | ProductionOrderDTO dto = productionOrderDTOList.get(0); |
| | | entity.updateEntity(dto); |
| | | super.updateById(entity); |
| | | } catch (Exception e) { |
| | | throw new JeecgBootException("请求SAP失败:" + e.getMessage()); |
| | | } |
| | | return true; |
| | | } |
| | | } |
| | |
| | | import org.jeecg.modules.mes.entity.MesKittingCompletenessCheck; |
| | | import org.jeecg.modules.mes.entity.MesProductionOrder; |
| | | import org.jeecg.modules.mes.enums.ProductionOrderStatus; |
| | | import org.jeecg.modules.mes.service.IMesKittingCompletenessCheckService; |
| | | import org.jeecg.modules.mes.service.IMesProductionOrderService; |
| | | import org.jeecg.modules.mes.service.IMesProductionWorkOrderService; |
| | | import org.jeecg.modules.mes.entity.MesProductionWorkOrder; |
| | |
| | | private ILswMaterialInventoryService lswMaterialInventoryService; |
| | | @Autowired |
| | | private ILineSideWarehouseService lineSideWarehouseService; |
| | | @Autowired |
| | | private IMesKittingCompletenessCheckService mesKittingCompletenessCheckService; |
| | | |
| | | @Override |
| | | public List<MesProductionWorkOrder> schedule(MesProductionWorkScheduleRequest request) { |
| | |
| | | .selectLineSideMaterialInventoryByMaterialNumber(bomMaterialNumberList, lineSideWarehouse.getId(), null).stream() |
| | | .collect(Collectors.toMap(LswMaterialInventoryVo::getMaterialNumber, v1 -> v1, (v1, v2) -> v1)); |
| | | List<MesKittingCompletenessCheck> completenessCheckResultList = CollectionUtil.newArrayList(); |
| | | //查询是否有齐套检查记录(已齐备的) |
| | | List<String> checkedMaterialNumberList = mesKittingCompletenessCheckService.list(new LambdaQueryWrapper<MesKittingCompletenessCheck>() |
| | | .eq(MesKittingCompletenessCheck::getWorkOrderId, workOrder.getId()) |
| | | .in(MesKittingCompletenessCheck::getMaterialNumber, bomMaterialNumberList) |
| | | .eq(MesKittingCompletenessCheck::getCheckFlag, CommonConstant.DEFAULT_1)) |
| | | .stream().map(MesKittingCompletenessCheck::getMaterialNumber).collect(Collectors.toList()); |
| | | //根据订单BOM明细列出齐套检查结果 |
| | | for (PmsProcessBillMaterialsDetail processBillMaterialsDetail : processBillMaterialsDetails) { |
| | | LswMaterialInventoryVo materialInventoryVo = lswMaterialInventoryMap.get(processBillMaterialsDetail.getMaterialNumber()); |
| | | String materialNumber = processBillMaterialsDetail.getMaterialNumber(); |
| | | if (checkedMaterialNumberList.contains(materialNumber)) { |
| | | //如果已经做过齐套性检查,并且齐备,就忽略掉 |
| | | continue; |
| | | } |
| | | LswMaterialInventoryVo materialInventoryVo = lswMaterialInventoryMap.get(materialNumber); |
| | | MesKittingCompletenessCheck completenessCheckItem = new MesKittingCompletenessCheck() |
| | | .setMaterialNumber(processBillMaterialsDetail.getMaterialNumber()) |
| | | .setMaterialNumber(materialNumber) |
| | | .setMaterialName(processBillMaterialsDetail.getMaterialName()) |
| | | //需求数量 = (bom明细的需求数量 / bom订单的数量) * 排产工单计划生产数量 |
| | | .setRequiredQuantity(processBillMaterialsDetail.getUsageQuantity() |
| | |
| | | package org.jeecg.modules.qms.controller; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLDecoder; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | |
| | | import org.jeecg.modules.qms.entity.InspectionItem; |
| | | import org.jeecg.modules.qms.entity.InspectionTools; |
| | | import org.jeecg.modules.qms.service.IInspectionItemService; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | QueryWrapper<InspectionItem> queryWrapper = QueryGenerator.initQueryWrapper(inspectionItem, req.getParameterMap()); |
| | | Page<InspectionItem> page = new Page<InspectionItem>(pageNo, pageSize); |
| | | IPage<InspectionItem> pageList = inspectionItemService.page(page, queryWrapper); |
| | | List<InspectionItem> records = pageList.getRecords(); |
| | | Set<String> uniqueToolIds = records.stream() |
| | | .map(InspectionItem::getInspectionTools) |
| | | .filter(StringUtils::isNotBlank) |
| | | .flatMap(tools -> Arrays.stream(tools.split(","))) |
| | | .map(String::trim) |
| | | .collect(Collectors.toSet()); |
| | | Map<String, String> toolIdNameMap = inspectionToolsService.listByIds(uniqueToolIds).stream() |
| | | .collect(Collectors.toMap(InspectionTools::getId, InspectionTools::getToolName)); |
| | | |
| | | records.forEach(record -> { |
| | | String inspectionTools = record.getInspectionTools(); |
| | | if (StringUtils.isNotBlank(inspectionTools)) { |
| | | String toolNames = Arrays.stream(inspectionTools.split(",")) |
| | | .map(String::trim) |
| | | .map(toolIdNameMap::get) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.joining(",")); |
| | | record.setInspectionToolNames(toolNames); |
| | | } |
| | | }); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | |
| | | package org.jeecg.modules.qms.entity; |
| | | |
| | | import java.io.Serializable; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.Date; |
| | | import java.math.BigDecimal; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import lombok.Data; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | |
| | | @Excel(name = "备注", width = 15) |
| | | @ApiModelProperty(value = "备注") |
| | | private String remark; |
| | | |
| | | /**测量工具名称*/ |
| | | @ApiModelProperty(value = "测量工具名称") |
| | | @TableField(exist = false) |
| | | private String inspectionToolNames; |
| | | } |