parent
9f8cf8f198
commit
47fe291ed0
@ -1,95 +1,103 @@
|
||||
package com.chanko.yunxi.mes.module.heli.controller.admin.plan;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.CommonResult;
|
||||
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
|
||||
import static com.chanko.yunxi.mes.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import com.chanko.yunxi.mes.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import com.chanko.yunxi.mes.framework.operatelog.core.annotations.OperateLog;
|
||||
import static com.chanko.yunxi.mes.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import com.chanko.yunxi.mes.module.heli.controller.admin.plan.vo.*;
|
||||
import com.chanko.yunxi.mes.module.heli.dal.dataobject.plan.PlanDO;
|
||||
import com.chanko.yunxi.mes.module.heli.service.plan.PlanService;
|
||||
|
||||
@Tag(name = "管理后台 - 生产计划")
|
||||
@RestController
|
||||
@RequestMapping("/heli/plan")
|
||||
@Validated
|
||||
public class PlanController {
|
||||
|
||||
@Resource
|
||||
private PlanService planService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建生产计划")
|
||||
@PreAuthorize("@ss.hasPermission('heli:plan:create')")
|
||||
public CommonResult<Long> createPlan(@Valid @RequestBody PlanSaveReqVO createReqVO) {
|
||||
return success(planService.createPlan(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新生产计划")
|
||||
@PreAuthorize("@ss.hasPermission('heli:plan:update')")
|
||||
public CommonResult<Boolean> updatePlan(@Valid @RequestBody PlanSaveReqVO updateReqVO) {
|
||||
planService.updatePlan(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除生产计划")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('heli:plan:delete')")
|
||||
public CommonResult<Boolean> deletePlan(@RequestParam("id") Long id) {
|
||||
planService.deletePlan(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得生产计划")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('heli:plan:query')")
|
||||
public CommonResult<PlanRespVO> getPlan(@RequestParam("id") Long id) {
|
||||
PlanDO plan = planService.getPlan(id);
|
||||
return success(BeanUtils.toBean(plan, PlanRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得生产计划分页")
|
||||
@PreAuthorize("@ss.hasPermission('heli:plan:query')")
|
||||
public CommonResult<PageResult<PlanRespVO>> getPlanPage(@Valid PlanPageReqVO pageReqVO) {
|
||||
PageResult<PlanDO> pageResult = planService.getPlanPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, PlanRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出生产计划 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('heli:plan:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportPlanExcel(@Valid PlanPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<PlanDO> list = planService.getPlanPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "生产计划.xls", "数据", PlanRespVO.class,
|
||||
BeanUtils.toBean(list, PlanRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
package com.chanko.yunxi.mes.module.heli.controller.admin.plan;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.CommonResult;
|
||||
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
|
||||
import static com.chanko.yunxi.mes.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import com.chanko.yunxi.mes.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import com.chanko.yunxi.mes.framework.operatelog.core.annotations.OperateLog;
|
||||
import static com.chanko.yunxi.mes.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import com.chanko.yunxi.mes.module.heli.controller.admin.plan.vo.*;
|
||||
import com.chanko.yunxi.mes.module.heli.dal.dataobject.plan.PlanDO;
|
||||
import com.chanko.yunxi.mes.module.heli.service.plan.PlanService;
|
||||
|
||||
@Tag(name = "管理后台 - 生产计划")
|
||||
@RestController
|
||||
@RequestMapping("/heli/plan")
|
||||
@Validated
|
||||
public class PlanController {
|
||||
|
||||
@Resource
|
||||
private PlanService planService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建生产计划")
|
||||
@PreAuthorize("@ss.hasPermission('heli:plan:create')")
|
||||
public CommonResult<Long> createPlan(@Valid @RequestBody PlanSaveReqVO createReqVO) {
|
||||
return success(planService.createPlan(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新生产计划")
|
||||
@PreAuthorize("@ss.hasPermission('heli:plan:update')")
|
||||
public CommonResult<Boolean> updatePlan(@Valid @RequestBody PlanSaveReqVO updateReqVO) {
|
||||
planService.updatePlan(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除生产计划")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('heli:plan:delete')")
|
||||
public CommonResult<Boolean> deletePlan(@RequestParam("id") Long id) {
|
||||
planService.deletePlan(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得生产计划")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('heli:plan:query')")
|
||||
public CommonResult<PlanRespVO> getPlan(@RequestParam("id") Long id) {
|
||||
PlanDO plan = planService.getPlan(id);
|
||||
return success(BeanUtils.toBean(plan, PlanRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得生产计划分页")
|
||||
@PreAuthorize("@ss.hasPermission('heli:plan:query')")
|
||||
public CommonResult<PageResult<PlanRespVO>> getPlanPage(@Valid PlanPageReqVO pageReqVO) {
|
||||
PageResult<PlanDO> pageResult = planService.getPlanPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, PlanRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page-by-status")
|
||||
@Operation(summary = "获得生产计划分页")
|
||||
@PreAuthorize("@ss.hasPermission('heli:plan:query')")
|
||||
public CommonResult<PageResult<PlanRespVO>> getPlanPageByStatus(@Valid PlanPageReqVO pageReqVO) {
|
||||
PageResult<PlanDO> pageResult = planService.getPlanPageByStatus(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, PlanRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出生产计划 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('heli:plan:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportPlanExcel(@Valid PlanPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<PlanDO> list = planService.getPlanPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "生产计划.xls", "数据", PlanRespVO.class,
|
||||
BeanUtils.toBean(list, PlanRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,74 +1,93 @@
|
||||
package com.chanko.yunxi.mes.module.heli.service.materialplan;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import com.chanko.yunxi.mes.module.heli.controller.admin.materialplan.vo.*;
|
||||
import com.chanko.yunxi.mes.module.heli.dal.dataobject.materialplan.MaterialPlanDO;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
|
||||
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
|
||||
|
||||
import com.chanko.yunxi.mes.module.heli.dal.mysql.materialplan.MaterialPlanMapper;
|
||||
|
||||
import static com.chanko.yunxi.mes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.chanko.yunxi.mes.module.heli.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 物料需求计划 Service 实现类
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class MaterialPlanServiceImpl implements MaterialPlanService {
|
||||
|
||||
@Resource
|
||||
private MaterialPlanMapper materialPlanMapper;
|
||||
|
||||
@Override
|
||||
public Long createMaterialPlan(MaterialPlanSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
MaterialPlanDO materialPlan = BeanUtils.toBean(createReqVO, MaterialPlanDO.class);
|
||||
materialPlanMapper.insert(materialPlan);
|
||||
// 返回
|
||||
return materialPlan.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMaterialPlan(MaterialPlanSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateMaterialPlanExists(updateReqVO.getId());
|
||||
// 更新
|
||||
MaterialPlanDO updateObj = BeanUtils.toBean(updateReqVO, MaterialPlanDO.class);
|
||||
materialPlanMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteMaterialPlan(Long id) {
|
||||
// 校验存在
|
||||
validateMaterialPlanExists(id);
|
||||
// 删除
|
||||
materialPlanMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateMaterialPlanExists(Long id) {
|
||||
if (materialPlanMapper.selectById(id) == null) {
|
||||
throw exception(MATERIAL_PLAN_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MaterialPlanDO getMaterialPlan(Long id) {
|
||||
return materialPlanMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<MaterialPlanDO> getMaterialPlanPage(MaterialPlanPageReqVO pageReqVO) {
|
||||
return materialPlanMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
package com.chanko.yunxi.mes.module.heli.service.materialplan;
|
||||
|
||||
import com.chanko.yunxi.mes.module.heli.dal.dataobject.serialnumber.SerialNumberDO;
|
||||
import com.chanko.yunxi.mes.module.heli.service.serialnumber.SerialNumberService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import com.chanko.yunxi.mes.module.heli.controller.admin.materialplan.vo.*;
|
||||
import com.chanko.yunxi.mes.module.heli.dal.dataobject.materialplan.MaterialPlanDO;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
|
||||
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
|
||||
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
|
||||
|
||||
import com.chanko.yunxi.mes.module.heli.dal.mysql.materialplan.MaterialPlanMapper;
|
||||
|
||||
import static com.chanko.yunxi.mes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.chanko.yunxi.mes.module.heli.enums.CodeEnum.MATERIAL_PLAN;
|
||||
import static com.chanko.yunxi.mes.module.heli.enums.CodeEnum.PROJECT_PLAN;
|
||||
import static com.chanko.yunxi.mes.module.heli.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 物料需求计划 Service 实现类
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class MaterialPlanServiceImpl implements MaterialPlanService {
|
||||
|
||||
@Resource
|
||||
private MaterialPlanMapper materialPlanMapper;
|
||||
|
||||
@Resource
|
||||
private SerialNumberService serialNumberService;
|
||||
|
||||
@Override
|
||||
public Long createMaterialPlan(MaterialPlanSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
MaterialPlanDO materialPlan = BeanUtils.toBean(createReqVO, MaterialPlanDO.class);
|
||||
|
||||
// 月度流水号
|
||||
SerialNumberDO serialNumberDO = new SerialNumberDO();
|
||||
serialNumberDO = serialNumberService.getSerialNumber(MATERIAL_PLAN.name(), new SimpleDateFormat("yyyyMMdd").format(new Date()));
|
||||
serialNumberDO.setSerialNumber(serialNumberDO.getSerialNumber()+1);
|
||||
|
||||
materialPlan.setProjectMaterialPlanNo(MATERIAL_PLAN.getCode(serialNumberDO.getSerialNumber().toString()));
|
||||
|
||||
materialPlanMapper.insert(materialPlan);
|
||||
|
||||
// 回写序列记录
|
||||
serialNumberService.updateSerialNumber(serialNumberDO);
|
||||
// 返回
|
||||
return materialPlan.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMaterialPlan(MaterialPlanSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateMaterialPlanExists(updateReqVO.getId());
|
||||
// 更新
|
||||
MaterialPlanDO updateObj = BeanUtils.toBean(updateReqVO, MaterialPlanDO.class);
|
||||
materialPlanMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteMaterialPlan(Long id) {
|
||||
// 校验存在
|
||||
validateMaterialPlanExists(id);
|
||||
// 删除
|
||||
materialPlanMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateMaterialPlanExists(Long id) {
|
||||
if (materialPlanMapper.selectById(id) == null) {
|
||||
throw exception(MATERIAL_PLAN_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MaterialPlanDO getMaterialPlan(Long id) {
|
||||
return materialPlanMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<MaterialPlanDO> getMaterialPlanPage(MaterialPlanPageReqVO pageReqVO) {
|
||||
return materialPlanMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in new issue