From f65443d8abeaedc9d102324565e8368e7c9d90c8 Mon Sep 17 00:00:00 2001
From: 郑永安 <zyazyz250@sina.com>
Date: 星期一, 19 六月 2023 14:41:54 +0800
Subject: [PATCH] commit

---
 src/main/java/com/gk/firework/Service/ServiceImpl/StandardLawListServiceImpl.java |  137 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 137 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/gk/firework/Service/ServiceImpl/StandardLawListServiceImpl.java b/src/main/java/com/gk/firework/Service/ServiceImpl/StandardLawListServiceImpl.java
new file mode 100644
index 0000000..9147d40
--- /dev/null
+++ b/src/main/java/com/gk/firework/Service/ServiceImpl/StandardLawListServiceImpl.java
@@ -0,0 +1,137 @@
+package com.gk.firework.Service.ServiceImpl;
+
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gk.firework.Domain.Exception.BusinessException;
+import com.gk.firework.Domain.StandardLawList;
+import com.gk.firework.Domain.UserInfo;
+import com.gk.firework.Domain.Utils.Properties;
+import com.gk.firework.Domain.Utils.StringUtils;
+import com.gk.firework.Domain.Utils.UploadUtil;
+import com.gk.firework.Mapper.StandardLawListMapper;
+import com.gk.firework.Service.StandardLawListService;
+import com.gk.firework.Service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.List;
+
+@Service("standardLawListService")
+public class StandardLawListServiceImpl extends ServiceImpl<StandardLawListMapper, StandardLawList> implements StandardLawListService {
+
+    @Autowired
+    private UserService userService;
+    @Autowired
+    private StandardLawListMapper standardLawListMapper;
+
+    /**
+    * @Description: 适用法律法规分页查询
+    * @date 2021/5/8 13:54
+    */
+    @Override
+    public IPage selectPage(Page<StandardLawList> page, Map filter, UserInfo userInfo) {
+
+        UserInfo user = userService.getById(userInfo.getId());
+        Map<String, Object> params = new HashMap<>();
+        //菜单
+        //可视权限
+        {
+            params.put("enterprisenumber", user.getCompanynumber());
+            params.put("province", user.getProvince());
+            params.put("city", user.getCity());
+            params.put("district", user.getArea());
+            params.put("street", user.getTown());
+            params.put("committee", user.getCommunity());
+        }
+
+        params.put("filterProvince", filter.get("province"));
+        params.put("filterCity", filter.get("city"));
+        params.put("filterDistrict", filter.get("district"));
+        params.put("filterStreet", filter.get("street"));
+        params.put("filterCommittee", filter.get("committee"));
+        params.put("safetysupervision", filter.get("safetysupervision"));
+        params.put("enterprisename", filter.get("enterprisename"));
+        //按法律法规标准查
+        params.put("name", filter.get("name"));
+        List<StandardLawList> list =  standardLawListMapper.selectPages(page,params);
+        return page.setRecords(list);
+    }
+
+
+    /**
+    * @Description: 新增法律法规清单
+    * @date 2021/5/8 14:06
+    */
+    @Override
+    @Transactional
+    public void addStandardLawList(StandardLawList standardLawList, UserInfo userInfo) {
+        if (standardLawList.getFile() == null) {
+            throw new BusinessException("需要上传文件");
+        }
+
+        UserInfo user = userService.getById(userInfo.getId());
+        standardLawList.setCreateby(user.getId());
+        standardLawList.setCreatebyname(user.getUsername());
+        standardLawList.setCreatetime(new Date());
+        standardLawList.setValidflag(true);
+        standardLawList.setEnterprisenumber(user.getUsername());
+        standardLawList.setEnterprisename(user.getUsername());
+
+        assert standardLawList.getFile() != null;
+        try {
+            String name = UploadUtil.uploadFile(standardLawList.getFile(), Properties.standardPath);
+            standardLawList.setFilename(standardLawList.getFile().getOriginalFilename());
+            standardLawList.setUrl(Properties.standard + name);
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new BusinessException("上传文件失败");
+        }
+        this.save(standardLawList);
+    }
+
+
+    /**
+    * @Description: 修改法律法规清单
+    * @date 2021/5/8 14:07
+    */
+    @Override
+    public void modStandardLawList(StandardLawList standardLawList, UserInfo user) {
+        standardLawList.setUpdateby(user.getId());
+        standardLawList.setUpdatebyname(user.getUsername());
+        standardLawList.setUpdatetime(new Date());
+
+        try {
+            if (standardLawList.getFile() != null) {
+                String name = UploadUtil.uploadFile(standardLawList.getFile(), Properties.standardPath);
+                standardLawList.setFilename(standardLawList.getFile().getOriginalFilename());
+                standardLawList.setUrl(Properties.standard + name);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new BusinessException("上传文件失败");
+        }
+        this.updateById(standardLawList);
+    }
+
+
+    /**
+    * @Description: 删除法律法规清单
+    * @date 2021/5/8 14:11
+    */
+    @Override
+    public void delStandardLawList(Long id, UserInfo user) {
+        LambdaUpdateWrapper<StandardLawList> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.set(StandardLawList::getValidflag, false)
+                .set(StandardLawList::getUpdatetime, new Date())
+                .set(StandardLawList::getUpdateby, user.getId())
+                .set(StandardLawList::getUpdatebyname,user.getUsername())
+                .eq(StandardLawList::getId, id);
+        this.update(updateWrapper);
+    }
+}

--
Gitblit v1.9.2