|
@ -70,6 +70,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
|
|
|
/**
|
|
/**
|
|
* 新增药品信息
|
|
* 新增药品信息
|
|
|
|
*
|
|
* @param jsonData
|
|
* @param jsonData
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@ -77,14 +78,14 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
public String createOrder(String jsonData) {
|
|
public String createOrder(String jsonData) {
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
if(StringUtils.isEmpty(jsonData)){
|
|
|
|
result.put("msg","jsonData is null");
|
|
|
|
|
|
if (StringUtils.isEmpty(jsonData)) {
|
|
|
|
result.put("msg", "jsonData is null");
|
|
result.put("response", ConstantUtils.FAIL);
|
|
result.put("response", ConstantUtils.FAIL);
|
|
return result.toJSONString();
|
|
return result.toJSONString();
|
|
}
|
|
}
|
|
JSONObject order = JSONObject.parseObject(jsonData);
|
|
JSONObject order = JSONObject.parseObject(jsonData);
|
|
if(null == order){
|
|
|
|
result.put("msg","parameter order of jsonData is null");
|
|
|
|
|
|
if (null == order) {
|
|
|
|
result.put("msg", "parameter order of jsonData is null");
|
|
result.put("response", ConstantUtils.FAIL);
|
|
result.put("response", ConstantUtils.FAIL);
|
|
return result.toJSONString();
|
|
return result.toJSONString();
|
|
}
|
|
}
|
|
@ -107,34 +108,35 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
return result.toJSONString();
|
|
return result.toJSONString();
|
|
}
|
|
}
|
|
this.save(mediicineorder);
|
|
this.save(mediicineorder);
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
|
|
result.put("msg",mediicineorder);
|
|
|
|
|
|
result.put("response", ConstantUtils.SUCCESS);
|
|
|
|
result.put("msg", mediicineorder);
|
|
return result.toJSONString();
|
|
return result.toJSONString();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 修改处方订单信息
|
|
* 修改处方订单信息
|
|
|
|
*
|
|
* @param jsonData
|
|
* @param jsonData
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public String updateOrder(String jsonData){
|
|
|
|
|
|
public String updateOrder(String jsonData) {
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
if(StringUtils.isEmpty(jsonData)){
|
|
|
|
result.put("msg","jsonData is null");
|
|
|
|
|
|
if (StringUtils.isEmpty(jsonData)) {
|
|
|
|
result.put("msg", "jsonData is null");
|
|
result.put("response", ConstantUtils.FAIL);
|
|
result.put("response", ConstantUtils.FAIL);
|
|
return result.toJSONString();
|
|
return result.toJSONString();
|
|
}
|
|
}
|
|
JSONObject order = JSONObject.parseObject(jsonData);
|
|
JSONObject order = JSONObject.parseObject(jsonData);
|
|
if(null == order){
|
|
|
|
result.put("msg","parameter order of jsonData is null");
|
|
|
|
|
|
if (null == order) {
|
|
|
|
result.put("msg", "parameter order of jsonData is null");
|
|
result.put("response", ConstantUtils.FAIL);
|
|
result.put("response", ConstantUtils.FAIL);
|
|
return result.toJSONString();
|
|
return result.toJSONString();
|
|
}
|
|
}
|
|
String orgCode="";
|
|
|
|
|
|
String orgCode = "";
|
|
//判断处方订单id是否存在
|
|
//判断处方订单id是否存在
|
|
if(StringUtils.isEmpty(order.getString("id"))){
|
|
|
|
result.put("msg","parameter id for order is null when update drug");
|
|
|
|
|
|
if (StringUtils.isEmpty(order.getString("id"))) {
|
|
|
|
result.put("msg", "parameter id for order is null when update drug");
|
|
result.put("response", ConstantUtils.FAIL);
|
|
result.put("response", ConstantUtils.FAIL);
|
|
return result.toJSONString();
|
|
return result.toJSONString();
|
|
}
|
|
}
|
|
@ -151,16 +153,16 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
return result.toJSONString();
|
|
return result.toJSONString();
|
|
}
|
|
}
|
|
this.save(mediicineorder);
|
|
this.save(mediicineorder);
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
|
|
result.put("msg",mediicineorder);
|
|
|
|
|
|
result.put("response", ConstantUtils.SUCCESS);
|
|
|
|
result.put("msg", mediicineorder);
|
|
return result.toJSONString();
|
|
return result.toJSONString();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
//orderNum, equNum, contact, startTime, endTime, sellState, orderState, dispensingWindow
|
|
//orderNum, equNum, contact, startTime, endTime, sellState, orderState, dispensingWindow
|
|
public JSONObject queryOrderListFullInfo(String orderNum, String equNum, String contact,
|
|
public JSONObject queryOrderListFullInfo(String orderNum, String equNum, String contact,
|
|
String startTime, String endTime, String sellState,
|
|
|
|
String orderState, String dispensingWindow, String community, String userId, int page, int size,String wechatId) throws Exception {
|
|
|
|
|
|
String startTime, String endTime, String sellState,
|
|
|
|
String orderState, String dispensingWindow, String community, String userId, int page, int size, String wechatId) throws Exception {
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
|
@ -277,31 +279,31 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(belongCommunitys)) {
|
|
if (!StringUtils.isEmpty(belongCommunitys)) {
|
|
conditionSql += " and ',"+ belongCommunitys +",' LIKE CONCAT('%,',t.belong_community,',%')\n";
|
|
|
|
|
|
conditionSql += " and '," + belongCommunitys + ",' LIKE CONCAT('%,',t.belong_community,',%')\n";
|
|
}
|
|
}
|
|
if (!StringUtils.isEmpty(community)) {
|
|
if (!StringUtils.isEmpty(community)) {
|
|
conditionSql += " and t.belong_community = '" + community + "'";
|
|
conditionSql += " and t.belong_community = '" + community + "'";
|
|
}
|
|
}
|
|
if (!StringUtils.isEmpty(orderNum)){
|
|
|
|
|
|
if (!StringUtils.isEmpty(orderNum)) {
|
|
conditionSql += " and t.order_num = '" + orderNum + "'";
|
|
conditionSql += " and t.order_num = '" + orderNum + "'";
|
|
}
|
|
}
|
|
if (!StringUtils.isEmpty(equNum)){
|
|
|
|
|
|
if (!StringUtils.isEmpty(equNum)) {
|
|
conditionSql += " and t.equ_num = '" + equNum + "'";
|
|
conditionSql += " and t.equ_num = '" + equNum + "'";
|
|
}
|
|
}
|
|
if (!StringUtils.isEmpty(contact)){
|
|
|
|
|
|
if (!StringUtils.isEmpty(contact)) {
|
|
conditionSql += " and t.contact like '%" + contact + "%'";
|
|
conditionSql += " and t.contact like '%" + contact + "%'";
|
|
}
|
|
}
|
|
if (org.apache.commons.lang.StringUtils.isNotBlank(startTime)&& org.apache.commons.lang.StringUtils.isNotBlank(endTime)){
|
|
|
|
conditionSql += " AND t.prescribe_time >= '" + startTime +"'" +
|
|
|
|
|
|
if (org.apache.commons.lang.StringUtils.isNotBlank(startTime) && org.apache.commons.lang.StringUtils.isNotBlank(endTime)) {
|
|
|
|
conditionSql += " AND t.prescribe_time >= '" + startTime + "'" +
|
|
" AND t.prescribe_time <= '" + endTime + "'";
|
|
" AND t.prescribe_time <= '" + endTime + "'";
|
|
}
|
|
}
|
|
if (!StringUtils.isEmpty(sellState)){
|
|
|
|
|
|
if (!StringUtils.isEmpty(sellState)) {
|
|
conditionSql += " and t.sell_state = '" + sellState + "'";
|
|
conditionSql += " and t.sell_state = '" + sellState + "'";
|
|
}
|
|
}
|
|
if (!StringUtils.isEmpty(orderState)){
|
|
|
|
|
|
if (!StringUtils.isEmpty(orderState)) {
|
|
conditionSql += " and t.order_state = '" + orderState + "'";
|
|
conditionSql += " and t.order_state = '" + orderState + "'";
|
|
}
|
|
}
|
|
if (!StringUtils.isEmpty(dispensingWindow)){
|
|
|
|
|
|
if (!StringUtils.isEmpty(dispensingWindow)) {
|
|
conditionSql += " and t.dispensing_window = '" + dispensingWindow + "'";
|
|
conditionSql += " and t.dispensing_window = '" + dispensingWindow + "'";
|
|
}
|
|
}
|
|
sencodSql = sencodSql + conditionSql;
|
|
sencodSql = sencodSql + conditionSql;
|
|
@ -315,8 +317,8 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
" where " +
|
|
" where " +
|
|
" 1=1 " +
|
|
" 1=1 " +
|
|
conditionSql;
|
|
conditionSql;
|
|
Logger.getAnonymousLogger().info("finalCountSql="+countSql);
|
|
|
|
int count = jdbcTemplate.queryForObject(countSql,Integer.class);
|
|
|
|
|
|
Logger.getAnonymousLogger().info("finalCountSql=" + countSql);
|
|
|
|
int count = jdbcTemplate.queryForObject(countSql, Integer.class);
|
|
for (Map<String, Object> stringObjectMap : orderList) {
|
|
for (Map<String, Object> stringObjectMap : orderList) {
|
|
if (stringObjectMap.get("sellState") != null) {
|
|
if (stringObjectMap.get("sellState") != null) {
|
|
if (!StringUtils.isEmpty(stringObjectMap.get("sellState").toString())) {
|
|
if (!StringUtils.isEmpty(stringObjectMap.get("sellState").toString())) {
|
|
@ -336,13 +338,14 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
}
|
|
}
|
|
|
|
|
|
//订单明细
|
|
//订单明细
|
|
public List<Mediicineorderdetail> getorderdetail(String idOrder) {
|
|
|
|
return orderdetailDao.getorderdetail(idOrder);
|
|
|
|
|
|
public List<Mediicineorderdetail> getorderdetail(String idOrder) {
|
|
|
|
return orderdetailDao.getorderdetail(idOrder);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 通过订单id,获取详细订单信息
|
|
* 通过订单id,获取详细订单信息
|
|
|
|
*
|
|
* @param orderId
|
|
* @param orderId
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@ -384,7 +387,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
jsonObject.put("orderTypeName", orderTypeMap.get(mediicineorder.getOrderType()));
|
|
jsonObject.put("orderTypeName", orderTypeMap.get(mediicineorder.getOrderType()));
|
|
//取药码
|
|
//取药码
|
|
jsonObject.put("pickUpNum", mediicineorder.getPickUpNum());
|
|
jsonObject.put("pickUpNum", mediicineorder.getPickUpNum());
|
|
jsonObject.put("device",StringUtils.isEmpty(mediicineorder.getShippingEqu()) ? null : deviceDao.findOne(mediicineorder.getShippingEqu()));
|
|
|
|
|
|
jsonObject.put("device", StringUtils.isEmpty(mediicineorder.getShippingEqu()) ? null : deviceDao.findOne(mediicineorder.getShippingEqu()));
|
|
result.put("msg", jsonObject);
|
|
result.put("msg", jsonObject);
|
|
result.put("response", ConstantUtils.SUCCESS);
|
|
result.put("response", ConstantUtils.SUCCESS);
|
|
return result;
|
|
return result;
|
|
@ -392,19 +395,20 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取时间范围内的订单销售额
|
|
* 获取时间范围内的订单销售额
|
|
|
|
*
|
|
* @param beg
|
|
* @param beg
|
|
* @param end
|
|
* @param end
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public JSONObject sumamount(String beg, String end) throws Exception {
|
|
|
|
|
|
public JSONObject sumamount(String beg, String end) throws Exception {
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
String sql = "select sum(t.amount) from t_mediicine_order t where t.prescribe_time >= '" + beg + "' and t.prescribe_time <= '" + end + "'";
|
|
String sql = "select sum(t.amount) from t_mediicine_order t where t.prescribe_time >= '" + beg + "' and t.prescribe_time <= '" + end + "'";
|
|
float count = jdbcTemplate.queryForObject(sql,Float.class);
|
|
|
|
|
|
float count = jdbcTemplate.queryForObject(sql, Float.class);
|
|
JSONObject jsonObject = new JSONObject();
|
|
JSONObject jsonObject = new JSONObject();
|
|
jsonObject.put("count", count);
|
|
jsonObject.put("count", count);
|
|
Date startDate = DateUtil.strToDateShort(beg);
|
|
Date startDate = DateUtil.strToDateShort(beg);
|
|
Date endDate = DateUtil.strToDateShort(end);
|
|
Date endDate = DateUtil.strToDateShort(end);
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
|
|
|
|
result.put("response", ConstantUtils.SUCCESS);
|
|
// result.put("msg", orderDao.getsumamount(startDate, endDate));
|
|
// result.put("msg", orderDao.getsumamount(startDate, endDate));
|
|
result.put("msg", jsonObject);
|
|
result.put("msg", jsonObject);
|
|
return result;
|
|
return result;
|
|
@ -413,6 +417,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取时间范围内的订单数量
|
|
* 获取时间范围内的订单数量
|
|
|
|
*
|
|
* @param beg
|
|
* @param beg
|
|
* @param end
|
|
* @param end
|
|
* @return
|
|
* @return
|
|
@ -420,34 +425,34 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
public JSONObject getcount(String beg, String end) {
|
|
public JSONObject getcount(String beg, String end) {
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
String sql = "select count(1) from t_mediicine_order t where t.prescribe_time >= '" + beg + "' and t.prescribe_time <= '" + end + "'";
|
|
String sql = "select count(1) from t_mediicine_order t where t.prescribe_time >= '" + beg + "' and t.prescribe_time <= '" + end + "'";
|
|
int count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
|
|
|
int count = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
Date startDate = DateUtil.strToDateShort(beg);
|
|
Date startDate = DateUtil.strToDateShort(beg);
|
|
Date endDate = DateUtil.strToDateShort(end);
|
|
Date endDate = DateUtil.strToDateShort(end);
|
|
JSONObject jsonObject = new JSONObject();
|
|
JSONObject jsonObject = new JSONObject();
|
|
jsonObject.put("count", count);
|
|
jsonObject.put("count", count);
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
|
|
|
|
result.put("response", ConstantUtils.SUCCESS);
|
|
// result.put("msg", orderDao.getcount(startDate, endDate));
|
|
// result.put("msg", orderDao.getcount(startDate, endDate));
|
|
result.put("msg", jsonObject);
|
|
result.put("msg", jsonObject);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
public JSONObject getsumquantity(String beg, String end) throws Exception {
|
|
|
|
|
|
public JSONObject getsumquantity(String beg, String end) throws Exception {
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
String sql = "select sum(t.quantity) from t_mediicine_order_detail t where t.prescribe_time >= '" + beg + "' and t.prescribe_time <= '" + end + "'";
|
|
String sql = "select sum(t.quantity) from t_mediicine_order_detail t where t.prescribe_time >= '" + beg + "' and t.prescribe_time <= '" + end + "'";
|
|
int count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
|
|
|
int count = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
JSONObject jsonObject = new JSONObject();
|
|
JSONObject jsonObject = new JSONObject();
|
|
jsonObject.put("quantity", count);
|
|
jsonObject.put("quantity", count);
|
|
|
|
|
|
Date startDate = DateUtil.strToDateShort(beg);
|
|
Date startDate = DateUtil.strToDateShort(beg);
|
|
Date endDate = DateUtil.strToDateShort(end);
|
|
Date endDate = DateUtil.strToDateShort(end);
|
|
result.put("response",ConstantUtils.SUCCESS);
|
|
|
|
|
|
result.put("response", ConstantUtils.SUCCESS);
|
|
// result.put("msg", orderDao.getsumamount(startDate, endDate));
|
|
// result.put("msg", orderDao.getsumamount(startDate, endDate));
|
|
result.put("msg", jsonObject);
|
|
result.put("msg", jsonObject);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
//订单明细中的总药品销量
|
|
|
|
|
|
//订单明细中的总药品销量
|
|
// public float getsumquantity(String beg, String end) {
|
|
// public float getsumquantity(String beg, String end) {
|
|
// Date startDate = DateUtil.strToDateShort(beg);
|
|
// Date startDate = DateUtil.strToDateShort(beg);
|
|
// Date endDate = DateUtil.strToDateShort(end);
|
|
// Date endDate = DateUtil.strToDateShort(end);
|
|
@ -455,7 +460,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
// }
|
|
// }
|
|
|
|
|
|
//订单明细中的总药品销量
|
|
//订单明细中的总药品销量
|
|
public List<Mediicinestockoutdetail> getoutdetail(String idorder) {
|
|
|
|
|
|
public List<Mediicinestockoutdetail> getoutdetail(String idorder) {
|
|
|
|
|
|
return stockoutdetailDao.getoutdetailbyorderid(idorder);
|
|
return stockoutdetailDao.getoutdetailbyorderid(idorder);
|
|
}
|
|
}
|
|
@ -463,6 +468,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
|
|
|
/**
|
|
/**
|
|
* 检查设备订单是否有药品和,生成出库单
|
|
* 检查设备订单是否有药品和,生成出库单
|
|
|
|
*
|
|
* @param deviceId
|
|
* @param deviceId
|
|
* @param pickUpNum
|
|
* @param pickUpNum
|
|
* @param cardNum
|
|
* @param cardNum
|
|
@ -472,21 +478,21 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
public JSONObject checkOrder(String deviceId, String pickUpNum, String cardNum) {
|
|
public JSONObject checkOrder(String deviceId, String pickUpNum, String cardNum) {
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
if (deviceId == null || StringUtils.isEmpty(deviceId)) {
|
|
if (deviceId == null || StringUtils.isEmpty(deviceId)) {
|
|
result.put("msg","parameter deviceId is null or empty");
|
|
|
|
|
|
result.put("msg", "parameter deviceId is null or empty");
|
|
result.put("response", ConstantUtils.FAIL);
|
|
result.put("response", ConstantUtils.FAIL);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
if (pickUpNum == null && cardNum == null) {
|
|
if (pickUpNum == null && cardNum == null) {
|
|
result.put("msg","parameter packUpNum or cardNum is null");
|
|
|
|
|
|
result.put("msg", "parameter packUpNum or cardNum is null");
|
|
result.put("response", ConstantUtils.FAIL);
|
|
result.put("response", ConstantUtils.FAIL);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
if (StringUtils.isEmpty(pickUpNum) && StringUtils.isEmpty(cardNum)) {
|
|
if (StringUtils.isEmpty(pickUpNum) && StringUtils.isEmpty(cardNum)) {
|
|
result.put("msg","parameter pickUpNum or cardNum is empty");
|
|
|
|
|
|
result.put("msg", "parameter pickUpNum or cardNum is empty");
|
|
result.put("response", ConstantUtils.FAIL);
|
|
result.put("response", ConstantUtils.FAIL);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
Mediicineorder mediicineorder = null;
|
|
|
|
|
|
Mediicineorder mediicineorder = null;
|
|
if (!StringUtils.isEmpty(pickUpNum)) {
|
|
if (!StringUtils.isEmpty(pickUpNum)) {
|
|
mediicineorder = orderDao.findMediicineorderByPickUpNum(pickUpNum);
|
|
mediicineorder = orderDao.findMediicineorderByPickUpNum(pickUpNum);
|
|
}
|
|
}
|
|
@ -494,7 +500,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
mediicineorder = orderDao.findMediicineorderBySocialSecurityCardNum(cardNum);
|
|
mediicineorder = orderDao.findMediicineorderBySocialSecurityCardNum(cardNum);
|
|
}
|
|
}
|
|
if (mediicineorder == null) {
|
|
if (mediicineorder == null) {
|
|
result.put("msg","order doesn't exist");
|
|
|
|
|
|
result.put("msg", "order doesn't exist");
|
|
result.put("response", ConstantUtils.FAIL);
|
|
result.put("response", ConstantUtils.FAIL);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
@ -558,7 +564,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
"FROM\n" +
|
|
"FROM\n" +
|
|
" t_mediicine_order_detail AS t\n";
|
|
" t_mediicine_order_detail AS t\n";
|
|
if (!StringUtils.isEmpty(pickUpNum)) {
|
|
if (!StringUtils.isEmpty(pickUpNum)) {
|
|
sql += "WHERE t.pick_up_num = '" + pickUpNum + "'";
|
|
|
|
|
|
sql += "WHERE t.pick_up_num = '" + pickUpNum + "'";
|
|
}
|
|
}
|
|
if (!StringUtils.isEmpty(cardNum)) {
|
|
if (!StringUtils.isEmpty(cardNum)) {
|
|
if (!StringUtils.isEmpty(pickUpNum)) {
|
|
if (!StringUtils.isEmpty(pickUpNum)) {
|
|
@ -567,7 +573,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
sql += "WHERE t.social_security_card_num = '" + cardNum + "'";
|
|
sql += "WHERE t.social_security_card_num = '" + cardNum + "'";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
List<Map<String,Object>> list = null;
|
|
|
|
|
|
List<Map<String, Object>> list = null;
|
|
//订单详细内容
|
|
//订单详细内容
|
|
list = hibenateUtils.createSQLQuery(sql);
|
|
list = hibenateUtils.createSQLQuery(sql);
|
|
//没有订单信息
|
|
//没有订单信息
|
|
@ -580,7 +586,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
"\t\t\tFROM\n" +
|
|
"\t\t\tFROM\n" +
|
|
"\t\t\t\tt_mediicinecabinet_inventory t WHERE t.drug_code = '" + stringObjectMap.get("drugCode") + "'\n" +
|
|
"\t\t\t\tt_mediicinecabinet_inventory t WHERE t.drug_code = '" + stringObjectMap.get("drugCode") + "'\n" +
|
|
"\t\t\tAND t.org_code = '" + stringObjectMap.get("orgCode") + "'\n" +
|
|
"\t\t\tAND t.org_code = '" + stringObjectMap.get("orgCode") + "'\n" +
|
|
"\t\t\tAND t.id_device = '"+ deviceId + "'\n" +
|
|
|
|
|
|
"\t\t\tAND t.id_device = '" + deviceId + "'\n" +
|
|
"\t\t\tGROUP BY\n" +
|
|
"\t\t\tGROUP BY\n" +
|
|
"\t\t\t\tt.drug_code,\n" +
|
|
"\t\t\t\tt.drug_code,\n" +
|
|
"\t\t\t\tt.org_code\n" +
|
|
"\t\t\t\tt.org_code\n" +
|
|
@ -589,7 +595,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
"\t\t),\n" +
|
|
"\t\t),\n" +
|
|
"\t\t0\n" +
|
|
"\t\t0\n" +
|
|
"\t)";
|
|
"\t)";
|
|
int count = jdbcTemplate.queryForObject(secondSql,Integer.class);
|
|
|
|
|
|
int count = jdbcTemplate.queryForObject(secondSql, Integer.class);
|
|
if (count == 0) {
|
|
if (count == 0) {
|
|
result.put("response", ConstantUtils.FAIL);
|
|
result.put("response", ConstantUtils.FAIL);
|
|
return result;
|
|
return result;
|
|
@ -603,7 +609,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
"FROM\n" +
|
|
"FROM\n" +
|
|
"\tt_medicine_shipment_log\n" +
|
|
"\tt_medicine_shipment_log\n" +
|
|
"WHERE\n" +
|
|
"WHERE\n" +
|
|
"\torder_id = '" + list.get(0).get("idOrder") + "'",Integer.class);
|
|
|
|
|
|
"\torder_id = '" + list.get(0).get("idOrder") + "'", Integer.class);
|
|
if (count > 0) {
|
|
if (count > 0) {
|
|
jsonObject.put("orderId", mediicineorder.getId());
|
|
jsonObject.put("orderId", mediicineorder.getId());
|
|
result.put("response", ConstantUtils.SUCCESS);
|
|
result.put("response", ConstantUtils.SUCCESS);
|
|
@ -625,15 +631,15 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
"FROM\n" +
|
|
"FROM\n" +
|
|
"\tt_mediicinecabinet_inventory t\n" +
|
|
"\tt_mediicinecabinet_inventory t\n" +
|
|
"WHERE\n" +
|
|
"WHERE\n" +
|
|
"\tt.drug_code = '"+ stringObjectMap.get("drugCode") +"'\n" +
|
|
|
|
"AND t.org_code = '" + stringObjectMap.get("orgCode") +"'\n" +
|
|
|
|
|
|
"\tt.drug_code = '" + stringObjectMap.get("drugCode") + "'\n" +
|
|
|
|
"AND t.org_code = '" + stringObjectMap.get("orgCode") + "'\n" +
|
|
"AND t.id_device = '" + deviceId + "'\n" +
|
|
"AND t.id_device = '" + deviceId + "'\n" +
|
|
"and t.qty > 0"
|
|
"and t.qty > 0"
|
|
);
|
|
);
|
|
for (int i = 0; i < qty; i++) {
|
|
for (int i = 0; i < qty; i++) {
|
|
for (Map<String, Object> objectMap : tempList) {
|
|
for (Map<String, Object> objectMap : tempList) {
|
|
if (Integer.parseInt(String.valueOf(objectMap.get("qty"))) >0) {
|
|
|
|
objectMap.put("qty",Integer.parseInt(String.valueOf(objectMap.get("qty"))) - 1 );
|
|
|
|
|
|
if (Integer.parseInt(String.valueOf(objectMap.get("qty"))) > 0) {
|
|
|
|
objectMap.put("qty", Integer.parseInt(String.valueOf(objectMap.get("qty"))) - 1);
|
|
MedicineShipmentLog shipmentLog = new MedicineShipmentLog();
|
|
MedicineShipmentLog shipmentLog = new MedicineShipmentLog();
|
|
shipmentLog.setDeviceId(deviceId);
|
|
shipmentLog.setDeviceId(deviceId);
|
|
shipmentLog.setOrderId(stringObjectMap.get("idOrder").toString());
|
|
shipmentLog.setOrderId(stringObjectMap.get("idOrder").toString());
|
|
@ -666,7 +672,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
result.put("msg", "orderId is null or empty");
|
|
result.put("msg", "orderId is null or empty");
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
String sql = "SELECT\n" +
|
|
|
|
|
|
String sql = "SELECT\n" +
|
|
" t.id AS id,\n" +
|
|
" t.id AS id,\n" +
|
|
" t.device_id AS deviceId,\n" +
|
|
" t.device_id AS deviceId,\n" +
|
|
" t.order_id AS orderId,\n" +
|
|
" t.order_id AS orderId,\n" +
|
|
@ -691,21 +697,23 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
" t.unit AS unit,\n" +
|
|
" t.unit AS unit,\n" +
|
|
" t.org_code AS orgCode,\n" +
|
|
" t.org_code AS orgCode,\n" +
|
|
" t.org_name AS orgName,\n" +
|
|
" t.org_name AS orgName,\n" +
|
|
" t.equ_name AS equName\n" +
|
|
|
|
|
|
" t.equ_name AS equName,\n" +
|
|
|
|
" t.dos_form AS dosForm\n" +
|
|
" FROM\n" +
|
|
" FROM\n" +
|
|
" t_medicine_shipment_log AS t" +
|
|
" t_medicine_shipment_log AS t" +
|
|
" WHERE \n" +
|
|
" WHERE \n" +
|
|
" t.order_id = '" + orderId + "'";
|
|
" t.order_id = '" + orderId + "'";
|
|
List<Map<String,Object >> list = null;
|
|
|
|
|
|
List<Map<String, Object>> list = null;
|
|
list = hibenateUtils.createSQLQuery(sql);
|
|
list = hibenateUtils.createSQLQuery(sql);
|
|
result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));
|
|
result.put("msg", JavaBeanUtils.getInstance().mapListJson(list));
|
|
result.put("response", ConstantUtils.SUCCESS);
|
|
result.put("response", ConstantUtils.SUCCESS);
|
|
return result;
|
|
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 出货后,更新订单出货单状态 1未出货,2已出货,3出货故障
|
|
* 出货后,更新订单出货单状态 1未出货,2已出货,3出货故障
|
|
|
|
*
|
|
* @param shipmentLogId
|
|
* @param shipmentLogId
|
|
* @param status
|
|
* @param status
|
|
* @return
|
|
* @return
|
|
@ -771,7 +779,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
"\torder_id = '" + orderId + "'\n" +
|
|
"\torder_id = '" + orderId + "'\n" +
|
|
"AND `status` = 1\n" +
|
|
"AND `status` = 1\n" +
|
|
"OR `status` = 3";
|
|
"OR `status` = 3";
|
|
int count = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
|
|
|
int count = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
if (count == 0) {
|
|
if (count == 0) {
|
|
Mediicineorder order = orderDao.findOne(orderId);
|
|
Mediicineorder order = orderDao.findOne(orderId);
|
|
order.setSellState("1");
|
|
order.setSellState("1");
|
|
@ -787,6 +795,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
|
|
|
|
/**
|
|
/**
|
|
* 检查订单&返回订单出货单列表 deviceId ---->equNum
|
|
* 检查订单&返回订单出货单列表 deviceId ---->equNum
|
|
|
|
*
|
|
* @param deviceId
|
|
* @param deviceId
|
|
* @param pickUpNum
|
|
* @param pickUpNum
|
|
* @param cardNum
|
|
* @param cardNum
|
|
@ -795,21 +804,21 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
public JSONObject checkOrderAndReturn(String deviceId, String pickUpNum, String cardNum) {
|
|
public JSONObject checkOrderAndReturn(String deviceId, String pickUpNum, String cardNum) {
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
if (deviceId == null || StringUtils.isEmpty(deviceId)) {
|
|
if (deviceId == null || StringUtils.isEmpty(deviceId)) {
|
|
result.put("msg","parameter deviceId is null or empty");
|
|
|
|
|
|
result.put("msg", "parameter deviceId is null or empty");
|
|
result.put("response", ConstantUtils.FAIL);
|
|
result.put("response", ConstantUtils.FAIL);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
if (pickUpNum == null && cardNum == null) {
|
|
if (pickUpNum == null && cardNum == null) {
|
|
result.put("msg","parameter packUpNum or cardNum is null");
|
|
|
|
|
|
result.put("msg", "parameter packUpNum or cardNum is null");
|
|
result.put("response", ConstantUtils.FAIL);
|
|
result.put("response", ConstantUtils.FAIL);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
if (StringUtils.isEmpty(pickUpNum) && StringUtils.isEmpty(cardNum)) {
|
|
if (StringUtils.isEmpty(pickUpNum) && StringUtils.isEmpty(cardNum)) {
|
|
result.put("msg","parameter pickUpNum or cardNum is empty");
|
|
|
|
|
|
result.put("msg", "parameter pickUpNum or cardNum is empty");
|
|
result.put("response", ConstantUtils.FAIL);
|
|
result.put("response", ConstantUtils.FAIL);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
Mediicineorder mediicineorder = null;
|
|
|
|
|
|
Mediicineorder mediicineorder = null;
|
|
if (!StringUtils.isEmpty(pickUpNum)) {
|
|
if (!StringUtils.isEmpty(pickUpNum)) {
|
|
mediicineorder = orderDao.findMediicineorderByPickUpNum(pickUpNum);
|
|
mediicineorder = orderDao.findMediicineorderByPickUpNum(pickUpNum);
|
|
}
|
|
}
|
|
@ -817,7 +826,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
mediicineorder = orderDao.findMediicineorderBySocialSecurityCardNum(cardNum);
|
|
mediicineorder = orderDao.findMediicineorderBySocialSecurityCardNum(cardNum);
|
|
}
|
|
}
|
|
if (mediicineorder == null) {
|
|
if (mediicineorder == null) {
|
|
result.put("msg","order doesn't exist");
|
|
|
|
|
|
result.put("msg", "order doesn't exist");
|
|
result.put("response", ConstantUtils.FAIL);
|
|
result.put("response", ConstantUtils.FAIL);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
@ -834,7 +843,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
"\t\t\t\tt_mediicinecabinet_inventory t WHERE t.drug_code = '" + mediicineorderdetail.getDrugCode() + "'\n" +
|
|
"\t\t\t\tt_mediicinecabinet_inventory t WHERE t.drug_code = '" + mediicineorderdetail.getDrugCode() + "'\n" +
|
|
"\t\t\tAND t.org_code = '" + mediicineorderdetail.getOrgCode() + "'\n" +
|
|
"\t\t\tAND t.org_code = '" + mediicineorderdetail.getOrgCode() + "'\n" +
|
|
// "\t\t\tAND t.state = '1'\n" +
|
|
// "\t\t\tAND t.state = '1'\n" +
|
|
"\t\t\tAND CONCAT(t.id_device, t.equ_num) like '%"+ deviceId + "%'\n" +
|
|
|
|
|
|
"\t\t\tAND CONCAT(t.id_device, t.equ_num) like '%" + deviceId + "%'\n" +
|
|
"\t\t\tGROUP BY\n" +
|
|
"\t\t\tGROUP BY\n" +
|
|
"\t\t\t\tt.drug_code,\n" +
|
|
"\t\t\t\tt.drug_code,\n" +
|
|
"\t\t\t\tt.org_code\n" +
|
|
"\t\t\t\tt.org_code\n" +
|
|
@ -843,7 +852,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
"\t\t),\n" +
|
|
"\t\t),\n" +
|
|
"\t\t0\n" +
|
|
"\t\t0\n" +
|
|
"\t)";
|
|
"\t)";
|
|
int count = jdbcTemplate.queryForObject(secondSql,Integer.class);
|
|
|
|
|
|
int count = jdbcTemplate.queryForObject(secondSql, Integer.class);
|
|
mediicineorderdetail.setOrderState("1");
|
|
mediicineorderdetail.setOrderState("1");
|
|
if (count == 0) {
|
|
if (count == 0) {
|
|
isInStock = false;
|
|
isInStock = false;
|
|
@ -861,14 +870,15 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
}
|
|
}
|
|
|
|
|
|
//生成出货单
|
|
//生成出货单
|
|
DmHospitalDO dmHospitalDO = hospitalDao.findOne(Integer.parseInt(mediicineorder.getBelongCommunity()));
|
|
|
|
|
|
//获取社区详细信息
|
|
|
|
DmHospitalDO dmHospitalDO = hospitalDao.findByCode(mediicineorder.getBelongCommunity());
|
|
int count = jdbcTemplate.queryForObject(
|
|
int count = jdbcTemplate.queryForObject(
|
|
"SELECT\n" +
|
|
"SELECT\n" +
|
|
"\tcount(DISTINCT(id))\n" +
|
|
"\tcount(DISTINCT(id))\n" +
|
|
"FROM\n" +
|
|
"FROM\n" +
|
|
"\tt_medicine_shipment_log\n" +
|
|
"\tt_medicine_shipment_log\n" +
|
|
"WHERE\n" +
|
|
"WHERE\n" +
|
|
"\torder_id = '" + mediicineorder.getId() + "'",Integer.class);
|
|
|
|
|
|
"\torder_id = '" + mediicineorder.getId() + "'", Integer.class);
|
|
if (count > 0) {
|
|
if (count > 0) {
|
|
String tempSql = "SELECT\n" +
|
|
String tempSql = "SELECT\n" +
|
|
"\tt.id AS id,\n" +
|
|
"\tt.id AS id,\n" +
|
|
@ -895,11 +905,12 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
"\tt.unit AS unit,\n" +
|
|
"\tt.unit AS unit,\n" +
|
|
"\tt.org_code AS orgCode,\n" +
|
|
"\tt.org_code AS orgCode,\n" +
|
|
"\tt.org_name AS orgName,\n" +
|
|
"\tt.org_name AS orgName,\n" +
|
|
"\tt.equ_name AS equName\n" +
|
|
|
|
|
|
" t.equ_name AS equName,\n" +
|
|
|
|
" t.dos_form AS dosForm\n" +
|
|
"FROM\n" +
|
|
"FROM\n" +
|
|
"\tt_medicine_shipment_log AS t\n" +
|
|
"\tt_medicine_shipment_log AS t\n" +
|
|
"WHERE \n" +
|
|
"WHERE \n" +
|
|
"\tt.order_id = '" + mediicineorder.getId()+"'";
|
|
|
|
|
|
"\tt.order_id = '" + mediicineorder.getId() + "'";
|
|
List<Map<String, Object>> tempList = hibenateUtils.createSQLQuery(tempSql);
|
|
List<Map<String, Object>> tempList = hibenateUtils.createSQLQuery(tempSql);
|
|
jsonObject.put("community", dmHospitalDO == null ? "" : dmHospitalDO.getName());
|
|
jsonObject.put("community", dmHospitalDO == null ? "" : dmHospitalDO.getName());
|
|
jsonObject.put("phone", "123456");
|
|
jsonObject.put("phone", "123456");
|
|
@ -931,16 +942,16 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
"FROM\n" +
|
|
"FROM\n" +
|
|
"\tt_mediicinecabinet_inventory t\n" +
|
|
"\tt_mediicinecabinet_inventory t\n" +
|
|
"WHERE\n" +
|
|
"WHERE\n" +
|
|
"\tt.drug_code = '"+ mediicineorderdetail.getDrugCode() +"'\n" +
|
|
|
|
"AND t.org_code = '" + mediicineorderdetail.getOrgCode() +"'\n" +
|
|
|
|
"AND CONCAT(t.id_device, t.equ_num) like '%"+ deviceId + "%'\n" +
|
|
|
|
|
|
"\tt.drug_code = '" + mediicineorderdetail.getDrugCode() + "'\n" +
|
|
|
|
"AND t.org_code = '" + mediicineorderdetail.getOrgCode() + "'\n" +
|
|
|
|
"AND CONCAT(t.id_device, t.equ_num) like '%" + deviceId + "%'\n" +
|
|
"AND ( t.state = '1' or t.state = '21')\n" +
|
|
"AND ( t.state = '1' or t.state = '21')\n" +
|
|
"and t.qty > 0"
|
|
"and t.qty > 0"
|
|
);
|
|
);
|
|
for (int i = 0; i < qty; i++) {
|
|
for (int i = 0; i < qty; i++) {
|
|
for (Map<String, Object> objectMap : tempList) {
|
|
for (Map<String, Object> objectMap : tempList) {
|
|
if (Integer.parseInt(String.valueOf(objectMap.get("qty"))) >0) {
|
|
|
|
objectMap.put("qty",Integer.parseInt(String.valueOf(objectMap.get("qty"))) - 1 );
|
|
|
|
|
|
if (Integer.parseInt(String.valueOf(objectMap.get("qty"))) > 0) {
|
|
|
|
objectMap.put("qty", Integer.parseInt(String.valueOf(objectMap.get("qty"))) - 1);
|
|
MedicineShipmentLog shipmentLog = new MedicineShipmentLog();
|
|
MedicineShipmentLog shipmentLog = new MedicineShipmentLog();
|
|
shipmentLog.setDeviceId(deviceId);
|
|
shipmentLog.setDeviceId(deviceId);
|
|
shipmentLog.setOrderId(mediicineorderdetail.getIdOrder());
|
|
shipmentLog.setOrderId(mediicineorderdetail.getIdOrder());
|
|
@ -959,6 +970,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
|
|
shipmentLog.setUnit(mediicinedrugs.getUnit());
|
|
shipmentLog.setUnit(mediicinedrugs.getUnit());
|
|
shipmentLog.setEquName(mediicinedevice.getEquName());
|
|
shipmentLog.setEquName(mediicinedevice.getEquName());
|
|
shipmentLog.setEquNum(mediicinedevice.getEquNum());
|
|
shipmentLog.setEquNum(mediicinedevice.getEquNum());
|
|
|
|
shipmentLog.setDosForm(mediicinedrugs.getDosForm());
|
|
shipmentLogDao.save(shipmentLog);
|
|
shipmentLogDao.save(shipmentLog);
|
|
shipmentLogs.add(shipmentLog);
|
|
shipmentLogs.add(shipmentLog);
|
|
}
|
|
}
|