aps-modules/aps-core/src/main/java/com/aps/core/controller/ApsPlatePlanController.java
@@ -5,6 +5,11 @@ import com.aps.common.core.domain.R; import com.aps.common.core.utils.file.FileUtils; import com.aps.common.core.utils.uuid.IdUtils; import com.aps.common.security.utils.DictUtils; import com.aps.core.domain.ApsPartPlanTemp; import com.aps.core.domain.ApsPlatePlanTemp; import com.aps.system.api.domain.SysDictData; import com.aps.system.api.domain.SysFile; import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; @@ -35,8 +40,7 @@ */ @RestController @RequestMapping("/ApsPlatePlan") public class ApsPlatePlanController extends BaseController { public class ApsPlatePlanController extends BaseController { @Autowired private IApsPlatePlanService apsPlatePlanService; @@ -45,8 +49,7 @@ */ @RequiresPermissions("ApsPlatePlan:ApsPlatePlan:list") @GetMapping("/list") public TableDataInfo list(ApsPlatePlan apsPlatePlan) { public TableDataInfo list(ApsPlatePlan apsPlatePlan) { startPage(); List<ApsPlatePlan> list = apsPlatePlanService.selectApsPlatePlanList(apsPlatePlan); return getDataTable(list); @@ -58,8 +61,7 @@ @RequiresPermissions("ApsPlatePlan:ApsPlatePlan:export") @Log(title = "钣金计划管理", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, ApsPlatePlan apsPlatePlan) { public void export(HttpServletResponse response, ApsPlatePlan apsPlatePlan) { List<ApsPlatePlan> list = apsPlatePlanService.selectApsPlatePlanList(apsPlatePlan); ExcelUtil<ApsPlatePlan> util = new ExcelUtil<ApsPlatePlan>(ApsPlatePlan.class); util.exportExcel(response, list, "钣金计划管理数据"); @@ -70,8 +72,7 @@ */ @RequiresPermissions("ApsPlatePlan:ApsPlatePlan:query") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") String id) { public AjaxResult getInfo(@PathVariable("id") String id) { return success(apsPlatePlanService.selectApsPlatePlanById(id)); } @@ -81,8 +82,7 @@ @RequiresPermissions("ApsPlatePlan:ApsPlatePlan:add") @Log(title = "钣金计划管理", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody ApsPlatePlan apsPlatePlan) { public AjaxResult add(@RequestBody ApsPlatePlan apsPlatePlan) { return toAjax(apsPlatePlanService.insertApsPlatePlan(apsPlatePlan)); } @@ -92,8 +92,7 @@ @RequiresPermissions("ApsPlatePlan:ApsPlatePlan:edit") @Log(title = "钣金计划管理", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody ApsPlatePlan apsPlatePlan) { public AjaxResult edit(@RequestBody ApsPlatePlan apsPlatePlan) { return toAjax(apsPlatePlanService.updateApsPlatePlan(apsPlatePlan)); } @@ -103,26 +102,35 @@ @RequiresPermissions("ApsPlatePlan:ApsPlatePlan:remove") @Log(title = "钣金计划管理", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable String[] ids) { public AjaxResult remove(@PathVariable String[] ids) { return toAjax(apsPlatePlanService.deleteApsPlatePlanByIds(ids)); } @PostMapping("/upload") public AjaxResult upload(MultipartFile file) { try { // 上传并返回访问地址 ExcelUtil<ApsPlatePlan> util = new ExcelUtil<ApsPlatePlan>(ApsPlatePlan.class); List<ApsPlatePlan> userList = util.importExcel(file.getInputStream()); System.out.println(userList.size()); /** * 导入Excel数据 * @param file * @return * @throws Exception */ @PostMapping("/importData") public AjaxResult importData(MultipartFile file) throws Exception { ExcelUtil<ApsPlatePlanTemp> util = new ExcelUtil<ApsPlatePlanTemp>(ApsPlatePlanTemp.class); List<ApsPlatePlanTemp> platePlanTemps = util.importExcel(file.getInputStream()); //判断导入数据是否为空 if (platePlanTemps.size() > 0) { String batchNum = apsPlatePlanService.importData(platePlanTemps); return AjaxResult.success("导入成功!",batchNum); } else { return AjaxResult.error("模板内容为空"); } catch (Exception e) { } return toAjax(true); /** * 确认部分计划控制器 * @param planTemp 包含部分计划信息的临时对象,用于确认计划 * @return 返回操作结果的AjaxResult对象 */ @GetMapping("/confirmPart") public AjaxResult confirmPart(ApsPlatePlanTemp planTemp) { return toAjax(apsPlatePlanService.confirmPlan(planTemp)); } } aps-modules/aps-core/src/main/java/com/aps/core/domain/ApsPlatePlanTemp.java
@@ -120,9 +120,11 @@ private String nextProcessDeparment; /** 是否挂起 */ @Excel(name = "是否挂起") private Integer isSuspended; /** 是否挂起 */ @Excel(name = "是否挂起") private String isSuspendedTxt; /** 外协标识 */ @Excel(name = "外协标识") private String isOutsourcing; @@ -527,7 +529,13 @@ { return batchNumber; } public String getIsSuspendedTxt() { return isSuspendedTxt; } public void setIsSuspendedTxt(String isSuspendedTxt) { this.isSuspendedTxt = isSuspendedTxt; } @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) aps-modules/aps-core/src/main/java/com/aps/core/service/IApsPlatePlanService.java
@@ -2,6 +2,7 @@ import java.util.List; import com.aps.core.domain.ApsPlatePlan; import com.aps.core.domain.ApsPlatePlanTemp; /** * 钣金计划管理Service接口 @@ -58,4 +59,16 @@ * @return 结果 */ public int deleteApsPlatePlanById(String id); /*** * 确认计划上传 * */ public int confirmPlan(ApsPlatePlanTemp tempPlan); /** * 导入计划数据到临时表 * @param tempList * @return * @throws Exception */ String importData(List<ApsPlatePlanTemp> tempList) throws Exception; } aps-modules/aps-core/src/main/java/com/aps/core/service/impl/ApsPlatePlanServiceImpl.java
@@ -1,6 +1,15 @@ package com.aps.core.service.impl; import java.util.List; import com.aps.common.core.utils.uuid.IdUtils; import com.aps.common.security.utils.DictUtils; import com.aps.core.domain.ApsPlatePlanTemp; import com.aps.core.mapper.ApsPartPlanTempMapper; import com.aps.core.mapper.ApsPlatePlanTempMapper; import com.aps.system.api.domain.SysDictData; import org.apache.logging.log4j.util.Strings; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.aps.core.mapper.ApsPlatePlanMapper; @@ -18,6 +27,11 @@ { @Autowired private ApsPlatePlanMapper apsPlatePlanMapper; @Autowired private ApsPartPlanTempMapper apsPartPlanTempMapper; @Autowired private ApsPlatePlanTempMapper apsPlatePlanTempMapper; /** * 查询钣金计划管理 @@ -52,6 +66,7 @@ @Override public int insertApsPlatePlan(ApsPlatePlan apsPlatePlan) { apsPlatePlan.setId(IdUtils.fastUUID()); return apsPlatePlanMapper.insertApsPlatePlan(apsPlatePlan); } @@ -90,4 +105,52 @@ { return apsPlatePlanMapper.deleteApsPlatePlanById(id); } @Override public int confirmPlan(ApsPlatePlanTemp tempPlan) { //查询临时表数据 List<ApsPlatePlanTemp> apsPartPlanTemps=apsPlatePlanTempMapper.selectApsPlatePlanTempList(tempPlan); int count=0; String[] ids=new String[apsPartPlanTemps.size()]; for (int i = 0; i <apsPartPlanTemps.size() ; i++) { //记录临时表id ids[i]=apsPartPlanTemps.get(i).getId(); ApsPlatePlan platePlan=new ApsPlatePlan(); BeanUtils.copyProperties(apsPartPlanTemps.get(i), platePlan); platePlan.setId(IdUtils.fastUUID()); //插入正式表,并记录 apsPlatePlanMapper.insertApsPlatePlan(platePlan); count++; } //插入数量与临时表查询一直则删除临时表数据 if (count==apsPartPlanTemps.size()) { apsPlatePlanTempMapper.deleteApsPlatePlanTempByIds(ids); } return 1; } @Override public String importData(List<ApsPlatePlanTemp> tempList) throws Exception { String batchNum= IdUtils.fastUUID(); //判断导入数据是否为空 if (tempList.size() > 0) { List<SysDictData> dictDataList = DictUtils.getDictCache("aps_is_suspended"); for (int i = 0; i < tempList.size(); i++) { ApsPlatePlanTemp planTemp = tempList.get(i); for (int j = 0; j < dictDataList.size(); j++) { if (planTemp.getIsSuspendedTxt().equals(dictDataList.get(j).getDictLabel())) { planTemp.setIsSuspended(Integer.parseInt(dictDataList.get(j).getDictValue())); break; } } //插入版本号 planTemp.setBatchNumber(batchNum); //插入临时表 apsPlatePlanTempMapper.insertApsPlatePlanTemp(planTemp); } return batchNum ; } else { return Strings.EMPTY; } } }