多单位版国产化地质资料管理系统
zs
2026-02-04 fe02f176b512a9d6a4e12437d929e04e99bb7567
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
package com.zbooksoft.gdmis.operate;
 
import com.ruili.wcp.common.SpringContextUtil;
import com.ruili.wcp.data.entity.config.View;
import com.ruili.wcp.service.config.ViewService;
import com.ruili.wcp.web.model.AjaxResponse;
import com.ruili.wcp.web.model.ErrorInfo;
import com.zbooksoft.gdmis.service.CatSmxxService;
import com.zbooksoft.gdmis.service.CatYswjxxService;
import com.zbooksoft.gdmis.service.PackingManageService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
import org.springframework.jdbc.core.JdbcTemplate;
 
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
 
/**
 * @Description:
 * @Author: zhai
 * @Date: 2025/10/15
 **/
public class TapeOperate {
    private static final Logger logger = LoggerFactory.getLogger(CatYswjxxOperate.class);
    CatYswjxxService catYswjxxService = (CatYswjxxService) SpringContextUtil.getBean("catYswjxxServiceImpl");
    CatSmxxService catSmxxService = (CatSmxxService) SpringContextUtil.getBean("catSmxxServiceImpl");
    PackingManageService packingManageService = (PackingManageService) SpringContextUtil.getBean("packingManageServiceImpl");
    ViewService viewService = (ViewService) SpringContextUtil.getBean("viewServiceImpl");
    JdbcTemplate jdbcTemplate = (JdbcTemplate) SpringContextUtil.getBean("jdbcTemplate");
 
    /**
     * 取消发布
     *
     * @param viewId
     * @param idList
     * @return
     */
    public AjaxResponse warehousing(Long viewId, ArrayList<Long> idList) {
        try {
            int state = 0;
            String columnName = "ZLZT";
            updateState(viewId, idList, state, columnName);
            return new AjaxResponse(true);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
    }
 
    public void updateState(Long viewId, ArrayList<Long> idList, Integer state, String columnName) {
        View view = viewService.getViewById(viewId);
        String strSql = "update " + view.getMainTableName() + " set " + columnName + " = " + state;
        jdbcTemplate.batchUpdate(strSql + " where " + view.getIdField() + "=?", new BatchPreparedStatementSetter() {
            @Override
            public void setValues(PreparedStatement ps, int i) throws SQLException {
                ps.setLong(1, idList.get(i));// 下标从1开始
            }
 
            @Override
            public int getBatchSize() {
                return idList.size();
            }
        });
    }
 
}