浏览代码

文档列表

5 年之前
父节点
当前提交
1402e57429

+ 73 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/controller/MouldMaintainController.java

@@ -0,0 +1,73 @@
+package com.hssx.cloudmodel.controller;
+
+
+import com.hssx.cloudmodel.entity.MouldMaintain;
+import com.hssx.cloudmodel.entity.vo.MouldVO;
+import com.hssx.cloudmodel.entity.vo.UserVO;
+import com.hssx.cloudmodel.service.MouldMaintainService;
+import com.hssx.cloudmodel.util.HttpRespMsg;
+import com.hssx.cloudmodel.util.PageUtil;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-08-13
+ */
+@Controller
+@RequestMapping("/mouldmaintain")
+public class MouldMaintainController {
+
+    @Autowired
+    private MouldMaintainService mouldMaintainService;
+    @Value("${upload.path}")
+    private String path;
+    /**
+     *
+     * 模具保养
+     * file 文件,token 用户身份凭证 ,mouldId 模具id,maintainType 保养类型 0-动作 1-易损件
+     * 方式 :ways
+     * (0-喷漆 1-检查 )==》对应maintainType 保养类型 选择了0-动作
+     * (2-易损件) ==》对应maintainType 保养类型 选择了1-动作 (此时ways传易损件的id)
+     * @return
+     */
+    @ApiOperation("模具保养")
+    @RequestMapping("/maintain")
+    @ResponseBody
+    public HttpRespMsg maintain(@RequestParam(required = false) MultipartFile file, MouldMaintain mouldMaintain,String token){
+        HttpRespMsg msg = new HttpRespMsg();
+        msg = mouldMaintainService.addMaintain(file,path,mouldMaintain,token);
+        return msg;
+    }
+
+    /**
+     * 保养列表
+     * token 用户身份凭证,pageNum 当前页码,pageSize 每页条数
+     * @return
+     */
+    @ApiOperation("保养图片上传")
+    @RequestMapping("/list")
+    @ResponseBody
+    public HttpRespMsg uploadFile(String token, PageUtil page) throws Exception {
+        HttpRespMsg msg = new HttpRespMsg();
+        msg = mouldMaintainService.getList(token,page);
+        return msg;
+    }
+
+}
+

+ 212 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/entity/MouldMaintain.java

@@ -0,0 +1,212 @@
+package com.hssx.cloudmodel.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import com.baomidou.mybatisplus.annotation.TableField;
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-08-13
+ */
+@TableName("tb_mould_maintain")
+public class MouldMaintain extends Model<MouldMaintain> {
+
+    private static final long serialVersionUID=1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 模板id
+     */
+    @TableField("mould_id")
+    private Integer mouldId;
+
+    /**
+     * 保养类型 0-动作 1-易损件
+     */
+    @TableField("maintain_type")
+    private Integer maintainType;
+
+    /**
+     * 方式 0-喷漆 1-检查 2-易损件中选择
+     */
+    @TableField("ways")
+    private Integer ways;
+
+    /**
+     * 文件名称
+     */
+    @TableField("file_name")
+    private String fileName;
+
+    /**
+     * 文件上传路径
+     */
+    @TableField("file_url")
+    private String fileUrl;
+
+    /**
+     * 保养人id
+     */
+    @TableField("maintain_user_id")
+    private Integer maintainUserId;
+
+    /**
+     * 保养人姓名
+     */
+    @TableField("maintain_user_name")
+    private String maintainUserName;
+
+    /**
+     * 保养日期
+     */
+    @TableField("indate")
+    private LocalDateTime indate;
+
+    /**
+     * 是否需要保养0-不需要 1-需要
+     */
+    @TableField("is_maintain")
+    private Integer isMaintain;
+
+    /**
+     * 文件大小
+     */
+    @TableField("file_size")
+    private String fileSize;
+
+    /**
+     * 项目id
+     */
+    @TableField("project_id")
+    private Integer projectId;
+
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getMouldId() {
+        return mouldId;
+    }
+
+    public void setMouldId(Integer mouldId) {
+        this.mouldId = mouldId;
+    }
+
+    public Integer getMaintainType() {
+        return maintainType;
+    }
+
+    public void setMaintainType(Integer maintainType) {
+        this.maintainType = maintainType;
+    }
+
+    public Integer getWays() {
+        return ways;
+    }
+
+    public void setWays(Integer ways) {
+        this.ways = ways;
+    }
+
+    public String getFileName() {
+        return fileName;
+    }
+
+    public void setFileName(String fileName) {
+        this.fileName = fileName;
+    }
+
+    public String getFileUrl() {
+        return fileUrl;
+    }
+
+    public void setFileUrl(String fileUrl) {
+        this.fileUrl = fileUrl;
+    }
+
+    public Integer getMaintainUserId() {
+        return maintainUserId;
+    }
+
+    public void setMaintainUserId(Integer maintainUserId) {
+        this.maintainUserId = maintainUserId;
+    }
+
+    public String getMaintainUserName() {
+        return maintainUserName;
+    }
+
+    public void setMaintainUserName(String maintainUserName) {
+        this.maintainUserName = maintainUserName;
+    }
+
+    public LocalDateTime getIndate() {
+        return indate;
+    }
+
+    public void setIndate(LocalDateTime indate) {
+        this.indate = indate;
+    }
+
+    public Integer getIsMaintain() {
+        return isMaintain;
+    }
+
+    public void setIsMaintain(Integer isMaintain) {
+        this.isMaintain = isMaintain;
+    }
+
+    public String getFileSize() {
+        return fileSize;
+    }
+
+    public void setFileSize(String fileSize) {
+        this.fileSize = fileSize;
+    }
+
+    public Integer getProjectId() {
+        return projectId;
+    }
+
+    public void setProjectId(Integer projectId) {
+        this.projectId = projectId;
+    }
+
+    @Override
+    protected Serializable pkVal() {
+        return this.id;
+    }
+
+    @Override
+    public String toString() {
+        return "MouldMaintain{" +
+        "id=" + id +
+        ", mouldId=" + mouldId +
+        ", maintainType=" + maintainType +
+        ", ways=" + ways +
+        ", fileName=" + fileName +
+        ", fileUrl=" + fileUrl +
+        ", maintainUserId=" + maintainUserId +
+        ", maintainUserName=" + maintainUserName +
+        ", indate=" + indate +
+        ", isMaintain=" + isMaintain +
+        ", fileSize=" + fileSize +
+        ", projectId=" + projectId +
+        "}";
+    }
+}

+ 20 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/mapper/MouldMaintainMapper.java

@@ -0,0 +1,20 @@
+package com.hssx.cloudmodel.mapper;
+
+import com.hssx.cloudmodel.entity.MouldMaintain;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-08-13
+ */
+public interface MouldMaintainMapper extends BaseMapper<MouldMaintain> {
+
+    List<MouldMaintain> selectListByProject(@Param("list") List<Integer> proIds);
+}

+ 23 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/service/MouldMaintainService.java

@@ -0,0 +1,23 @@
+package com.hssx.cloudmodel.service;
+
+import com.hssx.cloudmodel.entity.MouldMaintain;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.hssx.cloudmodel.entity.vo.MouldVO;
+import com.hssx.cloudmodel.util.HttpRespMsg;
+import com.hssx.cloudmodel.util.PageUtil;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-08-13
+ */
+public interface MouldMaintainService extends IService<MouldMaintain> {
+
+    HttpRespMsg addMaintain(MultipartFile file, String path, MouldMaintain mouldMaintain,String token);
+
+    HttpRespMsg getList(String token,PageUtil page);
+}

+ 149 - 0
cloud-model/src/main/java/com/hssx/cloudmodel/service/impl/MouldMaintainServiceImpl.java

@@ -0,0 +1,149 @@
+package com.hssx.cloudmodel.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.hssx.cloudmodel.constant.Constant;
+import com.hssx.cloudmodel.entity.*;
+import com.hssx.cloudmodel.entity.vo.MouldFileVO;
+import com.hssx.cloudmodel.entity.vo.MouldVO;
+import com.hssx.cloudmodel.mapper.*;
+import com.hssx.cloudmodel.service.MouldMaintainService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.hssx.cloudmodel.util.FileUtil;
+import com.hssx.cloudmodel.util.HttpRespMsg;
+import com.hssx.cloudmodel.util.PageUtil;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * @author 吴涛涛
+ * @since 2019-08-13
+ */
+@Service
+public class MouldMaintainServiceImpl extends ServiceImpl<MouldMaintainMapper, MouldMaintain> implements MouldMaintainService {
+
+    @Resource
+    UserMapper userMapper;
+    @Resource
+    MouldMaintainMapper mouldMaintainMapper;
+    @Resource
+    CompanyMapper companyMapper;
+    @Resource
+    CustomCompanyMapper customCompanyMapper;
+    @Resource
+    MouldMapper mouldMapper;
+    @Resource
+    ProjectApproveMapper projectApproveMapper;
+    @Resource
+    ProjectMapper projectMapper;
+    @Resource
+    ProjectUserMapper projectUserMapper;
+
+    @Override
+    public HttpRespMsg addMaintain(MultipartFile file, String path, MouldMaintain mouldMaintain, String token) {
+        HttpRespMsg msg = new HttpRespMsg();
+        Mould mould = mouldMapper.selectById(mouldMaintain.getMouldId());
+        User user = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl", token));
+        if (user != null) {
+            if (file != null && !file.isEmpty()) {
+                File dir = null;
+                dir = new File(path);
+                // D://cloud/upload 文件上传后所存储的位置,部署到服务器上时配置服务器地址即可
+                if (!dir.exists()) {
+                    dir.mkdirs();
+                }
+                String fileName = "";
+                if (file != null && !file.isEmpty()) {
+                    fileName = file.getOriginalFilename();
+                    mouldMaintain.setFileName(fileName);
+                    mouldMaintain.setFileSize(FileUtil.getReadableFileSize(file.getSize()));
+                    System.out.println("上传文件名称" + file.getName() + ", dir = " + dir.getAbsolutePath());
+                    int pos = fileName.lastIndexOf(".");
+                    String rand = UUID.randomUUID().toString().replaceAll("-", "");
+                    String sufix = fileName.substring(pos);
+                    fileName = rand + sufix;
+                    mouldMaintain.setMaintainUserId(user.getId());
+                    mouldMaintain.setMaintainUserName(user.getUsername());
+                    mouldMaintain.setFileUrl("/upload/" + fileName);
+                    if(mould.getProjectId() != null){
+                        mouldMaintain.setProjectId(mould.getProjectId());
+                    }
+                    File saveFile = new File(dir, fileName);
+                    mouldMaintainMapper.insert(mouldMaintain);
+                    try {
+                        saveFile.createNewFile();
+                        file.transferTo(saveFile);
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                        mouldMaintain = null;
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                        mouldMaintain = null;
+                    }
+                }
+                msg.data = mouldMaintain;
+            }
+        }
+        return msg;
+    }
+
+    @Override
+    public HttpRespMsg getList(String token, PageUtil page) {
+        HttpRespMsg msg = new HttpRespMsg();
+        List<Integer> proIds = new ArrayList<>();
+        User currentUser = userMapper.selectOne(new QueryWrapper<User>().eq("head_imgurl", token));
+        List<MouldMaintain> mouldMaintains = new ArrayList<>();
+        if (currentUser != null) {
+            //资产方管理员,获取他公司下的所有模具
+            PageHelper.startPage(page.getPageNum(), page.getPageSize());
+            if (Constant.SYS_ID == currentUser.getParentId()) {
+                QueryWrapper<Project> qw = new QueryWrapper<>();
+                List<Project> projects = projectMapper.selectList(qw.eq("creator_id", currentUser.getId()));
+                for (Project pro : projects) {
+                    proIds.add(pro.getId());
+                }
+                mouldMaintains = mouldMaintainMapper.selectListByProject(proIds);
+            } else if (Constant.SYS_PARENT_ID == currentUser.getParentId()) {
+                //系统管理员
+                mouldMaintains = mouldMaintainMapper.selectList(new QueryWrapper<MouldMaintain>());
+            } else {
+                QueryWrapper<Project> qw = new QueryWrapper<>();
+                qw.eq("manager_id", currentUser.getId());
+                List<Project> projects = projectMapper.selectList(qw);
+                if (projects.size() > 0) {
+                    for (Project project : projects) {
+                        proIds.add(project.getId());
+                    }
+                }
+//                //充当普通人员参与的项目
+                List<ProjectUser> projectUsers = projectUserMapper.selectList(new QueryWrapper<ProjectUser>().eq("user_id",currentUser.getId()));
+                if (projectUsers.size() > 0) {
+                    for (ProjectUser projectUser : projectUsers) {
+                        proIds.add(projectUser.getProjectId());
+                    }
+                }
+                //充当审批人员参与的项目
+                List<ProjectApprove> projectss = projectApproveMapper.selectList(new QueryWrapper<ProjectApprove>().eq("approver_id", currentUser.getId()));
+                if (projectss.size() > 0) {
+                    for (ProjectApprove projectUser : projectss) {
+                        proIds.add(projectUser.getProjectId());
+                    }
+                }
+                mouldMaintains = mouldMaintainMapper.selectListByProject(proIds);
+            }
+            PageInfo<MouldMaintain> pageInfos = new PageInfo<>(mouldMaintains);
+            msg.data = pageInfos;
+        } else {
+            msg.setError("用户不存在或者未登录");
+        }
+            return msg;
+        }
+    }

+ 39 - 0
cloud-model/src/main/resources/mapper/MouldMaintainMapper.xml

@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.hssx.cloudmodel.mapper.MouldMaintainMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.hssx.cloudmodel.entity.MouldMaintain">
+        <id column="id" property="id" />
+        <result column="mould_id" property="mouldId" />
+        <result column="maintain_type" property="maintainType" />
+        <result column="ways" property="ways" />
+        <result column="file_name" property="fileName" />
+        <result column="file_url" property="fileUrl" />
+        <result column="maintain_user_id" property="maintainUserId" />
+        <result column="maintain_user_name" property="maintainUserName" />
+        <result column="indate" property="indate" />
+        <result column="is_maintain" property="isMaintain" />
+        <result column="file_size" property="fileSize" />
+        <result column="project_id" property="projectId" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id, mould_id, maintain_type, ways, file_name, file_url, maintain_user_id, maintain_user_name, indate, is_maintain, file_size, project_id
+    </sql>
+
+    <select id="selectListByProject" resultMap="BaseResultMap">
+        select
+          id, mould_id, maintain_type, ways, file_name, file_url,
+          maintain_user_id, maintain_user_name, indate, is_maintain, file_size, project_id
+        from
+          tb_mould_maintain
+        <where>
+            project_id in
+            <foreach collection="list" separator="," close=")" item="item" open="(" index="index">
+                #{item}
+            </foreach>
+        </where>
+    </select>
+</mapper>