fanzherong_v há 1 mês atrás
pai
commit
f7a3ac6e66
15 ficheiros alterados com 329 adições e 23 exclusões
  1. 8 0
      snowy-admin-web/src/api/biz/bizAppointmentRecordApi.js
  2. 2 0
      snowy-admin-web/src/views/biz/bizappointmentrecord/detail.vue
  3. 65 1
      snowy-admin-web/src/views/biz/bizappointmentrecord/index.vue
  4. 2 0
      snowy-admin-web/src/views/biz/bizorder/detail.vue
  5. 1 0
      snowy-admin-web/src/views/biz/bizorder/index.vue
  6. 1 1
      snowy-admin-web/src/views/biz/bizsaleorder/form.vue
  7. 23 1
      snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizappointmentrecord/controller/BizAppointmentRecordController.java
  8. 2 0
      snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizappointmentrecord/mapper/BizAppointmentRecordMapper.java
  9. 21 1
      snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizappointmentrecord/mapper/mapping/BizAppointmentRecordMapper.xml
  10. 4 0
      snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizappointmentrecord/service/BizAppointmentRecordService.java
  11. 71 13
      snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizappointmentrecord/service/impl/BizAppointmentRecordServiceImpl.java
  12. 3 1
      snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizorder/mapper/mapping/BizOrderMapper.xml
  13. 113 1
      snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizorder/service/impl/BizOrderServiceImpl.java
  14. 2 0
      snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/record/controller/BizRecordController.java
  15. 11 4
      snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/record/service/impl/BizRecordServiceImpl.java

+ 8 - 0
snowy-admin-web/src/api/biz/bizAppointmentRecordApi.js

@@ -25,6 +25,14 @@ export default {
 	bizAppointmentRecordDelete(data) {
 		return request('delete', data)
 	},
+	//取消预约记录
+	bizAppointmentCancel(data){
+		return request('cancel',data)
+	},
+	//授权出场
+	bizAppointmentExit(data){
+		return request('exit',data)
+	},
 	// 获取预约记录详情
 	bizAppointmentRecordDetail(data) {
 		return request('detail', data, 'get')

+ 2 - 0
snowy-admin-web/src/views/biz/bizappointmentrecord/detail.vue

@@ -14,6 +14,8 @@
 				<a-descriptions-item label="货品编码" :span="2">{{ formData.goodsCode }}</a-descriptions-item>
 				<a-descriptions-item label="司机姓名" :span="2">{{ formData.driverName }}</a-descriptions-item>
 				<a-descriptions-item label="司机电话" :span="2">{{ formData.driverMobile }}</a-descriptions-item>
+				<a-descriptions-item label="创建人" :span="2">{{ formData.createUserName }}</a-descriptions-item>
+				<a-descriptions-item label="创建时间" :span="2">{{ formData.createTime }}</a-descriptions-item>
 
 				<a-descriptions-item label="预约状态" :span="4">
 					<a-tag

+ 65 - 1
snowy-admin-web/src/views/biz/bizappointmentrecord/index.vue

@@ -179,7 +179,7 @@
 									<a-menu-item v-if="hasPerm('bizAppointmentRecordEdit') && (record.status == '2')">
 										<a style="color:blue" @click="formRef.onOpen(record)" >编辑</a>
 									</a-menu-item>
-									<a-menu-item v-if="hasPerm('bizAppointmentRecordDelete') && (record.status == '2')">
+									<a-menu-item v-if="hasPerm('bizAppointmentRecordDelete') && (record.status == '2' || record.status == '4')">
 										<a style="color:red" type="link" danger size="small" @click="deleteConfig(record)">删除</a>
 									</a-menu-item>
 									<a-menu-item v-if="hasPerm('bizAppointmentDriverConfim') && record.status == '8'">
@@ -188,6 +188,12 @@
 									<a-menu-item v-if="hasPerm('bizAppointmentDriverSign') && record.status=='10' && record.orderType=='1'">
 										<a  @click="signRef.onOpen(record)" >回签</a>
 									</a-menu-item>
+									<a-menu-item v-if="record.status=='4'">
+										<a style="color:green"  @click="cancel(record)" >取消</a>
+									</a-menu-item>
+									<a-menu-item v-if="hasPerm('bizAppointmentDriverExit') && (record.status=='5' || record.status=='6' || record.status=='7' || record.status=='8')">
+										<a style="color:orange"  @click="exit(record)" >授权出场</a>
+									</a-menu-item>
 
 
 								</a-menu>
@@ -396,6 +402,64 @@
 			onCancel() {}
 		})
 	}
+
+	//取消预约
+	const cancel = (record) => {
+
+		Modal.confirm({
+			title: '确定要取消吗?',
+			icon: createVNode(ExclamationCircleOutlined),
+			content: '',
+			onOk() {
+				submitLoading.value = true
+				let params =
+					{
+						id: record.id
+					}
+
+
+				bizAppointmentRecordApi
+					.bizAppointmentCancel(params)
+					.then(() => {
+						tableRef.value.refresh(true)
+					})
+					.finally(() => {
+						submitLoading.value = false
+					})
+			},
+			onCancel() {}
+		})
+	}
+
+
+	//授权出场
+	const exit = (record) => {
+
+		Modal.confirm({
+			title: '确定要授权出场吗?',
+			icon: createVNode(ExclamationCircleOutlined),
+			content: '',
+			onOk() {
+				submitLoading.value = true
+				let params =
+					{
+						id: record.id
+					}
+
+
+				bizAppointmentRecordApi
+					.bizAppointmentExit(params)
+					.then(() => {
+						tableRef.value.refresh(true)
+					})
+					.finally(() => {
+						submitLoading.value = false
+					})
+			},
+			onCancel() {}
+		})
+	}
+
 	// 批量删除
 	const deleteBatchBizAppointmentRecord = (params) => {
 		bizAppointmentRecordApi.bizAppointmentRecordDelete(params).then(() => {

+ 2 - 0
snowy-admin-web/src/views/biz/bizorder/detail.vue

@@ -50,6 +50,8 @@
 				<a-descriptions-item label="过磅重量" :span="2">{{ formData.netWeight +'吨'}}</a-descriptions-item>
 				<a-descriptions-item label="提货开始时间" :span="2">{{ formData.confStartTime}}</a-descriptions-item>
 				<a-descriptions-item label="提货结束时间" :span="2">{{ formData.confEndTime}}</a-descriptions-item>
+				<a-descriptions-item label="创建时间" :span="2">{{ formData.createTime}}</a-descriptions-item>
+				<a-descriptions-item label="创建人" :span="2">{{ formData.createUserName}}</a-descriptions-item>
 				<a-descriptions-item label="送货地址" :span="4">{{ formData.shipAddress}}</a-descriptions-item>
 				<a-descriptions-item label="签名" :span="4">
 					<a-image v-if="formData.orderSign != null" :width="200" :src="formData.orderSign" />

+ 1 - 0
snowy-admin-web/src/views/biz/bizorder/index.vue

@@ -602,6 +602,7 @@
 		let param = {
 			id:record.id,
 			orderName:record.orderName,
+			orderNumber:record.orderNumber,
 			type:'1'
 		}
 		QRCode.toDataURL(JSON.stringify(param), {

+ 1 - 1
snowy-admin-web/src/views/biz/bizsaleorder/form.vue

@@ -104,7 +104,7 @@
 	// 默认要校验的
 	const formRules = {
 		saleOrderNumber: [required('请输入销售订单编号')],
-		saleOrderName: [required('请输入销售订单名称')],
+		//saleOrderName: [required('请输入销售订单名称')],
 		saleOrderType: [required('请选择订单类型')],
 		saleGoodsCode: [required('请选择货品信息')],
 		saleOrderWeight: [required('请输入销售订单重量')],

+ 23 - 1
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizappointmentrecord/controller/BizAppointmentRecordController.java

@@ -247,9 +247,31 @@ public class BizAppointmentRecordController {
      * 车辆执行状态分析
      */
     @Operation(summary = "车辆执行状态分析")
-    @CommonLog("车辆执行状态分析")
     @GetMapping("/biz/bizappointmentrecord/gerVehicleTotal")
     public CommonResult<List<Map<String,Object>>> gerVehicleTotal(BizAppointmentRecordPageParam bizAppointmentRecordPageParam){
         return CommonResult.data(bizAppointmentRecordService.gerVehicleTotal(bizAppointmentRecordPageParam));
     }
+
+
+    /**
+     * 取消预约
+     */
+    @Operation(summary = "取消预约")
+    @CommonLog("取消预约")
+    @PostMapping("/biz/bizappointmentrecord/cancel")
+    public CommonResult<String> cancel(@RequestBody BizAppointmentRecordIdParam bizAppointmentRecordIdParam){
+        bizAppointmentRecordService.cancel(bizAppointmentRecordIdParam);
+        return CommonResult.ok();
+    }
+
+    /**
+     * 授权出场
+     */
+    @Operation(summary = "授权出场")
+    @CommonLog("授权出场")
+    @PostMapping("/biz/bizappointmentrecord/exit")
+    public CommonResult<String> exit(@RequestBody BizAppointmentRecordIdParam bizAppointmentRecordIdParam){
+        bizAppointmentRecordService.exit(bizAppointmentRecordIdParam);
+        return CommonResult.ok();
+    }
 }

+ 2 - 0
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizappointmentrecord/mapper/BizAppointmentRecordMapper.java

@@ -35,4 +35,6 @@ public interface BizAppointmentRecordMapper extends BaseMapper<BizAppointmentRec
     List<BizAppointmentRecord> getRecord(@Param("ew") QueryWrapper<BizAppointmentRecord> ew);
 
     List<Map<String,Object>> gerVehicleTotal(@Param("beginTime") String beginTime,@Param("endTime") String endTime);
+
+    List<BizAppointmentRecord> getRecordList(@Param("ew") QueryWrapper<BizAppointmentRecord> ew);
 }

+ 21 - 1
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizappointmentrecord/mapper/mapping/BizAppointmentRecordMapper.xml

@@ -33,7 +33,8 @@
             br.audit_sign,
             bar.appointment_type,
             bar.appointment_classify,
-            bar.create_time
+            bar.create_time,
+            bar.create_user
         from biz_appointment_record bar
          left join biz_order bo on bar.order_id = bo.id
          left join biz_goods bg on bg.id = bo.good_id
@@ -96,4 +97,23 @@
                 GROUP BY bar.STATUS
             ) b ON a.DICT_VALUE = b.STATUS
     </select>
+
+    <select id="getRecordList"
+            resultType="vip.xiaonuo.biz.modular.bizappointmentrecord.entity.BizAppointmentRecord">
+        SELECT
+            bar.id,
+            bar.order_id,
+            bar.license_number,
+            bar.time_id,
+            bar.driver_name,
+            bar.driver_mobile,
+            bar.STATUS,
+            bar.appointment_reason,
+            bar.create_user,
+            bar.queue_number
+        FROM
+            biz_appointment_record bar
+                LEFT JOIN biz_record br ON br.appointment_id = bar.id
+            ${ew.customSqlSegment}
+    </select>
 </mapper>

+ 4 - 0
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizappointmentrecord/service/BizAppointmentRecordService.java

@@ -119,4 +119,8 @@ public interface BizAppointmentRecordService extends IService<BizAppointmentReco
     List<Map<String,Object>> gerVehicleTotal(BizAppointmentRecordPageParam bizAppointmentRecordPageParam);
 
     void sendAccount(BizAppointmentRecord bizAppointmentRecord);
+
+    void cancel(BizAppointmentRecordIdParam bizAppointmentRecordIdParam);
+
+    void exit(BizAppointmentRecordIdParam bizAppointmentRecordIdParam);
 }

+ 71 - 13
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizappointmentrecord/service/impl/BizAppointmentRecordServiceImpl.java

@@ -19,6 +19,7 @@ import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.PhoneUtil;
 import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -54,6 +55,7 @@ import vip.xiaonuo.biz.modular.goods.entity.BizGoods;
 import vip.xiaonuo.biz.modular.goods.service.BizGoodsService;
 import vip.xiaonuo.biz.modular.goodsConf.entity.BizGoodsConf;
 import vip.xiaonuo.biz.modular.goodsConf.service.BizGoodsConfService;
+import vip.xiaonuo.biz.modular.mq.MqttSubscribeClient;
 import vip.xiaonuo.biz.modular.oawxsendlog.entity.OaWxSendLog;
 import vip.xiaonuo.biz.modular.officialinfo.entity.OfficialInfo;
 import vip.xiaonuo.biz.modular.officialinfo.service.OfficialInfoService;
@@ -118,6 +120,9 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
     @Resource
     private BizCustomerService bizCustomerService;
 
+    @Resource
+    private MqttSubscribeClient mqttSubscribeClient;
+
     @Override
     public Page<BizAppointmentRecord> page(BizAppointmentRecordPageParam bizAppointmentRecordPageParam) {
         QueryWrapper<BizAppointmentRecord> queryWrapper = getQueryWrapper(bizAppointmentRecordPageParam);
@@ -566,7 +571,7 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
         //根据车牌号和状态查询
         BizAppointmentRecord bizAppointmentRecord = this.getOne(new QueryWrapper<BizAppointmentRecord>().lambda().
                 eq(BizAppointmentRecord::getLicenseNumber, bizAppointmentRecordPageParam.getLicenseNumber()).
-                eq(BizAppointmentRecord::getStatus, bizAppointmentRecordPageParam.getStatus()).
+                orderByDesc(BizAppointmentRecord::getCreateTime).
                 last("limit 1"));
         if(StringUtils.equals(bizAppointmentRecordPageParam.getStatus(),"4")){
             //待入场,如果为空,没有待入场的记录,不可进门禁
@@ -574,11 +579,15 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
                 bizAppointmentRecord = new BizAppointmentRecord();
                 bizAppointmentRecord.setIsFlag("4");
             }else{
-                if(StringUtils.equals(bizAppointmentRecord.getAppointmentType(),"1")){
-                    //订单预约
-                    bizAppointmentRecord = setBizAppointmentRecord(bizAppointmentRecord);
+                if(StringUtils.equals(bizAppointmentRecord.getStatus(),"4")){
+                    if(StringUtils.equals(bizAppointmentRecord.getAppointmentType(),"1")){
+                        //订单预约
+                        bizAppointmentRecord = setBizAppointmentRecord(bizAppointmentRecord);
+                    }else{
+                        bizAppointmentRecord.setIsFlag("1");
+                    }
                 }else{
-                    bizAppointmentRecord.setIsFlag("1");
+                    bizAppointmentRecord.setIsFlag("4");
                 }
             }
         }else if(StringUtils.equals(bizAppointmentRecordPageParam.getStatus(),"5")){
@@ -587,8 +596,12 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
                 bizAppointmentRecord = new BizAppointmentRecord();
                 bizAppointmentRecord.setIsFlag("5");
             }else{
-                if(StringUtils.equals(bizAppointmentRecord.getAppointmentType(),"1")){
-                    bizAppointmentRecord = setBizAppointmentRecord(bizAppointmentRecord);
+                if(StringUtils.equals(bizAppointmentRecord.getStatus(),"5")){
+                    if(StringUtils.equals(bizAppointmentRecord.getAppointmentType(),"1")){
+                        bizAppointmentRecord = setBizAppointmentRecord(bizAppointmentRecord);
+                    }else{
+                        bizAppointmentRecord.setIsFlag("5");
+                    }
                 }else{
                     bizAppointmentRecord.setIsFlag("5");
                 }
@@ -599,12 +612,21 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
                 bizAppointmentRecord = new BizAppointmentRecord();
                 bizAppointmentRecord.setIsFlag("7");
             }else{
-                if(StringUtils.equals(bizAppointmentRecord.getAppointmentType(),"1")){
-                    bizAppointmentRecord = setBizAppointmentRecord(bizAppointmentRecord);
+                if(StringUtils.equals(bizAppointmentRecord.getStatus(),"7")){
+                    if(StringUtils.equals(bizAppointmentRecord.getAppointmentType(),"1")){
+                        bizAppointmentRecord = setBizAppointmentRecord(bizAppointmentRecord);
+                    }else{
+                        bizAppointmentRecord.setIsFlag("7");
+                    }
+                }else if (StringUtils.equals(bizAppointmentRecord.getStatus(),"8")){
+                    if(StringUtils.equals(bizAppointmentRecord.getAppointmentType(),"1")){
+                        bizAppointmentRecord = setBizAppointmentRecord(bizAppointmentRecord);
+                    }else{
+                        bizAppointmentRecord.setIsFlag("7");
+                    }
                 }else{
                     bizAppointmentRecord.setIsFlag("7");
                 }
-
             }
         }else if(StringUtils.equals(bizAppointmentRecordPageParam.getStatus(),"9")){
             //待出场,如果为空,没有待出场的记录,不可出门禁
@@ -612,11 +634,16 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
                 bizAppointmentRecord = new BizAppointmentRecord();
                 bizAppointmentRecord.setIsFlag("9");
             }else{
-                if(StringUtils.equals(bizAppointmentRecord.getAppointmentType(),"1")){
-                    bizAppointmentRecord = setBizAppointmentRecord(bizAppointmentRecord);
+                if(StringUtils.equals(bizAppointmentRecord.getStatus(),"9")){
+                    if(StringUtils.equals(bizAppointmentRecord.getAppointmentType(),"1")){
+                        bizAppointmentRecord = setBizAppointmentRecord(bizAppointmentRecord);
+                    }else{
+                        bizAppointmentRecord.setIsFlag("1");
+                    }
                 }else{
-                    bizAppointmentRecord.setIsFlag("1");
+                    bizAppointmentRecord.setIsFlag("9");
                 }
+
             }
         }
         return bizAppointmentRecord;
@@ -823,4 +850,35 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
             }
         }
     }
+
+    @Override
+    public void cancel(BizAppointmentRecordIdParam bizAppointmentRecordIdParam) {
+        BizAppointmentRecord bizAppointmentRecord = this.queryEntity(bizAppointmentRecordIdParam.getId());
+        //取消
+        bizAppointmentRecord.setStatus("14");
+        this.updateById(bizAppointmentRecord);
+    }
+
+    @Transactional
+    @Override
+    public void exit(BizAppointmentRecordIdParam bizAppointmentRecordIdParam) {
+        //修改过磅记录已出场
+        BizAppointmentRecord bizAppointmentRecord = this.queryEntity(bizAppointmentRecordIdParam.getId());
+        //bizAppointmentRecord.setStatus("10");
+        this.removeById(bizAppointmentRecord);
+
+        //删除过磅记录
+        List<BizRecord> recordList = bizRecordService.list(new QueryWrapper<BizRecord>().lambda().
+                eq(BizRecord::getAppointmentId, bizAppointmentRecord.getId()));
+        for(BizRecord bizRecord : recordList){
+            //下发mqtt,地磅端删除过磅记录
+            Map<String,Object> map = Maps.newHashMap();
+            map.put("id",bizRecord.getRelationId());
+            map.put("type","20");
+            //mqtt发送过磅记录id给地磅端,告诉地磅端可打印磅单,抬道闸
+            mqttSubscribeClient.publishMessage("hnzydb", JSONObject.toJSONString(map));
+            log.info("授权出场mqtt下发车牌号:"+bizRecord.getLicensePlate());
+            bizRecordService.removeById(bizRecord.getId());
+        }
+    }
 }

+ 3 - 1
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizorder/mapper/mapping/BizOrderMapper.xml

@@ -28,7 +28,9 @@
             bo.order_sign,
             bo.order_reason,
             bo.end_reason,
-            bo.ship_address
+            bo.ship_address,
+            bo.create_time,
+            bo.create_user
         from biz_order bo
         left join biz_customer bc on bo.customer_id = bc.id
         left join biz_goods bg on bg.id = bo.good_id

+ 113 - 1
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/bizorder/service/impl/BizOrderServiceImpl.java

@@ -19,12 +19,16 @@ import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.img.ImgUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
-import cn.hutool.json.JSONObject;
+import cn.hutool.http.HttpException;
+import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fhs.trans.service.impl.TransService;
+import com.google.common.collect.Maps;
 import jakarta.annotation.Resource;
 import jakarta.servlet.http.HttpServletResponse;
 import lombok.extern.slf4j.Slf4j;
@@ -34,8 +38,11 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import vip.xiaonuo.auth.api.SaBaseLoginUserApi;
 import vip.xiaonuo.auth.core.util.StpLoginUserUtil;
+import vip.xiaonuo.biz.core.sign.utils.MD5;
 import vip.xiaonuo.biz.modular.bizappointmentrecord.entity.BizAppointmentRecord;
+import vip.xiaonuo.biz.modular.bizappointmentrecord.mapper.BizAppointmentRecordMapper;
 import vip.xiaonuo.biz.modular.bizappointmentrecord.param.BizAppointmentExportResult;
+import vip.xiaonuo.biz.modular.bizappointmentrecord.service.BizAppointmentRecordService;
 import vip.xiaonuo.biz.modular.bizconfig.entity.BizConfig;
 import vip.xiaonuo.biz.modular.bizconfig.service.BizConfigService;
 import vip.xiaonuo.biz.modular.bizorderconfig.entity.BizOrderConfig;
@@ -48,6 +55,8 @@ import vip.xiaonuo.biz.modular.bizorder.param.*;
 import vip.xiaonuo.biz.modular.goodsConf.entity.BizGoodsConf;
 import vip.xiaonuo.biz.modular.goodsConf.service.BizGoodsConfService;
 import vip.xiaonuo.biz.modular.record.entity.BizRecord;
+import vip.xiaonuo.biz.modular.user.entity.BizUser;
+import vip.xiaonuo.biz.modular.user.service.BizUserService;
 import vip.xiaonuo.biz.modular.utils.CommonExportUtil;
 import vip.xiaonuo.common.exception.CommonException;
 import vip.xiaonuo.common.page.CommonPageRequest;
@@ -59,7 +68,9 @@ import java.io.*;
 import java.math.BigDecimal;
 import java.net.URL;
 import java.net.URLConnection;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
@@ -90,6 +101,12 @@ public class BizOrderServiceImpl extends ServiceImpl<BizOrderMapper, BizOrder> i
     @Resource
     private BizSaleOrderService bizSaleOrderService;
 
+    @Resource
+    private BizAppointmentRecordMapper bizAppointmentRecordMapper;
+
+    @Resource
+    private BizUserService bizUserService;
+
     @Resource(name = "loginUserApi")
     private SaBaseLoginUserApi loginUserApi;
 
@@ -361,9 +378,12 @@ public class BizOrderServiceImpl extends ServiceImpl<BizOrderMapper, BizOrder> i
         orderConfigService.save(bizOrderConfig);
     }
 
+    @Transactional
     @Override
     public void endOrder(BizOrderEditParam bizOrderEditParam) {
         BizOrder bizOrder = this.queryEntity(bizOrderEditParam.getId());
+        //判断当前是否包运订单
+        checkEndParam(bizOrder);
         if(bizOrder.getNetWeight().compareTo(BigDecimal.ZERO) != 0){
             BigDecimal orderBalance = bizOrder.getOrderWeight().subtract(bizOrder.getNetWeight());
             BigDecimal result = orderBalance.divide(bizOrder.getOrderWeight(),2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
@@ -377,6 +397,9 @@ public class BizOrderServiceImpl extends ServiceImpl<BizOrderMapper, BizOrder> i
                     bizSaleOrder.setSaleStatus("3");
                     bizSaleOrderService.updateById(bizSaleOrder);
                 }
+
+                //上传订单给erp
+                sendOrderForErp(bizOrder);
             }else{
                 bizOrder.setOrderStatus("5");
             }
@@ -387,6 +410,92 @@ public class BizOrderServiceImpl extends ServiceImpl<BizOrderMapper, BizOrder> i
         this.updateById(bizOrder);
     }
 
+    public void sendOrderForErp(BizOrder bizOrder){
+        String code = null;
+        String msg = null;
+        BigDecimal weight=new BigDecimal(0);
+        try {
+            String appId = "0ol2749zps9xhid1";
+            String appSecret = "e4w9ylwk7grdsdzpbcq8kcedg7ailh1c";
+            String nonce = "21459479202627653";
+            long timestamp = System.currentTimeMillis() / 1000;
+            String sign = getSign(appId, appSecret, nonce, timestamp + "");
+            Map<String,String> map = new HashMap<>();
+            map.put("appId",appId);
+            map.put("appSecret",appSecret);
+            map.put("nonce",nonce);
+            map.put("timestamp",timestamp+"");
+            map.put("signature",sign);
+
+
+            //根据订单查询销售订单信息
+            BizSaleOrder bizSaleOrder = bizSaleOrderService.queryEntity(bizOrder.getSaleOrderInfo());
+            Map<String,Object> paramMap = Maps.newHashMap();
+            paramMap.put("cCode",bizOrder.getId());
+            BizUser bizUser = bizUserService.queryEntity(bizOrder.getCreateUser());
+            paramMap.put("cMaker",bizUser.getName());
+            JSONObject object = new JSONObject();
+            object.put("iorderdid",bizSaleOrder.getRelationId());
+            object.put("cInvCode",bizSaleOrder.getSaleGoodsCode());
+            if(StringUtils.equals(bizOrder.getOrderType(),"1")){
+                //包运订单
+                weight = bizOrder.getShippingWeight();
+                //object.put("iQuantity",bizOrder.getShippingWeight());
+            }else{
+                //自提订单
+                weight = bizOrder.getNetWeight();
+                //object.put("iQuantity",bizOrder.getNetWeight());
+            }
+            weight = weight.divide(new BigDecimal(1000),2,BigDecimal.ROUND_HALF_UP);
+            object.put("iQuantity",weight);
+            JSONArray array = new JSONArray();
+            array.add(object);
+            paramMap.put("details",array);
+
+            String result = HttpUtil.createPost("https://1072el542wi61.vicp.fun/api/erp/u8data/savesalefh")
+                    .addHeaders(map).body(JSONObject.toJSONString(paramMap)).execute().body();
+            JSONObject jsonObject = JSONObject.parseObject(result);
+            code = jsonObject.getString("code");
+            msg = jsonObject.getString("msg");
+        } catch (HttpException e) {
+            //throw new RuntimeException(e);
+            code = "1";
+            msg = "erp网络异常!";
+        }
+        log.info("订单结束上传erp,code:"+code+",msg:"+msg+",重量:"+weight);
+        if(!StringUtils.equals(code,"0")){
+            throw new CommonException(msg);
+        }
+    }
+
+    public static String getSign(String appId,String appSecret,String nonce,String timestamp){
+        StringBuffer buffer = new StringBuffer();
+        buffer.append("appId=").append(appId).append("&");
+        buffer.append("appSecret=").append(appSecret).append("&");
+        buffer.append("nonce=").append(nonce).append("&");
+        buffer.append("timestamp=").append(timestamp).append("&");
+        String sign = MD5.md5(buffer.toString());
+        return sign;
+    }
+
+    public void checkEndParam(BizOrder bizOrder){
+        if(ObjectUtil.isNotNull(bizOrder)){
+            //判断当前是否是包运订单 1:包运订单  2:自提订单
+            if(StringUtils.equals(bizOrder.getOrderType(),"1")){
+                //查询订单所有预约信息
+                QueryWrapper<BizAppointmentRecord> queryWrapper = new QueryWrapper<>();
+                queryWrapper.eq("bar.order_id",bizOrder.getId());
+                queryWrapper.eq("bar.delete_flag","NOT_DELETE");
+                queryWrapper.isNull("br.unload_weight");
+                List<BizAppointmentRecord> recordList = bizAppointmentRecordMapper.getRecordList(queryWrapper);
+                if(recordList.size()>0){
+                    throw new CommonException("该订单下还有未完成回签的预约记录,不可以结束!");
+                }
+
+            }
+        }
+    }
+
     @Override
     public void auditOrder(BizOrderEditParam bizOrderEditParam) {
         BizOrder bizOrder = this.queryEntity(bizOrderEditParam.getId());
@@ -407,6 +516,9 @@ public class BizOrderServiceImpl extends ServiceImpl<BizOrderMapper, BizOrder> i
                     bizSaleOrder.setSaleStatus("3");
                     bizSaleOrderService.updateById(bizSaleOrder);
                 }
+
+                //上传订单给erp
+                sendOrderForErp(bizOrder);
             }
             updateWrapper.eq("id",bizOrder.getId()).
                     set("order_status",status).

+ 2 - 0
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/record/controller/BizRecordController.java

@@ -28,6 +28,7 @@ import vip.xiaonuo.biz.modular.record.result.CarResult;
 import vip.xiaonuo.biz.modular.record.result.CompanyResult;
 import vip.xiaonuo.biz.modular.record.result.GoodsResult;
 import vip.xiaonuo.common.annotation.CommonLog;
+import vip.xiaonuo.common.annotation.CommonNoRepeat;
 import vip.xiaonuo.common.pojo.CommonResult;
 import vip.xiaonuo.biz.modular.record.entity.BizRecord;
 import vip.xiaonuo.biz.modular.record.service.BizRecordService;
@@ -311,6 +312,7 @@ public class BizRecordController {
     @Operation(summary = "二次过磅司机签名确认")
     @CommonLog("二次过磅司机签名确认")
     @PostMapping("/biz/record/updateDriverSign")
+    @CommonNoRepeat
     public CommonResult<String> updateDriverSign(@RequestBody @Valid BizRecordEditParam bizRecordEditParam) {
         bizRecordService.updateDriverSign(bizRecordEditParam);
         return CommonResult.ok();

+ 11 - 4
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/record/service/impl/BizRecordServiceImpl.java

@@ -231,11 +231,11 @@ public class BizRecordServiceImpl extends ServiceImpl<BizRecordMapper, BizRecord
             }
 
             //修改订单重量
-            BizOrder bizOrder = bizOrderService.getById(bizRecord.getOrderId());
+            /*BizOrder bizOrder = bizOrderService.getById(bizRecord.getOrderId());
             if(ObjectUtil.isNotNull(bizOrder)){
                 bizOrder.setNetWeight(bizOrder.getNetWeight().add(bizRecord.getNetWeight()));
                 bizOrderService.updateById(bizOrder);
-            }
+            }*/
         }
     }
 
@@ -599,7 +599,7 @@ public class BizRecordServiceImpl extends ServiceImpl<BizRecordMapper, BizRecord
             BizConfig bizConfig = bizConfigService.getOne(new QueryWrapper<BizConfig>().lambda().last("limit 1"));
             if(StringUtils.equals(bizConfig.getAccessControlSwitch(),"1")){
                 //开启门禁校验
-                //司机签名后修改为可场状态
+                //司机签名后修改为可场状态
                 appointmentRecord.setStatus("9");
             }else{
                 appointmentRecord.setStatus("10");
@@ -607,13 +607,20 @@ public class BizRecordServiceImpl extends ServiceImpl<BizRecordMapper, BizRecord
             bizAppointmentRecordService.updateById(appointmentRecord);
         }
 
+        //司机确认后,修改订单
+        BizOrder bizOrder = bizOrderService.getById(bizRecord.getOrderId());
+        if(ObjectUtil.isNotNull(bizOrder)){
+            bizOrder.setNetWeight(bizOrder.getNetWeight().add(bizRecord.getNetWeight()));
+            bizOrderService.updateById(bizOrder);
+        }
+
         Map<String,Object> map = Maps.newHashMap();
         map.put("id",bizRecord.getRelationId());
         map.put("type","0");
         map.put("loadUser",bizRecord.getConfirmUser());
         //mqtt发送过磅记录id给地磅端,告诉地磅端可打印磅单,抬道闸
         mqttSubscribeClient.publishMessage("hnzydb", JSONObject.toJSONString(map));
-
+        log.info("司机确认mqtt下发车牌号:"+bizRecord.getLicensePlate());
     }
 
     @Transactional