zhuguifei
2026-03-10 58402bd5e762361363a0f7d7907153c77dbb819f
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
package com.shlanbao.tzsc.pms.equ.sbglplan.service.impl;
 
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import com.shlanbao.tzsc.base.dao.EqmCheckcatPlanDaoI;
import com.shlanbao.tzsc.base.dao.EqmSpotchRecordDaoI;
import com.shlanbao.tzsc.base.mapping.EqmCheckcatPlan;
import com.shlanbao.tzsc.base.mapping.EqmSpotchRecode;
import com.shlanbao.tzsc.base.mapping.MdEquipment;
import com.shlanbao.tzsc.base.model.DataGrid;
import com.shlanbao.tzsc.base.model.PageParams;
import com.shlanbao.tzsc.base.service.BaseService;
import com.shlanbao.tzsc.pms.equ.sbglplan.beans.EqmSpotchRecodeBean;
import com.shlanbao.tzsc.pms.equ.sbglplan.service.EqmCheckcatPlanServiceI;
import com.shlanbao.tzsc.utils.tools.DateUtil;
import com.shlanbao.tzsc.utils.tools.StringUtil;
 
@Service
public class EqmCheckcatPlanServiceImpl extends BaseService implements EqmCheckcatPlanServiceI {
    
    @Autowired
    private EqmCheckcatPlanDaoI eqmCheckcatPlanDao;
    @Autowired
    private EqmSpotchRecordDaoI eqmSpotchRecordDao;
    /**
     * 根据id查询到具体的点修记录详情
     * @param esrBean
     * @return  czgId,wxgId,wxzugId
     */
    
    public DataGrid queryInfoById(String id){
        //String sql="select eqp_name,shift_name,team_name,ch_location,ch_status,ch_date,create_user_name,update_time,remark from EQM_SPOTCH_RECODE where id='"+id+"'";
        String hql="from EqmSpotchRecode where id='"+id+"'";
        List<EqmSpotchRecode> map=eqmSpotchRecordDao.query(hql, null);
        List<EqmSpotchRecodeBean> rows = new ArrayList<EqmSpotchRecodeBean>();
        if(map.size()>0){
            for(EqmSpotchRecode b:map){
                EqmSpotchRecodeBean bean = new EqmSpotchRecodeBean();
                bean.setEqpName(b.getEqpName());
                bean.setShiftName(b.getShiftName());
                bean.setTeamName(b.getTeamName());
                bean.setChLocation(b.getChLocation());
                /*int sta = b.getChStatus();
                String status="";
                if(sta==0){//状态,暂时写死,0-未完成,1-已完成,2-有故障
                    status="未完成";
                }else if(sta==1){
                    status="完成";
                }else if(sta==2){
                    status="有故障";
                }*/
                bean.setChStatus(b.getChStatus());
                bean.setChDate(b.getChDate().toString());
                bean.setCreateUserName(b.getCreateUserName());
                bean.setUpdateTime(b.getUpdateTime().toString());
                bean.setRemark(b.getRemark());
                bean.setId(b.getId());
                bean.setEqmId(b.getEqmId().toString());
                rows.add(bean);
            }
        }
        return new DataGrid(rows,null);
        /*String hql=null;
        List<EqmSpotchRecodeBean> rows=new ArrayList<EqmSpotchRecodeBean>();
        if (StringUtil.notNull(czgId)&&!czgId.equals("undefined")&&!czgId.equals("null")) {
            hql="from EqmSpotchRecode o where o.id= ?";
            EqmSpotchRecode map=(EqmSpotchRecode) eqmCheckcatPlanDao.unique(hql.toString(), czgId);
            EqmSpotchRecodeBean bean=new EqmSpotchRecodeBean(
                    czgId,
                    map.getEqmId().getId(), 
                    map.getEqpName(),
                    map.getShiftId().getId(),
                    map.getShiftName(),
                    map.getTeamId(), 
                    map.getTeamName(),
                    map.getChTypeId(), 
                    map.getChTypeName(), 
                    map.getChLocation(), 
                    map.getChStandard(), 
                    map.getChMethod(), 
                    DateUtil.formatDateToString(map.getChDate(),"yyyy-MM-dd"),
                    map.getCreateUserId(), 
                    map.getCreateUserName(),
                    DateUtil.formatDateToString(map.getCreateTime(),"yyyy-MM-dd HH:mm:ss"),
                    map.getChStatus(), 
                    map.getBreLocation(), 
                    map.getRemark(),
                    map.getBreId(),
                    map.getUpdateUserId(), 
                    map.getUpdateUserName(),
                    DateUtil.formatDateToString(map.getUpdateTime(),"yyyy-MM-dd HH:mm:ss"),
                    map.getDel()
                    );
            rows.add(bean);
            
        }
        if (StringUtil.notNull(wxgId)&&!wxgId.equals("undefined")&&!wxgId.equals("null")) {
            hql="from EqmSpotchRecode o where o.id= ?";
            EqmSpotchRecode map=(EqmSpotchRecode) eqmCheckcatPlanDao.unique(hql.toString(), wxgId);
            EqmSpotchRecodeBean bean=new EqmSpotchRecodeBean(
                    czgId,
                    map.getEqmId().getId(), 
                    map.getEqpName(),
                    map.getShiftId().getId(),
                    map.getShiftName(),
                    map.getTeamId(), 
                    map.getTeamName(),
                    map.getChTypeId(), 
                    map.getChTypeName(), 
                    map.getChLocation(), 
                    map.getChStandard(), 
                    map.getChMethod(), 
                    DateUtil.formatDateToString(map.getChDate(),"yyyy-MM-dd"),
                    map.getCreateUserId(), 
                    map.getCreateUserName(),
                    DateUtil.formatDateToString(map.getCreateTime(),"yyyy-MM-dd HH:mm:ss"),
                    map.getChStatus(), 
                    map.getBreLocation(), 
                    map.getRemark(),
                    map.getBreId(),
                    map.getUpdateUserId(), 
                    map.getUpdateUserName(),
                    DateUtil.formatDateToString(map.getUpdateTime(),"yyyy-MM-dd HH:mm:ss"),
                    map.getDel()
                    );
            rows.add(bean);
            
        }
        if (StringUtil.notNull(wxzugId)&&!wxzugId.equals("undefined")&&!wxzugId.equals("null")) {
            hql="from EqmSpotchRecode o where o.id= ?";
            EqmSpotchRecode map=(EqmSpotchRecode) eqmCheckcatPlanDao.unique(hql.toString(), wxzugId);
            EqmSpotchRecodeBean bean=new EqmSpotchRecodeBean(
                    czgId,
                    map.getEqmId().getId(), 
                    map.getEqpName(),
                    map.getShiftId().getId(),
                    map.getShiftName(),
                    map.getTeamId(), 
                    map.getTeamName(),
                    map.getChTypeId(), 
                    map.getChTypeName(), 
                    map.getChLocation(), 
                    map.getChStandard(), 
                    map.getChMethod(), 
                    DateUtil.formatDateToString(map.getChDate(),"yyyy-MM-dd"),
                    map.getCreateUserId(), 
                    map.getCreateUserName(),
                    DateUtil.formatDateToString(map.getCreateTime(),"yyyy-MM-dd HH:mm:ss"),
                    map.getChStatus(), 
                    map.getBreLocation(), 
                    map.getRemark(),
                    map.getBreId(),
                    map.getUpdateUserId(), 
                    map.getUpdateUserName(),
                    DateUtil.formatDateToString(map.getUpdateTime(),"yyyy-MM-dd HH:mm:ss"),
                    map.getDel()
                    );
            rows.add(bean);
        
        }
        return new DataGrid(rows, 10L);*/
    }
    
    /**
     * 根据工单查点检记录
     */
    @Override
    public DataGrid queryPlanInfo(EqmSpotchRecodeBean eSRBean,PageParams pageParams) {
        StringBuffer sb = new StringBuffer();
        
        sb.append("(SELECT eqp_name,to_char(create_time,'yyyy-MM-dd') as date_p,");
        sb.append(" shift_name,ch_date,(SELECT DES from SYS_EQP_TYPE et where et.id=s.set_id) des,(SELECT name from SYS_EQP_TYPE et where et.id=s.set_id) sys_name,ch_type_name,create_user_name,id,s.ch_status,ROW_NUMBER() OVER(ORDER BY s.ch_date DESC) num  FROM EQM_SPOTCH_RECODE s where 1=1");
        if(StringUtil.notNull(eSRBean.getShiftId())){
            sb.append(" and shift_id='"+eSRBean.getShiftId()+"'");
        }
        if(StringUtil.notNull(eSRBean.getEqmId())){
            sb.append(" and eqp_id='"+eSRBean.getEqmId()+"'");
        }
        //执行开始时间
        if(StringUtil.notNull(eSRBean.getChDate())){
            sb.append(" and to_char(create_time,'yyyy-MM-dd')>='"+eSRBean.getChDate()+"'");
        }
        //执行结束时间
        if(StringUtil.notNull(eSRBean.getEndChDate())){
            sb.append(" and to_char(create_time,'yyyy-MM-dd')<='"+eSRBean.getEndChDate()+"'");
        }        
        sb.append(" ) ");
        String sta="SELECT * from ";
        String end="zl where zl.num>"+pageParams.getRows()*(pageParams.getPage()-1)+" and zl.num<="+pageParams.getRows()*pageParams.getPage()+" ORDER BY zl.ch_date DESC";
        List<?> list= eqmCheckcatPlanDao.queryBySql(sta+sb.toString()+end);
        List<?> listFY= eqmCheckcatPlanDao.queryBySql(sb.toString());
        List<EqmSpotchRecodeBean> beans=new ArrayList<EqmSpotchRecodeBean>();
        if(list.size()>0){
            for(Object o:list){
                try {
                    Object[] temp=(Object[]) o;
                    EqmSpotchRecodeBean b= new EqmSpotchRecodeBean();
                    b.setEqpName(temp[0].toString());
                    if(temp[1]!=null){
                        b.setOrderDate(temp[1].toString());
                    }
                    b.setShiftName(temp[2].toString());
                    b.setChDate(temp[3].toString());
                    b.setEqpTypeDes(temp[4].toString());
                    b.setEqpTypeName(temp[5].toString());
                    b.setChTypeName(temp[6].toString());
                    b.setCreateUserName(temp[7].toString());
                    b.setId(temp[8].toString());
                    b.setStatus(Integer.valueOf(temp[9].toString()));
                    beans.add(b);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        long total=listFY.size();
        return new DataGrid(beans, total);
    }
}