Quellcode durchsuchen

Merge remote-tracking branch 'origin/master'

Joburgess vor 5 Jahren
Ursprung
Commit
a9f651826f

+ 21 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CooperationOrgan.java

@@ -41,6 +41,8 @@ public class CooperationOrgan {
 	/** 分部编号 */
 	@ApiModelProperty(value = "分部编号", required = false)
 	private Integer organId;
+	
+	private Organization organization = new Organization();
 
 	/** 联系人 */
 	@ApiModelProperty(value = "联系人", required = false)
@@ -60,6 +62,9 @@ public class CooperationOrgan {
 
 	@ApiModelProperty(value = "权属类型(OWN('自有'),COOPERATION('合作'),LEASE('租赁'))", required = false)
 	private OwnershipType ownershipType;
+	
+	@ApiModelProperty(value = "是否启用", required = false)
+	private Boolean isEnable;
 
 	/**  */
 	private java.util.Date createTime;
@@ -75,6 +80,14 @@ public class CooperationOrgan {
 		this.organId = organId;
 	}
 
+	public Organization getOrganization() {
+		return organization;
+	}
+
+	public void setOrganization(Organization organization) {
+		this.organization = organization;
+	}
+
 	public void setId(Integer id) {
 		this.id = id;
 	}
@@ -147,6 +160,14 @@ public class CooperationOrgan {
 		this.ownershipType = ownershipType;
 	}
 
+	public Boolean getIsEnable() {
+		return isEnable;
+	}
+
+	public void setIsEnable(Boolean isEnable) {
+		this.isEnable = isEnable;
+	}
+
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);

+ 23 - 8
mec-biz/src/main/resources/config/mybatis/CooperationOrganMapper.xml

@@ -12,10 +12,16 @@
         <result column="job_" property="job"/>
         <result column="mobile_no_" property="mobileNo"/>
         <result column="address_" property="address"/>
+        <result column="is_enable_" property="isEnable"/>
         <result column="ownership_type_" property="ownershipType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="create_time_" property="createTime"/>
         <result column="update_time_" property="updateTime"/>
     </resultMap>
+    
+    <resultMap type="com.ym.mec.biz.dal.entity.CooperationOrgan" id="ExtCooperationOrgan" extends="CooperationOrgan">
+    	<result column="organ_id_" property="organization.id"/>
+    	<result column="organ_name_" property="organization.name"/>
+    </resultMap>
 
     <!-- 根据主键查询一条记录 -->
     <select id="get" resultMap="CooperationOrgan">
@@ -33,8 +39,8 @@
     <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.CooperationOrgan"
             useGeneratedKeys="true" keyColumn="id" keyProperty="id">
         INSERT INTO cooperation_organ
-        (id_,name_,linkman_,job_,mobile_no_,address_,organ_id_,create_time_,update_time_,ownership_type_)
-        VALUES(#{id},#{name},#{linkman},#{job},#{mobileNo},#{address},#{organId},now(),now(),#{ownershipType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
+        (id_,name_,linkman_,job_,mobile_no_,address_,organ_id_,create_time_,update_time_,ownership_type_,is_enable_)
+        VALUES(#{id},#{name},#{linkman},#{job},#{mobileNo},#{address},#{organId},now(),now(),#{ownershipType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{isEnable})
     </insert>
 
     <!-- 根据主键查询一条记录 -->
@@ -65,6 +71,9 @@
             <if test="organId != null">
                 organ_id_ = #{organId},
             </if>
+            <if test="isEnable != null">
+                is_enable_ = #{isEnable},
+            </if>
         </set>
         WHERE id_ = #{id}
     </update>
@@ -75,19 +84,22 @@
 	</update>
 
     <!-- 分页查询 -->
-    <select id="queryPage" resultMap="CooperationOrgan"
+    <select id="queryPage" resultMap="ExtCooperationOrgan"
             parameterType="map">
-        SELECT * FROM cooperation_organ
+        SELECT co.*,o.name_ organ_name_ FROM cooperation_organ co left join organization o on co.organ_id_ = o.id_
         <where>
-                del_flag_ != 1
+                co.del_flag_ != 1
             <if test="search != null">
-                AND (id_ LIKE CONCAT('%',#{search},'%') OR name_ LIKE CONCAT('%',#{search},'%'))
+                AND (co.id_ LIKE CONCAT('%',#{search},'%') OR co.name_ LIKE CONCAT('%',#{search},'%'))
             </if>
 	        <if test="organId != null">
-	            AND FIND_IN_SET(organ_id_,#{organId})
+	            AND FIND_IN_SET(co.organ_id_,#{organId})
+	        </if>
+	        <if test="isEnable != null">
+	            AND co.is_enable_ = #{isEnable}
 	        </if>
         </where>
-        ORDER BY update_time_ DESC
+        ORDER BY co.update_time_ DESC
         <include refid="global.limit"/>
     </select>
 
@@ -102,6 +114,9 @@
 	        <if test="organId != null">
 	            AND FIND_IN_SET(organ_id_,#{organId})
 	        </if>
+	        <if test="isEnable != null">
+	            AND is_enable_ = #{isEnable}
+	        </if>
         </where>
 	</select>
 

+ 62 - 0
mec-web/src/main/java/com/ym/mec/web/controller/ExportController.java

@@ -14,8 +14,10 @@ import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
 import com.ym.mec.util.excel.POIUtil;
+
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -27,6 +29,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletResponse;
+
 import java.io.IOException;
 import java.io.OutputStream;
 import java.math.BigDecimal;
@@ -87,6 +90,9 @@ public class ExportController extends BaseController {
     @Autowired
     private DegreeRegistrationService degreeRegistrationService;
 
+    @Autowired
+    private CooperationOrganService cooperationOrganService;
+
     @ApiOperation(value = "导出教师考勤列表")
     @PostMapping("export/queryTeacherAttendances")
     @PreAuthorize("@pcs.hasPermissions('export/queryTeacherAttendances')")
@@ -1622,4 +1628,60 @@ public class ExportController extends BaseController {
             }
         }
     }
+
+
+    @ApiOperation(value = "合作单位导出")
+    @RequestMapping("export/cooperationOrgan")
+    @PreAuthorize("@pcs.hasPermissions('export/cooperationOrgan')")
+    public void cooperationOrgan(CooperationOrganQueryInfo queryInfo,HttpServletResponse response) throws IOException {
+    	SysUser sysUser = sysUserFeignService.queryUserInfo();
+		if (sysUser == null) {
+			throw new IOException("用户信息获取失败");
+		}
+		if(!sysUser.getIsSuperAdmin()){
+			Employee employee = employeeDao.get(sysUser.getId());
+			if (StringUtils.isEmpty(queryInfo.getOrganId())) {
+				queryInfo.setOrganId(employee.getOrganIdList());
+			}else if(StringUtils.isEmpty(employee.getOrganIdList())){
+				throw new IOException("用户所在分部异常");
+			}else {
+				List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+				if(!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))){
+					throw new IOException("非法请求");
+				}
+			}
+		}
+        queryInfo.setRows(65000);
+        PageInfo<CooperationOrgan> pageList = cooperationOrganService.queryPage(queryInfo);
+        if (pageList.getTotal() <= 0) {
+            response.setStatus(200);
+            response.setContentType("Content-Type: application/json;charset=UTF-8");
+            response.getOutputStream().write("{\"data\": null, \"code\": 500, \"status\": false, \"msg\": \"没有可导出的记录\"}".getBytes());
+            response.flushBuffer();
+            return;
+        }
+        OutputStream outputStream = response.getOutputStream();
+        try {
+
+            String[] header = {"分部", "单位编号", "单位名称", "联系人", "职位", "手机号", "是否启用"};
+            String[] body = {"organization.name", "id", "name", "linkman", "job", "mobileNo", "isEnable"};
+            HSSFWorkbook workbook = POIUtil.exportExcel(header, body, pageList.getRows());
+            response.setContentType("application/octet-stream");
+            response.setHeader("Content-Disposition", "attachment;filename=cooperationOrgan-" + DateUtil.getDate(new Date()) + ".xls");
+            response.flushBuffer();
+            outputStream = response.getOutputStream();
+            workbook.write(outputStream);
+            outputStream.flush();
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (outputStream != null) {
+                try {
+                    outputStream.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
 }