Commit dc664365 authored by 谢希宇's avatar 谢希宇

Submit by Strive

Date 2021/03/18
parent c29b84c8
......@@ -226,9 +226,9 @@
<input type="text" id="hospital" name="hospital"
value="$!{data.hospital}" class="form-control selHospital" readonly>
<span class="input-group-btn">
<button type="button" name="selHospital" id="selHospital"
class="btn btn-info btn-flat selHospital">选择</button>
</span>
<button type="button" name="selHospital" id="selHospital"
class="btn btn-info btn-flat selHospital">选择</button>
</span>
</div>
#end
</div>
......
......@@ -219,8 +219,8 @@
<!-- SlimScroll -->
<script src="plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!--<script src="plugins/bootstrap-dateTimePicker/bootstrap-datetimepicker.js"></script>-->
<!--<script src="plugins/bootstrap-dataTimePicker/bootstrap-datetimepicker.zh-CN.js"></script>-->
<script src="plugins/bootstrap-dateTimePicker/bootstrap-datetimepicker.js"></script>
<script src="plugins/bootstrap-dataTimePicker/bootstrap-datetimepicker.zh-CN.js"></script>
<!-- FastClick -->
<script src="plugins/fastclick/fastclick.min.js"></script>
<!--fileinput js-->
......@@ -234,7 +234,8 @@
<!-- AdminLTE for demo purposes -->
<script src="common/js/cfapp.js"></script>
<script src="js/moment.min.js"></script>
<script type="text/javascript" src="plugins/daterangepicker/daterangepicker.js"></script>
<script type="text/javascript"
src="plugins/daterangepicker/daterangepicker.js"></script>
<script>
function formatDates(now) {
var now = new Date(now);
......
......@@ -110,7 +110,7 @@ public class CouponrecordServiceImpl extends GenericServiceImpl<Couponrecord> im
Couponrecord lastCouponrecord = findCouponrecordBySort(null, openid).get(0);//获取最后一张券
if (StringUtils.equals(lastCouponrecord.getType(), "2")) {
//获取最后一张券失效时间购买数量
number = buyingMedicineNumber(openid, lastCouponrecord.getExpireDate());
number = buyingMedicineNumber(openid, lastCouponrecord.getCreateTime());
if (number >= 3) {//赠送第一张
String no = codingruleUtils.getPrimaryKey(CodingruleUtils.COUPON_KEY);
......@@ -152,8 +152,8 @@ public class CouponrecordServiceImpl extends GenericServiceImpl<Couponrecord> im
couponrecordMapper.save(couponrecord);
}
} else if (StringUtils.equals(lastCouponrecord.getType(), "1")) {//通过第一张开始时间获取购买数量
List<Couponrecord> firstCouponrecordList = findCouponrecordBySort("2", openid);
number = buyingMedicineNumber(openid, firstCouponrecordList.get(0).getExpireDate());//获取最后一张券购买数量
List<Couponrecord> lastCouponrecordList = findCouponrecordBySort("2", openid);
number = buyingMedicineNumber(openid, lastCouponrecordList.get(0).getCreateTime());//获取最后一张券购买数量
//通过第一张最后购买数量,所以只需赠送第二章
if (number >= 6) {//赠送第二张
......@@ -201,6 +201,8 @@ public class CouponrecordServiceImpl extends GenericServiceImpl<Couponrecord> im
conds.equal("d.drugs_id", SystemConfig.p.getProperty("THREE_DRUGS_ID"));
if (date != null) {
conds.greatEqual("t.pay_time", date);
} else {
conds.equal("DATE_FORMAT(t.pay_time, '%Y')", new Date().getYear());
}
conds.in("t.status", new String[]{"2", "3", "4"});
Map<String, Object> params = new HashMap<>();
......
......@@ -607,13 +607,13 @@
} else if (a == '1') {
return "<span style='color:RGB(255,51,0)'>待付款</span>";
} else if (a == '2') {
return "<span style='color:#06f'>待发货</span>";
return "<span>待发货</span>";
} else if (a == '3') {
return "<span style='color:#06f'>待收货</span>";
return "<span'>待收货</span>";
} else if (a == '4') {
return "<span style='color:#06f'>已完成</span>";
return "<span>已完成</span>";
} else if (a == '5') {
return "<span style='color:#06f'>已取消</span>";
return "<span>已取消</span>";
}
}
},
......
<!DOCTYPE html>
<!--[if IE 8]>
<html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]>
<html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html>
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
<base href="#springUrl('/assets/adminlte/')"/>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>工作台</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.5 -->
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="plugins/font-awesome/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="plugins/ionicons/css/ionicons.min.css">
<!-- DataTables -->
<link rel="stylesheet" href="plugins/datatables/dataTables.bootstrap.css">
<!-- Theme style -->
<link rel="stylesheet" href="dist/css/AdminLTE.min.css">
<!-- AdminLTE Skins. Choose a skin from the css/skins
folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
<!-- iCheck -->
<link rel="stylesheet" href="plugins/iCheck/flat/blue.css">
<!-- Date Picker -->
<link rel="stylesheet" href="plugins/datepicker/datepicker3.css">
<!-- Daterange picker -->
<link rel="stylesheet" href="plugins/daterangepicker/daterangepicker-bs3.css">
<!-- bootstrap wysihtml5 - text editor -->
<link rel="stylesheet" href="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
<!--validate css-->
<link rel="stylesheet" href="plugins/jquery-validation/css/validate.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 -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<!-- END HEAD -->
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
<div class="content-wrapper" style="margin-left:0;">
<section class="content-header">
<h1>
产品批次管理
<small>产品批次</small>
</h1>
<ol class="breadcrumb">
<li><a href="#"><i class="fa fa-dashboard"></i>首页</a></li>
<li><a class="active">产品批次</a></li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-xs-12">
<!-- general form elements disabled -->
<div class="box box-primary">
<form role="form" id="myForm">
<input name="id" value="$!{data.id}" hidden="true"/>
<div class="box-body">
<div class="form-group form-md-line-input col-md-12">
<label>产品名称</label>
<div class="input-group">
<input type="text" name="productId" id="productId" value="$!{data.productId}"
class="form-control" style="display: none">
<input type="text" id="productName" name="productName"
value="$!{data.commonName}" class="form-control selHospital" readonly>
<span class="input-group-btn">
<button type="button" name="selProduct" id="selProduct"
class="btn btn-info btn-flat selProduct">选择</button>
</span>
</div>
</div>
<div class="form-group form-md-line-input col-md-12">
<label>批次号</label>
<input type="text" required class="form-control pull-right"
value="$!{data.batchNo}" maxlength="500" required
name="batchNo" placeholder="批次号"
>
</div>
<div class="form-group form-md-line-input col-md-12">
<label>是否激活</label>
<select id="status" name="status" class="form-control pull-right">
<option value="0" #if($!{data.status}=='0') selected #end></option>
<option value="1" #if($!{data.status}=='1') selected #end></option>
</select>
</div>
<div class="form-group form-md-line-input col-md-12">
<label>描述</label>
<textarea type="text" required class="form-control pull-right"
value="" maxlength="1000" required rows="5"
name="description" placeholder="描述"
>$!{data.description}</textarea>
</div>
</div>
<div class="box-footer">
#if($shiro.hasPermission("qy:productBatch:edit"))
<input class="btn btn-primary" id="save" value="保存" type="submit">
#end
<a href="#springUrl('/a/productBatch/list')" class="btn btn-default">取消</a>
</div>
</form>
<!-- /.box-body -->
</div><!-- /.box -->
</div><!-- /.col -->
</div><!-- /.row -->
</section><!-- /.content -->
</div><!-- /.content-wrapper -->
<!-- Add the sidebar's background. This div must be placed
immediately after the control sidebar -->
<div class="control-sidebar-bg"></div>
</div><!-- ./wrapper -->
<script src="plugins/jQuery/jQuery-2.1.4.min.js"></script>
<!-- Bootstrap 3.3.5 -->
<script src="bootstrap/js/bootstrap.min.js"></script>
<!-- DataTables -->
<script src="plugins/datatables/jquery.dataTables.min.js"></script>
<script src="plugins/datatables/extensions/i18n/lanauage_ch.js"></script>
<script src="plugins/datatables/dataTables.bootstrap.min.js"></script>
<!-- SlimScroll -->
<script src="plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="plugins/fastclick/fastclick.min.js"></script>
<!--fileinput js-->
<script src="plugins/bootstrap-fileinput/bootstrap-fileinput.js"></script>
<!-- AdminLTE App -->
<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>
<script src="plugins/jquery-validation/js/jquery.validate.min.js"></script>
<script src="js/jquery.form.min.js"></script>
<script type="text/javascript" charset="utf-8" src="plugins/ueditor-min-1.4.3/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="plugins/ueditor-min-1.4.3/ueditor.all.js"></script>
<script type="text/javascript" charset="utf-8" src="plugins/ueditor-min-1.4.3/lang/zh-cn/zh-cn.js"></script>
<script src="common/js/cfapp.js"></script>
<script src="dist/js/app.min.js"></script>
<!-- END PAGE LEVEL PLUGINS -->
<script>
var csrfheader = {name: '_csrf_header', value: '${_csrf.headerName}'};
var csrftoken = {name: '_csrf', value: '${_csrf.token}'};
</script>
<script>
$().ready(function () {
Cfapp.init();
recdTypeAdd.init();
});
/**
* 处方医院
*/
$(".selProduct").click(function () {
Cfapp.f7({
dataUrl: "#springUrl('/a/product/listData')",
checkType: "single", // 多选为multi
title: '请选择产品',
btnoktext: "确定",
btncanceltext: "取消",
columns: ["选择", "产品名称"],
isSearch: '0',
searchColumns: ["commonName"],//搜索的字段名称
searchColumnsRemarks: ["请选择产品"],//搜索的字段备注
aoColumns: [{
"mData": "id"
}, {
"mData": "commonName"
}],
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.commonName + '">';
}
}, {
"aTargets": [1],
"mData": "commonName",
"mRender": function (a, b, c, d) {//a表示createtime对应的值,c表示当前记录行对象
return a;
}
}],
success: function () {
},
cancel: function () {
},
storeFields: 'productId', // 储存的字段
displayFields: 'productName'
})
});
var recdTypeAdd = function () {
var initForm = function () {
var initFormCtrl = function () {
bindEvent();
};
var bindEvent = function () {
$("#myForm").validate({
rules: {},
messages: {},
submitHandler: function (form) {
$("#save").attr("disabled", true);
$.getJSON("#springUrl('/a/productBatch/formData')", $("#myForm").serialize(), function (returnobj) {
$("#save").attr("disabled", false);
if (returnobj.errorNo == 2) { //保存成功
Cfapp.confirm({
message: "添加成功",
btnoktext: "继续添加",
btncanceltext: "关闭",
success: function () {
location.href = "#springUrl('/a/productBatch/form')";
},
cancel: function () {
location.href = "#springUrl('/a/productBatch/list')";
}
});
} else if (returnobj.errorNo == 0) { //修改成功
Cfapp.alert({
message: "更新成功",
btntext: "确定",
success: function () {
location.href = "#springUrl('/a/productBatch/list')";
}
});
} else {
Cfapp.alert({
message: "创建失败",
btntext: "确定",
success: function () {
location.href = "#springUrl('/a/productBatch/list')";
}
});
}
});
}
})
}
initFormCtrl();
}
return {
//main function to initiate the module
init: function () {
initForm();
}
};
}();
</script>
</body>
<!-- END BODY -->
</html>
\ No newline at end of file
<!DOCTYPE html>
<!--[if IE 8]>
<html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]>
<html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html>
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
<base href="#springUrl('/assets/adminlte/')"/>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>工作台</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.5 -->
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="plugins/font-awesome/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="plugins/ionicons/css/ionicons.min.css">
<!-- DataTables -->
<link rel="stylesheet" href="plugins/datatables/dataTables.bootstrap.css">
<!-- Theme style -->
<link rel="stylesheet" href="dist/css/AdminLTE.min.css">
<!-- AdminLTE Skins. Choose a skin from the css/skins
folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
<!-- iCheck -->
<link rel="stylesheet" href="plugins/iCheck/flat/blue.css">
<!-- Morris chart -->
<link rel="stylesheet" href="plugins/morris/morris.css">
<!-- jvectormap -->
<link rel="stylesheet" href="plugins/jvectormap/jquery-jvectormap-1.2.2.css">
<!-- Date Picker -->
<link rel="stylesheet" href="plugins/datepicker/datepicker3.css">
<!-- Daterange picker -->
<link rel="stylesheet" href="plugins/daterangepicker/daterangepicker-bs3.css">
<link rel="stylesheet"
href="plugins\bootstrap-fileinput\fileinput.min.css">
<!-- bootstrap wysihtml5 - text editor -->
<link rel="stylesheet" href="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.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]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
<div class="content-wrapper" style="margin-left:0;">
<div id="importExcelDiv"></div>
<section class="content-header">
<h1>
产品批次管理
<small>产品批次</small>
</h1>
<ol class="breadcrumb">
<li><a><i class="fa fa-dashboard"></i>首页</a></li>
<li><a class="active">产品批次管理列表</a></li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header">
<form id="seachTableForm" action="#springUrl('/a/productBatch/list')" method="get">
<div class="col-xs-2">
<input type="text" class="form-control "
name="productCode" placeholder="产品编码">
</div>
<div class="col-xs-2">
<input type="text" class="form-control "
name="commonName" placeholder="产品名称">
</div>
<div class="col-xs-5">
<button type="button" class="search btn btn-primary">搜索</button>
#if($shiro.hasPermission("qy:productBatch:edit"))
<a href="#springUrl('/a/productBatch/form')" class="btn btn-primary">新增</a>
<!-- <a href="#springUrl('/a/productBatch/exportExcel')" class="btn btn-primary">导出</a>-->
<!-- <a onclick="importExcel();" class="btn btn-primary">导入</a>-->
#end
</div>
</form>
</div><!-- /.box-header -->
<div class="box-body">
<table id="table" class="table table-bordered table-striped">
<thead>
<tr>
<td hidden="true">Id</td>
<th>产品编码</th>
<th>产品名称</th>
<th>批次号</th>
<th>状态</th>
<th>描述</th>
<th>创建时间</th>
<th>操作</th>
</tr>
</thead>
<tbody id="tablebody">
</tbody>
</table>
</div><!-- /.box-body -->
</div><!-- /.box -->
</div><!-- /.col -->
</div><!-- /.row -->
</section><!-- /.content -->
</div><!-- /.content-wrapper -->
<!-- Add the sidebar's background. This div must be placed
immediately after the control sidebar -->
<div class="control-sidebar-bg"></div>
</div><!-- ./wrapper -->
<!-- jQuery 2.1.4 -->
<script src="plugins/jQuery/jQuery-2.1.4.min.js"></script>
<!-- Bootstrap 3.3.5 -->
<script src="bootstrap/js/bootstrap.min.js"></script>
<!-- DataTables -->
<script src="plugins/datatables/jquery.dataTables.min.js"></script>
<script src="plugins/datatables/extensions/i18n/lanauage_ch.js"></script>
<script src="plugins/datatables/dataTables.bootstrap.min.js"></script>
<!-- SlimScroll -->
<script src="plugins/slimScroll/jquery.slimscroll.min.js"></script>
<script src="plugins/datepicker/bootstrap-datepicker.js"></script>
<script src="plugins/datepicker/locales/bootstrap-datepicker.zh-CN.js"></script>
<!-- FastClick -->
<script src="plugins/fastclick/fastclick.min.js"></script>
<!--fileinput js-->
<script src="plugins\bootstrap-fileinput\fileinput.js"></script>
<script src="plugins/bootstrap-fileinput/zh.js"></script>
<script src="plugins/bootstrap-fileinput/zh2.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/app.min.js"></script>
<script type="text/javascript"
src="plugins/jquery-validation/js/jquery.validate.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="common/js/cfapp.js"></script>
<script>
function formatDates(now) {
var now = new Date(now);
var year = now.getFullYear();
var month = now.getMonth() + 1;
var date = now.getDate();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
return year + "-" + month + "-" + date + " " + hour + ":"
+ minute + ":" + second;
}
function seachTable() {
var sSource = "#springUrl('/a/productBatch/listData')";
var aoData = {
iDisplayStart: 1,
iDosplayLength: 10
}
var retrieveData = function (sSource, aoData, fnCallback) {
$("#seachTableForm input").each(function () {
var params = {
name: $(this).attr("name"),
value: $(this).val()
};
aoData.push(params);
})
$.ajax({
"type": "GET",
"url": sSource,
"dataType": "json",
"data": aoData, //以json格式传递
"success": fnCallback
});
};
$('#table').DataTable({
"lengthChange": false,
"searching": false,
"ordering": false,
"bFiltered": false,
"bStateSave": true, // save datatable state(pagination, sort, etc) in cookie.
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": sSource,
"fnServerData": retrieveData,
"pagingType": "full_numbers",
"aoColumns": [
{
"mData": "id"
},
{
"mData": "productCode"
},
{
"mData": "commonName"
},
{
"mData": "batchNo"
},
{
"mData": "status"
},
{
"mData": "description"
},
{
"mData": "createTime"
},
{
"mData": "id"
}],
"aoColumnDefs": [
{ // set default column settings
'visible': false,
'targets': [0]
},
{
"aTargets": [4],
"mData": "status",
"mRender": function (a, b, c, d) {
if (a == '0') {
return '已激活';
} else if (a == '1') {
return '已失效';
}
return '';
}
},
{
"aTargets": [6],
"mData": "createTime",
"mRender": function (a, b, c, d) {
return formatDates(a, "yyyy-MM-dd HH:mm:ss");
}
},
{
"aTargets": [7],
"mData": "id",
"mRender": function (a, b, c, d) {
var html = '#if($shiro.hasPermission("qy:productBatch:edit"))';
if (c.status == '0') {
html += '<a href="javascript:void(0);" data-id="' + a + '" data-status="1" data-action="remove" onclick="updateStatus(this)" class="btn red">激活</a>';
} else if (c.status == '1') {
html += '<a href="javascript:void(0);" data-id="' + a + '" data-status="0" data-action="remove" onclick="updateStatus(this)" class="btn red">失效</a>';
}
html += '<a href="#springUrl("/a/productBatch/form?id=' + a + '")" data-id="' + a + '" data-action="view" class="btn green">修改</a>';
html += '<a href="javascript:void(0);" data-id="' + a + '" data-action="remove" onclick="removeData(' + a + ')" class="btn red">删除</a>';
html += '#end';
return html;
}
}
]
});
}
jQuery(document).ready(function () {
seachTable();
$('.datepicker').datepicker({
show: true,
format: 'yyyy-mm-dd',
autoclose: true,
language: 'zh-CN',
todayBtn: 'linked',
clearBtn: 'linked'
});
$('.search').click(function () {
$("#table").dataTable().fnClearTable();
});
});
Cfapp.init();
function removeData(data) {
Cfapp.confirm({
message: "确定要删除吗",
btnoktext: "确定",
btncanceltext: "取消",
success: function () {
$.ajax({
type: "POST",
url: "#springUrl('/a/productBatch/delete')",
data: {id: data},
dataType: "json",
success: function (data) {
if (data.errorNo == 0) {
Cfapp.alert({
message: "删除成功",
btntext: "确定",
success: function () {
location.href = "#springUrl('/a/productBatch/list')";
}
});
}
},
error: function () {
}
})
},
cancel: function () {
$(".modal-backdrop").fadeOut();
}
});
}
/**
* 批次号激活/失效
*/
function updateStatus(dom) {
}
function importExcel() {
var templateExcelUrl = "#springUrl('/a/productBatch/templateExcel')";
var importExcelUrl = "#springUrl('/a/productBatch/importExcel')";
Cfapp.importExcel({
title: '产品批次导入',
importurl: importExcelUrl,
templateurl: templateExcelUrl,
cancel: function () {
},
success: function () {
}
});
}
</script>
</body>
</html>
......@@ -312,7 +312,7 @@
"aTargets": [10],
"mData": "id",
"mRender": function (a, b, c, d) {
var html = '#if($shiro.hasPermission("qy:product:edit"))';//
var html = '#if($shiro.hasPermission("qy:product:edit"))';
html += '<a href="#springUrl("/a/product/form?id=' + a + '")" data-id="' + a + '" data-action="view" class="btn green">修改</a>';
html += '<a href="javascript:void(0);" data-id="' + a + '" data-action="remove" onclick="removeData(' + a + ')" class="btn red">删除</a>';
html += '#end';
......
package com.cftech.product.dao;
import com.cftech.core.generic.GenericDao;
import com.cftech.product.model.ProductBatch;
/**
* 产品批次Mapper
*
* @author Strive
* @date: 2021-03-18 14:30
*/
public interface ProductBatchMapper extends GenericDao<ProductBatch> {
}
\ No newline at end of file
<?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="com.cftech.product.dao.ProductBatchMapper">
<resultMap id="resultMap" type="com.cftech.product.model.ProductBatch">
<id column="id" property="id"/>
<result column="number" property="number"/>
<result column="batch_no" property="batchNo"/>
<result column="product_id" property="productId"/>
<result column="accounts_id" property="accountsId"/>
<result column="del_flag" property="delFlag"/>
<result column="status" property="status"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="description" property="description"/>
<result column="create_by" property="createBy"/>
<result column="update_by" property="updateBy"/>
<result column="productCode" property="productCode"/>
<result column="productName" property="productName"/>
<result column="commonName" property="commonName"/>
</resultMap>
<sql id="sqlWhere">
<if test="conds!=null">
<trim prefix="WHERE" prefixOverrides="AND|OR">
<foreach collection="conds.conds" index="index" item="cond">
${cond.linkType}
<if test="cond.condType == 'EQUAL'">${cond.param} = #{cond.value}</if>
<if test="cond.condType == 'NOTEQUAL'">${cond.param} &lt;&gt; #{cond.value}</if>
<if test="cond.condType == 'GREATEQUAL'">${cond.param} &gt;= #{cond.value}</if>
<if test="cond.condType == 'GREATTHAN'">${cond.param} &gt; #{cond.value}</if>
<if test="cond.condType == 'LESSEQUAL'">${cond.param} &lt;= #{cond.value}</if>
<if test="cond.condType == 'LESSTHAN'">${cond.param} &lt; #{cond.value}</if>
<if test="cond.condType == 'BETWEEN'">${cond.param} BETWEEN #{cond.startValue} AND
#{cond.endValue}
</if>
<if test="cond.condType == 'ISNULL'">${cond.param} IS NULL</if>
<if test="cond.condType == 'NOTNULL'">${cond.param} IS NOT NULL</if>
<if test="cond.condType == 'LIKE'">${cond.param} LIKE #{cond.value}</if>
<if test="cond.condType == 'IN'">${cond.param} IN
<foreach item="item" index="index" collection="cond.value" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</foreach>
</trim>
</if>
</sql>
<sql id="sqlColumns">
id,
number,
batch_no,
product_id,
accounts_id,
del_flag,
status,
create_time,
update_time,
description,
create_by,
update_by
</sql>
<insert id="save" parameterType="com.cftech.product.model.ProductBatch" useGeneratedKeys="true"
keyProperty="id">
insert into t_aidea_product_batch
(
<include refid="sqlColumns"/>
)
values
(
#{id, jdbcType=BIGINT},
#{number, jdbcType=VARCHAR},
#{batchNo, jdbcType=VARCHAR},
#{productId, jdbcType=VARCHAR},
#{accountsId, jdbcType=BIGINT},
#{delFlag, jdbcType=TINYINT},
#{status, jdbcType=VARCHAR},
now(),
now(),
#{description, jdbcType=VARCHAR},
#{createBy, jdbcType=BIGINT},
#{updateBy, jdbcType=BIGINT}
)
</insert>
<select id="fetchById" parameterType="java.lang.Long" resultMap="resultMap">
SELECT
<include refid="sqlColumns"/>,
p.product_number productCode,
p.product_name productName,
p.common_name commonName
FROM t_aidea_product_batch t
WHERE t.id=#{id}
</select>
<select id="count" parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT COUNT(1) FROM t_aidea_product_batch t
LEFT JOIN t_aidea_product p ON t.product_id = p.id
<include refid="sqlWhere"/>
</select>
<select id="fetchSearchByPage" parameterType="java.util.Map" resultMap="resultMap">
SELECT
t.id,
t.number,
t.batch_no,
t.product_id,
t.accounts_id,
t.del_flag,
t.status,
t.create_time,
t.update_time,
t.description,
t.create_by,
t.update_by,
p.product_number productCode,
p.product_name productName,
p.common_name commonName
FROM t_aidea_product_batch t
LEFT JOIN t_aidea_product p ON t.product_id = p.id
<include refid="sqlWhere"/>
<if test="sort!=null">ORDER BY ${sort.param} ${sort.type}</if>
<if test="limit>0">limit #{offset},#{limit}</if>
</select>
<update id="update" parameterType="com.cftech.product.model.ProductBatch">
update t_aidea_product_batch
<set>
<if test="id != null">
id = #{id, jdbcType=BIGINT},
</if>
<if test="number != null">
number = #{number, jdbcType=VARCHAR},
</if>
<if test="batchNo != null">
batch_no = #{batchNo, jdbcType=VARCHAR},
</if>
<if test="productId != null">
product_id = #{productId, jdbcType=VARCHAR},
</if>
<if test="accountsId != null">
accounts_id = #{accountsId, jdbcType=BIGINT},
</if>
<if test="delFlag != null">
del_flag = #{delFlag, jdbcType=TINYINT},
</if>
<if test="status != null">
status = #{status, jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime, jdbcType=TIMESTAMP},
</if>
<if test="description != null">
description = #{description, jdbcType=VARCHAR},
</if>
<if test="createBy != null">
create_by = #{createBy, jdbcType=BIGINT},
</if>
<if test="updateBy != null">
update_by = #{updateBy, jdbcType=BIGINT},
</if>
</set>
where id=#{id,jdbcType=BIGINT}
</update>
<update id="delete" parameterType="java.lang.Long">
update t_aidea_product_batch
set del_flag=1
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
package com.cftech.product.model;
import com.cftech.core.poi.ExportConfig;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 产品批次
*
* @author Strive
* @date: 2021-03-18 14:30
*/
@Data
public class ProductBatch implements Serializable {
/* 主键id */
private Long id;
/* 编码 */
@ExportConfig(value = "编码", width = 100, showLevel = 1)
private String number;
/* 产品批次号 */
@ExportConfig(value = "产品批次号", width = 100, showLevel = 1)
private String batchNo;
/* 产品Id */
@ExportConfig(value = "产品Id", width = 100, showLevel = 1)
private String productId;
/* 所属的账号 */
private Long accountsId;
/* 删除标识 */
private boolean delFlag;
/* 状态 */
private String status;
/* 创建时间 */
private Date createTime;
/* 更新时间 */
private Date updateTime;
/* 备注 */
private String description;
/* 创建人 */
private Long createBy;
/* 更新人 */
private Long updateBy;
private String productName;
private String productCode;
private String commonName;
public ProductBatch() {
this.delFlag = false;
this.status = "0";
}
}
\ No newline at end of file
package com.cftech.product.service;
import com.cftech.core.generic.GenericService;
import com.cftech.product.model.ProductBatch;
/**
* 产品批次Service
*
* @author Strive
* @date: 2021-03-18 14:30
*/
public interface ProductBatchService extends GenericService<ProductBatch> {
}
package com.cftech.product.service.impl;
import com.cftech.core.generic.GenericDao;
import com.cftech.core.generic.GenericServiceImpl;
import com.cftech.product.dao.ProductBatchMapper;
import com.cftech.product.model.ProductBatch;
import com.cftech.product.service.ProductBatchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
/**
* 产品批次ServiceImpl
*
* @author Strive
* @date: 2021-03-18 14:30
*/
@Service("productBatchService")
public class ProductBatchServiceImpl extends GenericServiceImpl<ProductBatch> implements ProductBatchService {
@Autowired
@Qualifier("productBatchMapper")
private ProductBatchMapper productBatchMapper;
@Override
public GenericDao<ProductBatch> getGenericMapper() {
return productBatchMapper;
}
}
\ No newline at end of file
package com.cftech.product.web;
import com.alibaba.fastjson.JSONObject;
import com.cftech.core.poi.ExcelKit;
import com.cftech.core.scope.OrderType;
import com.cftech.core.sql.Conds;
import com.cftech.core.sql.Sort;
import com.cftech.core.util.Constants;
import com.cftech.product.model.ProductBatch;
import com.cftech.product.service.ProductBatchService;
import com.cftech.sys.security.UserUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.List;
/**
* 产品批次Controller
* <p>
* 权限字符串说明:
* 查看:public static final String PRODUCTBATCH_VIEW = "qy:productBatch:view"
* 查看:public static final String PRODUCTBATCH_EDIT = "qy:productBatch:edit"
*
* @author Strive
* @date: 2021-03-18 14:30
*/
@Slf4j
@Controller
@RequestMapping("/a/productBatch")
public class ProductBatchController {
public static final String PRODUCTBATCH_VIEW = "qy:productBatch:view";
public static final String PRODUCTBATCH_EDIT = "qy:productBatch:edit";
@Autowired
private ProductBatchService productBatchService;
//列表页面
@RequiresPermissions(value = PRODUCTBATCH_VIEW)
@RequestMapping("/list")
public String list(HttpServletRequest request, Model model) {
Long accountId = UserUtils.getmpaccounts(request);
model.addAttribute("accountId", accountId);
return "product/productBatchlist";
}
//编辑页面(新增、修改)
@RequiresPermissions(value = PRODUCTBATCH_VIEW)
@RequestMapping("/form")
public String form(HttpServletRequest request, String id, Model model) {
if (!StringUtils.isEmpty(id)) {
ProductBatch productBatch = productBatchService.fetchById(id);
model.addAttribute("data", productBatch);
}
return "product/productBatchform";
}
//提交数据(新增、修改)
@RequiresPermissions(value = PRODUCTBATCH_EDIT)
@RequestMapping("/formData")
@ResponseBody
public JSONObject formData(ProductBatch productBatch, Model model, HttpServletRequest request) {
Long accountsId = UserUtils.getmpaccounts(request);
JSONObject rtnJson = new JSONObject();
try {
if (productBatch != null && productBatch.getId() != null) {
productBatch.setUpdateBy(UserUtils.getUser().getId());
productBatchService.update(productBatch);
rtnJson.put("errorNo", 0);
} else {
productBatch.setAccountsId(accountsId);
productBatch.setDelFlag(false);
productBatch.setAccountsId(UserUtils.getmpaccounts(request));
productBatch.setCreateBy(UserUtils.getUser().getId());
productBatch.setUpdateBy(UserUtils.getUser().getId());
productBatchService.save(productBatch);
rtnJson.put("errorNo", 2);
}
} catch (Exception e) {
rtnJson.put("errorNo", 1);
}
return rtnJson;
}
//获取列表数据
@RequiresPermissions(value = PRODUCTBATCH_VIEW)
@RequestMapping(value = "/listData")
@ResponseBody
public JSONObject listData(int iDisplayStart, int iDisplayLength, ProductBatch productBatch, HttpServletRequest request) {
Long accountsId = UserUtils.getmpaccounts(request);
Conds conds = new Conds();
conds.equal("t.del_flag", Constants.DEL_FLAG_0);
conds.equal("t.accounts_id", accountsId);
if (!StringUtils.isEmpty(productBatch.getProductName())) {
conds.like("p.product_name", productBatch.getProductName());
}
if (!StringUtils.isEmpty(productBatch.getProductCode())) {
conds.equal("p.product_number", productBatch.getProductCode());
}
Sort sort = new Sort("t.create_time", OrderType.DESC);
List<ProductBatch> list = productBatchService.fetchSearchByPage(conds, sort, iDisplayStart, iDisplayLength);
Integer counts = productBatchService.count(conds);
JSONObject rtnJson = new JSONObject();
rtnJson.put("iTotalRecords", counts);
rtnJson.put("iTotalDisplayRecords", counts);
rtnJson.put("aaData", list);
return rtnJson;
}
//删除数据
@RequiresPermissions(value = PRODUCTBATCH_EDIT)
@RequestMapping("/delete")
@ResponseBody
public JSONObject delete(String id) {
JSONObject rtnJosn = new JSONObject();
try {
productBatchService.delete(id);
rtnJosn.put("errorNo", 0);
} catch (Exception e) {
rtnJosn.put("errorNo", 1);
}
return rtnJosn;
}
@RequestMapping("/exportExcel")
@RequiresPermissions(value = PRODUCTBATCH_VIEW)
public void exportExcel(HttpServletRequest request, HttpServletResponse response) {
Long accountId = UserUtils.getmpaccounts(request);
Sort sort = new Sort("create_time", OrderType.ASC);
Conds conds = new Conds();
conds.equal("del_flag", 0);
conds.equal("accounts_id", accountId);
List<ProductBatch> list = productBatchService.fetchSearchByPage(conds, sort, 0, 0);
ExcelKit.$Export(ProductBatch.class, response).toExcel(list, "产品批次信息");
}
@RequestMapping("/templateExcel")
@RequiresPermissions(value = PRODUCTBATCH_VIEW)
public void templateExcel(HttpServletRequest request, HttpServletResponse response) {
ExcelKit.$Export(ProductBatch.class, response).toExcel(null, "产品批次信息");
}
@RequestMapping("/importExcel")
@RequiresPermissions(value = PRODUCTBATCH_EDIT)
public String importExcel(HttpServletRequest request, MultipartFile file, Model model) {
Long accountId = UserUtils.getmpaccounts(request);
if (file == null) {
return list(request, model);
}
// 构造临时路径来存储上传的文件
String uploadPath = System.getProperty("java.io.tmpdir");
File uploadDir = new File(uploadPath);
if (!uploadDir.exists()) {
uploadDir.mkdir();
}
String fileName = file.getOriginalFilename();
String filePath = uploadPath + File.separator + fileName;
File storeFile = new File(filePath);
try {
file.transferTo(storeFile);
ExcelKit.$Import().setEmptyCellValue("").readExcel(storeFile, rowData -> {
if (!StringUtils.isEmpty(rowData.get(0))) {
ProductBatch productBatch = new ProductBatch();
productBatch.setAccountsId(accountId);
productBatchService.save(productBatch);
}
});
} catch (IOException e) {
log.error(e.getMessage());
}
return list(request, model);
}
}
......@@ -65,10 +65,10 @@ public class ProductController {
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);
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";
}
......@@ -82,10 +82,10 @@ public class ProductController {
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);
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";
}
......@@ -115,7 +115,7 @@ public class ProductController {
product.setAccountsId(accountsId);
product.setDelFlag(false);
if (StringUtils.isBlank(product.getProductNumber())) {
product.setProductNumber(codingruleUtils.getNumber(accountsId,Product.class.getName()));
product.setProductNumber(codingruleUtils.getNumber(accountsId, Product.class.getName()));
}
product.setAccountsId(UserUtils.getmpaccounts(request));
product.setCreateBy(UserUtils.getUser().getId());
......@@ -140,16 +140,19 @@ public class ProductController {
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.getProductName())) {
conds.like("a.product_name", product.getProductName());
}
if(!StringUtils.isEmpty(product.getClassifyId())){
classifyId = Arrays.asList(product.getClassifyId().split(","));
if (!StringUtils.isEmpty(product.getCommonName())) {
conds.like("a.common_name", product.getCommonName());
}
if (!StringUtils.isEmpty(product.getClassifyId())) {
classifyId = Arrays.asList(product.getClassifyId().split(","));
}
Sort sort = new Sort("a.create_time", OrderType.DESC);
List<Product> list = productService.selectProduct(conds, sort, iDisplayStart, iDisplayLength,classifyId);
List<Product> list = productService.selectProduct(conds, sort, iDisplayStart, iDisplayLength, classifyId);
Integer counts = productService.count(conds);
JSONObject rtnJson = new JSONObject();
rtnJson.put("iTotalRecords", counts);
......@@ -175,21 +178,21 @@ public class ProductController {
@RequestMapping("/exportExcel")
@RequiresPermissions(value = PRODUCT_VIEW)
public void exportExcel(HttpServletRequest request, HttpServletResponse response ,Product product) {
public void exportExcel(HttpServletRequest request, HttpServletResponse response, Product product) {
Long accountsId = UserUtils.getmpaccounts(request);
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.getProductName())) {
conds.like("a.product_name", product.getProductName());
}
if(!StringUtils.isEmpty(product.getClassifyId())){
if (!StringUtils.isEmpty(product.getClassifyId())) {
classifyId = Arrays.asList(product.getClassifyId().split(","));
}
Sort sort = new Sort("a.create_time", OrderType.DESC);
List<Product> list = productService.selectProduct(conds, sort, 0, 0,classifyId);
List<Product> list = productService.selectProduct(conds, sort, 0, 0, classifyId);
ExcelKit.$Export(Product.class, response).toExcel(list, "产品信息");
}
......@@ -227,9 +230,9 @@ public class ProductController {
file.transferTo(storeFile);
ExcelKit.$Import().setEmptyCellValue("").readExcel(storeFile, rowData -> {
Product product = new Product();
if(!StringUtils.isEmpty(rowData.get(0))){
String ids = productclassifyService.selectIdsByNumber(rowData.get(0));
if(ids != null){
if (!StringUtils.isEmpty(rowData.get(0))) {
String ids = productclassifyService.selectIdsByNumber(rowData.get(0));
if (ids != null) {
//产品分类ID
product.setClassifyId(ids);
product.setClassifyNumber(rowData.get(0));
......@@ -238,13 +241,13 @@ public class ProductController {
product.setAccountsId(accountId);
//产品编码
Conds conds = new Conds();
conds.equal("a.product_number",rowData.get(1).trim());
conds.equal("a.del_flag",0);
conds.equal("a.product_number", rowData.get(1).trim());
conds.equal("a.del_flag", 0);
Product listProduct = productService.fetchSearchByConds(conds);
if(listProduct == null){
if (listProduct == null) {
sbProduct.append(rowData.get(1));
return;
}else{
} else {
product.setProductNumber(rowData.get(1).trim());
}
//产品名称
......@@ -272,14 +275,14 @@ public class ProductController {
//服用数量
product.setTakeAmount(rowData.get(13));
//库存
if(StringUtils.isEmpty(rowData.get(14)) || rowData.get(14).contains("-")){
if (StringUtils.isEmpty(rowData.get(14)) || rowData.get(14).contains("-")) {
sbClassify.append(rowData.get(1));
return;
}else{
} else {
product.setStock(Long.valueOf(rowData.get(14)));
}
//价格
if(!StringUtils.isEmpty(rowData.get(15))){
if (!StringUtils.isEmpty(rowData.get(15))) {
product.setPrice(Double.valueOf(rowData.get(15)));
}
//是否为处方药
......@@ -296,11 +299,11 @@ public class ProductController {
}
retJson.put("errorNo", "0");
if(sbClassify.length()>0){
retJson.put("errorMsg", "部分导入失败,产品编码有:"+sbClassify.toString()+"; 失败原因:库存不能为空或者为负数");
}else if(sbProduct.length() > 0){
retJson.put("errorMsg", "部分导入失败,产品编码有:"+sbProduct.toString()+"; 失败原因:错误产品编码");
}else{
if (sbClassify.length() > 0) {
retJson.put("errorMsg", "部分导入失败,产品编码有:" + sbClassify.toString() + "; 失败原因:库存不能为空或者为负数");
} else if (sbProduct.length() > 0) {
retJson.put("errorMsg", "部分导入失败,产品编码有:" + sbProduct.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