hjg
2023-11-17 3780c5e65b05bf23020810798babc6d20311fa79
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package com.mandi.fendan.service.impl;
 
 
import java.util.List;
import java.util.Map;
 
import javax.annotation.Resource;
 
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.mandi.common.JSONobj;
import com.mandi.common.Jacksonmethod;
import com.mandi.common.Wxhtmethod;
import com.mandi.common.ParamFileter.Fileoperation;
import com.mandi.dao.common.ObjectResult;
import com.mandi.fendan.mapper.Fd_BsheetMapper;
import com.mandi.fendan.mapper.Fd_ComVehicleMapper;
import com.mandi.fendan.mapper.Fd_VehicleMapper;
import com.mandi.fendan.mapper.Fd_XSTDMXMapper;
import com.mandi.fendan.mapper.Fd_XSTDMapper;
import com.mandi.fendan.mapper.VehicleXSTDMapper;
import com.mandi.fendan.persist.Fd_Bsheet;
import com.mandi.fendan.persist.Fd_Vehicle;
import com.mandi.fendan.persist.Fd_XSTD;
import com.mandi.fendan.persist.Fd_XSTDMX;
import com.mandi.fendan.persist.VehicleStatus;
import com.mandi.fendan.persist.VehicleType;
import com.mandi.fendan.util.Contants;
import com.mandi.fendan.util.FdtoNc;
import com.mandi.system.persist.Login;
 
/**
 * 业务事务处理类
 *
 */
@Service
public class BsTransService {
    @Resource
    private FdtoNc fdtonc;
    @Resource
    private Fd_BsheetMapper fdbper;
    @Resource
    private Fd_VehicleMapper fdvper;
    @Resource
    private Fd_ComVehicleMapper fdcvper;
    @Resource
    private Fd_XSTDMapper tdper;
    @Resource
    private Fd_XSTDMXMapper tdmxper;
    @Resource
    private VehicleXSTDMapper vxper;
    
    
    //业务单取消事务
    @Transactional(rollbackFor = Exception.class)
    public ObjectResult<Boolean> cancelBs(Fd_Bsheet fdb,Login lg,boolean delBs,List<Fd_XSTD> xstdlist,Fd_Vehicle fdv,Map<String, List<Fd_XSTDMX>> mxMap
            )throws Exception{
        ObjectResult<Boolean> orr=new ObjectResult<Boolean>();
        // 发送NC系统删除分单信息  这一块建议用线程执行
        String bsNo=fdb.getBsNo();
        String vehicleId=fdb.getVehicleId();
        String sdepartNo=fdb.getSdepartNo();
        if (xstdlist != null && xstdlist.size() > 0) {
            
        }
        
        if (delBs) {
            if (fdv.getType() == VehicleType.临时车) {
                this.fdvper.delByVehicleId(vehicleId);
            } else {
                fdv.setStatus(VehicleStatus.未配车);
                this.fdvper.update(fdv);
            }
            this.fdbper.delbybsNo(bsNo);
            
            // 发送一卡通服务删除表头信息
            JsonObject jo = new JsonObject();
            jo.addProperty("bussinessNo", bsNo);
            jo.addProperty("sdepartNo", sdepartNo);
            JsonObject pfob = Wxhtmethod.postJsonStr(Contants.YKTdelYwd_url, jo.toString());
            int code = JSONobj.getint(pfob, "code");
            if (code != 0) {
                throw new Exception(JSONobj.getstring(pfob, "errmsg"));
            }
            
        }
        this.fdcvper.del(vehicleId, lg.getDepartno(), sdepartNo);
        if (xstdlist != null && xstdlist.size() > 0) {
            for (Fd_XSTD fd_XSTD : xstdlist) {
                this.tdmxper.cancelFDBatch(fd_XSTD.getTd_tdls(), bsNo);
                this.vxper.delbyIDs(vehicleId, fd_XSTD.getTd_tdbh(),lg.getSdepartNo());
                this.tdper.updateFD(fd_XSTD);
            }
        }
        orr.setCode(0);
        orr.setItem(true);
        return orr;
    }
 
}