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();
|
}
|
});
|
}
|
|
}
|