Commit 28731320 authored by 卜远杰's avatar 卜远杰

产品分类改成多选

parent 606f0129
...@@ -39,4 +39,11 @@ public interface ProductclassifyMapper extends GenericDao<Productclassify> { ...@@ -39,4 +39,11 @@ public interface ProductclassifyMapper extends GenericDao<Productclassify> {
* @return * @return
**/ **/
List<ProductMenuVO> productMenu(); List<ProductMenuVO> productMenu();
/**
* 根据分类编码查分类ID
* @param classifyNumber
* @return
*/
String selectIdsByNumber(String classifyNumber);
} }
\ No newline at end of file
...@@ -146,6 +146,18 @@ ...@@ -146,6 +146,18 @@
<if test="limit>0">limit #{offset},#{limit}</if> <if test="limit>0">limit #{offset},#{limit}</if>
</select> </select>
<select id="selectIdsByNumber" parameterType="java.lang.String" resultType="java.lang.String">
SELECT
GROUP_CONCAT(c.id) id
FROM
t_aidea_product_classify c
WHERE
FIND_IN_SET(
c.classify_number,
#{classifyNumber})
and c.del_flag = 0
</select>
<update id="update" parameterType="com.cftech.productclassify.model.Productclassify"> <update id="update" parameterType="com.cftech.productclassify.model.Productclassify">
update t_aidea_product_classify update t_aidea_product_classify
......
...@@ -43,4 +43,11 @@ public interface ProductclassifyService extends GenericService<Productclassify> ...@@ -43,4 +43,11 @@ public interface ProductclassifyService extends GenericService<Productclassify>
**/ **/
JSONObject productMenu(); JSONObject productMenu();
/**
* 根据分类编码查分类ID
* @param classifyNumber
* @return
*/
String selectIdsByNumber(String classifyNumber);
} }
...@@ -91,4 +91,9 @@ public class ProductclassifyServiceImpl extends GenericServiceImpl<Productclassi ...@@ -91,4 +91,9 @@ public class ProductclassifyServiceImpl extends GenericServiceImpl<Productclassi
return rtnJson; return rtnJson;
} }
@Override
public String selectIdsByNumber(String classifyNumber) {
return productclassifyMapper.selectIdsByNumber(classifyNumber);
}
} }
\ No newline at end of file
...@@ -255,11 +255,12 @@ public class ProductclassifyController { ...@@ -255,11 +255,12 @@ public class ProductclassifyController {
Conds conds = new Conds(); Conds conds = new Conds();
conds.equal("del_flag", 0); conds.equal("del_flag", 0);
conds.equal("accounts_id", UserUtils.getmpaccounts(request)); conds.equal("accounts_id", UserUtils.getmpaccounts(request));
conds.equal("parent_id",0);
List<Productclassify> papercategories = productclassifyService.fetchTreeByPage(conds, sort, 0, 0); List<Productclassify> papercategories = productclassifyService.fetchTreeByPage(conds, sort, 0, 0);
JSONObject t = new JSONObject(); JSONObject t = new JSONObject();
t.put("id", 0); t.put("id", 0);
t.put("pId", -1); t.put("pId", -1);
t.put("name", fatherName); t.put("name", "产品分类");
t.put("open", true); t.put("open", true);
array.add(t); array.add(t);
for (Productclassify productclassify : papercategories) { for (Productclassify productclassify : papercategories) {
......
...@@ -213,7 +213,7 @@ ...@@ -213,7 +213,7 @@
},{ },{
"mData":"productNumber" "mData":"productNumber"
},{ },{
"mData":"" "mData":"productName"
},{ },{
"mData":"productImg" "mData":"productImg"
},{ },{
......
...@@ -128,7 +128,7 @@ ...@@ -128,7 +128,7 @@
d.product_detail_number productDetailNumber, d.product_detail_number productDetailNumber,
d.materiel_number materielNumber, d.materiel_number materielNumber,
d.product_number productNumber, d.product_number productNumber,
d.product_name productName, p.product_name productName,
d.product_classify_number productClassifyNumber, d.product_classify_number productClassifyNumber,
d.into_wareroom_number intoWareroomNumber, d.into_wareroom_number intoWareroomNumber,
d.out_wareroom_number outWareroomNumber, d.out_wareroom_number outWareroomNumber,
...@@ -145,12 +145,15 @@ ...@@ -145,12 +145,15 @@
d.update_by updateBy, d.update_by updateBy,
d.out_wareroom_time outWareroomTime, d.out_wareroom_time outWareroomTime,
p.product_img productImg, p.product_img productImg,
c.classify_name classifyName GROUP_CONCAT(c.classify_name) classifyName
FROM FROM
t_aidea_product_detail d t_aidea_product_detail d
LEFT JOIN t_aidea_product p on d.product_number = p.product_number and p.del_flag = 0 LEFT JOIN t_aidea_product p ON d.product_number = p.product_number
LEFT JOIN t_aidea_product_classify c on d.product_classify_number = c.classify_number and c.del_flag = 0 AND p.del_flag = 0
LEFT JOIN t_aidea_product_classify c ON FIND_IN_SET(c.classify_number,d.product_classify_number )
AND c.del_flag = 0
<include refid="sqlWhere"/> <include refid="sqlWhere"/>
GROUP BY d.id
<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>
</select> </select>
......
...@@ -39,6 +39,8 @@ ...@@ -39,6 +39,8 @@
<link rel="stylesheet" href="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css"> <link rel="stylesheet" href="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
<!--validate css--> <!--validate css-->
<link rel="stylesheet" href="plugins/jquery-validation/css/validate.css"> <link rel="stylesheet" href="plugins/jquery-validation/css/validate.css">
<!-- Select2 -->
<link rel="stylesheet" href="plugins/select2/select2.min.css">
<!--fileinput css--> <!--fileinput css-->
<link rel="stylesheet" href="plugins/bootstrap-fileinput/bootstrap-fileinput.css"> <link rel="stylesheet" href="plugins/bootstrap-fileinput/bootstrap-fileinput.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
...@@ -80,18 +82,11 @@ ...@@ -80,18 +82,11 @@
<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>
<div class="input-group"> <select class="form-control pull-right select2 role" multiple="multiple" data-placeholder="请选择分类">
<input type="text" name="classifyId" id="classifyId" #foreach( $classify in $list )
value="$!{data.classifyId}" <option value="${classify.id}" data-attr="${role.roleSign}">${classify.classifyName}</option>
class="form-control" style="display: none"> #end
<input type="text" id="classifyName" </select>
name="classifyName" value="$!{data.classifyName}"
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>
...@@ -222,6 +217,14 @@ ...@@ -222,6 +217,14 @@
</select> </select>
</div> </div>
<div class="form-group form-md-line-input col-md-12">
<label>销量</label>
<input type="text" class="form-control pull-right"
value="$!{data.reading}" maxlength="200" required
name="reading" placeholder="销量"
>
</div>
<input type="text" style="display: none" name="_csrf" value="${_csrf.token}"/> <input type="text" style="display: none" name="_csrf" value="${_csrf.token}"/>
...@@ -263,6 +266,8 @@ ...@@ -263,6 +266,8 @@
<!--fileinput js--> <!--fileinput js-->
<script src="plugins/bootstrap-fileinput/bootstrap-fileinput.js"></script> <script src="plugins/bootstrap-fileinput/bootstrap-fileinput.js"></script>
<!-- AdminLTE App --> <!-- AdminLTE App -->
<!-- Select2 -->
<script src="plugins/select2/select2.full.min.js"></script>
<script src="dist/js/app.min.js"></script> <script src="dist/js/app.min.js"></script>
<script src="plugins/bootstrap-maxlength/bootstrap-maxlength.min.js" type="text/javascript"></script> <script src="plugins/bootstrap-maxlength/bootstrap-maxlength.min.js" type="text/javascript"></script>
<script src="plugins/security/sha256.js" type="text/javascript"></script> <script src="plugins/security/sha256.js" type="text/javascript"></script>
...@@ -283,6 +288,10 @@ ...@@ -283,6 +288,10 @@
recdTypeAdd.init(); recdTypeAdd.init();
initPicsSel(); initPicsSel();
initPicsSelDetail(); initPicsSelDetail();
$(".select2").select2();
var classifyId ="$!{data.classifyId}";
$(".select2").val(classifyId.split(",")).trigger("change");
}); });
var coverPP = null; var coverPP = null;
...@@ -374,6 +383,8 @@ ...@@ -374,6 +383,8 @@
var data = $("#myForm").serializeJSON(); var data = $("#myForm").serializeJSON();
var productImg = coverPP.getStringValues().split(',')[0]; var productImg = coverPP.getStringValues().split(',')[0];
var productImgDetail = coverPPDetail.getStringValues(); var productImgDetail = coverPPDetail.getStringValues();
var classify = $('.select2').select2('val').toString();
data.classifyId = classify;
data.productImg = productImg; data.productImg = productImg;
data.productImgDetail = productImgDetail; data.productImgDetail = productImgDetail;
$.post("#springUrl('/a/product/formData')", data, function (returnobj) { $.post("#springUrl('/a/product/formData')", data, function (returnobj) {
......
...@@ -43,7 +43,8 @@ ...@@ -43,7 +43,8 @@
href="plugins\bootstrap-fileinput\fileinput.min.css"> href="plugins\bootstrap-fileinput\fileinput.min.css">
<!-- bootstrap wysihtml5 - text editor --> <!-- bootstrap wysihtml5 - text editor -->
<link rel="stylesheet" href="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css"> <link rel="stylesheet" href="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
<!-- Select2 -->
<link rel="stylesheet" href="plugins/select2/select2.min.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]> <!--[if lt IE 9]>
...@@ -84,8 +85,14 @@ ...@@ -84,8 +85,14 @@
</div> </div>
<div class="col-xs-2"> <div class="col-xs-2">
<input type="text" class="form-control " <!--<input type="text" class="form-control "
name="classifyName" placeholder="产品分类名称"> name="classifyName" placeholder="产品分类名称">-->
<select class="form-control" name="classifyId">
<option value="">请选择分类</option>
#foreach( $classify in $list )
<option value="${classify.id}" data-attr="${role.roleSign}">${classify.classifyName}</option>
#end
</select>
</div> </div>
<div class="col-xs-5"> <div class="col-xs-5">
...@@ -119,6 +126,7 @@ ...@@ -119,6 +126,7 @@
<td>库存</td> <td>库存</td>
<td>价格</td> <td>价格</td>
<td>是否为处方药</td> <td>是否为处方药</td>
<td>销量</td>
<td>创建时间</td> <td>创建时间</td>
<td>操作</td> <td>操作</td>
</tr> </tr>
...@@ -159,6 +167,8 @@ ...@@ -159,6 +167,8 @@
<script src="plugins/bootstrap-fileinput/zh2.js"></script> <script src="plugins/bootstrap-fileinput/zh2.js"></script>
<!-- AdminLTE App --> <!-- AdminLTE App -->
<script src="dist/js/app.min.js"></script> <script src="dist/js/app.min.js"></script>
<!-- Select2 -->
<script src="plugins/select2/select2.full.min.js"></script>
<script type="text/javascript" <script type="text/javascript"
src="plugins/jquery-validation/js/jquery.validate.min.js"></script> src="plugins/jquery-validation/js/jquery.validate.min.js"></script>
<!-- AdminLTE for demo purposes --> <!-- AdminLTE for demo purposes -->
...@@ -188,7 +198,7 @@ ...@@ -188,7 +198,7 @@
} }
var retrieveData = function (sSource, aoData, fnCallback) { var retrieveData = function (sSource, aoData, fnCallback) {
$("#seachTableForm input").each(function () { $("#seachTableForm input,select").each(function () {
var params = { var params = {
name: $(this).attr("name"), name: $(this).attr("name"),
value: $(this).val() value: $(this).val()
...@@ -268,6 +278,9 @@ ...@@ -268,6 +278,9 @@
{ {
"mData":"isRs" "mData":"isRs"
}, },
{
"mData":"reading"
},
{ {
"mData": "createTime" "mData": "createTime"
}, },
...@@ -289,7 +302,7 @@ ...@@ -289,7 +302,7 @@
}, },
{ {
"aTargets": [17], "aTargets": [18],
"mData": "createTime", "mData": "createTime",
"mRender": function (a, b, c, d) { "mRender": function (a, b, c, d) {
return formatDates(a, "yyyy-MM-dd HH:mm:ss"); return formatDates(a, "yyyy-MM-dd HH:mm:ss");
...@@ -297,7 +310,7 @@ ...@@ -297,7 +310,7 @@
}, },
{ {
"aTargets": [18], "aTargets": [19],
"mData": "id", "mData": "id",
"mRender": function (a, b, c, d) { "mRender": function (a, b, c, d) {
var html = '#if($shiro.hasPermission("qy:product:edit"))';// var html = '#if($shiro.hasPermission("qy:product:edit"))';//
...@@ -326,6 +339,7 @@ ...@@ -326,6 +339,7 @@
$('.search').click(function () { $('.search').click(function () {
$("#table").dataTable().fnClearTable(); $("#table").dataTable().fnClearTable();
}); });
$(".select2").select2();
}); });
Cfapp.init(); Cfapp.init();
......
...@@ -6,6 +6,7 @@ import com.cftech.product.model.ProductVO; ...@@ -6,6 +6,7 @@ import com.cftech.product.model.ProductVO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 产品Mapper * 产品Mapper
...@@ -22,4 +23,11 @@ public interface ProductMapper extends GenericDao<Product> { ...@@ -22,4 +23,11 @@ public interface ProductMapper extends GenericDao<Product> {
* @return * @return
**/ **/
List<ProductVO> product(@Param("ID") Long ID); List<ProductVO> product(@Param("ID") Long ID);
/**
* 查询产品列表
* @param params
* @return
*/
List<Product> selectProduct(Map<String,Object> params);
} }
\ No newline at end of file
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
<result column="product_number" property="productNumber"/> <result column="product_number" property="productNumber"/>
<result column="product_img_detail" property="productImgDetail"/> <result column="product_img_detail" property="productImgDetail"/>
<result column="is_rs" property="isRs"/> <result column="is_rs" property="isRs"/>
<result column="reading" property="reading"/>
</resultMap> </resultMap>
<sql id="sqlWhere"> <sql id="sqlWhere">
...@@ -86,7 +87,8 @@ ...@@ -86,7 +87,8 @@
update_by, update_by,
product_number, product_number,
product_img_detail, product_img_detail,
is_rs is_rs,
reading
</sql> </sql>
<sql id="productList"> <sql id="productList">
...@@ -148,7 +150,8 @@ ...@@ -148,7 +150,8 @@
#{updateBy, jdbcType=BIGINT}, #{updateBy, jdbcType=BIGINT},
#{productNumber,jdbcType=VARCHAR}, #{productNumber,jdbcType=VARCHAR},
#{productImgDetail,jdbcType=VARCHAR}, #{productImgDetail,jdbcType=VARCHAR},
#{isRs,jdbcType=VARCHAR} #{isRs,jdbcType=VARCHAR},
#{reading,jdbcType=VARCHAR}
) )
</insert> </insert>
...@@ -195,12 +198,57 @@ ...@@ -195,12 +198,57 @@
a.create_by createBy, a.create_by createBy,
a.update_by updateBy, a.update_by updateBy,
a.product_number productNumber, a.product_number productNumber,
a.is_rs isRs a.is_rs isRs,
a.reading reading
FROM FROM
t_aidea_product a t_aidea_product a
LEFT JOIN t_aidea_product_classify b ON a.classify_id = b.id LEFT JOIN t_aidea_product_classify b ON a.classify_id = b.id
AND b.del_flag = '0' AND b.del_flag = '0'
<if test="sort!=null">ORDER BY ${sort.param} ${sort.type}</if>
<if test="limit>0">limit #{offset},#{limit}</if>
</select>
<select id="selectProduct" parameterType="java.util.Map" resultMap="resultMap">
SELECT
a.id id,
a.classify_id classfyId,
GROUP_CONCAT(b.classify_name) classifyName,
a.product_name productName,
a.common_name commonName,
a.dosaga_from dosagaFrom,
a.format format,
a.approve_number approveNumber,
a.manufacturer manufacturer,
a.recommend_measure recommendMeasure,
a.tips tips,
a.take_type takeType,
a.take_frequency takeFrequency,
a.take_amount takeAmount,
a.stock stock,
a.price price,
a.product_img productImg,
a.accounts_id accountsId,
a.del_flag delFlag,
a.STATUS,
a.create_time createTime,
a.update_time updateTime,
a.description,
a.create_by createBy,
a.update_by updateBy,
a.product_number productNumber,
a.is_rs isRs,
a.reading reading
FROM
t_aidea_product a
LEFT JOIN t_aidea_product_classify b ON FIND_IN_SET(b.id,a.classify_id)
AND b.del_flag = '0'
<include refid="sqlWhere"/> <include refid="sqlWhere"/>
<if test="classifyId != null">
<foreach collection="classifyId" index="index" item="item" open="" separator="" close="">
AND FIND_IN_SET(#{item},a.classify_id)
</foreach>
</if>
GROUP BY a.id
<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>
</select> </select>
...@@ -284,6 +332,9 @@ ...@@ -284,6 +332,9 @@
<if test="isRs != null"> <if test="isRs != null">
is_rs = #{isRs, jdbcType=VARCHAR}, is_rs = #{isRs, jdbcType=VARCHAR},
</if> </if>
<if test="reading != null">
reading = #{reading , jdbcType=VARCHAR},
</if>
</set> </set>
where id=#{id,jdbcType=BIGINT} where id=#{id,jdbcType=BIGINT}
</update> </update>
......
...@@ -26,7 +26,7 @@ public class Product implements Serializable { ...@@ -26,7 +26,7 @@ public class Product implements Serializable {
/** /**
* 产品分类编码 * 产品分类编码
*/ */
@ExportConfig(value = "产品分类编码",width = 150 ,showLevel = 2) @ExportConfig(value = "产品分类编码(多个分类用英文逗号隔开)",width = 200 ,showLevel = 2)
private String classifyNumber; private String classifyNumber;
/** /**
* 产品分类名称 * 产品分类名称
...@@ -129,6 +129,11 @@ public class Product implements Serializable { ...@@ -129,6 +129,11 @@ public class Product implements Serializable {
* 入库编码 * 入库编码
*/ */
private String ruKuNumber; private String ruKuNumber;
/**
* 销量
*/
@ExportConfig(value = "销量",width = 200)
private String reading;
/* 所属的账号 */ /* 所属的账号 */
private Long accountsId; private Long accountsId;
/* 删除标识 */ /* 删除标识 */
......
package com.cftech.product.service; package com.cftech.product.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.cftech.core.sql.Conds;
import com.cftech.core.sql.Sort;
import com.cftech.product.model.Product; import com.cftech.product.model.Product;
import com.cftech.core.generic.GenericService; import com.cftech.core.generic.GenericService;
import com.cftech.product.model.ProductVO; import com.cftech.product.model.ProductVO;
import java.util.List;
/** /**
* 产品Service * 产品Service
* *
...@@ -28,4 +32,15 @@ public interface ProductService extends GenericService<Product> { ...@@ -28,4 +32,15 @@ public interface ProductService extends GenericService<Product> {
* @return * @return
**/ **/
JSONObject productId(Long ID); JSONObject productId(Long ID);
/**
* 查询产品列表
* @param conds
* @param sort
* @param pageSize
* @param pageNo
* @param classifyId
* @return
*/
List<Product> selectProduct(Conds conds, Sort sort,int pageSize,int pageNo,List<String> classifyId);
} }
...@@ -2,6 +2,7 @@ package com.cftech.product.service.impl; ...@@ -2,6 +2,7 @@ package com.cftech.product.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.cftech.base.codingrule.utils.CodingruleUtils; import com.cftech.base.codingrule.utils.CodingruleUtils;
import com.cftech.core.sql.Sort;
import com.cftech.core.util.StringUtils; import com.cftech.core.util.StringUtils;
import com.cftech.product.model.Product; import com.cftech.product.model.Product;
import com.cftech.product.dao.ProductMapper; import com.cftech.product.dao.ProductMapper;
...@@ -186,5 +187,16 @@ public class ProductServiceImpl extends GenericServiceImpl<Product> implements P ...@@ -186,5 +187,16 @@ public class ProductServiceImpl extends GenericServiceImpl<Product> implements P
return rtnJson; return rtnJson;
} }
@Override
public List<Product> selectProduct(Conds conds, Sort sort, int page, int pageSize, List<String> classifyId) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("conds", conds);
params.put("offset", page > 0 ? page : 0);
params.put("limit", pageSize > 0 ? pageSize : 0);
params.put("sort", sort);
params.put("classifyId",classifyId);
return productMapper.selectProduct(params);
}
} }
\ No newline at end of file
...@@ -28,6 +28,7 @@ import javax.servlet.http.HttpServletRequest; ...@@ -28,6 +28,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays;
import java.util.List; import java.util.List;
...@@ -64,6 +65,11 @@ public class ProductController { ...@@ -64,6 +65,11 @@ public class ProductController {
@RequestMapping("/list") @RequestMapping("/list")
public String list(HttpServletRequest request, Model model) { public String list(HttpServletRequest request, Model model) {
Long accountId = UserUtils.getmpaccounts(request); Long accountId = UserUtils.getmpaccounts(request);
Conds conds = new Conds();
conds.equal("a.del_flag",0);
Sort sort = new Sort("a.create_time",OrderType.DESC);
List<Productclassify> list = productclassifyService.fetchSearchByPage(conds,sort,0,0);
model.addAttribute("list",list);
model.addAttribute("accountId", accountId); model.addAttribute("accountId", accountId);
return "product/productlist"; return "product/productlist";
} }
...@@ -74,12 +80,13 @@ public class ProductController { ...@@ -74,12 +80,13 @@ public class ProductController {
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)) {
Product product = productService.fetchById(id); Product product = productService.fetchById(id);
if (!StringUtils.isEmpty(product.getClassifyId())) {
product.setClassifyName(productclassifyService.fetchById(product.getClassifyId()).getClassifyName());
}
model.addAttribute("data", product); model.addAttribute("data", product);
} }
Conds conds = new Conds();
conds.equal("a.del_flag",0);
Sort sort = new Sort("a.create_time",OrderType.DESC);
List<Productclassify> list = productclassifyService.fetchSearchByPage(conds,sort,0,0);
model.addAttribute("list",list);
return "product/productform"; return "product/productform";
} }
...@@ -121,16 +128,17 @@ public class ProductController { ...@@ -121,16 +128,17 @@ public class ProductController {
Conds conds = new Conds(); Conds conds = new Conds();
conds.equal("a.del_flag", Constants.DEL_FLAG_0); conds.equal("a.del_flag", Constants.DEL_FLAG_0);
conds.equal("a.accounts_id", accountsId); conds.equal("a.accounts_id", accountsId);
List<String> classifyId = null;
if(!StringUtils.isEmpty(product.getProductName())){ if(!StringUtils.isEmpty(product.getProductName())){
conds.like("a.product_name",product.getProductName()); conds.like("a.product_name",product.getProductName());
} }
if(!StringUtils.isEmpty(product.getClassifyId())){
if(!StringUtils.isEmpty(product.getClassifyName())){ classifyId = Arrays.asList(product.getClassifyId().split(","));
conds.like("b.classify_name",product.getClassifyName());
} }
Sort sort = new Sort("a.create_time", OrderType.DESC); Sort sort = new Sort("a.create_time", OrderType.DESC);
List<Product> list = productService.fetchSearchByPage(conds, sort, iDisplayStart, iDisplayLength); List<Product> list = productService.selectProduct(conds, sort, iDisplayStart, iDisplayLength,classifyId);
Integer counts = productService.count(conds); Integer counts = productService.count(conds);
JSONObject rtnJson = new JSONObject(); JSONObject rtnJson = new JSONObject();
rtnJson.put("iTotalRecords", counts); rtnJson.put("iTotalRecords", counts);
...@@ -157,19 +165,20 @@ public class ProductController { ...@@ -157,19 +165,20 @@ public class ProductController {
@RequestMapping("/exportExcel") @RequestMapping("/exportExcel")
@RequiresPermissions(value = PRODUCT_VIEW) @RequiresPermissions(value = PRODUCT_VIEW)
public void exportExcel(HttpServletRequest request, HttpServletResponse response ,Product product) { public void exportExcel(HttpServletRequest request, HttpServletResponse response ,Product product) {
Long accountId = UserUtils.getmpaccounts(request); Long accountsId = UserUtils.getmpaccounts(request);
Conds conds = new Conds(); Conds conds = new Conds();
conds.equal("a.del_flag", 0); conds.equal("a.del_flag", Constants.DEL_FLAG_0);
conds.equal("a.accounts_id", accountId); conds.equal("a.accounts_id", accountsId);
List<String> classifyId = null;
if(!StringUtils.isEmpty(product.getProductName())){ if(!StringUtils.isEmpty(product.getProductName())){
conds.like("a.product_name",product.getProductName()); conds.like("a.product_name",product.getProductName());
} }
if(!StringUtils.isEmpty(product.getClassifyId())){
if(!StringUtils.isEmpty(product.getClassifyName())){ classifyId = Arrays.asList(product.getClassifyId().split(","));
conds.like("a.classify_name",product.getClassifyName());
} }
Sort sort = new Sort("a.create_time", OrderType.DESC); Sort sort = new Sort("a.create_time", OrderType.DESC);
List<Product> list = productService.fetchSearchByPage(conds, sort, 0, 0);
List<Product> list = productService.selectProduct(conds, sort, 0, 0,classifyId);
ExcelKit.$Export(Product.class, response).toExcel(list, "产品信息"); ExcelKit.$Export(Product.class, response).toExcel(list, "产品信息");
} }
...@@ -185,6 +194,7 @@ public class ProductController { ...@@ -185,6 +194,7 @@ public class ProductController {
public JSONObject importExcel(HttpServletRequest request, MultipartFile file, Model model) { public JSONObject importExcel(HttpServletRequest request, MultipartFile file, Model model) {
JSONObject retJson = new JSONObject(); JSONObject retJson = new JSONObject();
StringBuffer sbClassify = new StringBuffer(); StringBuffer sbClassify = new StringBuffer();
StringBuffer sbProduct = new StringBuffer();
boolean classify = true; boolean classify = true;
Long accountId = UserUtils.getmpaccounts(request); Long accountId = UserUtils.getmpaccounts(request);
String ruKuNumber = codingruleUtils.getNumber(accountId, ProductIntoWareroom.class.getName()); String ruKuNumber = codingruleUtils.getNumber(accountId, ProductIntoWareroom.class.getName());
...@@ -207,19 +217,24 @@ public class ProductController { ...@@ -207,19 +217,24 @@ public class ProductController {
ExcelKit.$Import().setEmptyCellValue("").readExcel(storeFile, rowData -> { ExcelKit.$Import().setEmptyCellValue("").readExcel(storeFile, rowData -> {
Product product = new Product(); Product product = new Product();
if(!StringUtils.isEmpty(rowData.get(0))){ if(!StringUtils.isEmpty(rowData.get(0))){
Conds conds = new Conds(); String ids = productclassifyService.selectIdsByNumber(rowData.get(0));
conds.equal("a.classify_number",rowData.get(0)); if(ids != null){
conds.equal("a.del_flag","0");
Productclassify productClassifyParent = productclassifyService.fetchSearchByConds(conds);
if(productClassifyParent != null){
//产品分类ID //产品分类ID
product.setClassifyId(String.valueOf(productClassifyParent.getId())); product.setClassifyId(ids);
product.setClassifyNumber(rowData.get(0)); product.setClassifyNumber(rowData.get(0));
} }
} }
product.setAccountsId(accountId); product.setAccountsId(accountId);
//产品编码 //产品编码
product.setProductNumber(rowData.get(1)); product.setProductNumber(rowData.get(1));
Conds conds = new Conds();
conds.equal("product_number",rowData.get(1));
conds.equal("del_flag",0);
Product listProduct = productService.fetchSearchByConds(conds);
if(listProduct == null){
sbProduct.append(rowData.get(1));
return;
}
//产品名称 //产品名称
product.setProductName(rowData.get(2)); product.setProductName(rowData.get(2));
// 通用名 // 通用名
...@@ -271,6 +286,8 @@ public class ProductController { ...@@ -271,6 +286,8 @@ public class ProductController {
retJson.put("errorNo", "0"); retJson.put("errorNo", "0");
if(sbClassify.length()>0){ if(sbClassify.length()>0){
retJson.put("errorMsg", "部分导入失败,产品编码有:"+sbClassify.toString()+"; 失败原因:库存不能为空或者为负数"); retJson.put("errorMsg", "部分导入失败,产品编码有:"+sbClassify.toString()+"; 失败原因:库存不能为空或者为负数");
}else if(sbProduct.length() > 0){
retJson.put("errorMsg", "部分导入失败,产品编码有:"+sbClassify.toString()+"; 失败原因:错误产品编码");
}else{ }else{
retJson.put("errorMsg", "导入成功"); retJson.put("errorMsg", "导入成功");
} }
......
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