java110 лет назад: 3
Родитель
Сommit
f20966d00f

+ 11 - 0
java110-bean/src/main/java/com/java110/dto/data/ExportDataDto.java

@@ -12,6 +12,9 @@ public class ExportDataDto implements Serializable{
 
     private String fileName;
 
+    private String downloadId;
+
+
     public String getBusinessAdapt() {
         return businessAdapt;
     }
@@ -35,4 +38,12 @@ public class ExportDataDto implements Serializable{
     public void setFileName(String fileName) {
         this.fileName = fileName;
     }
+
+    public String getDownloadId() {
+        return downloadId;
+    }
+
+    public void setDownloadId(String downloadId) {
+        this.downloadId = downloadId;
+    }
 }

+ 135 - 0
java110-bean/src/main/java/com/java110/dto/userDownloadFile/UserDownloadFileDto.java

@@ -0,0 +1,135 @@
+package com.java110.dto.userDownloadFile;
+
+import com.java110.dto.PageDto;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @ClassName FloorDto
+ * @Description 文件下载数据层封装
+ * @Author wuxw
+ * @Date 2019/4/24 8:52
+ * @Version 1.0
+ * add by wuxw 2019/4/24
+ **/
+public class UserDownloadFileDto extends PageDto implements Serializable {
+
+    //等待 生成文件
+    public static final String STATE_WAIT = "1001";
+
+    // 生成文件中
+    public static final String STATE_DOING = "2002";
+
+    // 文件生成完成
+    public static final String STATE_FINISH = "3003";
+
+    //生成失败
+    public static final String STATE_FAIL = "4004";
+
+    private String name;
+    private String downloadId;
+    private String downloadUserId;
+    private String state;
+    private String tempUrl;
+    private String communityId;
+    private String downloadUserName;
+    private String fileType;
+
+
+    private Date createTime;
+
+    private String statusCd = "0";
+
+    private String remark;
+
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDownloadId() {
+        return downloadId;
+    }
+
+    public void setDownloadId(String downloadId) {
+        this.downloadId = downloadId;
+    }
+
+    public String getDownloadUserId() {
+        return downloadUserId;
+    }
+
+    public void setDownloadUserId(String downloadUserId) {
+        this.downloadUserId = downloadUserId;
+    }
+
+    public String getState() {
+        return state;
+    }
+
+    public void setState(String state) {
+        this.state = state;
+    }
+
+    public String getTempUrl() {
+        return tempUrl;
+    }
+
+    public void setTempUrl(String tempUrl) {
+        this.tempUrl = tempUrl;
+    }
+
+    public String getCommunityId() {
+        return communityId;
+    }
+
+    public void setCommunityId(String communityId) {
+        this.communityId = communityId;
+    }
+
+    public String getDownloadUserName() {
+        return downloadUserName;
+    }
+
+    public void setDownloadUserName(String downloadUserName) {
+        this.downloadUserName = downloadUserName;
+    }
+
+    public String getFileType() {
+        return fileType;
+    }
+
+    public void setFileType(String fileType) {
+        this.fileType = fileType;
+    }
+
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getStatusCd() {
+        return statusCd;
+    }
+
+    public void setStatusCd(String statusCd) {
+        this.statusCd = statusCd;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+}

+ 122 - 0
java110-bean/src/main/java/com/java110/po/userDownloadFile/UserDownloadFilePo.java

@@ -0,0 +1,122 @@
+/*
+ * Copyright 2017-2020 吴学文 and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.java110.po.userDownloadFile;
+
+import java.io.Serializable;
+
+/**
+ * 类表述: Po 数据模型实体对象 基本保持与数据库模型一直 用于 增加修改删除 等时的数据载体
+ * add by 吴学文 at 2022-10-19 17:00:35 mail: 928255095@qq.com
+ * open source address: https://gitee.com/wuxw7/MicroCommunity
+ * 官网:http://www.homecommunity.cn
+ * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下
+ * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行
+ */
+public class UserDownloadFilePo implements Serializable {
+
+    private String name;
+    private String downloadId;
+    private String downloadUserId;
+    private String statusCd = "0";
+    private String state;
+    private String tempUrl;
+    private String communityId;
+    private String downloadUserName;
+    private String fileType;
+
+    private String remark;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDownloadId() {
+        return downloadId;
+    }
+
+    public void setDownloadId(String downloadId) {
+        this.downloadId = downloadId;
+    }
+
+    public String getDownloadUserId() {
+        return downloadUserId;
+    }
+
+    public void setDownloadUserId(String downloadUserId) {
+        this.downloadUserId = downloadUserId;
+    }
+
+    public String getStatusCd() {
+        return statusCd;
+    }
+
+    public void setStatusCd(String statusCd) {
+        this.statusCd = statusCd;
+    }
+
+    public String getState() {
+        return state;
+    }
+
+    public void setState(String state) {
+        this.state = state;
+    }
+
+    public String getTempUrl() {
+        return tempUrl;
+    }
+
+    public void setTempUrl(String tempUrl) {
+        this.tempUrl = tempUrl;
+    }
+
+    public String getCommunityId() {
+        return communityId;
+    }
+
+    public void setCommunityId(String communityId) {
+        this.communityId = communityId;
+    }
+
+    public String getDownloadUserName() {
+        return downloadUserName;
+    }
+
+    public void setDownloadUserName(String downloadUserName) {
+        this.downloadUserName = downloadUserName;
+    }
+
+    public String getFileType() {
+        return fileType;
+    }
+
+    public void setFileType(String fileType) {
+        this.fileType = fileType;
+    }
+
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+}

+ 134 - 0
java110-db/src/main/resources/mapper/job/UserDownloadFileV1ServiceDaoImplMapper.xml

@@ -0,0 +1,134 @@
+<?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="userDownloadFileV1ServiceDaoImpl">
+
+
+    <!-- 保存文件下载信息 add by wuxw 2018-07-03 -->
+    <insert id="saveUserDownloadFileInfo" parameterType="Map">
+        insert into user_download_file(
+        name,download_id,download_user_id,state,temp_url,community_id,download_user_name,file_type
+        ) values (
+        #{name},#{downloadId},#{downloadUserId},#{state},#{tempUrl},#{communityId},#{downloadUserName},#{fileType}
+        )
+    </insert>
+
+
+    <!-- 查询文件下载信息 add by wuxw 2018-07-03 -->
+    <select id="getUserDownloadFileInfo" parameterType="Map" resultType="Map">
+        select t.name,t.download_id,t.download_id downloadId,t.download_user_id,t.download_user_id
+        downloadUserId,t.status_cd,t.status_cd statusCd,t.state,t.temp_url,t.temp_url
+        tempUrl,t.community_id,t.community_id communityId,t.download_user_name,t.download_user_name
+        downloadUserName,t.file_type,t.file_type fileType
+        from user_download_file t
+        where 1 =1
+        <if test="name !=null and name != ''">
+            and t.name= #{name}
+        </if>
+        <if test="downloadId !=null and downloadId != ''">
+            and t.download_id= #{downloadId}
+        </if>
+        <if test="downloadUserId !=null and downloadUserId != ''">
+            and t.download_user_id= #{downloadUserId}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="state !=null and state != ''">
+            and t.state= #{state}
+        </if>
+        <if test="tempUrl !=null and tempUrl != ''">
+            and t.temp_url= #{tempUrl}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        <if test="downloadUserName !=null and downloadUserName != ''">
+            and t.download_user_name= #{downloadUserName}
+        </if>
+        <if test="fileType !=null and fileType != ''">
+            and t.file_type= #{fileType}
+        </if>
+        order by t.create_time desc
+        <if test="page != -1 and page != null ">
+            limit #{page}, #{row}
+        </if>
+
+    </select>
+
+
+    <!-- 修改文件下载信息 add by wuxw 2018-07-03 -->
+    <update id="updateUserDownloadFileInfo" parameterType="Map">
+        update user_download_file t set t.status_cd = #{statusCd}
+        <if test="newBId != null and newBId != ''">
+            ,t.b_id = #{newBId}
+        </if>
+        <if test="name !=null and name != ''">
+            , t.name= #{name}
+        </if>
+        <if test="downloadUserId !=null and downloadUserId != ''">
+            , t.download_user_id= #{downloadUserId}
+        </if>
+        <if test="state !=null and state != ''">
+            , t.state= #{state}
+        </if>
+        <if test="tempUrl !=null and tempUrl != ''">
+            , t.temp_url= #{tempUrl}
+        </if>
+        <if test="remark !=null and remark != ''">
+            , t.remark= #{remark}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            , t.community_id= #{communityId}
+        </if>
+        <if test="downloadUserName !=null and downloadUserName != ''">
+            , t.download_user_name= #{downloadUserName}
+        </if>
+        <if test="fileType !=null and fileType != ''">
+            , t.file_type= #{fileType}
+        </if>
+        where 1=1
+        <if test="downloadId !=null and downloadId != ''">
+            and t.download_id= #{downloadId}
+        </if>
+
+    </update>
+
+    <!-- 查询文件下载数量 add by wuxw 2018-07-03 -->
+    <select id="queryUserDownloadFilesCount" parameterType="Map" resultType="Map">
+        select count(1) count
+        from user_download_file t
+        where 1 =1
+        <if test="name !=null and name != ''">
+            and t.name= #{name}
+        </if>
+        <if test="downloadId !=null and downloadId != ''">
+            and t.download_id= #{downloadId}
+        </if>
+        <if test="downloadUserId !=null and downloadUserId != ''">
+            and t.download_user_id= #{downloadUserId}
+        </if>
+        <if test="statusCd !=null and statusCd != ''">
+            and t.status_cd= #{statusCd}
+        </if>
+        <if test="state !=null and state != ''">
+            and t.state= #{state}
+        </if>
+        <if test="tempUrl !=null and tempUrl != ''">
+            and t.temp_url= #{tempUrl}
+        </if>
+        <if test="communityId !=null and communityId != ''">
+            and t.community_id= #{communityId}
+        </if>
+        <if test="downloadUserName !=null and downloadUserName != ''">
+            and t.download_user_name= #{downloadUserName}
+        </if>
+        <if test="fileType !=null and fileType != ''">
+            and t.file_type= #{fileType}
+        </if>
+
+
+    </select>
+
+</mapper>

+ 68 - 0
java110-interface/src/main/java/com/java110/intf/job/IUserDownloadFileV1InnerServiceSMO.java

@@ -0,0 +1,68 @@
+/*
+ * Copyright 2017-2020 吴学文 and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.java110.intf.job;
+
+import com.java110.config.feign.FeignConfiguration;
+import com.java110.dto.userDownloadFile.UserDownloadFileDto;
+import com.java110.po.userDownloadFile.UserDownloadFilePo;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import java.util.List;
+
+/**
+ * 类表述: 服务之前调用的接口类,不对外提供接口能力 只用于接口建调用
+ * add by 吴学文 at 2022-10-19 17:00:35 mail: 928255095@qq.com
+ * open source address: https://gitee.com/wuxw7/MicroCommunity
+ * 官网:http://www.homecommunity.cn
+ * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下
+ * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行
+ */
+@FeignClient(name = "job-service", configuration = {FeignConfiguration.class})
+@RequestMapping("/userDownloadFileV1Api")
+public interface IUserDownloadFileV1InnerServiceSMO {
+
+
+    @RequestMapping(value = "/saveUserDownloadFile", method = RequestMethod.POST)
+    public int saveUserDownloadFile(@RequestBody  UserDownloadFilePo userDownloadFilePo);
+
+    @RequestMapping(value = "/updateUserDownloadFile", method = RequestMethod.POST)
+    public int updateUserDownloadFile(@RequestBody  UserDownloadFilePo userDownloadFilePo);
+
+    @RequestMapping(value = "/deleteUserDownloadFile", method = RequestMethod.POST)
+    public int deleteUserDownloadFile(@RequestBody  UserDownloadFilePo userDownloadFilePo);
+
+    /**
+     * <p>查询小区楼信息</p>
+     *
+     *
+     * @param userDownloadFileDto 数据对象分享
+     * @return UserDownloadFileDto 对象数据
+     */
+    @RequestMapping(value = "/queryUserDownloadFiles", method = RequestMethod.POST)
+    List<UserDownloadFileDto> queryUserDownloadFiles(@RequestBody UserDownloadFileDto userDownloadFileDto);
+
+    /**
+     * 查询<p>小区楼</p>总记录数
+     *
+     * @param userDownloadFileDto 数据对象分享
+     * @return 小区下的小区楼记录数
+     */
+    @RequestMapping(value = "/queryUserDownloadFilesCount", method = RequestMethod.POST)
+    int queryUserDownloadFilesCount(@RequestBody UserDownloadFileDto userDownloadFileDto);
+}

+ 63 - 2
service-job/src/main/java/com/java110/job/cmd/export/ExportDataCmd.java

@@ -5,16 +5,39 @@ import com.java110.core.annotation.Java110Cmd;
 import com.java110.core.context.ICmdDataFlowContext;
 import com.java110.core.event.cmd.Cmd;
 import com.java110.core.event.cmd.CmdEvent;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.dto.data.ExportDataDto;
+import com.java110.dto.user.UserDto;
+import com.java110.dto.userDownloadFile.UserDownloadFileDto;
+import com.java110.intf.job.IUserDownloadFileV1InnerServiceSMO;
+import com.java110.intf.user.IUserV1InnerServiceSMO;
+import com.java110.job.export.ExportDataQueue;
+import com.java110.po.userDownloadFile.UserDownloadFilePo;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
+import com.java110.utils.util.DateUtil;
+import com.java110.vo.ResultVo;
+import org.springframework.beans.factory.annotation.Autowired;
 
-import java.text.ParseException;
+import java.util.List;
 
 /**
  * 数据导出处理类
  */
 @Java110Cmd(serviceCode = "export.exportData")
 public class ExportDataCmd extends Cmd {
+
+    private static final String EXPORT_DATA_PRE = "hc/temp/export/data/";
+
+    public static final String CODE_PREFIX_ID = "10";
+
+    @Autowired
+    private IUserDownloadFileV1InnerServiceSMO userDownloadFileV1InnerServiceSMOImpl;
+
+
+    @Autowired
+    private IUserV1InnerServiceSMO userV1InnerServiceSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
         Assert.hasKeyAndValue(reqJson, "communityId", "请求中未包含小区");
@@ -22,9 +45,47 @@ public class ExportDataCmd extends Cmd {
     }
 
     @Override
-    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
+
+        String userId = context.getReqHeaders().get("user-id");
+
+        UserDto userDto = new UserDto();
+        userDto.setUserId(userId);
+        List<UserDto> userDtos = userV1InnerServiceSMOImpl.queryUsers(userDto);
+
+        Assert.listOnlyOne(userDtos, "用户不存在");
+
+        ExportDataDto exportDataDto = new ExportDataDto();
+        exportDataDto.setBusinessAdapt(reqJson.getString("pagePath"));
+        exportDataDto.setReqJson(reqJson);
+        String fileName = DateUtil.getyyyyMMddhhmmssDateString()
+                + ".xlsx";
+        exportDataDto.setFileName(exportDataDto
+                + reqJson.getString("pagePath")
+                + "/"
+                + DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_B)
+                + "/"
+                + fileName);
+
+        UserDownloadFilePo userDownloadFilePo = new UserDownloadFilePo();
+        userDownloadFilePo.setDownloadId(GenerateCodeFactory.getGeneratorId(CODE_PREFIX_ID));
+        userDownloadFilePo.setDownloadUserId(userId);
+        userDownloadFilePo.setDownloadUserName(userDtos.get(0).getUserName());
+        userDownloadFilePo.setFileType(reqJson.getString("pagePath"));
+        userDownloadFilePo.setCommunityId(reqJson.getString("communityId"));
+        userDownloadFilePo.setName(fileName);
+        userDownloadFilePo.setState(UserDownloadFileDto.STATE_WAIT);
+        int flag = userDownloadFileV1InnerServiceSMOImpl.saveUserDownloadFile(userDownloadFilePo);
+
+        if (flag < 1) {
+            throw new CmdException("下载文件失败");
+        }
+
+        exportDataDto.setDownloadId(userDownloadFilePo.getDownloadId());
 
+        ExportDataQueue.addMsg(exportDataDto);
 
 
+        context.setResponseEntity(ResultVo.createResponseEntity(ResultVo.CODE_OK,"文件正在生成,请到文件下载页面下载"));
     }
 }

+ 71 - 0
service-job/src/main/java/com/java110/job/cmd/userDownloadFile/DeleteUserDownloadFileCmd.java

@@ -0,0 +1,71 @@
+/*
+ * Copyright 2017-2020 吴学文 and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.java110.job.cmd.userDownloadFile;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.annotation.Java110Cmd;
+import com.java110.core.annotation.Java110Transactional;
+import com.java110.core.context.ICmdDataFlowContext;
+import com.java110.core.event.cmd.Cmd;
+import com.java110.core.event.cmd.CmdEvent;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.intf.job.IUserDownloadFileV1InnerServiceSMO;
+import com.java110.po.userDownloadFile.UserDownloadFilePo;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
+import com.java110.vo.ResultVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+/**
+ * 类表述:删除
+ * 服务编码:userDownloadFile.deleteUserDownloadFile
+ * 请求路劲:/app/userDownloadFile.DeleteUserDownloadFile
+ * add by 吴学文 at 2022-10-19 17:00:35 mail: 928255095@qq.com
+ * open source address: https://gitee.com/wuxw7/MicroCommunity
+ * 官网:http://www.homecommunity.cn
+ * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下
+ * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行
+ */
+@Java110Cmd(serviceCode = "userDownloadFile.deleteUserDownloadFile")
+public class DeleteUserDownloadFileCmd extends Cmd {
+  private static Logger logger = LoggerFactory.getLogger(DeleteUserDownloadFileCmd.class);
+
+    @Autowired
+    private IUserDownloadFileV1InnerServiceSMO userDownloadFileV1InnerServiceSMOImpl;
+
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
+        Assert.hasKeyAndValue(reqJson, "downloadId", "downloadId不能为空");
+Assert.hasKeyAndValue(reqJson, "communityId", "communityId不能为空");
+
+    }
+
+    @Override
+    @Java110Transactional
+    public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
+
+       UserDownloadFilePo userDownloadFilePo = BeanConvertUtil.covertBean(reqJson, UserDownloadFilePo.class);
+        int flag = userDownloadFileV1InnerServiceSMOImpl.deleteUserDownloadFile(userDownloadFilePo);
+
+        if (flag < 1) {
+            throw new CmdException("删除数据失败");
+        }
+
+        cmdDataFlowContext.setResponseEntity(ResultVo.success());
+    }
+}

+ 84 - 0
service-job/src/main/java/com/java110/job/cmd/userDownloadFile/ListUserDownloadFileCmd.java

@@ -0,0 +1,84 @@
+/*
+ * Copyright 2017-2020 吴学文 and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.java110.job.cmd.userDownloadFile;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.annotation.Java110Cmd;
+import com.java110.core.annotation.Java110Transactional;
+import com.java110.core.context.ICmdDataFlowContext;
+import com.java110.core.event.cmd.Cmd;
+import com.java110.core.event.cmd.CmdEvent;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.intf.job.IUserDownloadFileV1InnerServiceSMO;
+import com.java110.po.userDownloadFile.UserDownloadFilePo;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
+import com.java110.vo.ResultVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import com.java110.dto.userDownloadFile.UserDownloadFileDto;
+import java.util.List;
+import java.util.ArrayList;
+import org.springframework.http.ResponseEntity;
+import org.springframework.http.HttpStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * 类表述:查询
+ * 服务编码:userDownloadFile.listUserDownloadFile
+ * 请求路劲:/app/userDownloadFile.ListUserDownloadFile
+ * add by 吴学文 at 2022-10-19 17:00:35 mail: 928255095@qq.com
+ * open source address: https://gitee.com/wuxw7/MicroCommunity
+ * 官网:http://www.homecommunity.cn
+ * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下
+ * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行
+ */
+@Java110Cmd(serviceCode = "userDownloadFile.listUserDownloadFile")
+public class ListUserDownloadFileCmd extends Cmd {
+
+  private static Logger logger = LoggerFactory.getLogger(ListUserDownloadFileCmd.class);
+    @Autowired
+    private IUserDownloadFileV1InnerServiceSMO userDownloadFileV1InnerServiceSMOImpl;
+
+    @Override
+    public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
+        super.validatePageInfo(reqJson);
+    }
+
+    @Override
+    public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
+
+           UserDownloadFileDto userDownloadFileDto = BeanConvertUtil.covertBean(reqJson, UserDownloadFileDto.class);
+
+           int count = userDownloadFileV1InnerServiceSMOImpl.queryUserDownloadFilesCount(userDownloadFileDto);
+
+           List<UserDownloadFileDto> userDownloadFileDtos = null;
+
+           if (count > 0) {
+               userDownloadFileDtos = userDownloadFileV1InnerServiceSMOImpl.queryUserDownloadFiles(userDownloadFileDto);
+           } else {
+               userDownloadFileDtos = new ArrayList<>();
+           }
+
+           ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reqJson.getInteger("row")), count, userDownloadFileDtos);
+
+           ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
+
+           cmdDataFlowContext.setResponseEntity(responseEntity);
+    }
+}

+ 77 - 0
service-job/src/main/java/com/java110/job/dao/IUserDownloadFileV1ServiceDao.java

@@ -0,0 +1,77 @@
+/*
+ * Copyright 2017-2020 吴学文 and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.java110.job.dao;
+
+
+import com.java110.utils.exception.DAOException;
+import com.java110.entity.merchant.BoMerchant;
+import com.java110.entity.merchant.BoMerchantAttr;
+import com.java110.entity.merchant.Merchant;
+import com.java110.entity.merchant.MerchantAttr;
+
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 类表述:
+ * add by 吴学文 at 2022-10-19 17:00:35 mail: 928255095@qq.com
+ * open source address: https://gitee.com/wuxw7/MicroCommunity
+ * 官网:http://www.homecommunity.cn
+ * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下
+ * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行
+ */
+public interface IUserDownloadFileV1ServiceDao {
+
+
+    /**
+     * 保存 文件下载信息
+     * @param info
+     * @throws DAOException DAO异常
+     */
+    int saveUserDownloadFileInfo(Map info) throws DAOException;
+
+
+
+
+    /**
+     * 查询文件下载信息(instance过程)
+     * 根据bId 查询文件下载信息
+     * @param info bId 信息
+     * @return 文件下载信息
+     * @throws DAOException DAO异常
+     */
+    List<Map> getUserDownloadFileInfo(Map info) throws DAOException;
+
+
+
+    /**
+     * 修改文件下载信息
+     * @param info 修改信息
+     * @throws DAOException DAO异常
+     */
+    int updateUserDownloadFileInfo(Map info) throws DAOException;
+
+
+    /**
+     * 查询文件下载总数
+     *
+     * @param info 文件下载信息
+     * @return 文件下载数量
+     */
+    int queryUserDownloadFilesCount(Map info);
+
+}

+ 112 - 0
service-job/src/main/java/com/java110/job/dao/impl/UserDownloadFileV1ServiceDaoImpl.java

@@ -0,0 +1,112 @@
+/*
+ * Copyright 2017-2020 吴学文 and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.java110.job.dao.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.utils.constant.ResponseConstant;
+import com.java110.utils.exception.DAOException;
+import com.java110.utils.util.DateUtil;
+import com.java110.core.base.dao.BaseServiceDao;
+import com.java110.job.dao.IUserDownloadFileV1ServiceDao;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 类表述:
+ * add by 吴学文 at 2022-10-19 17:00:35 mail: 928255095@qq.com
+ * open source address: https://gitee.com/wuxw7/MicroCommunity
+ * 官网:http://www.homecommunity.cn
+ * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下
+ * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行
+ */
+@Service("userDownloadFileV1ServiceDaoImpl")
+public class UserDownloadFileV1ServiceDaoImpl extends BaseServiceDao implements IUserDownloadFileV1ServiceDao {
+
+    private static Logger logger = LoggerFactory.getLogger(UserDownloadFileV1ServiceDaoImpl.class);
+
+
+
+
+
+    /**
+     * 保存文件下载信息 到 instance
+     * @param info   bId 信息
+     * @throws DAOException DAO异常
+     */
+    @Override
+    public int saveUserDownloadFileInfo(Map info) throws DAOException {
+        logger.debug("保存 saveUserDownloadFileInfo 入参 info : {}",info);
+
+        int saveFlag = sqlSessionTemplate.insert("userDownloadFileV1ServiceDaoImpl.saveUserDownloadFileInfo",info);
+
+        return saveFlag;
+    }
+
+
+    /**
+     * 查询文件下载信息(instance)
+     * @param info bId 信息
+     * @return List<Map>
+     * @throws DAOException DAO异常
+     */
+    @Override
+    public List<Map> getUserDownloadFileInfo(Map info) throws DAOException {
+        logger.debug("查询 getUserDownloadFileInfo 入参 info : {}",info);
+
+        List<Map> businessUserDownloadFileInfos = sqlSessionTemplate.selectList("userDownloadFileV1ServiceDaoImpl.getUserDownloadFileInfo",info);
+
+        return businessUserDownloadFileInfos;
+    }
+
+
+    /**
+     * 修改文件下载信息
+     * @param info 修改信息
+     * @throws DAOException DAO异常
+     */
+    @Override
+    public int updateUserDownloadFileInfo(Map info) throws DAOException {
+        logger.debug("修改 updateUserDownloadFileInfo 入参 info : {}",info);
+
+        int saveFlag = sqlSessionTemplate.update("userDownloadFileV1ServiceDaoImpl.updateUserDownloadFileInfo",info);
+
+        return saveFlag;
+    }
+
+     /**
+     * 查询文件下载数量
+     * @param info 文件下载信息
+     * @return 文件下载数量
+     */
+    @Override
+    public int queryUserDownloadFilesCount(Map info) {
+        logger.debug("查询 queryUserDownloadFilesCount 入参 info : {}",info);
+
+        List<Map> businessUserDownloadFileInfos = sqlSessionTemplate.selectList("userDownloadFileV1ServiceDaoImpl.queryUserDownloadFilesCount", info);
+        if (businessUserDownloadFileInfos.size() < 1) {
+            return 0;
+        }
+
+        return Integer.parseInt(businessUserDownloadFileInfos.get(0).get("count").toString());
+    }
+
+
+}

+ 49 - 28
service-job/src/main/java/com/java110/job/export/ExportDataExecutor.java

@@ -1,39 +1,47 @@
 package com.java110.job.export;
 
-import com.java110.core.client.*;
+import com.java110.core.client.FileUploadTemplate;
 import com.java110.core.log.LoggerFactory;
 import com.java110.dto.data.ExportDataDto;
-import com.java110.utils.cache.MappingCache;
+import com.java110.dto.userDownloadFile.UserDownloadFileDto;
+import com.java110.intf.job.IUserDownloadFileV1InnerServiceSMO;
+import com.java110.po.userDownloadFile.UserDownloadFilePo;
 import com.java110.utils.factory.ApplicationContextFactory;
-import com.java110.utils.util.COSUtil;
-import com.java110.utils.util.OSSUtil;
+import com.java110.utils.util.ExceptionUtil;
+import com.java110.utils.util.StringUtil;
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
 import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.util.List;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
 /**
  * 导出数据执行器
  */
-public class ExportDataExecutor implements Runnable{
+public class ExportDataExecutor implements Runnable {
     private static final Logger log = LoggerFactory.getLogger(ExportDataQueue.class);
 
+    private IUserDownloadFileV1InnerServiceSMO userDownloadFileV1InnerServiceSMOImpl;
+
+    private FileUploadTemplate fileUploadTemplate;
 
     //默认线程大小
     private static final int DEFAULT_EXPORT_POOL = 4;
 
+    public ExportDataExecutor() {
+        this.userDownloadFileV1InnerServiceSMOImpl = ApplicationContextFactory.getBean("userDownloadFileV1InnerServiceSMOImpl", IUserDownloadFileV1InnerServiceSMO.class);
+        this.fileUploadTemplate = ApplicationContextFactory.getBean("fileUploadTemplate", FileUploadTemplate.class);
+    }
+
     @Override
     public void run() {
 
         try {
             doExportData();
-        }catch (Exception e){
-            log.error("处理消息异常",e);
+        } catch (Exception e) {
+            log.error("处理消息异常", e);
             e.printStackTrace();
         }
 
@@ -41,9 +49,14 @@ public class ExportDataExecutor implements Runnable{
 
     private void doExportData() throws Exception {
 
-        ExportDataDto exportDataDto =  ExportDataQueue.getData();
+        ExportDataDto exportDataDto = ExportDataQueue.getData();
+
+        ByteArrayInputStream inputStream = null;
+        ByteArrayOutputStream os = null;
+        SXSSFWorkbook workbook = null;
+        String fileName = "";
 
-        if(exportDataDto == null){
+        if (exportDataDto == null) {
             return;
         }
 
@@ -51,49 +64,57 @@ public class ExportDataExecutor implements Runnable{
 
         IExportDataAdapt exportDataAdaptImpl = ApplicationContextFactory.getBean(businessAdapt, IExportDataAdapt.class);
 
-        if(exportDataAdaptImpl == null){
-            return ;
+        if (exportDataAdaptImpl == null) {
+            return;
         }
-        SXSSFWorkbook workbook= exportDataAdaptImpl.exportData(exportDataDto);
-
-        //保存文件路径到 文件下载表
-        FileUploadTemplate fileUploadTemplate = ApplicationContextFactory.getBean("fileUploadTemplate", FileUploadTemplate.class);
-
-
-        ByteArrayInputStream inputStream = null;
-        ByteArrayOutputStream os = null;
+        updateUserDownloadFile(exportDataDto, UserDownloadFileDto.STATE_DOING,"", "开始下载");
         try {
-
+            workbook = exportDataAdaptImpl.exportData(exportDataDto);
+            //保存文件路径到 文件下载表
             os = new ByteArrayOutputStream();
             workbook.write(os);
             inputStream = new ByteArrayInputStream(os.toByteArray());
 
-            fileUploadTemplate.saveFile(inputStream,exportDataDto.getFileName());
+            fileName = fileUploadTemplate.saveFile(inputStream, exportDataDto.getFileName());
+            updateUserDownloadFile(exportDataDto, UserDownloadFileDto.STATE_FINISH,fileName, "下载完成");
 
-        }finally {
+        } catch (Exception e) {
+            updateUserDownloadFile(exportDataDto, UserDownloadFileDto.STATE_FAIL, "","下载失败" + ExceptionUtil.getStackTrace(e));
+        } finally {
             try {
                 workbook.close();
-            }catch (Exception e){
+            } catch (Exception e) {
 
             }
             try {
                 inputStream.close();
-            }catch (Exception e){
+            } catch (Exception e) {
 
             }
             try {
                 os.close();
-            }catch (Exception e){
+            } catch (Exception e) {
 
             }
 
         }
     }
 
+    private void updateUserDownloadFile(ExportDataDto exportDataDto, String state,String url, String remark) {
+        UserDownloadFilePo userDownloadFilePo = new UserDownloadFilePo();
+        userDownloadFilePo.setDownloadId(exportDataDto.getDownloadId());
+        userDownloadFilePo.setState(state);
+        if(!StringUtil.isEmpty(url)){
+            userDownloadFilePo.setTempUrl(url);
+        }
+        userDownloadFilePo.setRemark(remark.length() > 512 ? remark.substring(0, 512): remark);
+        userDownloadFileV1InnerServiceSMOImpl.updateUserDownloadFile(userDownloadFilePo);
+    }
+
     /**
      * 线程启动器
      */
-    public static void startExportDataExecutor(){
+    public static void startExportDataExecutor() {
         ExecutorService executorService = Executors.newFixedThreadPool(DEFAULT_EXPORT_POOL);
         executorService.execute(new ExportDataExecutor());
     }

+ 89 - 0
service-job/src/main/java/com/java110/job/smo/impl/UserDownloadFileV1InnerServiceSMOImpl.java

@@ -0,0 +1,89 @@
+/*
+ * Copyright 2017-2020 吴学文 and java110 team.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.java110.job.smo.impl;
+
+
+import com.java110.job.dao.IUserDownloadFileV1ServiceDao;
+import com.java110.intf.job.IUserDownloadFileV1InnerServiceSMO;
+import com.java110.dto.userDownloadFile.UserDownloadFileDto;
+import com.java110.po.userDownloadFile.UserDownloadFilePo;
+import com.java110.utils.util.BeanConvertUtil;
+import com.java110.core.base.smo.BaseServiceSMO;
+import com.java110.dto.user.UserDto;
+import com.java110.dto.PageDto;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 类表述: 服务之前调用的接口实现类,不对外提供接口能力 只用于接口建调用
+ * add by 吴学文 at 2022-10-19 17:00:35 mail: 928255095@qq.com
+ * open source address: https://gitee.com/wuxw7/MicroCommunity
+ * 官网:http://www.homecommunity.cn
+ * 温馨提示:如果您对此文件进行修改 请不要删除原有作者及注释信息,请补充您的 修改的原因以及联系邮箱如下
+ * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行
+ */
+@RestController
+public class UserDownloadFileV1InnerServiceSMOImpl extends BaseServiceSMO implements IUserDownloadFileV1InnerServiceSMO {
+
+    @Autowired
+    private IUserDownloadFileV1ServiceDao userDownloadFileV1ServiceDaoImpl;
+
+
+    @Override
+    public int saveUserDownloadFile(@RequestBody  UserDownloadFilePo userDownloadFilePo) {
+        int saveFlag = userDownloadFileV1ServiceDaoImpl.saveUserDownloadFileInfo(BeanConvertUtil.beanCovertMap(userDownloadFilePo));
+        return saveFlag;
+    }
+
+     @Override
+    public int updateUserDownloadFile(@RequestBody  UserDownloadFilePo userDownloadFilePo) {
+        int saveFlag = userDownloadFileV1ServiceDaoImpl.updateUserDownloadFileInfo(BeanConvertUtil.beanCovertMap(userDownloadFilePo));
+        return saveFlag;
+    }
+
+     @Override
+    public int deleteUserDownloadFile(@RequestBody  UserDownloadFilePo userDownloadFilePo) {
+       userDownloadFilePo.setStatusCd("1");
+       int saveFlag = userDownloadFileV1ServiceDaoImpl.updateUserDownloadFileInfo(BeanConvertUtil.beanCovertMap(userDownloadFilePo));
+       return saveFlag;
+    }
+
+    @Override
+    public List<UserDownloadFileDto> queryUserDownloadFiles(@RequestBody  UserDownloadFileDto userDownloadFileDto) {
+
+        //校验是否传了 分页信息
+
+        int page = userDownloadFileDto.getPage();
+
+        if (page != PageDto.DEFAULT_PAGE) {
+            userDownloadFileDto.setPage((page - 1) * userDownloadFileDto.getRow());
+        }
+
+        List<UserDownloadFileDto> userDownloadFiles = BeanConvertUtil.covertBeanList(userDownloadFileV1ServiceDaoImpl.getUserDownloadFileInfo(BeanConvertUtil.beanCovertMap(userDownloadFileDto)), UserDownloadFileDto.class);
+
+        return userDownloadFiles;
+    }
+
+
+    @Override
+    public int queryUserDownloadFilesCount(@RequestBody UserDownloadFileDto userDownloadFileDto) {
+        return userDownloadFileV1ServiceDaoImpl.queryUserDownloadFilesCount(BeanConvertUtil.beanCovertMap(userDownloadFileDto));    }
+
+}