|
@@ -68,9 +68,9 @@ public class DataCollectController {
|
|
|
// private ErpOrderInfoMapper erpOrderInfoMapper;
|
|
|
|
|
|
@RequestMapping("/checkCisData")
|
|
|
- public List<TisTimeVO> checkCisData(@RequestBody List<TisTimeVO> tisList) {
|
|
|
- if(!CollectionUtils.isEmpty(tisList)){
|
|
|
- for (TisTimeVO tisTimeVO : tisList) {
|
|
|
+ public List<TisTimeVO> checkCisData(@RequestBody List<TisTimeVO> toSendList) {
|
|
|
+ if(!CollectionUtils.isEmpty(toSendList)){
|
|
|
+ for (TisTimeVO tisTimeVO : toSendList) {
|
|
|
String sqlQuery = "select top 1 iRealCOID from ca_batchmap where cMOCode = ? and iMOSubSN = ? ";
|
|
|
try (Connection connection = sqlServerDataSource.getConnection()) {
|
|
|
PreparedStatement queryStmt = connection.prepareStatement(sqlQuery);
|
|
@@ -85,32 +85,51 @@ public class DataCollectController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return tisList;
|
|
|
+ return toSendList;
|
|
|
}
|
|
|
|
|
|
@RequestMapping("/insertCisData")
|
|
|
public String insertCisData(@RequestBody List<TisTimeVO> tisList) {
|
|
|
if(!CollectionUtils.isEmpty(tisList)){
|
|
|
- int count = 0;
|
|
|
+ int insertCount = 0;
|
|
|
+ int updateCount = 0;
|
|
|
for (TisTimeVO tisTimeVO : tisList) {
|
|
|
+ String sqlQuery = "select count(*) from CA_DayTiS where cPPID = ? and dDate = ? ";
|
|
|
String sqlInsert = "insert into CA_DayTiS(cPPID,iRealWkt,dDate) values(?,?,?)";
|
|
|
+ String sqlUpdate = "update CA_DayTiS set iRealWkt = ? where cPPID = ? and dDate = ? ";
|
|
|
try (Connection connection = sqlServerDataSource.getConnection()) {
|
|
|
- PreparedStatement insertStmt = connection.prepareStatement(sqlInsert);
|
|
|
- insertStmt.setString(1,tisTimeVO.getCoId());
|
|
|
- insertStmt.setBigDecimal(2,tisTimeVO.getWorkTime());
|
|
|
- insertStmt.setString(3,tisTimeVO.getDateStr());
|
|
|
- int i = insertStmt.executeUpdate();
|
|
|
- if(i>0){
|
|
|
- count++;
|
|
|
-// System.out.println("执行成功");
|
|
|
+ PreparedStatement queryStmt = connection.prepareStatement(sqlQuery);
|
|
|
+ queryStmt.setString(1, tisTimeVO.getCoId());
|
|
|
+ queryStmt.setString(2, tisTimeVO.getDateStr());
|
|
|
+ ResultSet queryRs = queryStmt.executeQuery();
|
|
|
+ if(queryRs.next() && queryRs.getInt(1) > 0){
|
|
|
+ //更新
|
|
|
+ PreparedStatement updateStmt = connection.prepareStatement(sqlUpdate);
|
|
|
+ queryStmt.setString(1, tisTimeVO.getCoId());
|
|
|
+ queryStmt.setString(2, tisTimeVO.getDateStr());
|
|
|
+ int i = updateStmt.executeUpdate();
|
|
|
+ if(i>0){
|
|
|
+ updateCount++;
|
|
|
+ }else{
|
|
|
+ System.out.println(tisTimeVO.getCoId()+"执行失败");
|
|
|
+ }
|
|
|
}else{
|
|
|
- System.out.println(tisTimeVO.getCoId()+"执行失败");
|
|
|
+ PreparedStatement insertStmt = connection.prepareStatement(sqlInsert);
|
|
|
+ insertStmt.setString(1,tisTimeVO.getCoId());
|
|
|
+ insertStmt.setBigDecimal(2,tisTimeVO.getWorkTime());
|
|
|
+ insertStmt.setString(3,tisTimeVO.getDateStr());
|
|
|
+ int i = insertStmt.executeUpdate();
|
|
|
+ if(i>0){
|
|
|
+ insertCount++;
|
|
|
+ }else{
|
|
|
+ System.out.println(tisTimeVO.getCoId()+"执行失败");
|
|
|
+ }
|
|
|
}
|
|
|
} catch (SQLException e) {
|
|
|
System.err.println("数据库操作错误: " + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
- System.out.println("本批次总数量:"+tisList.size()+",成功插入条数:"+count);
|
|
|
+ System.out.println("本批次总数量:"+tisList.size()+",成功插入条数:"+insertCount+",成功更新条数:"+updateCount);
|
|
|
}
|
|
|
// List<TisTimeVO> tisTimeVOS = JSONArray.parseArray(jsonarray, TisTimeVO.class);
|
|
|
// if(!CollectionUtils.isEmpty(tisList)){
|