Commit 774ca8e5 authored by 黎聪聪's avatar 黎聪聪

二维码管理

parent 6c482644
...@@ -99,13 +99,31 @@ ...@@ -99,13 +99,31 @@
<label>二维码类别</label> <label>二维码类别</label>
<select class="form-control select2" name="typeselect" <select class="form-control select2" name="typeselect"
id="typeselect" style="width: 100%;"> id="typeselect" style="width: 100%;">
<option value="0">门店</option> <option value="1">医师二维码</option>
<option value="1">SA人员</option> <option value="2">客服二维码</option>
<option value="2">门店车辆</option> <option value="3">医生二维码</option>
<option value="4">组织二维码</option>
</select> </select>
</div> </div>
</div> </div>
<!--<div class="form-group form-md-line-input col-md-20">
<label>所属栏目</label>
<div class="input-group">
<input type="text" name="column" id="column"
value="$!{data.column}"
class="form-control" style="display: none">
<input type="text" id="columnName"
name="columnName" value="$!{columnName}"
class="form-control" disabled>
<span class="input-group-btn">
<button type="button" id="columnSelect"
class="btn btn-info btn-flat">选择</button>
</span>
</div>
</div>-->
<div class="row"> <div class="row">
<div class="form-group form-md-line-input col-md-12"> <div class="form-group form-md-line-input col-md-12">
<label>描述</label> <label>描述</label>
...@@ -179,6 +197,8 @@ ...@@ -179,6 +197,8 @@
Cfapp.init(); Cfapp.init();
recdTypeAdd.init(); recdTypeAdd.init();
}); });
//选择栏目
var recdTypeAdd = function () { var recdTypeAdd = function () {
......
...@@ -110,13 +110,30 @@ ...@@ -110,13 +110,30 @@
<label>二维码类别</label> <label>二维码类别</label>
<select class="form-control select2" name="typeselect" <select class="form-control select2" name="typeselect"
id="typeselect" style="width: 100%;"> id="typeselect" style="width: 100%;">
<option value="0">门店</option> <option value="0">客服二维码</option>
<option value="1">SA人员</option> <option value="1">药师二维码</option>
<option value="2">门店车辆</option> <option value="2">医生二维码</option>
<option value="3">组织二维码</option>
</select> </select>
</div> </div>
<div class="form-group form-md-line-input col-md-6">
<label>选择二维码所绑定的对象</label>
<div class="input-group">
<input type="text" name="bindId" id="bindId"
value="$!{data.bindId}"
class="form-control" style="display: none">
<input type="text" id="columnName"
name="columnName" value="$!{columnName}"
class="form-control" disabled>
<span class="input-group-btn">
<button type="button" id="columnSelect"
class="btn btn-info btn-flat">选择</button>
</span>
</div>
</div>
</div> </div>
<div class="row"> <div class="row">
<div class="form-group form-md-line-input col-md-12"> <div class="form-group form-md-line-input col-md-12">
<label>描述</label> <label>描述</label>
...@@ -197,8 +214,76 @@ ...@@ -197,8 +214,76 @@
$().ready(function () { $().ready(function () {
Cfapp.init(); Cfapp.init();
recdTypeAdd.init(); recdTypeAdd.init();
}); });
// var Id ="";
// $("#typeselect").click(function () {
// var value = $("#typeselect").val();
// if (value=="医师二维码"){
// Id = 1;
// }else if (value=="客服二维码"){
// Id = 2;
// }else if (value=="医生二维码"){
// Id = 3;
// }else if (value=="组织二维码"){
// Id = 4;
// }
// })
// var columnUrl = "#springUrl('/a/wxQrcode/listUser?userId=" + Id + "')";
// var cfArticleUrl = "#springUrl('/a/cfarticle/listData')";
var columnUrl = "";
//选择栏目
$("#columnSelect").click(function () {
var Id= $("#typeselect").val()
if (Id=="3"){
columnUrl ="#springUrl('/a/wxQrcode/listOrg')"
}else{
columnUrl ="#springUrl('/a/wxQrcode/listUser?userId=" + Id + "')"
}
Cfapp.f7({
dataUrl: columnUrl,
checkType: 'single', // 多选为multi
title: "选择二维码绑定对象",
btnoktext: "确定",
btncanceltext: "取消",
columns: ['选择', '人员名称'],
isSearch: '0',
searchColumns: ["name"],//搜索的字段名称
searchColumnsRemarks: ['人员名称'],//搜索的字段备注
aoColumns: [{
"mData": "id"
}, {
"mData": "name"
}
],
aoColumnDefs: [{
"aTargets": [0],
"mData": "id",
"mRender": function (a, b, c, d) {
return '<input class="bindId" value="' + a + '" type="radio" id="' + a + '" name="sel" data-value="' + a + '" data-name="' + c.name + '">';
}
}, {
"aTargets": [1],
"mData": "name",
"mRender": function (a, b, c, d) {//a表示createtime对应的值,c表示当前记录行对象
return a;
}
}],
success: function () {
},
cancel: function () {
},
storeFields: 'bindId', // 储存的字段
displayFields: 'columnName'
})
});
var recdTypeAdd = function () { var recdTypeAdd = function () {
var initForm = function () { var initForm = function () {
......
...@@ -97,9 +97,10 @@ ...@@ -97,9 +97,10 @@
<select class="form-control select2" name="type" <select class="form-control select2" name="type"
id="type"> id="type">
<option value="-1" selected="selected">全部</option> <option value="-1" selected="selected">全部</option>
<option value="0">门店</option> <option value="1">医师二维码</option>
<option value="1">Sa人员</option> <option value="2">客服二维码</option>
<option value="2">门店车辆</option> <option value="3">医生二维码</option>
<option value="4">组织二维码</option>
</select> </select>
</div> </div>
</div> </div>
...@@ -201,7 +202,7 @@ ...@@ -201,7 +202,7 @@
var sSource = "#springUrl('/a/wxQrcode/listData')"; var sSource = "#springUrl('/a/wxQrcode/listData')";
var aoData = { var aoData = {
iDisplayStart: 1, iDisplayStart: 1,
iDosplayLength: 20 iDosplayLength: 10
} }
var retrieveData = function (sSource, aoData, fnCallback) { var retrieveData = function (sSource, aoData, fnCallback) {
...@@ -253,9 +254,11 @@ ...@@ -253,9 +254,11 @@
}, },
{ {
"mData": "ticket" "mData": "ticket"
},{
"mData": "storeName"
}, },
{
"mData": "qrcodeNames"
},
{ {
"mData": "sceneId" "mData": "sceneId"
}, },
...@@ -285,16 +288,12 @@ ...@@ -285,16 +288,12 @@
} }
},{ },{
"aTargets": [2], "aTargets": [2],
"mData": "storeName", "mData": "qrcodeNames",
"mRender": function (a, b, c, d) { "mRender": function (a, b, c, d) {
if (a!==null && a !== '') { if (a!==null && a !== '') {
return '<font color="blue">'+a+'</font>'; return a;
} else if (c.empName !== null && c.empName !== '') { }else{
return '<font color="green">'+c.empName+'</font>'; return "";
}else if (c.carName !== null && c.carName !== '') {
return '<font color="orange">'+c.carName+'</font>';
} else {
return '<font color="red">未被绑定</font>';
} }
} }
...@@ -303,7 +302,7 @@ ...@@ -303,7 +302,7 @@
"aTargets": [3], "aTargets": [3],
"mData": "sceneId", "mData": "sceneId",
"mRender": function (a, b, c, d) { "mRender": function (a, b, c, d) {
return '<a href="#springUrl("/a/wxQrcode/form?id=' + c.id + '")" data-id="' + c.id + '" data-action="view">' + a + '</a>'; return a;
} }
}, },
...@@ -312,11 +311,15 @@ ...@@ -312,11 +311,15 @@
"mData": "type", "mData": "type",
"mRender": function (a, b, c, d) { "mRender": function (a, b, c, d) {
if (a == '0') { if (a == '0') {
return '门店'; return '客服二维码';
} else if (a == '1') { } else if (a == '1') {
return 'SA人员'; return '医师二位码';
}else if(a == '2'){ }else if(a == '2'){
return '门店车辆'; return '医生二维码';
}else if(a=="3"){
return '组织二维码';
}else{
return "";
} }
} }
}, },
...@@ -329,6 +332,13 @@ ...@@ -329,6 +332,13 @@
return formatDates(a, "yyyy-MM-dd HH:mm:ss"); return formatDates(a, "yyyy-MM-dd HH:mm:ss");
} }
}, },
{
"aTargets": [6],
"mData": "description",
"mRender": function (a, b, c, d) {//a表示createtime对应的值,c表示当前记录行对象
return a;
}
},
{ {
"aTargets": [7], "aTargets": [7],
"mData": "id", "mData": "id",
......
package com.cftech.shop.qrcode.dao; package com.cftech.shop.qrcode.dao;
import com.alibaba.fastjson.JSONObject;
import com.cftech.shop.qrcode.model.QyUser;
import com.cftech.shop.qrcode.model.WxQrcode; import com.cftech.shop.qrcode.model.WxQrcode;
import com.cftech.core.generic.GenericDao; import com.cftech.core.generic.GenericDao;
import com.cftech.shop.qrcode.model.vo.WxQrcodeVO; import com.cftech.shop.qrcode.model.vo.WxQrcodeVO;
import org.apache.ibatis.annotations.Param;
import org.apache.poi.ss.formula.functions.T; import org.apache.poi.ss.formula.functions.T;
import java.util.List; import java.util.List;
...@@ -26,4 +29,11 @@ public interface WxQrcodeMapper extends GenericDao<WxQrcode> { ...@@ -26,4 +29,11 @@ public interface WxQrcodeMapper extends GenericDao<WxQrcode> {
List<WxQrcode> fetchSingleSearchInfo(Map<String, Object> params); List<WxQrcode> fetchSingleSearchInfo(Map<String, Object> params);
List<QyUser> fromUser(@Param("userId") int userId, @Param("name")String name);
List<WxQrcode> fromOrg(@Param("name")String name);
int countUser(int userId);
int countOrg();
} }
\ No newline at end of file
...@@ -129,8 +129,9 @@ ...@@ -129,8 +129,9 @@
</select> </select>
<select id="count" parameterType="java.util.Map" resultType="java.lang.Integer"> <select id="count" parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT COUNT(1) FROM t_shop_wxqrcode t SELECT COUNT(1) FROM t_shop_wxqrcode t
left join t_orgunit o on o.id = t.org_id LEFT JOIN t_qyuser q ON q.id = t.bind_id
LEFT JOIN t_orgunit o ON o.id = t.bind_id AND t.type='3'
<include refid="sqlWhere"/> <include refid="sqlWhere"/>
<if test="orgId > 0"> <if test="orgId > 0">
and instr(o.parent_ids,',${orgId},')>0 and instr(o.parent_ids,',${orgId},')>0
...@@ -139,13 +140,25 @@ ...@@ -139,13 +140,25 @@
</select> </select>
<select id="fetchSearchByPageVO" parameterType="java.util.Map" resultMap="resultMapVO"> <select id="fetchSearchByPageVO" parameterType="java.util.Map" resultMap="resultMapVO">
SELECT t.id id, s.name store_name, u.name emp_name,c.name car_name, t.scene_id scene_id, SELECT
t.type type, t.ticket ticket, t.create_time create_time, t.description description t.id,
FROM t_shop_wxqrcode t t.ticket,
left join t_dc_store s on s.id = t.bind_id and t.type='0' t.scene_id sceneId,
left join t_qyuser u on u.id = t.bind_id and t.type='1' t.type,
LEFT JOIN t_fours_store_car sc on sc.id=t.bind_id and t.type='2' t.create_time createTime,
LEFT JOIN t_fours_base_cars c on c.id=sc.carid t.description,
q.`name`,
o.org_name,
CASE
WHEN t.type = '0' OR t.type = '1' OR t.type = '2' THEN
q.`name`
WHEN t.type = '3' THEN
o.org_name ELSE ''
END qrcodeNames
FROM
t_shop_wxqrcode t
LEFT JOIN t_qyuser q ON q.id = t.bind_id
LEFT JOIN t_orgunit o ON o.id = t.bind_id AND t.type='3'
<include refid="sqlWhere"/> <include refid="sqlWhere"/>
<if test="sort!=null">ORDER BY ${sort.param} ${sort.type}</if> <if test="sort!=null">ORDER BY ${sort.param} ${sort.type}</if>
<if test="limit>0">limit #{offset},#{limit}</if> <if test="limit>0">limit #{offset},#{limit}</if>
...@@ -208,7 +221,7 @@ ...@@ -208,7 +221,7 @@
</if> </if>
<if test="updateBy != null"> <if test="updateBy != null">
update_by = #{updateBy, jdbcType=BIGINT}, update_by = #{updateBy, jdbcType=BIGINT},
</if>,update_time = now() </if>update_time = now()
</set> </set>
where id=#{id,jdbcType=BIGINT} where id=#{id,jdbcType=BIGINT}
</update> </update>
...@@ -229,5 +242,16 @@ ...@@ -229,5 +242,16 @@
limit 0,1 limit 0,1
</select> </select>
<select id="fromUser" resultType="com.cftech.shop.qrcode.model.QyUser">
select id,name from t_qyuser where user_type=#{userId} <if test=" name !=null and name != '' "> and name like '%${name}%'</if>
</select>
<select id="fromOrg" resultType="com.cftech.shop.qrcode.model.Orgunit">
select id,org_name name from t_orgunit <if test=" name !=null and name != '' "> where org_name like '%${name}%'</if>
</select>
<select id="countUser" resultType="java.lang.Integer">
select count(1) from t_qyuser where user_type=#{userId}
</select>
<select id="countOrg" resultType="java.lang.Integer">
select count(1) from t_orgunit
</select>
</mapper> </mapper>
\ No newline at end of file
package com.cftech.shop.qrcode.model;
import lombok.Data;
/**
* @author :licc
* @date :Created in 2020/9/29 10:44
* @description:
*/
@Data
public class Orgunit {
/* 人员id*/
private Long id;
/* 人员name*/
private String name;
}
package com.cftech.shop.qrcode.model;
import lombok.Data;
import java.security.PrivateKey;
/**
* @author :licc
* @date :Created in 2020/9/28 15:19
* @description:
*/
@Data
public class QyUser {
/* 人员id*/
private Long id;
/* 人员name*/
private String name;
}
...@@ -13,7 +13,7 @@ import java.util.Date; ...@@ -13,7 +13,7 @@ import java.util.Date;
* @date: 2017-12-04 17:56 * @date: 2017-12-04 17:56
*/ */
@Data @Data
public class WxQrcode implements Serializable { public class WxQrcode implements Serializable {
/* 主键id */ /* 主键id */
private Long id; private Long id;
...@@ -46,7 +46,8 @@ public class WxQrcode implements Serializable { ...@@ -46,7 +46,8 @@ public class WxQrcode implements Serializable {
private Long createBy; private Long createBy;
/* 更新人 */ /* 更新人 */
private Long updateBy; private Long updateBy;
/* 绑定对象 */
private String qrcodeNames;
public WxQrcode() { public WxQrcode() {
this.delFlag = false; this.delFlag = false;
this.status = "0"; this.status = "0";
......
...@@ -46,5 +46,6 @@ public class WxQrcodeVO implements Serializable { ...@@ -46,5 +46,6 @@ public class WxQrcodeVO implements Serializable {
*/ */
private String description; private String description;
/* 绑定对象 */
private String qrcodeNames;
} }
package com.cftech.shop.qrcode.service; package com.cftech.shop.qrcode.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.cftech.shop.qrcode.model.QyUser;
import com.cftech.shop.qrcode.model.WxQrcode; import com.cftech.shop.qrcode.model.WxQrcode;
import com.cftech.core.generic.GenericService; import com.cftech.core.generic.GenericService;
import com.cftech.core.sql.Conds; import com.cftech.core.sql.Conds;
...@@ -26,4 +29,11 @@ public interface WxQrcodeService extends GenericService<WxQrcode> { ...@@ -26,4 +29,11 @@ public interface WxQrcodeService extends GenericService<WxQrcode> {
boolean updateBindId(WxQrcode wxQrcode); boolean updateBindId(WxQrcode wxQrcode);
List<WxQrcode> fetchSingleSearchInfo(Conds conds, Sort sort, int page, int pageSize); List<WxQrcode> fetchSingleSearchInfo(Conds conds, Sort sort, int page, int pageSize);
List<QyUser> fromUser(int userId,String name);
List<WxQrcode> fromOrg(String name);
int countUser(int userId);
int countOrg();
} }
package com.cftech.shop.qrcode.service.impl; package com.cftech.shop.qrcode.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.cftech.shop.qrcode.model.QyUser;
import com.cftech.shop.qrcode.model.WxQrcode; import com.cftech.shop.qrcode.model.WxQrcode;
import com.cftech.shop.qrcode.dao.WxQrcodeMapper; import com.cftech.shop.qrcode.dao.WxQrcodeMapper;
import com.cftech.shop.qrcode.model.vo.WxQrcodeVO; import com.cftech.shop.qrcode.model.vo.WxQrcodeVO;
...@@ -83,4 +85,24 @@ public class WxQrcodeServiceImpl extends GenericServiceImpl<WxQrcode> implements ...@@ -83,4 +85,24 @@ public class WxQrcodeServiceImpl extends GenericServiceImpl<WxQrcode> implements
return wxQrcodeMapper.fetchSingleSearchInfo(params); return wxQrcodeMapper.fetchSingleSearchInfo(params);
} }
@Override
public List<QyUser> fromUser(int userId,String name) {
return wxQrcodeMapper.fromUser(userId,name);
}
@Override
public List<WxQrcode> fromOrg(String name) {
return wxQrcodeMapper.fromOrg(name);
}
@Override
public int countUser(int userId) {
return wxQrcodeMapper.countUser(userId);
}
@Override
public int countOrg() {
return wxQrcodeMapper.countOrg();
}
} }
\ No newline at end of file
...@@ -3,6 +3,7 @@ package com.cftech.shop.qrcode.web; ...@@ -3,6 +3,7 @@ package com.cftech.shop.qrcode.web;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.cftech.core.util.HttpURLConnectionUtil; import com.cftech.core.util.HttpURLConnectionUtil;
import com.cftech.core.util.SystemConfig; import com.cftech.core.util.SystemConfig;
import com.cftech.shop.qrcode.model.QyUser;
import com.cftech.shop.qrcode.model.WxQrcode; import com.cftech.shop.qrcode.model.WxQrcode;
import com.cftech.shop.qrcode.model.vo.WxQrcodeVO; import com.cftech.shop.qrcode.model.vo.WxQrcodeVO;
import com.cftech.shop.qrcode.service.WxQrcodeService; import com.cftech.shop.qrcode.service.WxQrcodeService;
...@@ -14,17 +15,19 @@ import com.cftech.core.util.Constants; ...@@ -14,17 +15,19 @@ import com.cftech.core.util.Constants;
import com.cftech.shop.qrcode.util.QrcodeDown; import com.cftech.shop.qrcode.util.QrcodeDown;
import com.cftech.shop.qrcode.util.WxQrcodeUtil; import com.cftech.shop.qrcode.util.WxQrcodeUtil;
import com.cftech.sys.security.UserUtils; import com.cftech.sys.security.UserUtils;
import com.sun.org.apache.bcel.internal.generic.NEWARRAY;
import jdk.nashorn.internal.ir.ReturnNode;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.naming.Name;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
...@@ -62,34 +65,34 @@ public class WxQrcodeController { ...@@ -62,34 +65,34 @@ public class WxQrcodeController {
//下载展厅二维码 //下载展厅二维码
@RequestMapping(value = "/downloadcode", method = {RequestMethod.GET, RequestMethod.POST}) @RequestMapping(value = "/downloadcode", method = {RequestMethod.GET, RequestMethod.POST})
public void downloadcode(Long id, WxQrcode qrcode, String name,HttpServletRequest request, HttpServletResponse response) throws IOException { public void downloadcode(Long id, WxQrcode qrcode, String name, HttpServletRequest request, HttpServletResponse response) throws IOException {
Long accountsId = UserUtils.getmpaccounts(request); Long accountsId = UserUtils.getmpaccounts(request);
try { try {
Conds countConds = new Conds(); Conds countConds = new Conds();
countConds.equal("t.del_flag", 0); countConds.equal("t.del_flag", 0);
int count = wxQrcodeService.count(countConds); int count = wxQrcodeService.count(countConds);
JSONObject wxObj = wxQrcodeUtil.createLimitQrcode(accountsId, Long.valueOf(count)); JSONObject wxObj = wxQrcodeUtil.createLimitQrcode(accountsId, Long.valueOf(count));
if (wxObj.containsKey("ticket")) { if (wxObj.containsKey("ticket")) {
qrcode.setTicket(wxObj.getString("ticket")); qrcode.setTicket(wxObj.getString("ticket"));
} }
qrcode.setId(null); qrcode.setId(null);
String tempTicket = qrcode.getTicket(); String tempTicket = qrcode.getTicket();
qrcode.setCreateBy(UserUtils.getUser().getId()); qrcode.setCreateBy(UserUtils.getUser().getId());
qrcode.setUpdateBy(UserUtils.getUser().getId()); qrcode.setUpdateBy(UserUtils.getUser().getId());
qrcode.setSceneId(String.valueOf(count)); qrcode.setSceneId(String.valueOf(count));
qrcode.setBindId(0L); qrcode.setBindId(0L);
qrcode.setDelFlag(false); qrcode.setDelFlag(false);
wxQrcodeService.save(qrcode); wxQrcodeService.save(qrcode);
QrcodeDown.downPicture(request, response, tempTicket, name); QrcodeDown.downPicture(request, response, tempTicket, name);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
//列表页面 //列表页面
@RequiresPermissions(value = WXQRCODE_VIEW) @RequiresPermissions(value = WXQRCODE_VIEW)
@RequestMapping(value = "/list",method = {RequestMethod.GET,RequestMethod.POST}) @RequestMapping(value = "/list", method = {RequestMethod.GET, RequestMethod.POST})
public String list(HttpServletRequest request, Model model) { public String list(HttpServletRequest request, Model model) {
Long accountId = UserUtils.getmpaccounts(request); Long accountId = UserUtils.getmpaccounts(request);
model.addAttribute("accountId", accountId); model.addAttribute("accountId", accountId);
...@@ -98,7 +101,7 @@ public class WxQrcodeController { ...@@ -98,7 +101,7 @@ public class WxQrcodeController {
//编辑页面(新增、修改) //编辑页面(新增、修改)
@RequiresPermissions(value = WXQRCODE_VIEW) @RequiresPermissions(value = WXQRCODE_VIEW)
@RequestMapping(value = "/form",method = {RequestMethod.GET,RequestMethod.POST}) @RequestMapping(value = "/form", method = {RequestMethod.GET, RequestMethod.POST})
public String form(HttpServletRequest request, String id, Model model) { public String form(HttpServletRequest request, String id, Model model) {
if (!StringUtils.isEmpty(id)) { if (!StringUtils.isEmpty(id)) {
WxQrcode wxQrcode = wxQrcodeService.fetchById(id); WxQrcode wxQrcode = wxQrcodeService.fetchById(id);
...@@ -110,14 +113,14 @@ public class WxQrcodeController { ...@@ -110,14 +113,14 @@ public class WxQrcodeController {
//编辑页面(新增、修改) //编辑页面(新增、修改)
@RequiresPermissions(value = WXQRCODE_EDIT) @RequiresPermissions(value = WXQRCODE_EDIT)
@RequestMapping(value = "/pform",method = {RequestMethod.GET,RequestMethod.POST}) @RequestMapping(value = "/pform", method = {RequestMethod.GET, RequestMethod.POST})
public String pform(HttpServletRequest request, String id, Model model) { public String pform(HttpServletRequest request, String id, Model model) {
return "wxQrcode/wxQrcodePform"; return "wxQrcode/wxQrcodePform";
} }
//提交数据(新增、修改) //提交数据(新增、修改)
@RequiresPermissions(value = WXQRCODE_EDIT) @RequiresPermissions(value = WXQRCODE_EDIT)
@RequestMapping(value = "/formData",method = {RequestMethod.POST}) @RequestMapping(value = "/formData", method = {RequestMethod.POST})
@ResponseBody @ResponseBody
public JSONObject formData(WxQrcode wxQrcode, Model model, HttpServletRequest request) { public JSONObject formData(WxQrcode wxQrcode, Model model, HttpServletRequest request) {
Long accountsId = UserUtils.getmpaccounts(request); Long accountsId = UserUtils.getmpaccounts(request);
...@@ -135,7 +138,7 @@ public class WxQrcodeController { ...@@ -135,7 +138,7 @@ public class WxQrcodeController {
wxQrcode.setAccountsId(UserUtils.getmpaccounts(request)); wxQrcode.setAccountsId(UserUtils.getmpaccounts(request));
wxQrcode.setCreateBy(UserUtils.getUser().getId()); wxQrcode.setCreateBy(UserUtils.getUser().getId());
wxQrcode.setUpdateBy(UserUtils.getUser().getId()); wxQrcode.setUpdateBy(UserUtils.getUser().getId());
wxQrcode.setBindId(wxQrcode.getBindId());
JSONObject wxObj = wxQrcodeUtil.createLimitQrcode(accountsId, sceneId); JSONObject wxObj = wxQrcodeUtil.createLimitQrcode(accountsId, sceneId);
if (wxObj.containsKey("ticket")) { if (wxObj.containsKey("ticket")) {
wxQrcode.setTicket(wxObj.getString("ticket")); wxQrcode.setTicket(wxObj.getString("ticket"));
...@@ -153,9 +156,38 @@ public class WxQrcodeController { ...@@ -153,9 +156,38 @@ public class WxQrcodeController {
return rtnJson; return rtnJson;
} }
//获取用户展示数据
@RequestMapping(value = "/listUser",method = {RequestMethod.GET})
@ResponseBody
public JSONObject fromUser( int userId,String name) {
JSONObject rtnJson = new JSONObject();
if (!StringUtils.isEmpty(userId)) {
List<QyUser> qyUsers = wxQrcodeService.fromUser(userId,name);
int countUser = wxQrcodeService.countUser(userId);
rtnJson.put("iTotalRecords", countUser);
rtnJson.put("iTotalDisplayRecords", countUser);
rtnJson.put("data", qyUsers);
}
return rtnJson;
}
//获取组织展示数据
@RequestMapping(value = "/listOrg",method = {RequestMethod.GET})
@ResponseBody
public JSONObject fromOrg(@RequestParam(required = false)String name) {
JSONObject rtnJson = new JSONObject();
List<WxQrcode> wxQrcodes = wxQrcodeService.fromOrg(name);
int countOrg = wxQrcodeService.countOrg();
rtnJson.put("iTotalRecords", countOrg);
rtnJson.put("iTotalDisplayRecords", countOrg);
rtnJson.put("data", wxQrcodes);
return rtnJson;
}
//获取列表数据 //获取列表数据
@RequiresPermissions(value = WXQRCODE_VIEW) @RequiresPermissions(value = WXQRCODE_VIEW)
@RequestMapping(value = "/listData",method = {RequestMethod.GET,RequestMethod.POST}) @RequestMapping(value = "/listData", method = {RequestMethod.GET, RequestMethod.POST})
@ResponseBody @ResponseBody
public JSONObject listData(int iDisplayStart, int iDisplayLength, WxQrcode wxQrcode, HttpServletRequest request, @RequestParam(required = false) String isempty) { public JSONObject listData(int iDisplayStart, int iDisplayLength, WxQrcode wxQrcode, HttpServletRequest request, @RequestParam(required = false) String isempty) {
Long accountsId = UserUtils.getmpaccounts(request); Long accountsId = UserUtils.getmpaccounts(request);
...@@ -184,7 +216,7 @@ public class WxQrcodeController { ...@@ -184,7 +216,7 @@ public class WxQrcodeController {
//删除数据 //删除数据
@RequiresPermissions(value = WXQRCODE_EDIT) @RequiresPermissions(value = WXQRCODE_EDIT)
@RequestMapping(value = "/delete",method = {RequestMethod.POST}) @RequestMapping(value = "/delete", method = {RequestMethod.POST})
@ResponseBody @ResponseBody
public JSONObject delete(String id) { public JSONObject delete(String id) {
JSONObject rtnJosn = new JSONObject(); JSONObject rtnJosn = new JSONObject();
...@@ -200,7 +232,7 @@ public class WxQrcodeController { ...@@ -200,7 +232,7 @@ public class WxQrcodeController {
//提交数据(新增、修改) //提交数据(新增、修改)
@RequiresPermissions(value = WXQRCODE_EDIT) @RequiresPermissions(value = WXQRCODE_EDIT)
@RequestMapping(value = "/pformData",method = {RequestMethod.POST}) @RequestMapping(value = "/pformData", method = {RequestMethod.POST})
@ResponseBody @ResponseBody
public JSONObject pformData(WxQrcode wxQrcode, Model model, HttpServletRequest request, Long qty) { public JSONObject pformData(WxQrcode wxQrcode, Model model, HttpServletRequest request, Long qty) {
Long accountsId = UserUtils.getmpaccounts(request); Long accountsId = UserUtils.getmpaccounts(request);
...@@ -236,7 +268,7 @@ public class WxQrcodeController { ...@@ -236,7 +268,7 @@ public class WxQrcodeController {
//获取列表数据 //获取列表数据
@RequiresPermissions(value = WXQRCODE_VIEW) @RequiresPermissions(value = WXQRCODE_VIEW)
@RequestMapping(value = "/exportQrcode",method = {RequestMethod.GET,RequestMethod.POST}) @RequestMapping(value = "/exportQrcode", method = {RequestMethod.GET, RequestMethod.POST})
@ResponseBody @ResponseBody
public void exportQrcode(int iDisplayStart, int iDisplayLength, WxQrcode wxQrcode, HttpServletRequest request, HttpServletResponse response, @RequestParam(required = false) String isempty) { public void exportQrcode(int iDisplayStart, int iDisplayLength, WxQrcode wxQrcode, HttpServletRequest request, HttpServletResponse response, @RequestParam(required = false) String isempty) {
response.setHeader("Pragma", "No-cache"); response.setHeader("Pragma", "No-cache");
...@@ -244,7 +276,7 @@ public class WxQrcodeController { ...@@ -244,7 +276,7 @@ public class WxQrcodeController {
response.setDateHeader("Expires", 0); response.setDateHeader("Expires", 0);
response.setContentType("application/zip"); response.setContentType("application/zip");
List<BufferedImage> buffImgs = new ArrayList<BufferedImage>(); List<BufferedImage> buffImgs = new ArrayList<BufferedImage>();
try{ try {
Long accountsId = UserUtils.getmpaccounts(request); Long accountsId = UserUtils.getmpaccounts(request);
Conds conds = new Conds(); Conds conds = new Conds();
conds.equal("t.del_flag", Constants.DEL_FLAG_0); conds.equal("t.del_flag", Constants.DEL_FLAG_0);
...@@ -261,26 +293,26 @@ public class WxQrcodeController { ...@@ -261,26 +293,26 @@ public class WxQrcodeController {
Sort sort = new Sort("t.create_time", OrderType.DESC); Sort sort = new Sort("t.create_time", OrderType.DESC);
List<WxQrcodeVO> list = wxQrcodeService.fetchSearchByPageVO(conds, sort, iDisplayStart, iDisplayLength); List<WxQrcodeVO> list = wxQrcodeService.fetchSearchByPageVO(conds, sort, iDisplayStart, iDisplayLength);
String fileName= URLEncoder.encode("二维码信息", "UTF-8")+"-"+System.currentTimeMillis()/1000; String fileName = URLEncoder.encode("二维码信息", "UTF-8") + "-" + System.currentTimeMillis() / 1000;
response.setHeader("Content-Disposition", "attachment;fileName="+fileName+".zip"); response.setHeader("Content-Disposition", "attachment;fileName=" + fileName + ".zip");
ZipOutputStream zos = new ZipOutputStream(response ZipOutputStream zos = new ZipOutputStream(response
.getOutputStream()); .getOutputStream());
int i=1; int i = 1;
for(WxQrcodeVO obj:list){ for (WxQrcodeVO obj : list) {
String uri=SystemConfig.p.getProperty("WX_MP_QRCODE_URI")+obj.getTicket(); String uri = SystemConfig.p.getProperty("WX_MP_QRCODE_URI") + obj.getTicket();
String name=""; String name = "";
String type=obj.getType(); String type = obj.getType();
if(type.equals("0")){ if (type.equals("0")) {
name=obj.getStoreName(); name = obj.getStoreName();
}else if(type.equals("1")){ } else if (type.equals("1")) {
name=obj.getEmpName(); name = obj.getEmpName();
}else if(type.equals("2")){ } else if (type.equals("2")) {
name=obj.getCarName(); name = obj.getCarName();
} }
if(StringUtils.isEmpty(name)){ if (StringUtils.isEmpty(name)) {
name="未被绑定"; name = "未被绑定";
} }
ZipEntry entry = new ZipEntry(name+String.valueOf(i) + ".png"); ZipEntry entry = new ZipEntry(name + String.valueOf(i) + ".png");
// 设置压缩包的入口 // 设置压缩包的入口
zos.putNextEntry(entry); zos.putNextEntry(entry);
zos.write(HttpURLConnectionUtil.getByteInputStreamByGet(uri)); zos.write(HttpURLConnectionUtil.getByteInputStreamByGet(uri));
...@@ -289,9 +321,9 @@ public class WxQrcodeController { ...@@ -289,9 +321,9 @@ public class WxQrcodeController {
} }
zos.close(); zos.close();
response.getOutputStream().flush(); response.getOutputStream().flush();
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
}finally { } finally {
try { try {
response.getOutputStream().close(); response.getOutputStream().close();
} catch (IOException e) { } catch (IOException e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment