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

产品分类改成多选

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