From 400896cd17f5e9fe14744ec8e6ec96f6d665ed97 Mon Sep 17 00:00:00 2001 From: ljlong_2630 Date: Tue, 5 Dec 2023 14:35:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=BA=E7=A1=80=E9=A1=B5=E9=9D=A2=E9=83=A8?= =?UTF-8?q?=E5=88=86=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lzbi/module/base/BaseModuleEntity.java | 22 +++++ .../DcBaseWorkSpecialController.java | 92 ++++++++++++++++--- ...SpecialDao.java => DcBaseWorkSpecial.java} | 7 +- .../mapper/DcBaseWorkSpecialMapper.java | 22 ++--- .../service/DcBaseWorkSpecialService.java | 38 ++++---- .../mapper/asset/DcBaseWorkSpecialMapper.xml | 19 ++-- 6 files changed, 147 insertions(+), 53 deletions(-) rename lzbi-module/src/main/java/com/lzbi/special/domain/{DcBaseWorkSpecialDao.java => DcBaseWorkSpecial.java} (94%) diff --git a/lzbi-module/src/main/java/com/lzbi/module/base/BaseModuleEntity.java b/lzbi-module/src/main/java/com/lzbi/module/base/BaseModuleEntity.java index cfee29c..05ab81b 100644 --- a/lzbi-module/src/main/java/com/lzbi/module/base/BaseModuleEntity.java +++ b/lzbi-module/src/main/java/com/lzbi/module/base/BaseModuleEntity.java @@ -36,6 +36,12 @@ public class BaseModuleEntity implements Serializable,Cloneable{ /** 删除时间 */ @ApiModelProperty(name = "删除时间",notes = "") private Date deleteTime ; + /** 部门id */ + @ApiModelProperty(name = "部门id",notes = "") + private Long deptId ; + /** 用户id */ + @ApiModelProperty(name = "用户id",notes = "") + private Long userId ; public String getTenantId() { return tenantId; @@ -100,4 +106,20 @@ public class BaseModuleEntity implements Serializable,Cloneable{ public void setDeleteTime(Date deleteTime) { this.deleteTime = deleteTime; } + + public Long getDeptId() { + return deptId; + } + + public void setDeptId(Long deptId) { + this.deptId = deptId; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } } diff --git a/lzbi-module/src/main/java/com/lzbi/special/controller/DcBaseWorkSpecialController.java b/lzbi-module/src/main/java/com/lzbi/special/controller/DcBaseWorkSpecialController.java index 2ed7651..d02b40f 100644 --- a/lzbi-module/src/main/java/com/lzbi/special/controller/DcBaseWorkSpecialController.java +++ b/lzbi-module/src/main/java/com/lzbi/special/controller/DcBaseWorkSpecialController.java @@ -1,8 +1,15 @@ package com.lzbi.special.controller; +import java.time.LocalDateTime; +import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletResponse; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; +import com.lzbi.common.utils.DateUtils; +import com.lzbi.special.domain.DcBaseWorkSpecial; import com.lzbi.special.service.DcBaseWorkSpecialService; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; @@ -18,7 +25,6 @@ import com.lzbi.common.annotation.Log; import com.lzbi.common.core.controller.BaseController; import com.lzbi.common.core.domain.AjaxResult; import com.lzbi.common.enums.BusinessType; -import com.lzbi.special.domain.DcBaseWorkSpecialDao; import com.lzbi.common.utils.poi.ExcelUtil; import com.lzbi.common.core.page.TableDataInfo; @@ -40,10 +46,10 @@ public class DcBaseWorkSpecialController extends BaseController */ @PreAuthorize("@ss.hasPermi('special:specialManager:list')") @GetMapping("/list") - public TableDataInfo list(DcBaseWorkSpecialDao dcBaseWorkSpecialDao) + public TableDataInfo list(DcBaseWorkSpecial dcBaseWorkSpecial) { startPage(); - List list = dcBaseWorkSpecialService.selectDcBaseWorkSpecialDaoList(dcBaseWorkSpecialDao); + List list = dcBaseWorkSpecialService.selectDcBaseWorkSpecialDaoList(dcBaseWorkSpecial); return getDataTable(list); } @@ -53,10 +59,10 @@ public class DcBaseWorkSpecialController extends BaseController @PreAuthorize("@ss.hasPermi('special:specialManager:export')") @Log(title = "生产专业管理", businessType = BusinessType.EXPORT) @PostMapping("/export") - public void export(HttpServletResponse response, DcBaseWorkSpecialDao dcBaseWorkSpecialDao) + public void export(HttpServletResponse response, DcBaseWorkSpecial dcBaseWorkSpecial) { - List list = dcBaseWorkSpecialService.selectDcBaseWorkSpecialDaoList(dcBaseWorkSpecialDao); - ExcelUtil util = new ExcelUtil(DcBaseWorkSpecialDao.class); + List list = dcBaseWorkSpecialService.selectDcBaseWorkSpecialDaoList(dcBaseWorkSpecial); + ExcelUtil util = new ExcelUtil(DcBaseWorkSpecial.class); util.exportExcel(response, list, "生产专业管理数据"); } @@ -67,7 +73,7 @@ public class DcBaseWorkSpecialController extends BaseController @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { - return success(dcBaseWorkSpecialService.selectDcBaseWorkSpecialDaoById(id)); + return success(dcBaseWorkSpecialService.selectDcBaseWorkSpecialById(id)); } /** @@ -76,9 +82,9 @@ public class DcBaseWorkSpecialController extends BaseController @PreAuthorize("@ss.hasPermi('special:specialManager:add')") @Log(title = "生产专业管理", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody DcBaseWorkSpecialDao dcBaseWorkSpecialDao) + public AjaxResult add(@RequestBody DcBaseWorkSpecial dcBaseWorkSpecial) { - return toAjax(dcBaseWorkSpecialService.insertDcBaseWorkSpecialDao(dcBaseWorkSpecialDao)); + return toAjax(dcBaseWorkSpecialService.insertDcBaseWorkSpecial(dcBaseWorkSpecial)); } /** @@ -87,9 +93,9 @@ public class DcBaseWorkSpecialController extends BaseController @PreAuthorize("@ss.hasPermi('special:specialManager:edit')") @Log(title = "生产专业管理", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody DcBaseWorkSpecialDao dcBaseWorkSpecialDao) + public AjaxResult edit(@RequestBody DcBaseWorkSpecial dcBaseWorkSpecial) { - return toAjax(dcBaseWorkSpecialService.updateDcBaseWorkSpecialDao(dcBaseWorkSpecialDao)); + return toAjax(dcBaseWorkSpecialService.updateDcBaseWorkSpecialDao(dcBaseWorkSpecial)); } /** @@ -100,7 +106,7 @@ public class DcBaseWorkSpecialController extends BaseController @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { - return toAjax(dcBaseWorkSpecialService.deleteDcBaseWorkSpecialDaoByIds(ids)); + return toAjax(dcBaseWorkSpecialService.deleteDcBaseWorkSpecialByIds(ids)); } @@ -109,12 +115,70 @@ public class DcBaseWorkSpecialController extends BaseController */ @PreAuthorize("@ss.hasPermi('special:specialManager:list')") @GetMapping("/listNoPage") - public AjaxResult listNoPage(DcBaseWorkSpecialDao dcBaseWorkSpecialDao) + public AjaxResult listNoPage(DcBaseWorkSpecial dcBaseWorkSpecial) { - List list = dcBaseWorkSpecialService.selectDcBaseWorkSpecialDaoList(dcBaseWorkSpecialDao); + List list = dcBaseWorkSpecialService.selectDcBaseWorkSpecialDaoList(dcBaseWorkSpecial); return AjaxResult.success(list); } + /** + * 新增生产专业管理 + */ + @PreAuthorize("@ss.hasPermi('special:specialManager:add')") + @Log(title = "生产专业管理", businessType = BusinessType.INSERT) + @PostMapping("/addBatch") + public AjaxResult addBatch(@RequestBody JSONArray jsonArray) + { + if (jsonArray == null) { + throw new IllegalArgumentException("未能接收任何参数!"); + } + List beanList = new ArrayList<>(); + try { + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject beanObject = jsonArray.getJSONObject(i); + // 移除ID属性 + beanObject.remove("id"); + DcBaseWorkSpecial dcBaseWorkSpecial = JSON.toJavaObject(beanObject, DcBaseWorkSpecial.class); + dcBaseWorkSpecial.setCreatedTime(DateUtils.getNowDate()); + dcBaseWorkSpecial.setDeptId(getDeptId()); + dcBaseWorkSpecial.setUserId(getUserId()); + dcBaseWorkSpecial.setCreatedBy(String.valueOf(getUserId())); + dcBaseWorkSpecial.setCreatedTime(DateUtils.getNowDate()); + beanList.add(dcBaseWorkSpecial); + } + } catch (Exception e) { + throw new IllegalArgumentException("解析list对象异常!"); + } + return toAjax(dcBaseWorkSpecialService.saveBatch(beanList)); + } + + + /** + * 修改生产专业管理 + */ + @PreAuthorize("@ss.hasPermi('special:specialManager:edit')") + @Log(title = "生产专业管理", businessType = BusinessType.UPDATE) + @PutMapping("editBatch") + public AjaxResult editBatch(@RequestBody JSONArray jsonArray) + { + if (jsonArray == null) { + throw new IllegalArgumentException("未能接收任何参数!"); + } + List dcBaseWorkSpecialList = new ArrayList<>(); + try { + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject beanObject = jsonArray.getJSONObject(i); + DcBaseWorkSpecial dcBaseWorkSpecial = JSON.toJavaObject(beanObject, DcBaseWorkSpecial.class); + dcBaseWorkSpecial.setUpdatedBy(String.valueOf(getUserId())); + dcBaseWorkSpecial.setUpdatedTime(DateUtils.getNowDate()); + dcBaseWorkSpecialList.add(dcBaseWorkSpecial); + } + } catch (Exception e) { + throw new IllegalArgumentException("解析list对象异常!"); + } + return toAjax(dcBaseWorkSpecialService.updateBatchById(dcBaseWorkSpecialList)); + } + } diff --git a/lzbi-module/src/main/java/com/lzbi/special/domain/DcBaseWorkSpecialDao.java b/lzbi-module/src/main/java/com/lzbi/special/domain/DcBaseWorkSpecial.java similarity index 94% rename from lzbi-module/src/main/java/com/lzbi/special/domain/DcBaseWorkSpecialDao.java rename to lzbi-module/src/main/java/com/lzbi/special/domain/DcBaseWorkSpecial.java index abb9030..9ba942a 100644 --- a/lzbi-module/src/main/java/com/lzbi/special/domain/DcBaseWorkSpecialDao.java +++ b/lzbi-module/src/main/java/com/lzbi/special/domain/DcBaseWorkSpecial.java @@ -1,7 +1,9 @@ package com.lzbi.special.domain; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.lzbi.common.annotation.Excel; @@ -13,7 +15,7 @@ import com.lzbi.module.base.BaseModuleEntity; * @author win * @date 2023-11-28 */ -public class DcBaseWorkSpecialDao extends BaseModuleEntity +public class DcBaseWorkSpecial extends BaseModuleEntity { private static final long serialVersionUID = 1L; @@ -41,6 +43,7 @@ public class DcBaseWorkSpecialDao extends BaseModuleEntity /** 删除时间 */ private Date deleteTime; + @TableId(value = "id", type = IdType.AUTO) /** 主键 */ private Long id; diff --git a/lzbi-module/src/main/java/com/lzbi/special/mapper/DcBaseWorkSpecialMapper.java b/lzbi-module/src/main/java/com/lzbi/special/mapper/DcBaseWorkSpecialMapper.java index e2421e9..12f6b15 100644 --- a/lzbi-module/src/main/java/com/lzbi/special/mapper/DcBaseWorkSpecialMapper.java +++ b/lzbi-module/src/main/java/com/lzbi/special/mapper/DcBaseWorkSpecialMapper.java @@ -3,7 +3,7 @@ package com.lzbi.special.mapper; import java.util.List; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.lzbi.special.domain.DcBaseWorkSpecialDao; +import com.lzbi.special.domain.DcBaseWorkSpecial; /** @@ -13,7 +13,7 @@ import com.lzbi.special.domain.DcBaseWorkSpecialDao; * @date 2023-11-28 */ -public interface DcBaseWorkSpecialMapper extends BaseMapper +public interface DcBaseWorkSpecialMapper extends BaseMapper { /** * 查询生产专业管理 @@ -21,31 +21,31 @@ public interface DcBaseWorkSpecialMapper extends BaseMapper selectDcBaseWorkSpecialDaoList(DcBaseWorkSpecialDao dcBaseWorkSpecialDao); + public List selectDcBaseWorkSpecialList(DcBaseWorkSpecial dcBaseWorkSpecial); /** * 新增生产专业管理 * - * @param dcBaseWorkSpecialDao 生产专业管理 + * @param dcBaseWorkSpecial 生产专业管理 * @return 结果 */ - public int insertDcBaseWorkSpecialDao(DcBaseWorkSpecialDao dcBaseWorkSpecialDao); + public int insertDcBaseWorkSpecial(DcBaseWorkSpecial dcBaseWorkSpecial); /** * 修改生产专业管理 * - * @param dcBaseWorkSpecialDao 生产专业管理 + * @param dcBaseWorkSpecial 生产专业管理 * @return 结果 */ - public int updateDcBaseWorkSpecialDao(DcBaseWorkSpecialDao dcBaseWorkSpecialDao); + public int updateDcBaseWorkSpecial(DcBaseWorkSpecial dcBaseWorkSpecial); /** * 删除生产专业管理 @@ -53,7 +53,7 @@ public interface DcBaseWorkSpecialMapper extends BaseMapper implements IService +public class DcBaseWorkSpecialService extends ServiceImpl implements IService { @@ -26,47 +26,47 @@ public class DcBaseWorkSpecialService extends ServiceImpl selectDcBaseWorkSpecialDaoList(DcBaseWorkSpecialDao dcBaseWorkSpecialDao) + public List selectDcBaseWorkSpecialDaoList(DcBaseWorkSpecial dcBaseWorkSpecial) { - return baseMapper.selectDcBaseWorkSpecialDaoList(dcBaseWorkSpecialDao); + return baseMapper.selectDcBaseWorkSpecialList(dcBaseWorkSpecial); } /** * 新增生产专业管理 * - * @param dcBaseWorkSpecialDao 生产专业管理 + * @param dcBaseWorkSpecial 生产专业管理 * @return 结果 */ - public int insertDcBaseWorkSpecialDao(DcBaseWorkSpecialDao dcBaseWorkSpecialDao) + public int insertDcBaseWorkSpecial(DcBaseWorkSpecial dcBaseWorkSpecial) { - dcBaseWorkSpecialDao.setCreatedTime(DateUtils.getNowDate()); - return baseMapper.insertDcBaseWorkSpecialDao(dcBaseWorkSpecialDao); + dcBaseWorkSpecial.setCreatedTime(DateUtils.getNowDate()); + return baseMapper.insertDcBaseWorkSpecial(dcBaseWorkSpecial); } /** * 修改生产专业管理 * - * @param dcBaseWorkSpecialDao 生产专业管理 + * @param dcBaseWorkSpecial 生产专业管理 * @return 结果 */ - public int updateDcBaseWorkSpecialDao(DcBaseWorkSpecialDao dcBaseWorkSpecialDao) + public int updateDcBaseWorkSpecialDao(DcBaseWorkSpecial dcBaseWorkSpecial) { - dcBaseWorkSpecialDao.setUpdatedTime(DateUtils.getNowDate()); - return baseMapper.updateDcBaseWorkSpecialDao(dcBaseWorkSpecialDao); + dcBaseWorkSpecial.setUpdatedTime(DateUtils.getNowDate()); + return baseMapper.updateDcBaseWorkSpecial(dcBaseWorkSpecial); } /** @@ -76,9 +76,9 @@ public class DcBaseWorkSpecialService extends ServiceImpl - + @@ -22,20 +22,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select TENANT_ID, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME, DELETE_BY, DELETE_TIME, id, special_code, special_name from dc_base_work_special - and special_code = #{specialCode} and special_name like concat('%', #{specialName}, '%') + ORDER BY + CASE + WHEN updated_time IS NOT NULL AND updated_time > created_time THEN updated_time + ELSE created_time + END DESC - where id = #{id} - + insert into dc_base_work_special TENANT_ID, @@ -63,7 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + update dc_base_work_special TENANT_ID = #{tenantId}, @@ -80,11 +85,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} - + delete from dc_base_work_special where id = #{id} - + delete from dc_base_work_special where id in #{id}